Merge pull request #93128 from Ma27/fix-rust-build-flags

rust: Fix build flags
This commit is contained in:
Florian Klink 2020-07-16 12:47:26 +02:00 committed by GitHub
commit ba20bc872f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 8 deletions

View File

@ -74,6 +74,7 @@ let
ccForHost="${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc"; ccForHost="${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc";
cxxForHost="${stdenv.cc}/bin/${stdenv.cc.targetPrefix}c++"; cxxForHost="${stdenv.cc}/bin/${stdenv.cc.targetPrefix}c++";
releaseDir = "target/${rustTarget}/${buildType}"; releaseDir = "target/${rustTarget}/${buildType}";
tmpDir = "${releaseDir}-tmp";
# Specify the stdenv's `diff` by abspath to ensure that the user's build # Specify the stdenv's `diff` by abspath to ensure that the user's build
# inputs do not cause us to find the wrong `diff`. # inputs do not cause us to find the wrong `diff`.
@ -193,13 +194,15 @@ stdenv.mkDerivation (args // {
# This needs to be done after postBuild: packages like `cargo` do a pushd/popd in # This needs to be done after postBuild: packages like `cargo` do a pushd/popd in
# the pre/postBuild-hooks that need to be taken into account before gathering # the pre/postBuild-hooks that need to be taken into account before gathering
# all binaries to install. # all binaries to install.
bins=$(find $releaseDir \ mkdir -p $tmpDir
cp -r $releaseDir/* $tmpDir/
bins=$(find $tmpDir \
-maxdepth 1 \ -maxdepth 1 \
-type f \ -type f \
-executable ! \( -regex ".*\.\(so.[0-9.]+\|so\|a\|dylib\)" \)) -executable ! \( -regex ".*\.\(so.[0-9.]+\|so\|a\|dylib\)" \))
''; '';
installCheckPhase = args.checkPhase or (let checkPhase = args.checkPhase or (let
argstr = "${stdenv.lib.optionalString (checkType == "release") "--release"} --target ${rustTarget} --frozen"; argstr = "${stdenv.lib.optionalString (checkType == "release") "--release"} --target ${rustTarget} --frozen";
in '' in ''
${stdenv.lib.optionalString (buildAndTestSubdir != null) "pushd ${buildAndTestSubdir}"} ${stdenv.lib.optionalString (buildAndTestSubdir != null) "pushd ${buildAndTestSubdir}"}
@ -214,13 +217,13 @@ stdenv.mkDerivation (args // {
strictDeps = true; strictDeps = true;
inherit releaseDir; inherit releaseDir tmpDir;
installPhase = args.installPhase or '' installPhase = args.installPhase or ''
runHook preInstall runHook preInstall
# rename the output dir to a architecture independent one # rename the output dir to a architecture independent one
mapfile -t targets < <(find "$NIX_BUILD_TOP" -type d | grep '${releaseDir}$') mapfile -t targets < <(find "$NIX_BUILD_TOP" -type d | grep '${tmpDir}$')
for target in "''${targets[@]}"; do for target in "''${targets[@]}"; do
rm -rf "$target/../../${buildType}" rm -rf "$target/../../${buildType}"
ln -srf "$target" "$target/../../" ln -srf "$target" "$target/../../"
@ -228,7 +231,7 @@ stdenv.mkDerivation (args // {
mkdir -p $out/bin $out/lib mkdir -p $out/bin $out/lib
xargs -r cp -t $out/bin <<< $bins xargs -r cp -t $out/bin <<< $bins
find $releaseDir \ find $tmpDir \
-maxdepth 1 \ -maxdepth 1 \
-regex ".*\.\(so.[0-9.]+\|so\|a\|dylib\)" \ -regex ".*\.\(so.[0-9.]+\|so\|a\|dylib\)" \
-print0 | xargs -r -0 cp -t $out/lib -print0 | xargs -r -0 cp -t $out/lib

View File

@ -39,9 +39,7 @@ rustPlatform.buildRustPackage rec {
) )
]; ];
# Disable tests until they can be run with --features no-self-update doCheck = !stdenv.isAarch64 && !stdenv.isDarwin;
doCheck = false;
#doCheck = !stdenv.isAarch64 && !stdenv.isDarwin;
postInstall = '' postInstall = ''
pushd $out/bin pushd $out/bin