-
Notifications
You must be signed in to change notification settings - Fork 202
Description
From ruby/zlib#75
Affects: TruffleRuby >= 24.0
There is a bug in XCode 14.2 that even though TruffleRuby passes RTLD_LAZY to dlopen() and -Wl,-undefined,dynamic_lookup when linking,
the new linker in XCode 14.2 ignores those and resolves symbols eagerly.
Which seems nothing less than a violation of the POSIX semantics of dlopen() with RTLD_LAZY and yet another breaking change for macOS's native toolchain.
And the macOS man page for dlopen doesn't even bother mentioning this issue.
This is thankfully fixed in XCode 14.3+, so it's really only an issue with XCode 14.2.
This caused similar issues in CRuby and CPython, links at ruby/zlib#75 (comment), notably https://bugs.ruby-lang.org/issues/18912 and https://bugs.ruby-lang.org/issues/19005.
Possible workarounds:
- Using
-no_fixup_chainsbut this flag seems to not exist on older versions of XCode so it seems inconvenient. BTW getting the XCode version seems a bit messy. - Using
MACOSX_DEPLOYMENT_TARGET=11.0this likely disables the fixup chains stuff and 11.0=Big Sur the currently minimum supported version. But it might disable using newer macOS stuff, so it seems not ideal to set that when installing extensions. - Use
-bundle_loaderwhich seems to be what CRuby did Link ext bundles with bundle loader option for newer ld64 of Ventura ruby/ruby#6193. But macOS linker warnings in macOS ventura python/cpython#97524 makes it sound like all symbols need to be resolved and that's not the case. - Define dummy functions which raise for all C API functions, this is not OK because it breaks
have_func "foo"and so prevents extensions to detect if a function is available. Maybe it could be worked around by using a different native lib forhave_funcbut it sounds hacky.
So my current plan instead is to rely on users using a non-broken version of XCode, i.e., not XCode 14.2.
It's not ideal because GitHub Actions macos-latest = macos-12 currently actually uses XCode 14.2 :/
Either macos-13 or macos-11 works fine.