Skip to content

Commit

Permalink
rustc: fix build with unbundled jemalloc and llvm on darwin
Browse files Browse the repository at this point in the history
jemalloc with stripped prefix would cause segfaults in free:
NixOS#49557 (comment)

This commit has been adjusted from the one on master to only carry the
relevant changes (the new optional `stripPrefix`) flag while still
keeping the other flags that were removed on master since they are no
loner supported by the version used there.

(cherry picked from commit 973eca7)
  • Loading branch information
symphorien authored and andir committed Jan 23, 2019
1 parent ae83566 commit 5a0116e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 18 deletions.
2 changes: 2 additions & 0 deletions pkgs/development/compilers/rust/rustc.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ let

llvmShared = llvm.override { enableSharedLibraries = true; };

prefixedJemalloc = jemalloc.override { stripPrefix = false; };

target = builtins.replaceStrings [" "] [","] (builtins.toString targets);
in

Expand Down
18 changes: 11 additions & 7 deletions pkgs/development/libraries/jemalloc/common.nix
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -9,10 +16,7 @@ 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="
configureFlags = stdenv.lib.optional (stdenv.isDarwin && stripPrefix) "--with-jemalloc-prefix="
# jemalloc is unable to correctly detect transparent hugepage support on
# ARM (https://github.com/jemalloc/jemalloc/issues/526), and the default
# kernel ARMv6/7 kernel does not enable it, so we explicitly disable support
Expand All @@ -32,4 +36,4 @@ stdenv.mkDerivation (rec {
platforms = platforms.all;
maintainers = with maintainers; [ wkennington ];
};
} // (builtins.removeAttrs args [ "stdenv" "fetchurl" "version" "sha256" ]))
}
10 changes: 2 additions & 8 deletions pkgs/development/libraries/jemalloc/default.nix
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
{ stdenv, fetchurl, fetchpatch }:
import ./common.nix {
inherit stdenv fetchurl;
version = "5.0.1";
sha256 = "4814781d395b0ef093b21a08e8e6e0bd3dab8762f9935bbfb71679b0dea7c3e9";
patches = stdenv.lib.optional stdenv.isAarch64 (fetchpatch {
url = "https://patch-diff.githubusercontent.com/raw/jemalloc/jemalloc/pull/1035.patch";
sha256 = "02y0q3dp253bipxv4r954nqipbjbj92p6ww9bx5bk3d8pa81wkqq";
});
version = "5.1.0";
sha256 = "0s3jpcyhzia8d4k0xyc67is78kg416p9yc3c2f9w6fhhqqffd5jk";
}
4 changes: 1 addition & 3 deletions pkgs/development/libraries/jemalloc/jemalloc450.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{ stdenv, fetchurl }:
import ./common.nix {
inherit stdenv fetchurl;
version = "4.5.0";
sha256 = "10373xhpc10pgmai9fkc1z0rs029qlcb3c0qfnvkbwdlcibdh2cl";
}
}

0 comments on commit 5a0116e

Please sign in to comment.