From 8682bd0a81797f64a825c8941272df2a6342bb5c Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Mon, 22 Aug 2022 02:05:50 -0700 Subject: [PATCH] build-support/rust: toTargetArch: strip off endianness `toTargetArch` in `pkgs/build-support/rust/lib/default.nix` is used to set `CARGO_CFG_TARGET_ARCH`. This environment variable is supposed to be the `` portion of an LLVM-style platform name: ``` -- ``` Note that the pointer-width (the "64" in "x86_64" and "mips64") is part of ``, but the endianness (the `_be` in `aarch64_be`) is *not*. Unfortunately at the moment nixpkgs' parsed `cpuType` has no way to query for the three subparts (name, pointer-width, and subarch/endianness), nor any way to ask for just the first two parts. For now, this commit simply fixes the problem in the two cases that matter: `mips64el` and `powerpc64le`, which I believe are the only two platforms supported by both rust and nixpkgs which have a "subarchitecture". --- pkgs/build-support/rust/lib/default.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/build-support/rust/lib/default.nix b/pkgs/build-support/rust/lib/default.nix index 34aaa8c516a9..2be0c2567879 100644 --- a/pkgs/build-support/rust/lib/default.nix +++ b/pkgs/build-support/rust/lib/default.nix @@ -5,6 +5,8 @@ rec { toTargetArch = platform: /**/ if platform ? rustc.platform then platform.rustc.platform.arch else if platform.isAarch32 then "arm" + else if platform.isMips64 then "mips64" # never add "el" suffix + else if platform.isPower64 then "powerpc64" # never add "le" suffix else platform.parsed.cpu.name; # https://doc.rust-lang.org/reference/conditional-compilation.html#target_os