From 88c41d8a918925f5ccc915734bb8095833496d82 Mon Sep 17 00:00:00 2001 From: Julius Michaelis Date: Mon, 7 Oct 2024 21:11:46 +0900 Subject: [PATCH] Revert "rust: allow linker to be different from compiler" This reverts commit b8076b893eacf2e6bec67453fbf4d421ee28ff03. --- pkgs/build-support/rust/hooks/default.nix | 4 ++-- pkgs/build-support/rust/lib/default.nix | 15 ++++++--------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/pkgs/build-support/rust/hooks/default.nix b/pkgs/build-support/rust/hooks/default.nix index 874f23fe7ed3..7703ff4abad4 100644 --- a/pkgs/build-support/rust/hooks/default.nix +++ b/pkgs/build-support/rust/hooks/default.nix @@ -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" ] ''; diff --git a/pkgs/build-support/rust/lib/default.nix b/pkgs/build-support/rust/lib/default.nix index 9e0efb08607a..c23f779bfe5d 100644 --- a/pkgs/build-support/rust/lib/default.nix +++ b/pkgs/build-support/rust/lib/default.nix @@ -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++" \