From 454813293521972c721b0e476f85ff2f2e9500ec Mon Sep 17 00:00:00 2001 From: Ben Wolsieffer Date: Tue, 29 Sep 2020 01:15:06 -0400 Subject: buildRustCrate: fix target config environment variables on 32-bit ARM (cherry picked from commit f0fdecfbb45c74bfb6f46017563e7ec941b604e9) --- nixpkgs/pkgs/development/compilers/rust/default.nix | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'nixpkgs/pkgs/development/compilers') diff --git a/nixpkgs/pkgs/development/compilers/rust/default.nix b/nixpkgs/pkgs/development/compilers/rust/default.nix index 22d8d4e02da7..74c076c204b4 100644 --- a/nixpkgs/pkgs/development/compilers/rust/default.nix +++ b/nixpkgs/pkgs/development/compilers/rust/default.nix @@ -14,12 +14,23 @@ , pkgsBuildTarget, pkgsBuildBuild , makeRustPlatform }: rec { + # https://doc.rust-lang.org/reference/conditional-compilation.html#target_arch + toTargetArch = platform: + if platform.isAarch32 then "arm" + else platform.parsed.cpu.name; + + # https://doc.rust-lang.org/reference/conditional-compilation.html#target_os + toTargetOs = platform: + if platform.isDarwin then "macos" + else platform.parsed.kernel.name; + + # Target triple. Rust has slightly different naming conventions than we use. toRustTarget = platform: with platform.parsed; let - cpu_ = { + cpu_ = platform.rustc.arch or { "armv7a" = "armv7"; "armv7l" = "armv7"; "armv6l" = "arm"; - }.${cpu.name} or platform.rustc.arch or cpu.name; + }.${cpu.name} or cpu.name; in platform.rustc.config or "${cpu_}-${vendor.name}-${kernel.name}${lib.optionalString (abi.name != "unknown") "-${abi.name}"}"; -- cgit 1.4.1