rustc: fix build with unbundled jemalloc and llvm on darwin
jemalloc with stripped prefix would cause segfaults in free: https://github.com/NixOS/nixpkgs/pull/49557#issuecomment-436734677 Thanks to @danieldk for darwin testing/debugging.
This commit is contained in:
parent
4b0d441cc4
commit
973eca740b
@ -20,6 +20,8 @@ let
|
|||||||
|
|
||||||
llvmShared = llvm.override { enableSharedLibraries = true; };
|
llvmShared = llvm.override { enableSharedLibraries = true; };
|
||||||
|
|
||||||
|
prefixedJemalloc = jemalloc.override { stripPrefix = false; };
|
||||||
|
|
||||||
target = builtins.replaceStrings [" "] [","] (builtins.toString targets);
|
target = builtins.replaceStrings [" "] [","] (builtins.toString targets);
|
||||||
in
|
in
|
||||||
|
|
||||||
@ -43,6 +45,7 @@ stdenv.mkDerivation {
|
|||||||
NIX_LDFLAGS =
|
NIX_LDFLAGS =
|
||||||
# when linking stage1 libstd: cc: undefined reference to `__cxa_begin_catch'
|
# when linking stage1 libstd: cc: undefined reference to `__cxa_begin_catch'
|
||||||
optional (stdenv.isLinux && !withBundledLLVM) "--push-state --as-needed -lstdc++ --pop-state"
|
optional (stdenv.isLinux && !withBundledLLVM) "--push-state --as-needed -lstdc++ --pop-state"
|
||||||
|
++ optional (stdenv.isDarwin && !withBundledLLVM) "-lc++"
|
||||||
++ optional stdenv.isDarwin "-rpath ${llvmShared}/lib";
|
++ optional stdenv.isDarwin "-rpath ${llvmShared}/lib";
|
||||||
|
|
||||||
# Enable nightly features in stable compiles (used for
|
# Enable nightly features in stable compiles (used for
|
||||||
@ -59,7 +62,7 @@ stdenv.mkDerivation {
|
|||||||
configureFlags = configureFlags
|
configureFlags = configureFlags
|
||||||
++ [ "--enable-local-rust" "--local-rust-root=${rustPlatform.rust.rustc}" "--enable-rpath"
|
++ [ "--enable-local-rust" "--local-rust-root=${rustPlatform.rust.rustc}" "--enable-rpath"
|
||||||
"--enable-vendor"
|
"--enable-vendor"
|
||||||
"--jemalloc-root=${jemalloc}/lib"
|
"--jemalloc-root=${prefixedJemalloc}/lib"
|
||||||
"--default-linker=${targetPackages.stdenv.cc}/bin/cc" ]
|
"--default-linker=${targetPackages.stdenv.cc}/bin/cc" ]
|
||||||
++ optional (!withBundledLLVM) [ "--enable-llvm-link-shared" "--llvm-root=${llvmShared}" ]
|
++ optional (!withBundledLLVM) [ "--enable-llvm-link-shared" "--llvm-root=${llvmShared}" ]
|
||||||
++ optional (targets != []) "--target=${target}";
|
++ optional (targets != []) "--target=${target}";
|
||||||
|
@ -1,6 +1,13 @@
|
|||||||
{ stdenv, fetchurl, version, sha256, ... }@args:
|
{ version, sha256 }:
|
||||||
|
{ stdenv, fetchurl,
|
||||||
|
# By default, jemalloc puts a je_ prefix onto all its symbols on OSX, which
|
||||||
|
# then stops downstream builds (mariadb in particular) from detecting it. This
|
||||||
|
# option should remove the prefix and give us a working jemalloc.
|
||||||
|
# Causes segfaults with some software (ex. rustc), but defaults to true for backward
|
||||||
|
# compatibility. Ignored on non OSX.
|
||||||
|
stripPrefix ? true }:
|
||||||
|
|
||||||
stdenv.mkDerivation (rec {
|
stdenv.mkDerivation rec {
|
||||||
name = "jemalloc-${version}";
|
name = "jemalloc-${version}";
|
||||||
inherit version;
|
inherit version;
|
||||||
|
|
||||||
@ -9,10 +16,8 @@ stdenv.mkDerivation (rec {
|
|||||||
inherit sha256;
|
inherit sha256;
|
||||||
};
|
};
|
||||||
|
|
||||||
# By default, jemalloc puts a je_ prefix onto all its symbols on OSX, which
|
# see the comment on stripPrefix
|
||||||
# then stops downstream builds (mariadb in particular) from detecting it. This
|
configureFlags = stdenv.lib.optional (stdenv.isDarwin && stripPrefix) "--with-jemalloc-prefix=";
|
||||||
# option should remove the prefix and give us a working jemalloc.
|
|
||||||
configureFlags = stdenv.lib.optional stdenv.isDarwin "--with-jemalloc-prefix=";
|
|
||||||
doCheck = true;
|
doCheck = true;
|
||||||
|
|
||||||
enableParallelBuilding = true;
|
enableParallelBuilding = true;
|
||||||
@ -28,4 +33,4 @@ stdenv.mkDerivation (rec {
|
|||||||
platforms = platforms.all;
|
platforms = platforms.all;
|
||||||
maintainers = with maintainers; [ wkennington ];
|
maintainers = with maintainers; [ wkennington ];
|
||||||
};
|
};
|
||||||
} // (builtins.removeAttrs args [ "stdenv" "fetchurl" "version" "sha256" ]))
|
}
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
{ stdenv, fetchurl, fetchpatch }:
|
|
||||||
import ./common.nix {
|
import ./common.nix {
|
||||||
inherit stdenv fetchurl;
|
|
||||||
version = "5.1.0";
|
version = "5.1.0";
|
||||||
sha256 = "0s3jpcyhzia8d4k0xyc67is78kg416p9yc3c2f9w6fhhqqffd5jk";
|
sha256 = "0s3jpcyhzia8d4k0xyc67is78kg416p9yc3c2f9w6fhhqqffd5jk";
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
{ stdenv, fetchurl }:
|
|
||||||
import ./common.nix {
|
import ./common.nix {
|
||||||
inherit stdenv fetchurl;
|
|
||||||
version = "4.5.0";
|
version = "4.5.0";
|
||||||
sha256 = "10373xhpc10pgmai9fkc1z0rs029qlcb3c0qfnvkbwdlcibdh2cl";
|
sha256 = "10373xhpc10pgmai9fkc1z0rs029qlcb3c0qfnvkbwdlcibdh2cl";
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user