about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/compilers
diff options
context:
space:
mode:
authorBen Wolsieffer <benwolsieffer@gmail.com>2020-09-29 01:15:06 -0400
committerAlyssa Ross <hi@alyssa.is>2020-11-27 13:29:15 +0000
commit454813293521972c721b0e476f85ff2f2e9500ec (patch)
tree3f6a8b45cf37d710d0650128c77550a99fe63c78 /nixpkgs/pkgs/development/compilers
parent51da610320fbb39fa9fca2ce9f2079ee1cccf76b (diff)
downloadnixlib-454813293521972c721b0e476f85ff2f2e9500ec.tar
nixlib-454813293521972c721b0e476f85ff2f2e9500ec.tar.gz
nixlib-454813293521972c721b0e476f85ff2f2e9500ec.tar.bz2
nixlib-454813293521972c721b0e476f85ff2f2e9500ec.tar.lz
nixlib-454813293521972c721b0e476f85ff2f2e9500ec.tar.xz
nixlib-454813293521972c721b0e476f85ff2f2e9500ec.tar.zst
nixlib-454813293521972c721b0e476f85ff2f2e9500ec.zip
buildRustCrate: fix target config environment variables on 32-bit ARM
(cherry picked from commit f0fdecfbb45c74bfb6f46017563e7ec941b604e9)
Diffstat (limited to 'nixpkgs/pkgs/development/compilers')
-rw-r--r--nixpkgs/pkgs/development/compilers/rust/default.nix15
1 files changed, 13 insertions, 2 deletions
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}"}";