From 5a0116e4c307265850b825bf1949c81dca6da3d3 Mon Sep 17 00:00:00 2001 From: Symphorien Gibol Date: Thu, 8 Nov 2018 12:58:56 +0100 Subject: [PATCH] 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 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 973eca740bec22df9760f9db9e1e66f3e5f6c164) --- pkgs/development/compilers/rust/rustc.nix | 2 ++ pkgs/development/libraries/jemalloc/common.nix | 18 +++++++++++------- .../development/libraries/jemalloc/default.nix | 10 ++-------- .../libraries/jemalloc/jemalloc450.nix | 4 +--- 4 files changed, 16 insertions(+), 18 deletions(-) diff --git a/pkgs/development/compilers/rust/rustc.nix b/pkgs/development/compilers/rust/rustc.nix index 9c9788ff48345..b300327dab5eb 100644 --- a/pkgs/development/compilers/rust/rustc.nix +++ b/pkgs/development/compilers/rust/rustc.nix @@ -20,6 +20,8 @@ let llvmShared = llvm.override { enableSharedLibraries = true; }; + prefixedJemalloc = jemalloc.override { stripPrefix = false; }; + target = builtins.replaceStrings [" "] [","] (builtins.toString targets); in diff --git a/pkgs/development/libraries/jemalloc/common.nix b/pkgs/development/libraries/jemalloc/common.nix index d8866ae3ff891..2cca02a1af301 100644 --- a/pkgs/development/libraries/jemalloc/common.nix +++ b/pkgs/development/libraries/jemalloc/common.nix @@ -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,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 @@ -32,4 +36,4 @@ stdenv.mkDerivation (rec { platforms = platforms.all; maintainers = with maintainers; [ wkennington ]; }; -} // (builtins.removeAttrs args [ "stdenv" "fetchurl" "version" "sha256" ])) +} diff --git a/pkgs/development/libraries/jemalloc/default.nix b/pkgs/development/libraries/jemalloc/default.nix index 40c06cbffdf01..7ea7bccd6b872 100644 --- a/pkgs/development/libraries/jemalloc/default.nix +++ b/pkgs/development/libraries/jemalloc/default.nix @@ -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"; } diff --git a/pkgs/development/libraries/jemalloc/jemalloc450.nix b/pkgs/development/libraries/jemalloc/jemalloc450.nix index 00b38a855532f..d328ab8016a18 100644 --- a/pkgs/development/libraries/jemalloc/jemalloc450.nix +++ b/pkgs/development/libraries/jemalloc/jemalloc450.nix @@ -1,6 +1,4 @@ -{ stdenv, fetchurl }: import ./common.nix { - inherit stdenv fetchurl; version = "4.5.0"; sha256 = "10373xhpc10pgmai9fkc1z0rs029qlcb3c0qfnvkbwdlcibdh2cl"; -} +}