diff --git a/pkgs/development/compilers/rust/rustc.nix b/pkgs/development/compilers/rust/rustc.nix index 48710753d803b..3ec08a82d0179 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 @@ -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}"; diff --git a/pkgs/development/libraries/jemalloc/common.nix b/pkgs/development/libraries/jemalloc/common.nix index 593f4411f19f9..5ac1067d92fb5 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,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" ])) +} diff --git a/pkgs/development/libraries/jemalloc/default.nix b/pkgs/development/libraries/jemalloc/default.nix index 8cb7c1f96733e..7ea7bccd6b872 100644 --- a/pkgs/development/libraries/jemalloc/default.nix +++ b/pkgs/development/libraries/jemalloc/default.nix @@ -1,6 +1,4 @@ -{ stdenv, fetchurl, fetchpatch }: import ./common.nix { - inherit stdenv fetchurl; 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"; -} +}