Skip to content
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

cc-wrapper: add libcxxabi include flag for LLVM #255488

Merged
merged 2 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pkgs/build-support/cc-wrapper/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ stdenv.mkDerivation {
''
+ optionalString (libcxx.isLLVM or false) ''
echo "-isystem ${lib.getDev libcxx}/include/c++/v1" >> $out/nix-support/libcxx-cxxflags
Copy link
Member

@Artturin Artturin Sep 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before llvm 15 __cxxabi_config.h was included in libcxx so this worked correctly

llvmPackages_13.libcxx.dev                        3,133 r /nix/store/5wfncnq3svyf54hfahi44smavyfbhq5b-libcxx-13.0.1-dev/include/c++/v1/__cxxabi_config.h
llvmPackages_7.libcxx.dev                         2,278 r /nix/store/2i745a6pvd2qbi0lf9a61ia0svvg9q0b-libcxx-7.1.0-dev/include/c++/v1/__cxxabi_config.h
llvmPackages_14.libcxx.dev                        3,142 r /nix/store/jri1wy9fxnnln4wv7dmzdhs9w5ll4jfa-libcxx-14.0.6-dev/include/c++/v1/__cxxabi_config.h
llvmPackages_15.libcxxabi.dev                     3,266 r /nix/store/bbvhnvq66lr6yzqxqbzff2341h9xg332-libcxxabi-15.0.7-dev/include/c++/v1/__cxxabi_config.h
llvmPackages_6.libcxx.dev                         2,032 r /nix/store/bpyj2sk6mh9vlli539jsr0w45rpig5pc-libcxx-6.0.1-dev/include/c++/v1/__cxxabi_config.h
llvmPackages_5.libcxx.dev                         2,032 r /nix/store/fciabccmn17ijmfxxn50diin0dcjz7m6-libcxx-5.0.2-dev/include/c++/v1/__cxxabi_config.h
llvmPackages_8.libcxx.dev                         2,278 r /nix/store/8sg9d3j38i3p13sg7pp4bc44szqakj7s-libcxx-8.0.1-dev/include/c++/v1/__cxxabi_config.h
llvmPackages_9.libcxx.dev                         2,411 r /nix/store/1b5yn18w09n9r50i9162zvn3zq3jn98k-libcxx-9.0.1-dev/include/c++/v1/__cxxabi_config.h
llvmPackages_16.libcxxabi.dev                     3,266 r /nix/store/02wpjmp2zjjxz13z7g599mniwi25zkcy-libcxxabi-16.0.6-dev/include/c++/v1/__cxxabi_config.h
llvmPackages_10.libcxx.dev                        2,500 r /nix/store/j41yp16y29b7gw2bd5c1ljfyyykgsh12-libcxx-10.0.1-dev/include/c++/v1/__cxxabi_config.h
llvmPackages_12.libcxx.dev                        3,133 r /nix/store/fyr084bq8496099nllfjzapis7mxpj39-libcxx-12.0.1-dev/include/c++/v1/__cxxabi_config.h

and
cxxabi.h was in both libcxx and libcxxabi

llvmPackages_13.libcxx.dev                        7,215 r /nix/store/5wfncnq3svyf54hfahi44smavyfbhq5b-libcxx-13.0.1-dev/include/c++/v1/cxxabi.h
llvmPackages_7.libcxx.dev                         6,945 r /nix/store/2i745a6pvd2qbi0lf9a61ia0svvg9q0b-libcxx-7.1.0-dev/include/c++/v1/cxxabi.h
llvmPackages_14.libcxx.dev                        7,215 r /nix/store/jri1wy9fxnnln4wv7dmzdhs9w5ll4jfa-libcxx-14.0.6-dev/include/c++/v1/cxxabi.h
libcxxrt.out                                      9,040 r /nix/store/sdw3q6nzxgdh6n6jdnnsgm7jpg5wsp1v-libcxxrt-unstable-2022-08-08/include/cxxabi.h
llvmPackages_12.libcxxabi.dev                     7,215 r /nix/store/6lzf327lxdi743i8n8s3igq962jcp5r7-libcxxabi-12.0.1-dev/include/cxxabi.h
llvmPackages_15.libcxxabi.dev                     7,237 r /nix/store/bbvhnvq66lr6yzqxqbzff2341h9xg332-libcxxabi-15.0.7-dev/include/c++/v1/cxxabi.h
llvmPackages_15.libcxxabi.dev                     7,237 r /nix/store/bbvhnvq66lr6yzqxqbzff2341h9xg332-libcxxabi-15.0.7-dev/include/cxxabi.h
llvmPackages_5.libcxxabi.dev                      6,945 r /nix/store/qlzdwhhd0x9fda4mk1a83jmmxza4a64p-libcxxabi-5.0.2-dev/include/cxxabi.h
libcxxabi.dev                                     7,029 r /nix/store/h84lr9b4q34f37jvqzqkkf4gnrlrgahl-libcxxabi-11.1.0-dev/include/cxxabi.h
llvmPackages_14.libcxxabi.dev                     7,215 r /nix/store/zkfgj0hy0za0yhwnrfdndvzr301aj4pq-libcxxabi-14.0.6-dev/include/cxxabi.h
llvmPackages_6.libcxx.dev                         6,945 r /nix/store/bpyj2sk6mh9vlli539jsr0w45rpig5pc-libcxx-6.0.1-dev/include/c++/v1/cxxabi.h
llvmPackages_5.libcxx.dev                         6,945 r /nix/store/fciabccmn17ijmfxxn50diin0dcjz7m6-libcxx-5.0.2-dev/include/c++/v1/cxxabi.h
llvmPackages_8.libcxx.dev                         6,987 r /nix/store/8sg9d3j38i3p13sg7pp4bc44szqakj7s-libcxx-8.0.1-dev/include/c++/v1/cxxabi.h
llvmPackages_9.libcxx.dev                         7,023 r /nix/store/1b5yn18w09n9r50i9162zvn3zq3jn98k-libcxx-9.0.1-dev/include/c++/v1/cxxabi.h
llvmPackages_16.libcxxabi.dev                     7,237 r /nix/store/02wpjmp2zjjxz13z7g599mniwi25zkcy-libcxxabi-16.0.6-dev/include/c++/v1/cxxabi.h
llvmPackages_16.libcxxabi.dev                     7,237 r /nix/store/02wpjmp2zjjxz13z7g599mniwi25zkcy-libcxxabi-16.0.6-dev/include/cxxabi.h
llvmPackages_10.libcxxabi.dev                     7,029 r /nix/store/pwx93kc21scj2ikif98d9zzyzaicag8x-libcxxabi-10.0.1-dev/include/cxxabi.h
llvmPackages_7.libcxxabi.dev                      6,945 r /nix/store/wx2xdg98ddhrs5iif85w8dgmskgkmjv2-libcxxabi-7.1.0-dev/include/cxxabi.h
llvmPackages_9.libcxxabi.dev                      7,023 r /nix/store/lhjbqxfqqckm3x2ci9v7vgblmw6jr2jc-libcxxabi-9.0.1-dev/include/cxxabi.h
llvmPackages_6.libcxxabi.dev                      6,945 r /nix/store/lc41k1nfaslcp8gbgl948ksx52n19j20-libcxxabi-6.0.1-dev/include/cxxabi.h
llvmPackages_8.libcxxabi.dev                      6,987 r /nix/store/khf9r8s7llkmpsxza19pqavr26j3w6lb-libcxxabi-8.0.1-dev/include/cxxabi.h
llvmPackages_10.libcxx.dev                        7,029 r /nix/store/j41yp16y29b7gw2bd5c1ljfyyykgsh12-libcxx-10.0.1-dev/include/c++/v1/cxxabi.h
llvmPackages_12.libcxx.dev                        7,215 r /nix/store/fyr084bq8496099nllfjzapis7mxpj39-libcxx-12.0.1-dev/include/c++/v1/cxxabi.h

because we were copying it manually to libcxx.dev/include

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
''
Expand Down
8 changes: 0 additions & 8 deletions pkgs/development/compilers/llvm/16/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed old workaround

]
++ lib.optional (!stdenv.targetPlatform.isWasm) "--unwindlib=libunwind"
++ lib.optional
Expand Down
7 changes: 7 additions & 0 deletions pkgs/test/cc-wrapper/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pr fixes this test for tests.cc-wrapper.llvmTests.llvmPackages_{15,16}.libcxx

${emulator} ./include-cxxabi

${lib.optionalString (stdenv.isDarwin && stdenv.cc.isClang) ''
echo "checking whether compiler can build with CoreFoundation.framework... " >&2
mkdir -p foo/lib
Expand Down
8 changes: 8 additions & 0 deletions pkgs/test/cc-wrapper/include-cxxabi.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <cxxabi.h>
#include <iostream>

int main(int argc, char **argv)
{
std::cerr << "ok" << std::endl;
return 0;
}