tpwrules / nixos-apple-silicon

Resources to install NixOS bare metal on Apple Silicon Macs
MIT License
838 stars 80 forks source link

Build fails with rust 1.64.0 (from the current stable channel 22.11) #58

Closed psanford closed 1 year ago

psanford commented 1 year ago

I'm trying to upgrade to the latest nixos-apple-silicon release (my system is on channel nixos-22.11). Kernel builds now fail for me, even though the kernel version has not changed (I've been running asahi-6.1-2 since December). The errors are:

error: attributes starting with `rustc` are reserved for use by the `rustc` compiler
  --> ../rust/alloc/alloc.rs:33:7
   |
33 |     #[rustc_nounwind]
   |       ^^^^^^^^^^^^^^

I see that there are now some preConfigure sed commands that are mucking with these attributes for rust 1.66.x. Nixos-22.11 is still on 1.64.x though. Removing the preConfigure changes fixes the build for me:

diff --git a/apple-silicon-support/packages/linux-asahi/default.nix b/apple-silicon-support/packages/linux-asahi/default.nix
index 4f00f3b..1c8a4d8 100644
--- a/apple-silicon-support/packages/linux-asahi/default.nix
+++ b/apple-silicon-support/packages/linux-asahi/default.nix
@@ -100,19 +100,7 @@ let
         '')
       ];
       RUST_LIB_SRC = rustPlatform.rustLibSrc;
-
-      preConfigure = ''
-        # Fixes for Rust 1.66.x
-        sed -i -e 's/rustc_allocator_nounwind/rustc_nounwind/g' rust/alloc/alloc.rs
-        sed -i -e 's/const Unpin/Unpin/' rust/alloc/boxed.rs
-        sed -i -e '/^pub unsafe trait RawDeviceId/i #[const_trait]' rust/kernel/driver.rs
-
-        # Fixes for rust-bindgen 0.63.0
-        sed -i -e 's/blacklist/blocklist/g' rust/Makefile
-        sed -i -e 's/whitelist/allowlist/g' rust/Makefile
-      '';
     } else {});

   linux-asahi = (callPackage linux-asahi-pkg { });
 in lib.recurseIntoAttrs (linuxPackagesFor linux-asahi)
tpwrules commented 1 year ago

While I don't think I can guarantee compatibility with 22.11 forever, this is an easy issue to fix and I believe I have done so. These patches are now only applied when using the relevant Rust versions.

psanford commented 1 year ago

While I don't think I can guarantee compatibility with 22.11 forever

I don't think anyone expects compatibility with 22.11 forever, maybe just while it is the latest stable release :)