-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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
Some libc++abi
symbols are missing with LLVM12+'s stdenv
on Darwin
#166205
Comments
Any updates on this issue? |
Crystal requires linking libc++abi when building with newer versions of clang. See NixOS#166205.
* Set deployment target based on stdenv; and * Work around NixOS#166205.
Work around clang’s not linking libc++abi when invoked as `clang` or `cc` even when it’s needed to link a C++ library or C++ code. See NixOS#166205.
Work around clang’s not linking libc++abi when invoked as `clang` or `cc` even when it’s needed to link a C++ library or C++ code. See NixOS#166205.
Crystal requires linking libc++abi when building with newer versions of clang. See NixOS#166205.
Work around NixOS#166205.
Working around NixOS/nixpkgs#166205
Workaround for #166205 similar to 51451ac And warning fix similar to `bazel_6` fix for ``` external/upb~0.0.0-20220923-a547704/upb/mini_table.c:634:14: error: defining a type within '__builtin_offsetof' is a Clang extension [-Werror,-Wgnu-offsetof-extensions] UPB_ASSERT(UPB_ALIGN_OF(upb_StringView) == ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``` (cherry picked from commit 306e8ea)
nixpkgs/pkgs/servers/sql/postgresql/ext/postgis.nix Lines 38 to 40 in c79898e
Hey it looks like we wound up with 33 copy-and-pastes of this code:
This means that when there's a bug in the copy-and-pasted code (which there is -- it breaks CI if One of Nix's superpowers is that it provides abstraction, so we can refactor instead of copying and pasting. Please use those superpowers next time -- probably by changing |
@amjoseph-nixpkgs thats a very good find ! we should fix it, is it darwin specific ? |
…59825) Host clang for bazel reason: ``` ERROR: /Users/noah/Sourcegraph/sourcegraph/BUILD.bazel:305:5: GoLink sg_nogo_actual_/sg_nogo_actual [for tool] failed: (Exit 1): builder failed: error executing GoLink command (from target //:sg_nogo_actual) bazel-out/darwin_arm64-opt-exec-ST-1a88b5d644a4/bin/external/go_sdk/builder_reset/builder '-param=bazel-out/darwin_arm64-opt-exec-ST-1a88b5d644a4/bin/sg_nogo_actual_/sg_nogo_actual-0.params' -- -extld ... (remaining 6 arguments skipped) Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging external/go_sdk/pkg/tool/darwin_arm64/link: running external/local_config_cc/cc_wrapper.sh failed: exit status 1 ld: framework not found CoreFoundation clang: error: linker command failed with exit code 1 (use -v to see invocation) ``` clang 11 for shell reason: NixOS/nixpkgs#166205 ## Test plan `./dev/scip-ctags-install.sh` and `bazel build //:gazelle`
Hi! This hits internal users where I work about once a week, as they add a native library and have to add this override. By and large, they are unfamiliar with the peculiarities of the linker, and the errors we get are strange as they usually reference other libraries, which is a red herring. Is there some path to a default fix for this problem? From the above, there are a lot of workarounds being exported (which we apply internally), but there's no direct proposal for an override fix (adding the same override to ld-wrapper?). Is it reasonable to (internally) automatically apply something which adds this linker flag to everything? |
the change still needs to go through the review processes. |
…abi into libcxx (#292043) - merge libcxxabi into libcxx for LLVM 12, 13, 14, 15, 16, 17, and git. - remove the link time workaround `-lc++ -lc++abi` from 58 packages as it is no longer required. - fixes #166205 - provides alternative fixes for. #269548 NixOS/nix#9640 - pkgsCross.x86_64-freebsd builds work again This change can be represented in 3 stages 1. merge libcxxabi into libcxx -- files: pkgs/development/compilers/llvm/[12, git]/{libcxx, libcxxabi} 2. update stdenv to account for merge -- files: stdenv.{adapters, cc.wrapper, darwin} 3. remove all references to libcxxabi outside of llvm (about 58 packages modified) ### merging libcxxabi into libcxx - take the union of the libcxxabi and libcxx cmake flags - eliminate the libcxx-headers-only package - it was only needed to break libcxx <-> libcxxabi circular dependency - libcxx.cxxabi is removed. external cxxabi (freebsd) will symlink headers / libs into libcxx. - darwin will re-export the libcxxabi symbols into libcxx so linking `-lc++` is sufficient. - linux/freebsd `libc++.so` is a linker script `LINK(libc++.so.1, -lc++abi)` making `-lc++` sufficient. - libcxx/default.nix [12, 17] are identical except for patches and `LIBCXX_ADDITIONAL_LIBRARIES` (only used in 16+) - git/libcxx/defaul.nix does not link with -nostdlib when useLLVM is true so flag is removed. this is not much different than before as libcxxabi used -nostdlib where libcxx did not, so libc was linked in anyway. ### stdenv changes - darwin bootstrap, remove references to libcxxabi and cxxabi - cc-wrapper: remove c++ link workaround when libcxx.cxxabi doesn't exist (still exists for LLVM pre 12) - adapter: update overrideLibcxx to account for a pkgs.stdenv that only has libcxx ### 58 package updates - remove `NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}` as no longer needed - swift, nodejs_v8 remove libcxxabi references in the clang override #292043
Problem
When using
stdenv
s (or even justlibc++
versions, really) fromllvmPackages
corresponding to LLVM 12 and newer on macOS, symbols related to exceptions (such as__cxa_allocate_exception
) are not found by the linker.This can be reproduced by compiling and linking any C++ program that makes use of exceptions, i.e.:
Results in:
Comparing the
libc++
dylibs used by the wrappedclang++
in the LLVM 12 and 13stdenv
s (i.e.llvmPackages_12.libcxxStdenv
) to that used in the LLVM 11stdenv
reveals that while LLVM 11'slibc++.dylib
reexports such symbols, newerlibc++.dylib
s do not.When run through
llvm-nm -C
and grepped for__cxa_allocate_exception
, here is the output for LLVM 11'slibc++
dylib:And LLVM 13's:
Both of these
libc++
dylibs have a dynamic dependency onlibc++abi
which actually provides a definition for this symbol (this can be observed withotool -L <dylib path>
which shows thelibc++abi.dylib
dep and thenllvm-nm -C <libc++abi.dylib path>
which shows that the symbol is defined in thelibc++abi
dylib) however onlylibc++
versions prior to LLVM 12's reexport the symbol.This is consistent with the
libc++
source code. These symbols were initially removed from the main list of symbols reexported and gated onlibc++
exception support. However later this logic and the special list of symbols was removed.Open Questions
I am not certain I understand the changes in the commit linked above; it's not clear to me why
libcxxabi
was changed to reexport these symbols.This seems like an ABI break but there is no mention of this being potentially problematic on the CL and the comments added to the changelog in this commit seem to insist that it only adds some reexports to
libc++
.Potential Solutions
I am not sure what the "right" solution is but anecdotally it seems like it's common to pass in
-lc++abi
as a linkopt on macOS.cc-wrapper
already does this on Linux.To Reproduce
Here's a flake:
Running
nix flake check
shows the error when compiling with the LLVM 12 and 13stdenv
s; entering the dev shells withnix develop
prints the path of thelibc++
dylib that's used and greps it for__cxa_allocate_exception
(one of the missing symbols).The above also contains an example of a workaround that adds
-lc++abi
to the wrapper used in the LLVM 13stdenv
.I think this is reproducible with any nixpkgs version after the LLVM 12.0.0 package was added but just in case, here's my flake.lock file:
Click to expand
The text was updated successfully, but these errors were encountered: