From 57c79b1999821e94751651d60767aa9c7e9ace6e Mon Sep 17 00:00:00 2001 From: Olivia Lee Date: Sun, 2 Mar 2025 01:08:31 -0800 Subject: [PATCH] Fix native compilation on aarch64 Turns out fenix.packages.aarch64-linux.targets.x86_64-*.minimal.rustc is an x86_64 compiler. The only component that you actually need to pull from 'targets' for cross compilation is rust-std. Because x86_64-unknown-linux-gnu is first in the target list, we were getting x86 rustc and cargo binaries, making it impossible to compile grapevine on an aarch64 host. We were also missing aarch64-unknown-linux-gnu in the targets list, which is used by the default package on a aarch64 host. --- flake.nix | 12 ++++++++---- rust-toolchain.toml | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/flake.nix b/flake.nix index 62084c91..d704a0fd 100644 --- a/flake.nix +++ b/flake.nix @@ -59,12 +59,16 @@ toolchainFile.toolchain.components; targets = toolchainFile.toolchain.targets; fenix = inputs.fenix.packages.${pkgs.stdenv.buildPlatform.system}; - in - fenix.combine (builtins.map + + nativeToolchain = (fenix.fromManifestFile inputs.rust-manifest) + .withComponents components; + crossComponents = builtins.map (target: (fenix.targets.${target}.fromManifestFile inputs.rust-manifest) - .withComponents components) - targets); + .rust-std) + targets; + in + fenix.combine ([nativeToolchain] ++ crossComponents); website-root = self.callPackage ./nix/pkgs/website-root {}; }); diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 12390a29..244b9085 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -17,5 +17,6 @@ components = [ targets = [ "x86_64-unknown-linux-gnu", "x86_64-unknown-linux-musl", + "aarch64-unknown-linux-gnu", "aarch64-unknown-linux-musl", ]