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_*.stdenv: use top-level libc++ on Darwin #264091

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
45 changes: 45 additions & 0 deletions pkgs/development/compilers/llvm/10/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,51 @@ let
# pick clang appropriate for package set we are targeting
clang =
/**/ if stdenv.targetPlatform.libc == null then tools.clangNoLibc
# Treat Darwin’s top-level libc++ as the standard one for the platform. Otherwise, binaries
# built with a non-default version of clang can end up linked against multiple versions of
# libc++ simultaneously, which can lead to runtime crashes when both dylibs are loaded.
# Note that the headers from the requested clang will be used, but the runtime library
# will be the default version for Darwin. This is okay because libc++ defaults to building
# with the stable API (LIBCXX_ABI_VERSION is 1).
else if stdenv.targetPlatform.isDarwin then (
let
llvmLibcxxVersion = lib.getVersion llvmLibcxx;
stdenvLibcxxVersion = lib.getVersion stdenvLibcxx;

stdenvLibcxx = pkgs.stdenv.cc.libcxx;
stdenvCxxabi = pkgs.stdenv.cc.libcxx.cxxabi;

llvmLibcxx = tools.libcxxClang.libcxx;
llvmCxxabi = tools.libcxxClang.libcxx.cxxabi;

libcxx = pkgs.runCommand "${stdenvLibcxx.name}-${llvmLibcxxVersion}" {
outputs = [ "out" "dev" ];
inherit cxxabi;
isLLVM = true;
} ''
mkdir -p "$dev/nix-support"
ln -s '${stdenvLibcxx}' "$out"
echo '${stdenvLibcxx}' > "$dev/nix-support/propagated-build-inputs"
ln -s '${lib.getDev llvmLibcxx}/include' "$dev/include"
'';

cxxabi = pkgs.runCommand "${stdenvCxxabi.name}-${llvmLibcxxVersion}" {
outputs = [ "out" "dev" ];
inherit (stdenvCxxabi) libName;
} ''
mkdir -p "$dev/nix-support"
ln -s '${stdenvCxxabi}' "$out"
echo '${stdenvCxxabi}' > "$dev/nix-support/propagated-build-inputs"
ln -s '${lib.getDev llvmCxxabi}/include' "$dev/include"
'';
in
if llvmLibcxxVersion != stdenvLibcxxVersion
then tools.libcxxClang.override {
inherit libcxx;
extraPackages = [ cxxabi targetLlvmLibraries.compiler-rt ];
}
else tools.libcxxClang
)
else if stdenv.targetPlatform.useLLVM or false then tools.clangUseLLVM
else if (pkgs.targetPackages.stdenv or stdenv).cc.isGNU then tools.libstdcxxClang
else tools.libcxxClang;
Expand Down
45 changes: 45 additions & 0 deletions pkgs/development/compilers/llvm/11/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,51 @@ let
# pick clang appropriate for package set we are targeting
clang =
/**/ if stdenv.targetPlatform.libc == null then tools.clangNoLibc
# Treat Darwin’s top-level libc++ as the standard one for the platform. Otherwise, binaries
# built with a non-default version of clang can end up linked against multiple versions of
# libc++ simultaneously, which can lead to runtime crashes when both dylibs are loaded.
# Note that the headers from the requested clang will be used, but the runtime library
# will be the default version for Darwin. This is okay because libc++ defaults to building
# with the stable API (LIBCXX_ABI_VERSION is 1).
else if stdenv.targetPlatform.isDarwin then (
let
llvmLibcxxVersion = lib.getVersion llvmLibcxx;
stdenvLibcxxVersion = lib.getVersion stdenvLibcxx;

stdenvLibcxx = pkgs.stdenv.cc.libcxx;
stdenvCxxabi = pkgs.stdenv.cc.libcxx.cxxabi;

llvmLibcxx = tools.libcxxClang.libcxx;
llvmCxxabi = tools.libcxxClang.libcxx.cxxabi;

libcxx = pkgs.runCommand "${stdenvLibcxx.name}-${llvmLibcxxVersion}" {
outputs = [ "out" "dev" ];
inherit cxxabi;
isLLVM = true;
} ''
mkdir -p "$dev/nix-support"
ln -s '${stdenvLibcxx}' "$out"
echo '${stdenvLibcxx}' > "$dev/nix-support/propagated-build-inputs"
ln -s '${lib.getDev llvmLibcxx}/include' "$dev/include"
'';

cxxabi = pkgs.runCommand "${stdenvCxxabi.name}-${llvmLibcxxVersion}" {
outputs = [ "out" "dev" ];
inherit (stdenvCxxabi) libName;
} ''
mkdir -p "$dev/nix-support"
ln -s '${stdenvCxxabi}' "$out"
echo '${stdenvCxxabi}' > "$dev/nix-support/propagated-build-inputs"
ln -s '${lib.getDev llvmCxxabi}/include' "$dev/include"
'';
in
if llvmLibcxxVersion != stdenvLibcxxVersion
then tools.libcxxClang.override {
inherit libcxx;
extraPackages = [ cxxabi targetLlvmLibraries.compiler-rt ];
}
else tools.libcxxClang
)
else if stdenv.targetPlatform.useLLVM or false then tools.clangUseLLVM
else if (pkgs.targetPackages.stdenv or stdenv).cc.isGNU then tools.libstdcxxClang
else tools.libcxxClang;
Expand Down
45 changes: 45 additions & 0 deletions pkgs/development/compilers/llvm/12/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,51 @@ let
# pick clang appropriate for package set we are targeting
clang =
/**/ if stdenv.targetPlatform.libc == null then tools.clangNoLibc
# Treat Darwin’s top-level libc++ as the standard one for the platform. Otherwise, binaries
# built with a non-default version of clang can end up linked against multiple versions of
# libc++ simultaneously, which can lead to runtime crashes when both dylibs are loaded.
# Note that the headers from the requested clang will be used, but the runtime library
# will be the default version for Darwin. This is okay because libc++ defaults to building
# with the stable API (LIBCXX_ABI_VERSION is 1).
else if stdenv.targetPlatform.isDarwin then (
let
llvmLibcxxVersion = lib.getVersion llvmLibcxx;
stdenvLibcxxVersion = lib.getVersion stdenvLibcxx;

stdenvLibcxx = pkgs.stdenv.cc.libcxx;
stdenvCxxabi = pkgs.stdenv.cc.libcxx.cxxabi;

llvmLibcxx = tools.libcxxClang.libcxx;
llvmCxxabi = tools.libcxxClang.libcxx.cxxabi;

libcxx = pkgs.runCommand "${stdenvLibcxx.name}-${llvmLibcxxVersion}" {
outputs = [ "out" "dev" ];
inherit cxxabi;
isLLVM = true;
} ''
mkdir -p "$dev/nix-support"
ln -s '${stdenvLibcxx}' "$out"
echo '${stdenvLibcxx}' > "$dev/nix-support/propagated-build-inputs"
ln -s '${lib.getDev llvmLibcxx}/include' "$dev/include"
'';

cxxabi = pkgs.runCommand "${stdenvCxxabi.name}-${llvmLibcxxVersion}" {
outputs = [ "out" "dev" ];
inherit (stdenvCxxabi) libName;
} ''
mkdir -p "$dev/nix-support"
ln -s '${stdenvCxxabi}' "$out"
echo '${stdenvCxxabi}' > "$dev/nix-support/propagated-build-inputs"
ln -s '${lib.getDev llvmCxxabi}/include' "$dev/include"
'';
in
if llvmLibcxxVersion != stdenvLibcxxVersion
then tools.libcxxClang.override {
inherit libcxx;
extraPackages = [ cxxabi targetLlvmLibraries.compiler-rt ];
}
else tools.libcxxClang
)
else if stdenv.targetPlatform.useLLVM or false then tools.clangUseLLVM
else if (pkgs.targetPackages.stdenv or stdenv).cc.isGNU then tools.libstdcxxClang
else tools.libcxxClang;
Expand Down
45 changes: 45 additions & 0 deletions pkgs/development/compilers/llvm/13/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,51 @@ let
# pick clang appropriate for package set we are targeting
clang =
/**/ if stdenv.targetPlatform.libc == null then tools.clangNoLibc
# Treat Darwin’s top-level libc++ as the standard one for the platform. Otherwise, binaries
# built with a non-default version of clang can end up linked against multiple versions of
# libc++ simultaneously, which can lead to runtime crashes when both dylibs are loaded.
# Note that the headers from the requested clang will be used, but the runtime library
# will be the default version for Darwin. This is okay because libc++ defaults to building
# with the stable API (LIBCXX_ABI_VERSION is 1).
else if stdenv.targetPlatform.isDarwin then (
let
llvmLibcxxVersion = lib.getVersion llvmLibcxx;
stdenvLibcxxVersion = lib.getVersion stdenvLibcxx;

stdenvLibcxx = pkgs.stdenv.cc.libcxx;
stdenvCxxabi = pkgs.stdenv.cc.libcxx.cxxabi;

llvmLibcxx = tools.libcxxClang.libcxx;
llvmCxxabi = tools.libcxxClang.libcxx.cxxabi;

libcxx = pkgs.runCommand "${stdenvLibcxx.name}-${llvmLibcxxVersion}" {
outputs = [ "out" "dev" ];
inherit cxxabi;
isLLVM = true;
} ''
mkdir -p "$dev/nix-support"
ln -s '${stdenvLibcxx}' "$out"
echo '${stdenvLibcxx}' > "$dev/nix-support/propagated-build-inputs"
ln -s '${lib.getDev llvmLibcxx}/include' "$dev/include"
'';

cxxabi = pkgs.runCommand "${stdenvCxxabi.name}-${llvmLibcxxVersion}" {
outputs = [ "out" "dev" ];
inherit (stdenvCxxabi) libName;
} ''
mkdir -p "$dev/nix-support"
ln -s '${stdenvCxxabi}' "$out"
echo '${stdenvCxxabi}' > "$dev/nix-support/propagated-build-inputs"
ln -s '${lib.getDev llvmCxxabi}/include' "$dev/include"
'';
in
if llvmLibcxxVersion != stdenvLibcxxVersion
then tools.libcxxClang.override {
inherit libcxx;
extraPackages = [ cxxabi targetLlvmLibraries.compiler-rt ];
}
else tools.libcxxClang
)
else if stdenv.targetPlatform.useLLVM or false then tools.clangUseLLVM
else if (pkgs.targetPackages.stdenv or stdenv).cc.isGNU then tools.libstdcxxClang
else tools.libcxxClang;
Expand Down
45 changes: 45 additions & 0 deletions pkgs/development/compilers/llvm/14/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,51 @@ let
# pick clang appropriate for package set we are targeting
clang =
/**/ if stdenv.targetPlatform.libc == null then tools.clangNoLibc
# Treat Darwin’s top-level libc++ as the standard one for the platform. Otherwise, binaries
# built with a non-default version of clang can end up linked against multiple versions of
# libc++ simultaneously, which can lead to runtime crashes when both dylibs are loaded.
# Note that the headers from the requested clang will be used, but the runtime library
# will be the default version for Darwin. This is okay because libc++ defaults to building
# with the stable API (LIBCXX_ABI_VERSION is 1).
else if stdenv.targetPlatform.isDarwin then (
let
llvmLibcxxVersion = lib.getVersion llvmLibcxx;
stdenvLibcxxVersion = lib.getVersion stdenvLibcxx;

stdenvLibcxx = pkgs.stdenv.cc.libcxx;
stdenvCxxabi = pkgs.stdenv.cc.libcxx.cxxabi;

llvmLibcxx = tools.libcxxClang.libcxx;
llvmCxxabi = tools.libcxxClang.libcxx.cxxabi;

libcxx = pkgs.runCommand "${stdenvLibcxx.name}-${llvmLibcxxVersion}" {
outputs = [ "out" "dev" ];
inherit cxxabi;
isLLVM = true;
} ''
mkdir -p "$dev/nix-support"
ln -s '${stdenvLibcxx}' "$out"
echo '${stdenvLibcxx}' > "$dev/nix-support/propagated-build-inputs"
ln -s '${lib.getDev llvmLibcxx}/include' "$dev/include"
'';

cxxabi = pkgs.runCommand "${stdenvCxxabi.name}-${llvmLibcxxVersion}" {
outputs = [ "out" "dev" ];
inherit (stdenvCxxabi) libName;
} ''
mkdir -p "$dev/nix-support"
ln -s '${stdenvCxxabi}' "$out"
echo '${stdenvCxxabi}' > "$dev/nix-support/propagated-build-inputs"
ln -s '${lib.getDev llvmCxxabi}/include' "$dev/include"
'';
in
if llvmLibcxxVersion != stdenvLibcxxVersion
then tools.libcxxClang.override {
inherit libcxx;
extraPackages = [ cxxabi targetLlvmLibraries.compiler-rt ];
}
else tools.libcxxClang
)
else if stdenv.targetPlatform.useLLVM or false then tools.clangUseLLVM
else if (pkgs.targetPackages.stdenv or stdenv).cc.isGNU then tools.libstdcxxClang
else tools.libcxxClang;
Expand Down
45 changes: 45 additions & 0 deletions pkgs/development/compilers/llvm/15/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,51 @@ in let
# pick clang appropriate for package set we are targeting
clang =
/**/ if stdenv.targetPlatform.libc == null then tools.clangNoLibc
# Treat Darwin’s top-level libc++ as the standard one for the platform. Otherwise, binaries
# built with a non-default version of clang can end up linked against multiple versions of
# libc++ simultaneously, which can lead to runtime crashes when both dylibs are loaded.
# Note that the headers from the requested clang will be used, but the runtime library
# will be the default version for Darwin. This is okay because libc++ defaults to building
# with the stable API (LIBCXX_ABI_VERSION is 1).
else if stdenv.targetPlatform.isDarwin then (
let
llvmLibcxxVersion = lib.getVersion llvmLibcxx;
stdenvLibcxxVersion = lib.getVersion stdenvLibcxx;

stdenvLibcxx = pkgs.stdenv.cc.libcxx;
stdenvCxxabi = pkgs.stdenv.cc.libcxx.cxxabi;

llvmLibcxx = tools.libcxxClang.libcxx;
llvmCxxabi = tools.libcxxClang.libcxx.cxxabi;

libcxx = pkgs.runCommand "${stdenvLibcxx.name}-${llvmLibcxxVersion}" {
outputs = [ "out" "dev" ];
inherit cxxabi;
isLLVM = true;
} ''
mkdir -p "$dev/nix-support"
ln -s '${stdenvLibcxx}' "$out"
echo '${stdenvLibcxx}' > "$dev/nix-support/propagated-build-inputs"
ln -s '${lib.getDev llvmLibcxx}/include' "$dev/include"
'';

cxxabi = pkgs.runCommand "${stdenvCxxabi.name}-${llvmLibcxxVersion}" {
outputs = [ "out" "dev" ];
inherit (stdenvCxxabi) libName;
} ''
mkdir -p "$dev/nix-support"
ln -s '${stdenvCxxabi}' "$out"
echo '${stdenvCxxabi}' > "$dev/nix-support/propagated-build-inputs"
ln -s '${lib.getDev llvmCxxabi}/include' "$dev/include"
'';
in
if llvmLibcxxVersion != stdenvLibcxxVersion
then tools.libcxxClang.override {
inherit libcxx;
extraPackages = [ cxxabi targetLlvmLibraries.compiler-rt ];
}
else tools.libcxxClang
)
else if stdenv.targetPlatform.useLLVM or false then tools.clangUseLLVM
else if (pkgs.targetPackages.stdenv or stdenv).cc.isGNU then tools.libstdcxxClang
else tools.libcxxClang;
Expand Down
49 changes: 47 additions & 2 deletions pkgs/development/compilers/llvm/16/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ in
(gitRelease != null)
(officialRelease != null))
("must specify `gitRelease` or `officialRelease`" +
(lib.optionalString (gitRelease != null) " not both"));
(lib.optionalString (gitRelease != null) " not both"));
let
monorepoSrc' = monorepoSrc;
in let
Expand Down Expand Up @@ -157,6 +157,51 @@ in let
# pick clang appropriate for package set we are targeting
clang =
/**/ if stdenv.targetPlatform.useLLVM or false then tools.clangUseLLVM
# Treat Darwin’s top-level libc++ as the standard one for the platform. Otherwise, binaries
# built with a non-default version of clang can end up linked against multiple versions of
# libc++ simultaneously, which can lead to runtime crashes when both dylibs are loaded.
# Note that the headers from the requested clang will be used, but the runtime library
# will be the default version for Darwin. This is okay because libc++ defaults to building
# with the stable API (LIBCXX_ABI_VERSION is 1).
else if stdenv.targetPlatform.isDarwin then (
let
llvmLibcxxVersion = lib.getVersion llvmLibcxx;
stdenvLibcxxVersion = lib.getVersion stdenvLibcxx;

stdenvLibcxx = pkgs.stdenv.cc.libcxx;
stdenvCxxabi = pkgs.stdenv.cc.libcxx.cxxabi;

llvmLibcxx = tools.libcxxClang.libcxx;
llvmCxxabi = tools.libcxxClang.libcxx.cxxabi;

libcxx = pkgs.runCommand "${stdenvLibcxx.name}-${llvmLibcxxVersion}" {
outputs = [ "out" "dev" ];
inherit cxxabi;
isLLVM = true;
} ''
mkdir -p "$dev/nix-support"
ln -s '${stdenvLibcxx}' "$out"
echo '${stdenvLibcxx}' > "$dev/nix-support/propagated-build-inputs"
ln -s '${lib.getDev llvmLibcxx}/include' "$dev/include"
'';

cxxabi = pkgs.runCommand "${stdenvCxxabi.name}-${llvmLibcxxVersion}" {
outputs = [ "out" "dev" ];
inherit (stdenvCxxabi) libName;
} ''
mkdir -p "$dev/nix-support"
ln -s '${stdenvCxxabi}' "$out"
echo '${stdenvCxxabi}' > "$dev/nix-support/propagated-build-inputs"
ln -s '${lib.getDev llvmCxxabi}/include' "$dev/include"
'';
in
if llvmLibcxxVersion != stdenvLibcxxVersion
then tools.libcxxClang.override {
inherit libcxx;
extraPackages = [ cxxabi targetLlvmLibraries.compiler-rt ];
}
else tools.libcxxClang
)
else if (pkgs.targetPackages.stdenv or stdenv).cc.isGNU then tools.libstdcxxClang
else tools.libcxxClang;

Expand Down Expand Up @@ -226,7 +271,7 @@ in let
# fully LLVM toolchain from scratch. No GCC toolchain should be
# pulled in. As a consequence, it is very quick to build different
# targets provided by LLVM and we can also build for what GCC
# doesnt support like LLVM. Probably we should move to some other
# doesnt support like LLVM. Probably we should move to some other
# file.

bintools-unwrapped = callPackage ../common/bintools.nix { };
Expand Down
Loading