rustc: fix build with structuredAttrs (#470983)
This commit is contained in:
@@ -76,33 +76,35 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
# See: https://github.com/NixOS/nixpkgs/pull/56540#issuecomment-471624656
|
||||
stripDebugList = [ "bin" ];
|
||||
|
||||
NIX_LDFLAGS = toString (
|
||||
# when linking stage1 libstd: cc: undefined reference to `__cxa_begin_catch'
|
||||
# This doesn't apply to cross-building for FreeBSD because the host
|
||||
# uses libstdc++, but the target (used for building std) uses libc++
|
||||
optional (
|
||||
stdenv.hostPlatform.isLinux && !withBundledLLVM && !stdenv.targetPlatform.isFreeBSD && !useLLVM
|
||||
) "--push-state --as-needed -lstdc++ --pop-state"
|
||||
++
|
||||
optional
|
||||
(stdenv.hostPlatform.isLinux && !withBundledLLVM && !stdenv.targetPlatform.isFreeBSD && useLLVM)
|
||||
"--push-state --as-needed -L${llvmPackages.libcxx}/lib -lc++ -lc++abi -lLLVM-${lib.versions.major llvmPackages.llvm.version} --pop-state"
|
||||
++ optional (stdenv.hostPlatform.isDarwin && !withBundledLLVM) "-lc++ -lc++abi"
|
||||
++ optional stdenv.hostPlatform.isDarwin "-rpath ${llvmSharedForHost.lib}/lib"
|
||||
);
|
||||
env = {
|
||||
NIX_LDFLAGS = toString (
|
||||
# when linking stage1 libstd: cc: undefined reference to `__cxa_begin_catch'
|
||||
# This doesn't apply to cross-building for FreeBSD because the host
|
||||
# uses libstdc++, but the target (used for building std) uses libc++
|
||||
optional (
|
||||
stdenv.hostPlatform.isLinux && !withBundledLLVM && !stdenv.targetPlatform.isFreeBSD && !useLLVM
|
||||
) "--push-state --as-needed -lstdc++ --pop-state"
|
||||
++
|
||||
optional
|
||||
(stdenv.hostPlatform.isLinux && !withBundledLLVM && !stdenv.targetPlatform.isFreeBSD && useLLVM)
|
||||
"--push-state --as-needed -L${llvmPackages.libcxx}/lib -lc++ -lc++abi -lLLVM-${lib.versions.major llvmPackages.llvm.version} --pop-state"
|
||||
++ optional (stdenv.hostPlatform.isDarwin && !withBundledLLVM) "-lc++ -lc++abi"
|
||||
++ optional stdenv.hostPlatform.isDarwin "-rpath ${llvmSharedForHost.lib}/lib"
|
||||
);
|
||||
|
||||
RUSTFLAGS = lib.concatStringsSep " " (
|
||||
[
|
||||
# Increase codegen units to introduce parallelism within the compiler.
|
||||
"-Ccodegen-units=10"
|
||||
]
|
||||
++ lib.optionals (stdenv.hostPlatform.rust.rustcTargetSpec == "x86_64-unknown-linux-gnu") [
|
||||
# Upstream defaults to lld on x86_64-unknown-linux-gnu, we want to use our linker
|
||||
"-Clinker-features=-lld"
|
||||
"-Clink-self-contained=-linker"
|
||||
]
|
||||
);
|
||||
RUSTDOCFLAGS = "-A rustdoc::broken-intra-doc-links";
|
||||
RUSTFLAGS = lib.concatStringsSep " " (
|
||||
[
|
||||
# Increase codegen units to introduce parallelism within the compiler.
|
||||
"-Ccodegen-units=10"
|
||||
]
|
||||
++ lib.optionals (stdenv.hostPlatform.rust.rustcTargetSpec == "x86_64-unknown-linux-gnu") [
|
||||
# Upstream defaults to lld on x86_64-unknown-linux-gnu, we want to use our linker
|
||||
"-Clinker-features=-lld"
|
||||
"-Clink-self-contained=-linker"
|
||||
]
|
||||
);
|
||||
RUSTDOCFLAGS = "-A rustdoc::broken-intra-doc-links";
|
||||
};
|
||||
|
||||
# We need rust to build rust. If we don't provide it, configure will try to download it.
|
||||
# Reference: https://github.com/rust-lang/rust/blob/master/src/bootstrap/configure.py
|
||||
@@ -263,7 +265,7 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
]
|
||||
++ optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) [
|
||||
# https://github.com/rust-lang/rust/issues/92173
|
||||
"--set rust.jemalloc"
|
||||
"--set=rust.jemalloc"
|
||||
]
|
||||
++ optionals (useLLVM && !stdenv.targetPlatform.isFreeBSD) [
|
||||
# https://github.com/NixOS/nixpkgs/issues/311930
|
||||
@@ -279,7 +281,7 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
# applies to functions that can be immediately compiled when building
|
||||
# std. Generic functions that do codegen when called in user code obey
|
||||
# -Cforce-frame-pointers specified then, if any)
|
||||
"--set rust.frame-pointers"
|
||||
"--set=rust.frame-pointers"
|
||||
];
|
||||
|
||||
# if we already have a rust compiler for build just compile the target std
|
||||
@@ -451,6 +453,8 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
// lib.optionalAttrs stdenv.hostPlatform.isLinux { inherit firefox thunderbird; };
|
||||
};
|
||||
|
||||
__structuredAttrs = true;
|
||||
|
||||
meta = {
|
||||
homepage = "https://www.rust-lang.org/";
|
||||
description = "Safe, concurrent, practical language";
|
||||
|
||||
Reference in New Issue
Block a user