Merge pull request #186443 from yu-re-ka/feature/rustc-musl2
fix pkgsMusl.rustc
This commit is contained in:
commit
f08b424f73
5 changed files with 16 additions and 34 deletions
|
@ -75,11 +75,8 @@ in {
|
|||
${lib.optionalString (stdenv.buildPlatform.config != stdenv.hostPlatform.config) ''
|
||||
[target."${shortTarget}"]
|
||||
"linker" = "${ccForHost}"
|
||||
${# https://github.com/rust-lang/rust/issues/46651#issuecomment-433611633
|
||||
lib.optionalString (stdenv.hostPlatform.isMusl && stdenv.hostPlatform.isAarch64) ''
|
||||
"rustflags" = [ "-C", "target-feature=+crt-static", "-C", "link-arg=-lgcc" ]
|
||||
''}
|
||||
''}
|
||||
"rustflags" = [ "-C", "target-feature=${if stdenv.hostPlatform.isStatic then "+" else "-"}crt-static" ]
|
||||
'';
|
||||
};
|
||||
} ./cargo-setup-hook.sh) {};
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{ lib, stdenv, makeWrapper, bash, curl, darwin, zlib
|
||||
, autoPatchelfHook, gcc
|
||||
, version
|
||||
, src
|
||||
, platform
|
||||
|
@ -31,7 +32,9 @@ rec {
|
|||
license = [ licenses.mit licenses.asl20 ];
|
||||
};
|
||||
|
||||
nativeBuildInputs = lib.optional (!stdenv.isDarwin) autoPatchelfHook;
|
||||
buildInputs = [ bash ]
|
||||
++ lib.optionals (!stdenv.isDarwin) [ gcc.cc.lib zlib ]
|
||||
++ lib.optional stdenv.isDarwin Security;
|
||||
|
||||
postPatch = ''
|
||||
|
@ -42,24 +45,6 @@ rec {
|
|||
./install.sh --prefix=$out \
|
||||
--components=${installComponents}
|
||||
|
||||
${optionalString (stdenv.isLinux && bootstrapping) (''
|
||||
patchelf \
|
||||
--set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
|
||||
"$out/bin/rustc"
|
||||
'' + optionalString (lib.versionAtLeast version "1.46")
|
||||
# rustc bootstrap needs libz starting from 1.46
|
||||
''
|
||||
ln -s ${zlib}/lib/libz.so.1 $out/lib/libz.so.1
|
||||
ln -s ${zlib}/lib/libz.so $out/lib/libz.so
|
||||
'' + ''
|
||||
patchelf \
|
||||
--set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
|
||||
"$out/bin/rustdoc"
|
||||
patchelf \
|
||||
--set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
|
||||
"$out/bin/cargo"
|
||||
'')}
|
||||
|
||||
# Do NOT, I repeat, DO NOT use `wrapProgram` on $out/bin/rustc
|
||||
# (or similar) here. It causes strange effects where rustc loads
|
||||
# the wrong libraries in a bootstrap-build causing failures that
|
||||
|
@ -83,8 +68,11 @@ rec {
|
|||
license = [ licenses.mit licenses.asl20 ];
|
||||
};
|
||||
|
||||
nativeBuildInputs = [ makeWrapper ];
|
||||
buildInputs = [ bash ] ++ lib.optional stdenv.isDarwin Security;
|
||||
nativeBuildInputs = [ makeWrapper ]
|
||||
++ lib.optional (!stdenv.isDarwin) autoPatchelfHook;
|
||||
buildInputs = [ bash ]
|
||||
++ lib.optional (!stdenv.isDarwin) gcc.cc.lib
|
||||
++ lib.optional stdenv.isDarwin Security;
|
||||
|
||||
postPatch = ''
|
||||
patchShebangs .
|
||||
|
@ -95,12 +83,6 @@ rec {
|
|||
./install.sh --prefix=$out \
|
||||
--components=cargo
|
||||
|
||||
${optionalString (stdenv.isLinux && bootstrapping) ''
|
||||
patchelf \
|
||||
--set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
|
||||
"$out/bin/cargo"
|
||||
''}
|
||||
|
||||
wrapProgram "$out/bin/cargo" \
|
||||
--suffix PATH : "${rustc}/bin"
|
||||
'';
|
||||
|
|
|
@ -72,5 +72,7 @@ rustPlatform.buildRustPackage {
|
|||
maintainers = with maintainers; [ retrry ];
|
||||
license = [ licenses.mit licenses.asl20 ];
|
||||
platforms = platforms.unix;
|
||||
# weird segfault in a build script
|
||||
broken = stdenv.targetPlatform.isMusl && !stdenv.targetPlatform.isStatic;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -87,6 +87,10 @@ in stdenv.mkDerivation rec {
|
|||
"${setBuild}.cxx=${cxxForBuild}"
|
||||
"${setHost}.cxx=${cxxForHost}"
|
||||
"${setTarget}.cxx=${cxxForTarget}"
|
||||
|
||||
"${setBuild}.crt-static=${lib.boolToString stdenv.buildPlatform.isStatic}"
|
||||
"${setHost}.crt-static=${lib.boolToString stdenv.hostPlatform.isStatic}"
|
||||
"${setTarget}.crt-static=${lib.boolToString stdenv.targetPlatform.isStatic}"
|
||||
] ++ optionals (!withBundledLLVM) [
|
||||
"--enable-llvm-link-shared"
|
||||
"${setBuild}.llvm-config=${llvmSharedForBuild.dev}/bin/llvm-config"
|
||||
|
@ -188,8 +192,5 @@ in stdenv.mkDerivation rec {
|
|||
maintainers = with maintainers; [ madjar cstrahan globin havvy ];
|
||||
license = [ licenses.mit licenses.asl20 ];
|
||||
platforms = platforms.linux ++ platforms.darwin;
|
||||
# rustc can't generate binaries for dynamically linked Musl.
|
||||
# https://github.com/NixOS/nixpkgs/issues/179242
|
||||
broken = stdenv.targetPlatform.isMusl && !stdenv.targetPlatform.isStatic;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ buildPythonPackage rec {
|
|||
hash = "sha256-+T5C0ah2oj5E8fWaQbuzYRVgD5bSiUbaArrlxNLojvw=";
|
||||
};
|
||||
|
||||
doCheck = stdenv.hostPlatform.system == "x86_64-linux";
|
||||
doCheck = stdenv.hostPlatform.system == "x86_64-linux" && stdenv.hostPlatform.isGnu;
|
||||
|
||||
checkPhase = ''
|
||||
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" test/external_tools/readelf
|
||||
|
|
Loading…
Reference in a new issue