From accafc0ed36ba6da401e1abc9595f633fc7d4401 Mon Sep 17 00:00:00 2001 From: Amneesh Singh Date: Sat, 16 Sep 2023 19:19:33 +0530 Subject: cc-wrapper: add libcxxabi include flag for LLVM Removed workaround from llvm 16. Fixes including cxxabi.h on llvm >=15 libcxxStdenv. ```c int main() {} ``` ``` /nix/store/qwnvng0cbyx0bijm654jpmpl0516hfhx-libcxxabi-15.0.7-dev/include/cxxabi.h:20:10: fatal error: '__cxxabi_config.h' file not found ``` Before llvm 15 this used to work because `libcxx` copied the headers from `cxxabi` to it's own `include`, which was then picked up by the line above this one Alternative fix would be to copy all files from `${cxxabi.dev}/include/c++/v1` to `${cxxabi.dev}/include` so the cc-wrapper setup hook would pick them up, but that would depend on in cxxabi being in buildInputs. Signed-off-by: Amneesh Singh --- pkgs/build-support/cc-wrapper/default.nix | 1 + pkgs/development/compilers/llvm/16/default.nix | 8 -------- 2 files changed, 1 insertion(+), 8 deletions(-) (limited to 'pkgs') diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix index e1da3ceb5bc9..eef67154ef94 100644 --- a/pkgs/build-support/cc-wrapper/default.nix +++ b/pkgs/build-support/cc-wrapper/default.nix @@ -469,6 +469,7 @@ stdenv.mkDerivation { '' + optionalString (libcxx.isLLVM or false) '' echo "-isystem ${lib.getDev libcxx}/include/c++/v1" >> $out/nix-support/libcxx-cxxflags + echo "-isystem ${lib.getDev libcxx.cxxabi}/include/c++/v1" >> $out/nix-support/libcxx-cxxflags echo "-stdlib=libc++" >> $out/nix-support/libcxx-ldflags echo "-l${libcxx.cxxabi.libName}" >> $out/nix-support/libcxx-ldflags '' diff --git a/pkgs/development/compilers/llvm/16/default.nix b/pkgs/development/compilers/llvm/16/default.nix index 9dbe65ed68da..24dd31ea9fef 100644 --- a/pkgs/development/compilers/llvm/16/default.nix +++ b/pkgs/development/compilers/llvm/16/default.nix @@ -255,14 +255,6 @@ in let [ "-rtlib=compiler-rt" "-Wno-unused-command-line-argument" "-B${targetLlvmLibraries.compiler-rt}/lib" - - # Combat "__cxxabi_config.h not found". Maybe this could be fixed by - # copying these headers into libcxx? Note that building libcxx - # outside of monorepo isn't supported anymore, might be related to - # https://github.com/llvm/llvm-project/issues/55632 - # ("16.0.3 libcxx, libcxxabi: circular build dependencies") - # Looks like the machinery changed in https://reviews.llvm.org/D120727. - "-I${lib.getDev targetLlvmLibraries.libcxx.cxxabi}/include/c++/v1" ] ++ lib.optional (!stdenv.targetPlatform.isWasm) "--unwindlib=libunwind" ++ lib.optional -- cgit 1.4.1 From 42f329261698805c6367cc488105c6573f0e4cf5 Mon Sep 17 00:00:00 2001 From: Artturin Date: Sun, 17 Sep 2023 23:59:10 +0300 Subject: tests.cc-wrapper.supported: add test for cxxabi header `#include ` `/nix/store/02wpjmp2zjjxz13z7g599mniwi25zkcy-libcxxabi-16.0.6-dev/include/cxxabi.h:20:10: fatal error: '__cxxabi_config.h' file not found` --- pkgs/test/cc-wrapper/default.nix | 7 +++++++ pkgs/test/cc-wrapper/include-cxxabi.cc | 8 ++++++++ 2 files changed, 15 insertions(+) create mode 100644 pkgs/test/cc-wrapper/include-cxxabi.cc (limited to 'pkgs') diff --git a/pkgs/test/cc-wrapper/default.nix b/pkgs/test/cc-wrapper/default.nix index 8809030989e6..74009c97980d 100644 --- a/pkgs/test/cc-wrapper/default.nix +++ b/pkgs/test/cc-wrapper/default.nix @@ -30,6 +30,13 @@ in stdenv.mkDerivation { $CXX -o cxx-check ${./cxx-main.cc} ${emulator} ./cxx-check + # test for https://github.com/NixOS/nixpkgs/issues/214524#issuecomment-1431745905 + # .../include/cxxabi.h:20:10: fatal error: '__cxxabi_config.h' file not found + # in libcxxStdenv + echo "checking whether cxxabi.h can be included... " >&2 + $CXX -o include-cxxabi ${./include-cxxabi.cc} + ${emulator} ./include-cxxabi + ${lib.optionalString (stdenv.isDarwin && stdenv.cc.isClang) '' echo "checking whether compiler can build with CoreFoundation.framework... " >&2 mkdir -p foo/lib diff --git a/pkgs/test/cc-wrapper/include-cxxabi.cc b/pkgs/test/cc-wrapper/include-cxxabi.cc new file mode 100644 index 000000000000..6ffc97e414a5 --- /dev/null +++ b/pkgs/test/cc-wrapper/include-cxxabi.cc @@ -0,0 +1,8 @@ +#include +#include + +int main(int argc, char **argv) +{ + std::cerr << "ok" << std::endl; + return 0; +} -- cgit 1.4.1