diff options
author | Peter Waller <p@pwaller.net> | 2024-04-27 11:41:46 +0100 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2024-05-10 17:22:20 +0200 |
commit | 3c03811683fecb816d2b8eb01e918f83956c7220 (patch) | |
tree | 8296ea3f20484db9268c7ffb52dc3976b8c519ae /pkgs/test | |
parent | 45ada9cefd97511e0e9bfab147d046efef53d6b9 (diff) |
llvmPackages_*.libcxx: include libcxxabi within libcxx
Key test case: nixpkgs#pkgsStatic.pkgsLLVM.ncurses Prior to this patch, this fails with errors such as: ``` error: undefined symbol: __cxa_throw ``` I think this is a reasonable solution because in #292043, libcxxabi was 'merged into libcxx', however, the commit message suggests that only dynamic linking was accounted for, because it says: ``` * linux/freebsd `libc++.so` is a linker script `LINK(libc++.so.1, -lc++abi)` making `-lc++` sufficient. ``` Whereas, I found that if I tried linking a "hello world" C++ program with a static hostPlatform, it failed unless -lc++abi was passed. Signed-off-by: Peter Waller <p@pwaller.net>
Diffstat (limited to 'pkgs/test')
-rw-r--r-- | pkgs/test/cc-wrapper/default.nix | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/pkgs/test/cc-wrapper/default.nix b/pkgs/test/cc-wrapper/default.nix index a0088751d4a24..6a0b11a6cc974 100644 --- a/pkgs/test/cc-wrapper/default.nix +++ b/pkgs/test/cc-wrapper/default.nix @@ -46,6 +46,17 @@ in stdenv.mkDerivation { $READELF -d ./atomics.so | grep libatomic.so && echo "ok" >&2 || echo "failed" >&2 ''} + # Test that linking libc++ works, and statically. + ${lib.optionalString isCxx '' + echo "checking whether can link with libc++... " >&2 + NIX_DEBUG=1 $CXX ${./cxx-main.cc} -c -o cxx-main.o + NIX_DEBUG=1 $CC cxx-main.o -lc++ -o cxx-main + NIX_DEBUG=1 $CC cxx-main.o ${lib.getLib stdenv.cc.libcxx}/lib/libc++.a -o cxx-main-static + ${emulator} ./cxx-main + ${emulator} ./cxx-main-static + rm cxx-main{,-static,.o} + ''} + ${lib.optionalString (stdenv.isDarwin && stdenv.cc.isClang) '' echo "checking whether compiler can build with CoreFoundation.framework... " >&2 mkdir -p foo/lib |