Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

__builtin_available is intermittently not available on macOS #504

Open
jdm opened this issue Sep 18, 2024 · 6 comments
Open

__builtin_available is intermittently not available on macOS #504

jdm opened this issue Sep 18, 2024 · 6 comments

Comments

@jdm
Copy link
Member

jdm commented Sep 18, 2024

When building mozjs on macOS arm64, I intermittently receive linker errors like this:

          Undefined symbols for architecture arm64:
            "___isPlatformVersionAtLeast", referenced from:
                js::jit::AutoMarkJitCodeWritableForThread::markExecutable(bool) in libmozjs_sys-13c131082aca4d88.rlib[85](Unified_cpp_js_src_jit9.o)
          ld: symbol(s) not found for architecture arm64
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

There is one use of this function in mozjs:

if (__builtin_available(macOS 11.0, *)) {

The most recent spidermonkey upgrade removed a patch that removed a previous use of __builtinAvailable: bf41ed0#diff-5c427df1c88acdb6a3478df156bdd162ecf6bc6abd7231cfdec3b4ccb5a35138L1

curl/curl#4314 suggests that the issue here is that __builtinAvailable is only available in dynamic libraries, but we're building a static library. I have no idea why I would only hit this intermittently, or why CI never appears to run into this problem.

@jdm
Copy link
Member Author

jdm commented Sep 18, 2024

Just removing the __builtin_available check results in:

  In file included from Unified_cpp_js_src_jit9.cpp:29:
  /Users/jdm/src/mozjs/mozjs-sys/mozjs/js/src/jit/ProcessExecutableMemory.cpp:1010:3: error: 'pthread_jit_write_protect_np' is only available on macOS 11.0 or newer [-Werror,-Wunguarded-availability-new]
    pthread_jit_write_protect_np(executable);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include/pthread.h:588:6: note: 'pthread_jit_write_protect_np' has been marked as being introduced in macOS 11.0 here, but the deployment target is macOS 10.10.0
  void pthread_jit_write_protect_np(int enabled);
       ^
  /Users/jdm/src/mozjs/mozjs-sys/mozjs/js/src/jit/ProcessExecutableMemory.cpp:1010:3: note: enclose 'pthread_jit_write_protect_np' in a __builtin_available check to silence this warning
    pthread_jit_write_protect_np(executable);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

@jdm
Copy link
Member Author

jdm commented Sep 18, 2024

Strangely,

option(
"--enable-macos-target",
env="MACOSX_DEPLOYMENT_TARGET",
nargs=1,
default=depends(target, developer_options)
# We continue to target 10.15 on Intel, but can target 11.0 for
# aarch64 since the earliest hardware was released alongside 11.0.
# For local builds, we want to target 10.15 regardless of the
# underlying platform to catch any errors or warnings that wouldn't
# show up when targeting 11.0, since these would later show up on
# CI for Intel builds.
(lambda t, d: "11.0" if (t.cpu == "aarch64" and not d) else "10.15"),
help="Set the minimum MacOS version needed at runtime{|}",
looks like it should be setting a 11.0 deployment target in this case, and I have no idea where the 10.10 value comes from.

@jdm
Copy link
Member Author

jdm commented Sep 18, 2024

I am able to build after removing the __builtin_available check with ./mach clean and MACOSX_DEPLOYMENT_TARGET=11.0.

@mrobinson
Copy link
Member

mrobinson commented Sep 18, 2024

Servo is setting the MACOSX_DEPLOYMENT_TARGET to 10.10 in .cargo/config.toml. I believe this was previously set in the environment by mach.

@sagudev
Copy link
Member

sagudev commented Sep 18, 2024

Then we should probably set MACOSX_DEPLOYMENT_TARGET in mozjs-sys and remove __builtin_available check.

@jschwe
Copy link
Member

jschwe commented Sep 22, 2024

Shouldn't we just bump MACOSX_DEPLOYMENT_TARGET in servo? The oldest available version in github CI is macOS-12, so I don't think we can even test at all if servo can actually run on 10.10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants