Revert "rust: allow linker to be different from compiler"

This reverts commit b8076b893e.
This commit is contained in:
Julius Michaelis 2024-10-07 21:11:46 +09:00 committed by Alyssa Ross
parent 351899cd4b
commit 88c41d8a91
2 changed files with 8 additions and 11 deletions

View File

@ -66,10 +66,10 @@
cargoConfig = ''
[target."${stdenv.buildPlatform.rust.rustcTarget}"]
"linker" = "${rust.envVars.linkerForBuild}"
"linker" = "${rust.envVars.ccForBuild}"
${lib.optionalString (stdenv.buildPlatform.config != stdenv.hostPlatform.config) ''
[target."${stdenv.hostPlatform.rust.rustcTarget}"]
"linker" = "${rust.envVars.linkerForHost}"
"linker" = "${rust.envVars.ccForHost}"
''}
"rustflags" = [ "-C", "target-feature=${if stdenv.hostPlatform.isStatic then "+" else "-"}crt-static" ]
'';

View File

@ -16,11 +16,9 @@ rec {
ccForBuild = "${pkgsBuildHost.stdenv.cc}/bin/${pkgsBuildHost.stdenv.cc.targetPrefix}cc";
cxxForBuild = "${pkgsBuildHost.stdenv.cc}/bin/${pkgsBuildHost.stdenv.cc.targetPrefix}c++";
linkerForBuild = ccForBuild;
ccForHost = "${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc";
cxxForHost = "${stdenv.cc}/bin/${stdenv.cc.targetPrefix}c++";
linkerForHost = ccForHost;
# Unfortunately we must use the dangerous `pkgsTargetTarget` here
# because hooks are artificially phase-shifted one slot earlier
@ -28,7 +26,6 @@ rec {
# a targetPlatform to them).
ccForTarget = "${pkgsTargetTarget.stdenv.cc}/bin/${pkgsTargetTarget.stdenv.cc.targetPrefix}cc";
cxxForTarget = "${pkgsTargetTarget.stdenv.cc}/bin/${pkgsTargetTarget.stdenv.cc.targetPrefix}c++";
linkerForTarget = ccForTarget;
rustBuildPlatform = stdenv.buildPlatform.rust.rustcTarget;
rustBuildPlatformSpec = stdenv.buildPlatform.rust.rustcTargetSpec;
@ -38,9 +35,9 @@ rec {
rustTargetPlatformSpec = stdenv.targetPlatform.rust.rustcTargetSpec;
in {
inherit
ccForBuild cxxForBuild linkerForBuild rustBuildPlatform rustBuildPlatformSpec
ccForHost cxxForHost linkerForHost rustHostPlatform rustHostPlatformSpec
ccForTarget cxxForTarget linkerForTarget rustTargetPlatform rustTargetPlatformSpec;
ccForBuild cxxForBuild rustBuildPlatform rustBuildPlatformSpec
ccForHost cxxForHost rustHostPlatform rustHostPlatformSpec
ccForTarget cxxForTarget rustTargetPlatform rustTargetPlatformSpec;
# Prefix this onto a command invocation in order to set the
# variables needed by cargo.
@ -56,15 +53,15 @@ rec {
+ lib.optionalString (rustTargetPlatform != rustHostPlatform) ''
"CC_${stdenv.targetPlatform.rust.cargoEnvVarTarget}=${ccForTarget}" \
"CXX_${stdenv.targetPlatform.rust.cargoEnvVarTarget}=${cxxForTarget}" \
"CARGO_TARGET_${stdenv.targetPlatform.rust.cargoEnvVarTarget}_LINKER=${linkerForTarget}" \
"CARGO_TARGET_${stdenv.targetPlatform.rust.cargoEnvVarTarget}_LINKER=${ccForTarget}" \
'' + ''
"CC_${stdenv.hostPlatform.rust.cargoEnvVarTarget}=${ccForHost}" \
"CXX_${stdenv.hostPlatform.rust.cargoEnvVarTarget}=${cxxForHost}" \
"CARGO_TARGET_${stdenv.hostPlatform.rust.cargoEnvVarTarget}_LINKER=${linkerForHost}" \
"CARGO_TARGET_${stdenv.hostPlatform.rust.cargoEnvVarTarget}_LINKER=${ccForHost}" \
'' + ''
"CC_${stdenv.buildPlatform.rust.cargoEnvVarTarget}=${ccForBuild}" \
"CXX_${stdenv.buildPlatform.rust.cargoEnvVarTarget}=${cxxForBuild}" \
"CARGO_TARGET_${stdenv.buildPlatform.rust.cargoEnvVarTarget}_LINKER=${linkerForBuild}" \
"CARGO_TARGET_${stdenv.buildPlatform.rust.cargoEnvVarTarget}_LINKER=${ccForBuild}" \
"CARGO_BUILD_TARGET=${rustBuildPlatform}" \
"HOST_CC=${pkgsBuildHost.stdenv.cc}/bin/cc" \
"HOST_CXX=${pkgsBuildHost.stdenv.cc}/bin/c++" \