2024-03-28 11:24:06 -07:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, llvm_meta
|
|
|
|
, release_version
|
|
|
|
, monorepoSrc ? null
|
|
|
|
, src ? null
|
|
|
|
, patches ? []
|
|
|
|
, runCommand
|
|
|
|
, substitute
|
|
|
|
, cmake
|
|
|
|
, lndir
|
|
|
|
, ninja
|
|
|
|
, python3
|
|
|
|
, fixDarwinDylibNames
|
|
|
|
, version
|
2024-05-14 13:10:12 -07:00
|
|
|
, cxxabi ? null
|
2024-03-28 11:24:06 -07:00
|
|
|
, libcxxrt
|
|
|
|
, libunwind
|
2022-02-27 18:42:36 +01:00
|
|
|
, enableShared ? !stdenv.hostPlatform.isStatic
|
|
|
|
}:
|
|
|
|
|
2024-05-14 13:10:12 -07:00
|
|
|
# note: our setup using libcxxabi instead of libcxxrt on FreeBSD diverges from
|
|
|
|
# normal FreeBSD. This may cause issues with binary patching down the line.
|
|
|
|
# If this becomes an issue, try adding as symlink libcxxrt.so -> libc++abi.so
|
|
|
|
|
llvmPackages_{12,13,14,15,16,17,git}.{libcxx,libcxxabi}: merge libcxxabi into libcxx (#292043)
- merge libcxxabi into libcxx for LLVM 12, 13, 14, 15, 16, 17, and git.
- remove the link time workaround `-lc++ -lc++abi` from 58 packages as it is no longer required.
- fixes https://github.com/NixOS/nixpkgs/issues/166205
- provides alternative fixes for. https://github.com/NixOS/nixpkgs/issues/269548 https://github.com/NixOS/nix/issues/9640
- pkgsCross.x86_64-freebsd builds work again
This change can be represented in 3 stages
1. merge libcxxabi into libcxx -- files: pkgs/development/compilers/llvm/[12, git]/{libcxx, libcxxabi}
2. update stdenv to account for merge -- files: stdenv.{adapters, cc.wrapper, darwin}
3. remove all references to libcxxabi outside of llvm (about 58 packages modified)
### merging libcxxabi into libcxx
- take the union of the libcxxabi and libcxx cmake flags
- eliminate the libcxx-headers-only package - it was only needed to break libcxx <-> libcxxabi circular dependency
- libcxx.cxxabi is removed. external cxxabi (freebsd) will symlink headers / libs into libcxx.
- darwin will re-export the libcxxabi symbols into libcxx so linking `-lc++` is sufficient.
- linux/freebsd `libc++.so` is a linker script `LINK(libc++.so.1, -lc++abi)` making `-lc++` sufficient.
- libcxx/default.nix [12, 17] are identical except for patches and `LIBCXX_ADDITIONAL_LIBRARIES` (only used in 16+)
- git/libcxx/defaul.nix does not link with -nostdlib when useLLVM is true so flag is removed. this is not much different than before as libcxxabi used -nostdlib where libcxx did not, so libc was linked in anyway.
### stdenv changes
- darwin bootstrap, remove references to libcxxabi and cxxabi
- cc-wrapper: remove c++ link workaround when libcxx.cxxabi doesn't exist (still exists for LLVM pre 12)
- adapter: update overrideLibcxx to account for a pkgs.stdenv that only has libcxx
### 58 package updates
- remove `NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}` as no longer needed
- swift, nodejs_v8 remove libcxxabi references in the clang override
https://github.com/NixOS/nixpkgs/pull/292043
2024-03-11 03:53:37 -07:00
|
|
|
# external cxxabi is not supported on Darwin as the build will not link libcxx
|
|
|
|
# properly and not re-export the cxxabi symbols into libcxx
|
|
|
|
# https://github.com/NixOS/nixpkgs/issues/166205
|
|
|
|
# https://github.com/NixOS/nixpkgs/issues/269548
|
|
|
|
assert cxxabi == null || !stdenv.hostPlatform.isDarwin;
|
2022-02-27 18:42:36 +01:00
|
|
|
let
|
|
|
|
basename = "libcxx";
|
2024-03-28 11:24:06 -07:00
|
|
|
pname = basename;
|
llvmPackages_{12,13,14,15,16,17,git}.{libcxx,libcxxabi}: merge libcxxabi into libcxx (#292043)
- merge libcxxabi into libcxx for LLVM 12, 13, 14, 15, 16, 17, and git.
- remove the link time workaround `-lc++ -lc++abi` from 58 packages as it is no longer required.
- fixes https://github.com/NixOS/nixpkgs/issues/166205
- provides alternative fixes for. https://github.com/NixOS/nixpkgs/issues/269548 https://github.com/NixOS/nix/issues/9640
- pkgsCross.x86_64-freebsd builds work again
This change can be represented in 3 stages
1. merge libcxxabi into libcxx -- files: pkgs/development/compilers/llvm/[12, git]/{libcxx, libcxxabi}
2. update stdenv to account for merge -- files: stdenv.{adapters, cc.wrapper, darwin}
3. remove all references to libcxxabi outside of llvm (about 58 packages modified)
### merging libcxxabi into libcxx
- take the union of the libcxxabi and libcxx cmake flags
- eliminate the libcxx-headers-only package - it was only needed to break libcxx <-> libcxxabi circular dependency
- libcxx.cxxabi is removed. external cxxabi (freebsd) will symlink headers / libs into libcxx.
- darwin will re-export the libcxxabi symbols into libcxx so linking `-lc++` is sufficient.
- linux/freebsd `libc++.so` is a linker script `LINK(libc++.so.1, -lc++abi)` making `-lc++` sufficient.
- libcxx/default.nix [12, 17] are identical except for patches and `LIBCXX_ADDITIONAL_LIBRARIES` (only used in 16+)
- git/libcxx/defaul.nix does not link with -nostdlib when useLLVM is true so flag is removed. this is not much different than before as libcxxabi used -nostdlib where libcxx did not, so libc was linked in anyway.
### stdenv changes
- darwin bootstrap, remove references to libcxxabi and cxxabi
- cc-wrapper: remove c++ link workaround when libcxx.cxxabi doesn't exist (still exists for LLVM pre 12)
- adapter: update overrideLibcxx to account for a pkgs.stdenv that only has libcxx
### 58 package updates
- remove `NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}` as no longer needed
- swift, nodejs_v8 remove libcxxabi references in the clang override
https://github.com/NixOS/nixpkgs/pull/292043
2024-03-11 03:53:37 -07:00
|
|
|
cxxabiName = "lib${if cxxabi == null then "cxxabi" else cxxabi.libName}";
|
|
|
|
runtimes = [ "libcxx" ] ++ lib.optional (cxxabi == null) "libcxxabi";
|
|
|
|
|
|
|
|
# Note: useLLVM is likely false for Darwin but true under pkgsLLVM
|
|
|
|
useLLVM = stdenv.hostPlatform.useLLVM or false;
|
|
|
|
|
2024-03-28 11:24:06 -07:00
|
|
|
src' = if monorepoSrc != null then
|
|
|
|
runCommand "${pname}-src-${version}" {} (''
|
|
|
|
mkdir -p "$out/llvm"
|
|
|
|
'' + (lib.optionalString (lib.versionAtLeast release_version "14") ''
|
|
|
|
cp -r ${monorepoSrc}/cmake "$out"
|
|
|
|
'') + ''
|
|
|
|
cp -r ${monorepoSrc}/libcxx "$out"
|
|
|
|
cp -r ${monorepoSrc}/llvm/cmake "$out/llvm"
|
|
|
|
cp -r ${monorepoSrc}/llvm/utils "$out/llvm"
|
|
|
|
'' + (lib.optionalString (lib.versionAtLeast release_version "14") ''
|
|
|
|
cp -r ${monorepoSrc}/third-party "$out"
|
|
|
|
'') + ''
|
|
|
|
cp -r ${monorepoSrc}/runtimes "$out"
|
|
|
|
'' + (lib.optionalString (cxxabi == null) ''
|
|
|
|
cp -r ${monorepoSrc}/libcxxabi "$out"
|
|
|
|
'')) else src;
|
|
|
|
|
|
|
|
cxxabiCMakeFlags = lib.optionals (lib.versionAtLeast release_version "18") [
|
|
|
|
"-DLIBCXXABI_USE_LLVM_UNWINDER=OFF"
|
|
|
|
] ++ lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) (if lib.versionAtLeast release_version "18" then [
|
|
|
|
"-DLIBCXXABI_ADDITIONAL_LIBRARIES=unwind"
|
|
|
|
"-DLIBCXXABI_USE_COMPILER_RT=ON"
|
|
|
|
] else [
|
2024-03-21 04:49:06 +00:00
|
|
|
"-DLIBCXXABI_USE_COMPILER_RT=ON"
|
llvmPackages_{12,13,14,15,16,17,git}.{libcxx,libcxxabi}: merge libcxxabi into libcxx (#292043)
- merge libcxxabi into libcxx for LLVM 12, 13, 14, 15, 16, 17, and git.
- remove the link time workaround `-lc++ -lc++abi` from 58 packages as it is no longer required.
- fixes https://github.com/NixOS/nixpkgs/issues/166205
- provides alternative fixes for. https://github.com/NixOS/nixpkgs/issues/269548 https://github.com/NixOS/nix/issues/9640
- pkgsCross.x86_64-freebsd builds work again
This change can be represented in 3 stages
1. merge libcxxabi into libcxx -- files: pkgs/development/compilers/llvm/[12, git]/{libcxx, libcxxabi}
2. update stdenv to account for merge -- files: stdenv.{adapters, cc.wrapper, darwin}
3. remove all references to libcxxabi outside of llvm (about 58 packages modified)
### merging libcxxabi into libcxx
- take the union of the libcxxabi and libcxx cmake flags
- eliminate the libcxx-headers-only package - it was only needed to break libcxx <-> libcxxabi circular dependency
- libcxx.cxxabi is removed. external cxxabi (freebsd) will symlink headers / libs into libcxx.
- darwin will re-export the libcxxabi symbols into libcxx so linking `-lc++` is sufficient.
- linux/freebsd `libc++.so` is a linker script `LINK(libc++.so.1, -lc++abi)` making `-lc++` sufficient.
- libcxx/default.nix [12, 17] are identical except for patches and `LIBCXX_ADDITIONAL_LIBRARIES` (only used in 16+)
- git/libcxx/defaul.nix does not link with -nostdlib when useLLVM is true so flag is removed. this is not much different than before as libcxxabi used -nostdlib where libcxx did not, so libc was linked in anyway.
### stdenv changes
- darwin bootstrap, remove references to libcxxabi and cxxabi
- cc-wrapper: remove c++ link workaround when libcxx.cxxabi doesn't exist (still exists for LLVM pre 12)
- adapter: update overrideLibcxx to account for a pkgs.stdenv that only has libcxx
### 58 package updates
- remove `NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}` as no longer needed
- swift, nodejs_v8 remove libcxxabi references in the clang override
https://github.com/NixOS/nixpkgs/pull/292043
2024-03-11 03:53:37 -07:00
|
|
|
"-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
|
2024-03-28 11:24:06 -07:00
|
|
|
]) ++ lib.optionals stdenv.hostPlatform.isWasm [
|
llvmPackages_{12,13,14,15,16,17,git}.{libcxx,libcxxabi}: merge libcxxabi into libcxx (#292043)
- merge libcxxabi into libcxx for LLVM 12, 13, 14, 15, 16, 17, and git.
- remove the link time workaround `-lc++ -lc++abi` from 58 packages as it is no longer required.
- fixes https://github.com/NixOS/nixpkgs/issues/166205
- provides alternative fixes for. https://github.com/NixOS/nixpkgs/issues/269548 https://github.com/NixOS/nix/issues/9640
- pkgsCross.x86_64-freebsd builds work again
This change can be represented in 3 stages
1. merge libcxxabi into libcxx -- files: pkgs/development/compilers/llvm/[12, git]/{libcxx, libcxxabi}
2. update stdenv to account for merge -- files: stdenv.{adapters, cc.wrapper, darwin}
3. remove all references to libcxxabi outside of llvm (about 58 packages modified)
### merging libcxxabi into libcxx
- take the union of the libcxxabi and libcxx cmake flags
- eliminate the libcxx-headers-only package - it was only needed to break libcxx <-> libcxxabi circular dependency
- libcxx.cxxabi is removed. external cxxabi (freebsd) will symlink headers / libs into libcxx.
- darwin will re-export the libcxxabi symbols into libcxx so linking `-lc++` is sufficient.
- linux/freebsd `libc++.so` is a linker script `LINK(libc++.so.1, -lc++abi)` making `-lc++` sufficient.
- libcxx/default.nix [12, 17] are identical except for patches and `LIBCXX_ADDITIONAL_LIBRARIES` (only used in 16+)
- git/libcxx/defaul.nix does not link with -nostdlib when useLLVM is true so flag is removed. this is not much different than before as libcxxabi used -nostdlib where libcxx did not, so libc was linked in anyway.
### stdenv changes
- darwin bootstrap, remove references to libcxxabi and cxxabi
- cc-wrapper: remove c++ link workaround when libcxx.cxxabi doesn't exist (still exists for LLVM pre 12)
- adapter: update overrideLibcxx to account for a pkgs.stdenv that only has libcxx
### 58 package updates
- remove `NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}` as no longer needed
- swift, nodejs_v8 remove libcxxabi references in the clang override
https://github.com/NixOS/nixpkgs/pull/292043
2024-03-11 03:53:37 -07:00
|
|
|
"-DLIBCXXABI_ENABLE_THREADS=OFF"
|
|
|
|
"-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF"
|
|
|
|
] ++ lib.optionals (!enableShared) [
|
|
|
|
"-DLIBCXXABI_ENABLE_SHARED=OFF"
|
|
|
|
];
|
|
|
|
|
|
|
|
cxxCMakeFlags = [
|
|
|
|
"-DLIBCXX_CXX_ABI=${cxxabiName}"
|
2024-04-27 11:41:46 +01:00
|
|
|
] ++ lib.optionals (cxxabi == null && lib.versionAtLeast release_version "16") [
|
|
|
|
# Note: llvm < 16 doesn't support this flag (or it's broken); handled in postInstall instead.
|
|
|
|
# Include libc++abi symbols within libc++.a for static linking libc++;
|
|
|
|
# dynamic linking includes them through libc++.so being a linker script
|
|
|
|
# which includes both shared objects.
|
|
|
|
"-DLIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY=ON"
|
llvmPackages_{12,13,14,15,16,17,git}.{libcxx,libcxxabi}: merge libcxxabi into libcxx (#292043)
- merge libcxxabi into libcxx for LLVM 12, 13, 14, 15, 16, 17, and git.
- remove the link time workaround `-lc++ -lc++abi` from 58 packages as it is no longer required.
- fixes https://github.com/NixOS/nixpkgs/issues/166205
- provides alternative fixes for. https://github.com/NixOS/nixpkgs/issues/269548 https://github.com/NixOS/nix/issues/9640
- pkgsCross.x86_64-freebsd builds work again
This change can be represented in 3 stages
1. merge libcxxabi into libcxx -- files: pkgs/development/compilers/llvm/[12, git]/{libcxx, libcxxabi}
2. update stdenv to account for merge -- files: stdenv.{adapters, cc.wrapper, darwin}
3. remove all references to libcxxabi outside of llvm (about 58 packages modified)
### merging libcxxabi into libcxx
- take the union of the libcxxabi and libcxx cmake flags
- eliminate the libcxx-headers-only package - it was only needed to break libcxx <-> libcxxabi circular dependency
- libcxx.cxxabi is removed. external cxxabi (freebsd) will symlink headers / libs into libcxx.
- darwin will re-export the libcxxabi symbols into libcxx so linking `-lc++` is sufficient.
- linux/freebsd `libc++.so` is a linker script `LINK(libc++.so.1, -lc++abi)` making `-lc++` sufficient.
- libcxx/default.nix [12, 17] are identical except for patches and `LIBCXX_ADDITIONAL_LIBRARIES` (only used in 16+)
- git/libcxx/defaul.nix does not link with -nostdlib when useLLVM is true so flag is removed. this is not much different than before as libcxxabi used -nostdlib where libcxx did not, so libc was linked in anyway.
### stdenv changes
- darwin bootstrap, remove references to libcxxabi and cxxabi
- cc-wrapper: remove c++ link workaround when libcxx.cxxabi doesn't exist (still exists for LLVM pre 12)
- adapter: update overrideLibcxx to account for a pkgs.stdenv that only has libcxx
### 58 package updates
- remove `NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}` as no longer needed
- swift, nodejs_v8 remove libcxxabi references in the clang override
https://github.com/NixOS/nixpkgs/pull/292043
2024-03-11 03:53:37 -07:00
|
|
|
] ++ lib.optionals (cxxabi != null) [
|
|
|
|
"-DLIBCXX_CXX_ABI_INCLUDE_PATHS=${lib.getDev cxxabi}/include"
|
|
|
|
] ++ lib.optionals (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) [
|
|
|
|
"-DLIBCXX_HAS_MUSL_LIBC=1"
|
2024-03-28 11:24:06 -07:00
|
|
|
] ++ lib.optionals (lib.versionAtLeast release_version "18" && !useLLVM && stdenv.hostPlatform.libc == "glibc" && !stdenv.hostPlatform.isStatic) [
|
|
|
|
"-DLIBCXX_ADDITIONAL_LIBRARIES=gcc_s"
|
llvmPackages_{12,13,14,15,16,17,git}.{libcxx,libcxxabi}: merge libcxxabi into libcxx (#292043)
- merge libcxxabi into libcxx for LLVM 12, 13, 14, 15, 16, 17, and git.
- remove the link time workaround `-lc++ -lc++abi` from 58 packages as it is no longer required.
- fixes https://github.com/NixOS/nixpkgs/issues/166205
- provides alternative fixes for. https://github.com/NixOS/nixpkgs/issues/269548 https://github.com/NixOS/nix/issues/9640
- pkgsCross.x86_64-freebsd builds work again
This change can be represented in 3 stages
1. merge libcxxabi into libcxx -- files: pkgs/development/compilers/llvm/[12, git]/{libcxx, libcxxabi}
2. update stdenv to account for merge -- files: stdenv.{adapters, cc.wrapper, darwin}
3. remove all references to libcxxabi outside of llvm (about 58 packages modified)
### merging libcxxabi into libcxx
- take the union of the libcxxabi and libcxx cmake flags
- eliminate the libcxx-headers-only package - it was only needed to break libcxx <-> libcxxabi circular dependency
- libcxx.cxxabi is removed. external cxxabi (freebsd) will symlink headers / libs into libcxx.
- darwin will re-export the libcxxabi symbols into libcxx so linking `-lc++` is sufficient.
- linux/freebsd `libc++.so` is a linker script `LINK(libc++.so.1, -lc++abi)` making `-lc++` sufficient.
- libcxx/default.nix [12, 17] are identical except for patches and `LIBCXX_ADDITIONAL_LIBRARIES` (only used in 16+)
- git/libcxx/defaul.nix does not link with -nostdlib when useLLVM is true so flag is removed. this is not much different than before as libcxxabi used -nostdlib where libcxx did not, so libc was linked in anyway.
### stdenv changes
- darwin bootstrap, remove references to libcxxabi and cxxabi
- cc-wrapper: remove c++ link workaround when libcxx.cxxabi doesn't exist (still exists for LLVM pre 12)
- adapter: update overrideLibcxx to account for a pkgs.stdenv that only has libcxx
### 58 package updates
- remove `NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}` as no longer needed
- swift, nodejs_v8 remove libcxxabi references in the clang override
https://github.com/NixOS/nixpkgs/pull/292043
2024-03-11 03:53:37 -07:00
|
|
|
] ++ lib.optionals useLLVM [
|
|
|
|
"-DLIBCXX_USE_COMPILER_RT=ON"
|
2024-03-28 11:24:06 -07:00
|
|
|
] ++ lib.optionals (useLLVM && lib.versionAtLeast release_version "16") [
|
|
|
|
"-DLIBCXX_ADDITIONAL_LIBRARIES=unwind"
|
llvmPackages_{12,13,14,15,16,17,git}.{libcxx,libcxxabi}: merge libcxxabi into libcxx (#292043)
- merge libcxxabi into libcxx for LLVM 12, 13, 14, 15, 16, 17, and git.
- remove the link time workaround `-lc++ -lc++abi` from 58 packages as it is no longer required.
- fixes https://github.com/NixOS/nixpkgs/issues/166205
- provides alternative fixes for. https://github.com/NixOS/nixpkgs/issues/269548 https://github.com/NixOS/nix/issues/9640
- pkgsCross.x86_64-freebsd builds work again
This change can be represented in 3 stages
1. merge libcxxabi into libcxx -- files: pkgs/development/compilers/llvm/[12, git]/{libcxx, libcxxabi}
2. update stdenv to account for merge -- files: stdenv.{adapters, cc.wrapper, darwin}
3. remove all references to libcxxabi outside of llvm (about 58 packages modified)
### merging libcxxabi into libcxx
- take the union of the libcxxabi and libcxx cmake flags
- eliminate the libcxx-headers-only package - it was only needed to break libcxx <-> libcxxabi circular dependency
- libcxx.cxxabi is removed. external cxxabi (freebsd) will symlink headers / libs into libcxx.
- darwin will re-export the libcxxabi symbols into libcxx so linking `-lc++` is sufficient.
- linux/freebsd `libc++.so` is a linker script `LINK(libc++.so.1, -lc++abi)` making `-lc++` sufficient.
- libcxx/default.nix [12, 17] are identical except for patches and `LIBCXX_ADDITIONAL_LIBRARIES` (only used in 16+)
- git/libcxx/defaul.nix does not link with -nostdlib when useLLVM is true so flag is removed. this is not much different than before as libcxxabi used -nostdlib where libcxx did not, so libc was linked in anyway.
### stdenv changes
- darwin bootstrap, remove references to libcxxabi and cxxabi
- cc-wrapper: remove c++ link workaround when libcxx.cxxabi doesn't exist (still exists for LLVM pre 12)
- adapter: update overrideLibcxx to account for a pkgs.stdenv that only has libcxx
### 58 package updates
- remove `NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}` as no longer needed
- swift, nodejs_v8 remove libcxxabi references in the clang override
https://github.com/NixOS/nixpkgs/pull/292043
2024-03-11 03:53:37 -07:00
|
|
|
] ++ lib.optionals stdenv.hostPlatform.isWasm [
|
|
|
|
"-DLIBCXX_ENABLE_THREADS=OFF"
|
|
|
|
"-DLIBCXX_ENABLE_FILESYSTEM=OFF"
|
|
|
|
"-DLIBCXX_ENABLE_EXCEPTIONS=OFF"
|
|
|
|
] ++ lib.optionals (!enableShared) [
|
|
|
|
"-DLIBCXX_ENABLE_SHARED=OFF"
|
|
|
|
];
|
2022-02-27 18:42:36 +01:00
|
|
|
|
llvmPackages_{12,13,14,15,16,17,git}.{libcxx,libcxxabi}: merge libcxxabi into libcxx (#292043)
- merge libcxxabi into libcxx for LLVM 12, 13, 14, 15, 16, 17, and git.
- remove the link time workaround `-lc++ -lc++abi` from 58 packages as it is no longer required.
- fixes https://github.com/NixOS/nixpkgs/issues/166205
- provides alternative fixes for. https://github.com/NixOS/nixpkgs/issues/269548 https://github.com/NixOS/nix/issues/9640
- pkgsCross.x86_64-freebsd builds work again
This change can be represented in 3 stages
1. merge libcxxabi into libcxx -- files: pkgs/development/compilers/llvm/[12, git]/{libcxx, libcxxabi}
2. update stdenv to account for merge -- files: stdenv.{adapters, cc.wrapper, darwin}
3. remove all references to libcxxabi outside of llvm (about 58 packages modified)
### merging libcxxabi into libcxx
- take the union of the libcxxabi and libcxx cmake flags
- eliminate the libcxx-headers-only package - it was only needed to break libcxx <-> libcxxabi circular dependency
- libcxx.cxxabi is removed. external cxxabi (freebsd) will symlink headers / libs into libcxx.
- darwin will re-export the libcxxabi symbols into libcxx so linking `-lc++` is sufficient.
- linux/freebsd `libc++.so` is a linker script `LINK(libc++.so.1, -lc++abi)` making `-lc++` sufficient.
- libcxx/default.nix [12, 17] are identical except for patches and `LIBCXX_ADDITIONAL_LIBRARIES` (only used in 16+)
- git/libcxx/defaul.nix does not link with -nostdlib when useLLVM is true so flag is removed. this is not much different than before as libcxxabi used -nostdlib where libcxx did not, so libc was linked in anyway.
### stdenv changes
- darwin bootstrap, remove references to libcxxabi and cxxabi
- cc-wrapper: remove c++ link workaround when libcxx.cxxabi doesn't exist (still exists for LLVM pre 12)
- adapter: update overrideLibcxx to account for a pkgs.stdenv that only has libcxx
### 58 package updates
- remove `NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}` as no longer needed
- swift, nodejs_v8 remove libcxxabi references in the clang override
https://github.com/NixOS/nixpkgs/pull/292043
2024-03-11 03:53:37 -07:00
|
|
|
cmakeFlags = [
|
|
|
|
"-DLLVM_ENABLE_RUNTIMES=${lib.concatStringsSep ";" runtimes}"
|
|
|
|
] ++ lib.optionals stdenv.hostPlatform.isWasm [
|
|
|
|
"-DCMAKE_C_COMPILER_WORKS=ON"
|
|
|
|
"-DCMAKE_CXX_COMPILER_WORKS=ON"
|
|
|
|
"-DUNIX=ON" # Required otherwise libc++ fails to detect the correct linker
|
|
|
|
] ++ cxxCMakeFlags
|
|
|
|
++ lib.optionals (cxxabi == null) cxxabiCMakeFlags;
|
|
|
|
|
|
|
|
in
|
2023-01-13 20:03:29 +00:00
|
|
|
|
2024-03-28 11:24:06 -07:00
|
|
|
stdenv.mkDerivation (rec {
|
|
|
|
inherit pname version cmakeFlags patches;
|
2022-02-27 18:42:36 +01:00
|
|
|
|
2024-03-28 11:24:06 -07:00
|
|
|
src = src';
|
2022-02-27 18:42:36 +01:00
|
|
|
|
2024-03-28 11:24:06 -07:00
|
|
|
outputs = [ "out" "dev" ];
|
llvmPackages_{12,13,14,15,16,17,git}.{libcxx,libcxxabi}: merge libcxxabi into libcxx (#292043)
- merge libcxxabi into libcxx for LLVM 12, 13, 14, 15, 16, 17, and git.
- remove the link time workaround `-lc++ -lc++abi` from 58 packages as it is no longer required.
- fixes https://github.com/NixOS/nixpkgs/issues/166205
- provides alternative fixes for. https://github.com/NixOS/nixpkgs/issues/269548 https://github.com/NixOS/nix/issues/9640
- pkgsCross.x86_64-freebsd builds work again
This change can be represented in 3 stages
1. merge libcxxabi into libcxx -- files: pkgs/development/compilers/llvm/[12, git]/{libcxx, libcxxabi}
2. update stdenv to account for merge -- files: stdenv.{adapters, cc.wrapper, darwin}
3. remove all references to libcxxabi outside of llvm (about 58 packages modified)
### merging libcxxabi into libcxx
- take the union of the libcxxabi and libcxx cmake flags
- eliminate the libcxx-headers-only package - it was only needed to break libcxx <-> libcxxabi circular dependency
- libcxx.cxxabi is removed. external cxxabi (freebsd) will symlink headers / libs into libcxx.
- darwin will re-export the libcxxabi symbols into libcxx so linking `-lc++` is sufficient.
- linux/freebsd `libc++.so` is a linker script `LINK(libc++.so.1, -lc++abi)` making `-lc++` sufficient.
- libcxx/default.nix [12, 17] are identical except for patches and `LIBCXX_ADDITIONAL_LIBRARIES` (only used in 16+)
- git/libcxx/defaul.nix does not link with -nostdlib when useLLVM is true so flag is removed. this is not much different than before as libcxxabi used -nostdlib where libcxx did not, so libc was linked in anyway.
### stdenv changes
- darwin bootstrap, remove references to libcxxabi and cxxabi
- cc-wrapper: remove c++ link workaround when libcxx.cxxabi doesn't exist (still exists for LLVM pre 12)
- adapter: update overrideLibcxx to account for a pkgs.stdenv that only has libcxx
### 58 package updates
- remove `NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}` as no longer needed
- swift, nodejs_v8 remove libcxxabi references in the clang override
https://github.com/NixOS/nixpkgs/pull/292043
2024-03-11 03:53:37 -07:00
|
|
|
|
2022-02-27 18:42:36 +01:00
|
|
|
preConfigure = lib.optionalString stdenv.hostPlatform.isMusl ''
|
|
|
|
patchShebangs utils/cat_files.py
|
|
|
|
'';
|
|
|
|
|
llvmPackages_{12,13,14,15,16,17,git}.{libcxx,libcxxabi}: merge libcxxabi into libcxx (#292043)
- merge libcxxabi into libcxx for LLVM 12, 13, 14, 15, 16, 17, and git.
- remove the link time workaround `-lc++ -lc++abi` from 58 packages as it is no longer required.
- fixes https://github.com/NixOS/nixpkgs/issues/166205
- provides alternative fixes for. https://github.com/NixOS/nixpkgs/issues/269548 https://github.com/NixOS/nix/issues/9640
- pkgsCross.x86_64-freebsd builds work again
This change can be represented in 3 stages
1. merge libcxxabi into libcxx -- files: pkgs/development/compilers/llvm/[12, git]/{libcxx, libcxxabi}
2. update stdenv to account for merge -- files: stdenv.{adapters, cc.wrapper, darwin}
3. remove all references to libcxxabi outside of llvm (about 58 packages modified)
### merging libcxxabi into libcxx
- take the union of the libcxxabi and libcxx cmake flags
- eliminate the libcxx-headers-only package - it was only needed to break libcxx <-> libcxxabi circular dependency
- libcxx.cxxabi is removed. external cxxabi (freebsd) will symlink headers / libs into libcxx.
- darwin will re-export the libcxxabi symbols into libcxx so linking `-lc++` is sufficient.
- linux/freebsd `libc++.so` is a linker script `LINK(libc++.so.1, -lc++abi)` making `-lc++` sufficient.
- libcxx/default.nix [12, 17] are identical except for patches and `LIBCXX_ADDITIONAL_LIBRARIES` (only used in 16+)
- git/libcxx/defaul.nix does not link with -nostdlib when useLLVM is true so flag is removed. this is not much different than before as libcxxabi used -nostdlib where libcxx did not, so libc was linked in anyway.
### stdenv changes
- darwin bootstrap, remove references to libcxxabi and cxxabi
- cc-wrapper: remove c++ link workaround when libcxx.cxxabi doesn't exist (still exists for LLVM pre 12)
- adapter: update overrideLibcxx to account for a pkgs.stdenv that only has libcxx
### 58 package updates
- remove `NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}` as no longer needed
- swift, nodejs_v8 remove libcxxabi references in the clang override
https://github.com/NixOS/nixpkgs/pull/292043
2024-03-11 03:53:37 -07:00
|
|
|
nativeBuildInputs = [ cmake ninja python3 ]
|
|
|
|
++ lib.optional stdenv.isDarwin fixDarwinDylibNames
|
|
|
|
++ lib.optional (cxxabi != null) lndir;
|
2022-11-14 01:31:26 +00:00
|
|
|
|
llvmPackages_{12,13,14,15,16,17,git}.{libcxx,libcxxabi}: merge libcxxabi into libcxx (#292043)
- merge libcxxabi into libcxx for LLVM 12, 13, 14, 15, 16, 17, and git.
- remove the link time workaround `-lc++ -lc++abi` from 58 packages as it is no longer required.
- fixes https://github.com/NixOS/nixpkgs/issues/166205
- provides alternative fixes for. https://github.com/NixOS/nixpkgs/issues/269548 https://github.com/NixOS/nix/issues/9640
- pkgsCross.x86_64-freebsd builds work again
This change can be represented in 3 stages
1. merge libcxxabi into libcxx -- files: pkgs/development/compilers/llvm/[12, git]/{libcxx, libcxxabi}
2. update stdenv to account for merge -- files: stdenv.{adapters, cc.wrapper, darwin}
3. remove all references to libcxxabi outside of llvm (about 58 packages modified)
### merging libcxxabi into libcxx
- take the union of the libcxxabi and libcxx cmake flags
- eliminate the libcxx-headers-only package - it was only needed to break libcxx <-> libcxxabi circular dependency
- libcxx.cxxabi is removed. external cxxabi (freebsd) will symlink headers / libs into libcxx.
- darwin will re-export the libcxxabi symbols into libcxx so linking `-lc++` is sufficient.
- linux/freebsd `libc++.so` is a linker script `LINK(libc++.so.1, -lc++abi)` making `-lc++` sufficient.
- libcxx/default.nix [12, 17] are identical except for patches and `LIBCXX_ADDITIONAL_LIBRARIES` (only used in 16+)
- git/libcxx/defaul.nix does not link with -nostdlib when useLLVM is true so flag is removed. this is not much different than before as libcxxabi used -nostdlib where libcxx did not, so libc was linked in anyway.
### stdenv changes
- darwin bootstrap, remove references to libcxxabi and cxxabi
- cc-wrapper: remove c++ link workaround when libcxx.cxxabi doesn't exist (still exists for LLVM pre 12)
- adapter: update overrideLibcxx to account for a pkgs.stdenv that only has libcxx
### 58 package updates
- remove `NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}` as no longer needed
- swift, nodejs_v8 remove libcxxabi references in the clang override
https://github.com/NixOS/nixpkgs/pull/292043
2024-03-11 03:53:37 -07:00
|
|
|
buildInputs = [ cxxabi ]
|
|
|
|
++ lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [ libunwind ];
|
2022-11-14 01:31:26 +00:00
|
|
|
|
llvmPackages_{12,13,14,15,16,17,git}.{libcxx,libcxxabi}: merge libcxxabi into libcxx (#292043)
- merge libcxxabi into libcxx for LLVM 12, 13, 14, 15, 16, 17, and git.
- remove the link time workaround `-lc++ -lc++abi` from 58 packages as it is no longer required.
- fixes https://github.com/NixOS/nixpkgs/issues/166205
- provides alternative fixes for. https://github.com/NixOS/nixpkgs/issues/269548 https://github.com/NixOS/nix/issues/9640
- pkgsCross.x86_64-freebsd builds work again
This change can be represented in 3 stages
1. merge libcxxabi into libcxx -- files: pkgs/development/compilers/llvm/[12, git]/{libcxx, libcxxabi}
2. update stdenv to account for merge -- files: stdenv.{adapters, cc.wrapper, darwin}
3. remove all references to libcxxabi outside of llvm (about 58 packages modified)
### merging libcxxabi into libcxx
- take the union of the libcxxabi and libcxx cmake flags
- eliminate the libcxx-headers-only package - it was only needed to break libcxx <-> libcxxabi circular dependency
- libcxx.cxxabi is removed. external cxxabi (freebsd) will symlink headers / libs into libcxx.
- darwin will re-export the libcxxabi symbols into libcxx so linking `-lc++` is sufficient.
- linux/freebsd `libc++.so` is a linker script `LINK(libc++.so.1, -lc++abi)` making `-lc++` sufficient.
- libcxx/default.nix [12, 17] are identical except for patches and `LIBCXX_ADDITIONAL_LIBRARIES` (only used in 16+)
- git/libcxx/defaul.nix does not link with -nostdlib when useLLVM is true so flag is removed. this is not much different than before as libcxxabi used -nostdlib where libcxx did not, so libc was linked in anyway.
### stdenv changes
- darwin bootstrap, remove references to libcxxabi and cxxabi
- cc-wrapper: remove c++ link workaround when libcxx.cxxabi doesn't exist (still exists for LLVM pre 12)
- adapter: update overrideLibcxx to account for a pkgs.stdenv that only has libcxx
### 58 package updates
- remove `NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}` as no longer needed
- swift, nodejs_v8 remove libcxxabi references in the clang override
https://github.com/NixOS/nixpkgs/pull/292043
2024-03-11 03:53:37 -07:00
|
|
|
# libc++.so is a linker script which expands to multiple libraries,
|
|
|
|
# libc++.so.1 and libc++abi.so or the external cxxabi. ld-wrapper doesn't
|
|
|
|
# support linker scripts so the external cxxabi needs to be symlinked in
|
|
|
|
postInstall = lib.optionalString (cxxabi != null) ''
|
2024-04-19 18:34:05 -04:00
|
|
|
lndir ${lib.getDev cxxabi}/include $dev/include/c++/v1
|
2024-03-28 11:24:06 -07:00
|
|
|
lndir ${lib.getLib cxxabi}/lib $out/lib
|
2024-04-27 11:41:46 +01:00
|
|
|
libcxxabi=$out/lib/lib${cxxabi.libName}.a
|
|
|
|
''
|
|
|
|
# LIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY=ON doesn't work for LLVM < 16 or
|
|
|
|
# external cxxabi libraries so merge libc++abi.a into libc++.a ourselves.
|
|
|
|
|
|
|
|
# GNU binutils emits objects in LIFO order in MRI scripts so after the merge
|
|
|
|
# the objects are in reversed order so a second MRI script is required so the
|
|
|
|
# objects in the archive are listed in proper order (libc++.a, libc++abi.a)
|
|
|
|
+ lib.optionalString (cxxabi != null || lib.versionOlder release_version "16") ''
|
|
|
|
libcxxabi=''${libcxxabi-$out/lib/libc++abi.a}
|
|
|
|
if [[ -f $out/lib/libc++.a && -e $libcxxabi ]]; then
|
|
|
|
$AR -M <<MRI
|
|
|
|
create $out/lib/libc++.a
|
|
|
|
addlib $out/lib/libc++.a
|
|
|
|
addlib $libcxxabi
|
|
|
|
save
|
|
|
|
end
|
|
|
|
MRI
|
|
|
|
$AR -M <<MRI
|
|
|
|
create $out/lib/libc++.a
|
|
|
|
addlib $out/lib/libc++.a
|
|
|
|
save
|
|
|
|
end
|
|
|
|
MRI
|
|
|
|
fi
|
2022-11-14 01:31:26 +00:00
|
|
|
'';
|
|
|
|
|
2022-02-27 18:42:36 +01:00
|
|
|
passthru = {
|
|
|
|
isLLVM = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
meta = llvm_meta // {
|
|
|
|
homepage = "https://libcxx.llvm.org/";
|
|
|
|
description = "C++ standard library";
|
|
|
|
longDescription = ''
|
|
|
|
libc++ is an implementation of the C++ standard library, targeting C++11,
|
|
|
|
C++14 and above.
|
|
|
|
'';
|
|
|
|
# "All of the code in libc++ is dual licensed under the MIT license and the
|
|
|
|
# UIUC License (a BSD-like license)":
|
|
|
|
license = with lib.licenses; [ mit ncsa ];
|
|
|
|
};
|
2024-03-28 11:24:06 -07:00
|
|
|
} // (if (lib.versionOlder release_version "16" || lib.versionAtLeast release_version "17") then {
|
|
|
|
postPatch = (lib.optionalString (lib.versionAtLeast release_version "14" && lib.versionOlder release_version "15") ''
|
|
|
|
# fix CMake error when static and LIBCXXABI_USE_LLVM_UNWINDER=ON. aren't
|
|
|
|
# building unwind so don't need to depend on it
|
|
|
|
substituteInPlace libcxx/src/CMakeLists.txt \
|
|
|
|
--replace-fail "add_dependencies(cxx_static unwind)" "# add_dependencies(cxx_static unwind)"
|
|
|
|
'') + ''
|
|
|
|
cd runtimes
|
|
|
|
'';
|
|
|
|
} else {
|
|
|
|
sourceRoot = "${src'.name}/runtimes";
|
|
|
|
}))
|