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:
Symphorien Gibol 2018-11-08 12:58:56 +01:00
parent 4b0d441cc4
commit 973eca740b
4 changed files with 17 additions and 13 deletions

View File

@ -20,6 +20,8 @@ let
llvmShared = llvm.override { enableSharedLibraries = true; };
prefixedJemalloc = jemalloc.override { stripPrefix = false; };
target = builtins.replaceStrings [" "] [","] (builtins.toString targets);
in
@ -43,6 +45,7 @@ stdenv.mkDerivation {
NIX_LDFLAGS =
# when linking stage1 libstd: cc: undefined reference to `__cxa_begin_catch'
optional (stdenv.isLinux && !withBundledLLVM) "--push-state --as-needed -lstdc++ --pop-state"
++ optional (stdenv.isDarwin && !withBundledLLVM) "-lc++"
++ optional stdenv.isDarwin "-rpath ${llvmShared}/lib";
# Enable nightly features in stable compiles (used for
@ -59,7 +62,7 @@ stdenv.mkDerivation {
configureFlags = configureFlags
++ [ "--enable-local-rust" "--local-rust-root=${rustPlatform.rust.rustc}" "--enable-rpath"
"--enable-vendor"
"--jemalloc-root=${jemalloc}/lib"
"--jemalloc-root=${prefixedJemalloc}/lib"
"--default-linker=${targetPackages.stdenv.cc}/bin/cc" ]
++ optional (!withBundledLLVM) [ "--enable-llvm-link-shared" "--llvm-root=${llvmShared}" ]
++ optional (targets != []) "--target=${target}";

View File

@ -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}";
inherit version;
@ -9,10 +16,8 @@ stdenv.mkDerivation (rec {
inherit sha256;
};
# 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.
configureFlags = stdenv.lib.optional stdenv.isDarwin "--with-jemalloc-prefix=";
# see the comment on stripPrefix
configureFlags = stdenv.lib.optional (stdenv.isDarwin && stripPrefix) "--with-jemalloc-prefix=";
doCheck = true;
enableParallelBuilding = true;
@ -28,4 +33,4 @@ stdenv.mkDerivation (rec {
platforms = platforms.all;
maintainers = with maintainers; [ wkennington ];
};
} // (builtins.removeAttrs args [ "stdenv" "fetchurl" "version" "sha256" ]))
}

View File

@ -1,6 +1,4 @@
{ stdenv, fetchurl, fetchpatch }:
import ./common.nix {
inherit stdenv fetchurl;
version = "5.1.0";
sha256 = "0s3jpcyhzia8d4k0xyc67is78kg416p9yc3c2f9w6fhhqqffd5jk";
}

View File

@ -1,6 +1,4 @@
{ stdenv, fetchurl }:
import ./common.nix {
inherit stdenv fetchurl;
version = "4.5.0";
sha256 = "10373xhpc10pgmai9fkc1z0rs029qlcb3c0qfnvkbwdlcibdh2cl";
}
}