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

llvmPackages_15.libcxx: specify LIBCXX_CXX_ABI_{LIBRARY_PATH,INCLUDE_PATHS} for all cxxabis #216273

Closed
Closed
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
12 changes: 7 additions & 5 deletions pkgs/development/compilers/llvm/15/libcxx/default.nix
Copy link
Member

Choose a reason for hiding this comment

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

are both of the changes needed or only one or is the libcxx/default.nix change unneeded or is it needed in 16 too

Copy link
Contributor

Choose a reason for hiding this comment

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

AFAIR, LIBCXX_CXX_ABI_* doesn't exist in 16, which is why I introduced the change to include it via the clangUseLLVM wrapper.

There could be further issues lurking within the LLVM build; some time around LLVM 16 they moved things to assume that you're doing an in-tree build and that libcxx can access libcxxabi's headers; I see that nixpkgs has worked around that to some degree.

I don't fully understand how libcxxabi should get into the compilation environment for nixpkgs, whether it's really a part of libcxx's install or not for example. I consider what I did above as a bit of a hack.

Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,16 @@ stdenv.mkDerivation rec {

cmakeFlags = let
# See: https://libcxx.llvm.org/BuildingLibcxx.html#cmdoption-arg-libcxx-cxx-abi-string
libcxx_cxx_abi_opt = {
"c++abi" = "system-libcxxabi";
"cxxrt" = "libcxxrt";
# And: https://github.com/llvm/llvm-project/blob/aa656f6c2dec73faceeed21e15401d8f0c743c8b/libcxx/cmake/Modules/HandleLibCXXABI.cmake#L82-L180
libcxx_cxx_abi_options = {
"c++abi" = { name = "system-libcxxabi"; headers = "${cxxabi.dev}/include/c++/v1"; };
"cxxrt" = { name = "libcxxrt"; headers = "${cxxabi}/include"; };
}.${cxxabi.libName} or (throw "unknown cxxabi: ${cxxabi.libName} (${cxxabi.pname})");
in [
"-DLLVM_ENABLE_RUNTIMES=libcxx"
"-DLIBCXX_CXX_ABI=${if headersOnly then "none" else libcxx_cxx_abi_opt}"
] ++ lib.optional (!headersOnly && cxxabi.libName == "c++abi") "-DLIBCXX_CXX_ABI_INCLUDE_PATHS=${cxxabi.dev}/include/c++/v1"
"-DLIBCXX_CXX_ABI=${if headersOnly then "none" else libcxx_cxx_abi_options.name}"
] ++ lib.optional (!headersOnly) "-DLIBCXX_CXX_ABI_INCLUDE_PATHS=${libcxx_cxx_abi_options.headers}"
++ lib.optional (!headersOnly) "-DLIBCXX_CXX_ABI_LIBRARY_PATH=${cxxabi}/lib"
++ lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) "-DLIBCXX_HAS_MUSL_LIBC=1"
++ lib.optionals (stdenv.hostPlatform.useLLVM or false) [
"-DLIBCXX_USE_COMPILER_RT=ON"
Expand Down