diff options
author | 2022-07-11 03:52:30 -0500 | |
---|---|---|
committer | 2022-07-11 01:52:30 -0700 | |
commit | 71992634a641337483d391a552d047bd7f281738 (patch) | |
tree | 03a09a43f8cfec4a1f4dc886b3f560a990cf8331 /src/futex.zig | |
parent | 90ff529b5556ffffad931d4b16b6cd90f5928918 (diff) | |
download | bun-71992634a641337483d391a552d047bd7f281738.tar.gz bun-71992634a641337483d391a552d047bd7f281738.tar.zst bun-71992634a641337483d391a552d047bd7f281738.zip |
Fix macOS build (#525)
* style: remove some trailing whitespace
* docs: make `identifier-cache` _before_ `jsc`
Running them the other way around results in a failed build.
* docs: `npm i` in both `test/snippets` _and_ `test/scripts`
`test/scripts` has node packages as well. If they aren't installed, then
some of the tests fail to start.
* docs: add `rust` to list of homebrew packages
One of the dependencies tries to run `cargo`, and will fail the build if
it can't. The `cargo` command is provided by the `rust` brew package.
* docs: clean up section on macOS code signing
This requirement applies to _all_ macOS builds, not just those on Apple
Silicon, and also had some slightly confusing wording.
* build: remove leading whitespace from flags
This leading whitespace was making my system treat the argument as a
file with name ` -L$(LLVM_PREFIX)/lib` (leading whitespace included),
instead of as a library path argument.
* build: try llvm@13 first, then fall back on bare llvm
The macOS instructions say to install `llvm@13`, which has a different
path than the bare `llvm` install (`brew --prefix llvm@13` != `brew
--prefix llvm`). This patch takes a slightly smarter approach:
1. If the user defined `LLVM_PREFIX` and it points to a valid path on
disk, use that.
2. If `LLVM_PREFIX` is NOT a valid path, try setting it to the `llvm@13`
path.
3. If it's STILL not a valid path, try the plain `llvm` path
4. If it's STILL not valid, set it to a user-friendly error.
There might be a better solution for doing this, I'm not well-versed in
Makefile syntax, but it's at least slightly better than it was before.
* fix(build): update cast signature
`std.math.cast` was changed in 0e6285c8fc31ff866df96847fe34e660da38b4a9.
It used to throw if the cast would overflow, but now it returns `null`
instead.
Diffstat (limited to '')
-rw-r--r-- | src/futex.zig | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/futex.zig b/src/futex.zig index ad8ff84b9..77af4aeca 100644 --- a/src/futex.zig +++ b/src/futex.zig @@ -1,7 +1,7 @@ //! Futex is a mechanism used to block (`wait`) and unblock (`wake`) threads using a 32bit memory address as hints. //! Blocking a thread is acknowledged only if the 32bit memory address is equal to a given value. //! This check helps avoid block/unblock deadlocks which occur if a `wake()` happens before a `wait()`. -//! Using Futex, other Thread synchronization primitives can be built which efficiently wait for cross-thread events or signals. +//! Using Futex, other Thread synchronization primitives can be built which efficiently wait for cross-thread events or signals. // This is copy-pasted from Zig's source code to fix an issue with linking on macOS Catalina and earlier. @@ -22,7 +22,7 @@ const spinLoopHint = std.atomic.spinLoopHint; /// - The value at `ptr` is no longer equal to `expect`. /// - The caller is unblocked by a matching `wake()`. /// - The caller is unblocked spuriously by an arbitrary internal signal. -/// +/// /// If `timeout` is provided, and the caller is blocked for longer than `timeout` nanoseconds`, `error.TimedOut` is returned. /// /// The checking of `ptr` and `expect`, along with blocking the caller, is done atomically @@ -200,9 +200,10 @@ const DarwinFutex = struct { // true so that we we know to ignore the ETIMEDOUT result. var timeout_overflowed = false; const status = blk: { - const timeout_us = std.math.cast(u32, timeout_ns / std.time.ns_per_us) catch overflow: { - timeout_overflowed = true; - break :overflow std.math.maxInt(u32); + const timeout_us = cast: { + const timeout_u32 = std.math.cast(u32, timeout_ns / std.time.ns_per_us); + timeout_overflowed = timeout_u32 == null; + break :cast timeout_u32 orelse std.math.maxInt(u32); }; break :blk darwin.__ulock_wait(flags, addr, expect, timeout_us); }; |