From 18d9f16d0a068ab3830c79bc95d83e881f5b9c31 Mon Sep 17 00:00:00 2001 From: Rahul Butani Date: Wed, 5 Oct 2022 10:16:21 -0500 Subject: [PATCH 1/4] llvmPackages_git.libcxx: updates from LLVM15 Port of bc4dbee1150281fbd46663ef5e0e80493de9320e ("llvmPackages_15: updates for LLVM 15"). None of the patches required any touch-up; the only change of note is: - due to changes in the libc++/libc++abi build (https://reviews.llvm.org/D120719 and https://reviews.llvm.org/D131037) we have to add an extra build option to the libc++ header only build that sidesteps bits of the libc++ build config that assume libc++-abi is present in the build: https://github.com/llvm/llvm-project/blob/4f827318e3e8ccab4ff131e06234caa827e91e4e/libcxx/src/CMakeLists.txt#L255-L256 Rather than maintaining a precise set of build options that let us dodge referencing libc++-abi variables in the libc++ header only build, we set `LIBCXX_CXX_ABI` to `none`, as suggested by @lovesegfault. More discussion about this here: https://github.com/NixOS/nixpkgs/pull/194634#discussion_r990267037 Co-authored-by: Bernardo Meurer --- pkgs/development/compilers/llvm/git/libcxx/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/compilers/llvm/git/libcxx/default.nix b/pkgs/development/compilers/llvm/git/libcxx/default.nix index de4260540e92..84902c68eda3 100644 --- a/pkgs/development/compilers/llvm/git/libcxx/default.nix +++ b/pkgs/development/compilers/llvm/git/libcxx/default.nix @@ -66,7 +66,7 @@ stdenv.mkDerivation rec { cmakeFlags = [ "-DLLVM_ENABLE_RUNTIMES=libcxx" - "-DLIBCXX_CXX_ABI=${lib.optionalString (!headersOnly) "system-"}${cxxabi.pname}" + "-DLIBCXX_CXX_ABI=${if headersOnly then "none" else libcxx_cxx_abi_opt}" ] ++ lib.optional (!headersOnly && cxxabi.pname == "libcxxabi") "-DLIBCXX_CXX_ABI_INCLUDE_PATHS=${cxxabi.dev}/include/c++/v1" ++ lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) "-DLIBCXX_HAS_MUSL_LIBC=1" ++ lib.optional (stdenv.hostPlatform.useLLVM or false) "-DLIBCXX_USE_COMPILER_RT=ON" From 2e453ee51beff39ae1904807a973237451aea863 Mon Sep 17 00:00:00 2001 From: Rahul Butani Date: Sun, 15 Jan 2023 12:58:24 -0800 Subject: [PATCH 2/4] llvmPackages_git.libcxxabi: fix cycles that arise when `stdenv` is the LLVM stdenv Port of 8db72e3b7eac911b4c14a24c56741d98ac7eac94 ("llvmPackages_15.libcxxabi: fix cycles that arise when `stdenv` is the LLVM stdenv"). --- pkgs/development/compilers/llvm/git/libcxx/default.nix | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkgs/development/compilers/llvm/git/libcxx/default.nix b/pkgs/development/compilers/llvm/git/libcxx/default.nix index 84902c68eda3..af4bd85a1b6d 100644 --- a/pkgs/development/compilers/llvm/git/libcxx/default.nix +++ b/pkgs/development/compilers/llvm/git/libcxx/default.nix @@ -74,7 +74,13 @@ stdenv.mkDerivation rec { "-DLIBCXX_ENABLE_THREADS=OFF" "-DLIBCXX_ENABLE_FILESYSTEM=OFF" "-DLIBCXX_ENABLE_EXCEPTIONS=OFF" - ] ++ lib.optional (!enableShared) "-DLIBCXX_ENABLE_SHARED=OFF"; + ] ++ lib.optional (!enableShared) "-DLIBCXX_ENABLE_SHARED=OFF" + # If we're only building the headers we don't actually *need* a functioning + # C/C++ compiler: + ++ lib.optionals (headersOnly) [ + "-DCMAKE_C_COMPILER_WORKS=ON" + "-DCMAKE_CXX_COMPILER_WORKS=ON" + ]; ninjaFlags = lib.optional headersOnly "generate-cxx-headers"; installTargets = lib.optional headersOnly "install-cxx-headers"; From 5fbf2cd1a04a4e7a6ef34bb359e4d02cb334a165 Mon Sep 17 00:00:00 2001 From: Rahul Butani Date: Fri, 27 Jan 2023 12:23:54 -0800 Subject: [PATCH 3/4] llvmPackages_git: apply #211230 to llvmPackages_git Port of 4fabcf49458fc01f89ce494d0e5c18ec9ce167fb ("llvmPackages_15: apply #211230 to llvmPackages_15"). See the comments here for context: https://github.com/NixOS/nixpkgs/pull/194634#discussion_r1089389188 Co-authored-by: Weijia Wang <9713184+wegank@users.noreply.github.com> --- .../compilers/llvm/git/libcxx/default.nix | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pkgs/development/compilers/llvm/git/libcxx/default.nix b/pkgs/development/compilers/llvm/git/libcxx/default.nix index af4bd85a1b6d..cd023b353528 100644 --- a/pkgs/development/compilers/llvm/git/libcxx/default.nix +++ b/pkgs/development/compilers/llvm/git/libcxx/default.nix @@ -17,7 +17,7 @@ let basename = "libcxx"; in -assert stdenv.isDarwin -> cxxabi.pname == "libcxxabi"; +assert stdenv.isDarwin -> cxxabi.libName == "c++abi"; stdenv.mkDerivation rec { pname = basename + lib.optionalString headersOnly "-headers"; @@ -64,10 +64,16 @@ stdenv.mkDerivation rec { buildInputs = lib.optionals (!headersOnly) [ cxxabi ]; - cmakeFlags = [ + 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"; + }.${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.pname == "libcxxabi") "-DLIBCXX_CXX_ABI_INCLUDE_PATHS=${cxxabi.dev}/include/c++/v1" + ] ++ lib.optional (!headersOnly && cxxabi.libName == "c++abi") "-DLIBCXX_CXX_ABI_INCLUDE_PATHS=${cxxabi.dev}/include/c++/v1" ++ lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) "-DLIBCXX_HAS_MUSL_LIBC=1" ++ lib.optional (stdenv.hostPlatform.useLLVM or false) "-DLIBCXX_USE_COMPILER_RT=ON" ++ lib.optionals stdenv.hostPlatform.isWasm [ From 92bf9338909d29b8e85a1bd426e15efbc4c87226 Mon Sep 17 00:00:00 2001 From: Raito Bezarius Date: Sun, 26 Mar 2023 17:20:04 +0200 Subject: [PATCH 4/4] llvmPackages_git.libcxx: remove `preInstall` phase for Darwin This has not been added for `llvmPackages_15.libcxx`, therefore, we do not need it anymore. --- .../compilers/llvm/git/libcxx/default.nix | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/pkgs/development/compilers/llvm/git/libcxx/default.nix b/pkgs/development/compilers/llvm/git/libcxx/default.nix index cd023b353528..94374c8a312d 100644 --- a/pkgs/development/compilers/llvm/git/libcxx/default.nix +++ b/pkgs/development/compilers/llvm/git/libcxx/default.nix @@ -91,20 +91,6 @@ stdenv.mkDerivation rec { ninjaFlags = lib.optional headersOnly "generate-cxx-headers"; installTargets = lib.optional headersOnly "install-cxx-headers"; - preInstall = lib.optionalString (stdenv.isDarwin && !headersOnly) '' - for file in lib/*.dylib; do - if [ -L "$file" ]; then continue; fi - - baseName=$(basename $(${stdenv.cc.targetPrefix}otool -D $file | tail -n 1)) - installName="$out/lib/$baseName" - abiName=$(echo "$baseName" | sed -e 's/libc++/libc++abi/') - - for other in $(${stdenv.cc.targetPrefix}otool -L $file | awk '$1 ~ "/libc\\+\\+abi" { print $1 }'); do - ${stdenv.cc.targetPrefix}install_name_tool -change $other ${cxxabi}/lib/$abiName $file - done - done - ''; - passthru = { isLLVM = true; inherit cxxabi;