Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[runtimes] Fix link order of system librarires on Apple platforms
On Apple platforms, we always support the -nostdlib++ flag. Hence, it is not necessary to manually link against system libraries. In fact, doing so causes us to link against libSystem explicitly, which messes up with the order of libraries we should use. Indeed: Before patch, using the system unwinder (LIBCXXABI_USE_LLVM_UNWINDER = OFF) =========================================================================== $ otool -L lib/{libc++.1.dylib,libc++abi.1.dylib,libunwind.1.dylib} lib/libc++.1.dylib: @rpath/libc++.1.dylib /usr/lib/libSystem.B.dylib @rpath/libc++abi.1.dylib lib/libc++abi.1.dylib: @rpath/libc++abi.1.dylib /usr/lib/libSystem.B.dylib lib/libunwind.1.dylib: @rpath/libunwind.1.dylib /usr/lib/libSystem.B.dylib After patch, using the system unwinder (LIBCXXABI_USE_LLVM_UNWINDER = OFF) =========================================================================== $ otool -L lib/{libc++.1.dylib,libc++abi.1.dylib,libunwind.1.dylib} lib/libc++.1.dylib: @rpath/libc++.1.dylib @rpath/libc++abi.1.dylib /usr/lib/libSystem.B.dylib lib/libc++abi.1.dylib: @rpath/libc++abi.1.dylib /usr/lib/libSystem.B.dylib lib/libunwind.1.dylib: @rpath/libunwind.1.dylib /usr/lib/libSystem.B.dylib Before patch, with the LLVM unwinder (LIBCXXABI_USE_LLVM_UNWINDER = ON) ======================================================================= $ otool -L lib/{libc++.1.dylib,libc++abi.1.dylib,libunwind.1.dylib} lib/libc++.1.dylib: @rpath/libc++.1.dylib /usr/lib/libSystem.B.dylib @rpath/libc++abi.1.dylib @rpath/libunwind.1.dylib lib/libc++abi.1.dylib: @rpath/libc++abi.1.dylib /usr/lib/libSystem.B.dylib @rpath/libunwind.1.dylib lib/libunwind.1.dylib: @rpath/libunwind.1.dylib /usr/lib/libSystem.B.dylib After patch, with the LLVM unwinder (LIBCXXABI_USE_LLVM_UNWINDER = ON) ====================================================================== $ otool -L lib/{libc++.1.dylib,libc++abi.1.dylib,libunwind.1.dylib} lib/libc++.1.dylib: @rpath/libc++.1.dylib @rpath/libc++abi.1.dylib @rpath/libunwind.1.dylib /usr/lib/libSystem.B.dylib lib/libc++abi.1.dylib: @rpath/libc++abi.1.dylib @rpath/libunwind.1.dylib /usr/lib/libSystem.B.dylib lib/libunwind.1.dylib: @rpath/libunwind.1.dylib /usr/lib/libSystem.B.dylib As we can see, libSystem appears before the just-built libraries before the patch, which causes the libunwind.dylib bundled in libSystem.dylib to be used instead of the just-built libunwind.dylib. We didn't notice the issue until recently when I tried to update the macOS CI builders to macOS 13.5, where it is necessary to use the right libunwind library (the exact reason still needs to be investigated).
- Loading branch information