NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.64k stars 13.79k forks source link

Build failure: qmk on aarch64-darwin. #270986

Open SmolPatches opened 10 months ago

SmolPatches commented 10 months ago

Steps To Reproduce

M1 Mac(aarch64-darwin) Steps to reproduce the behavior:

  1. build qmk on a M1 system nix-shell -p qmk

    Build log

    
    error:
       … while calling the 'derivationStrict' builtin
    
         at /builtin/derivation.nix:9:12: (source not available)
    
       … while evaluating derivation 'shell'
         whose name attribute is located at /nix/store/0wgcaahfgvf0yr5g65q99qwv6bkxr4xk-nixpkgs/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:300:7
    
       … while evaluating attribute 'buildInputs' of derivation 'shell'
    
         at /nix/store/0wgcaahfgvf0yr5g65q99qwv6bkxr4xk-nixpkgs/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:347:7:
    
          346|       depsHostHost                = lib.elemAt (lib.elemAt dependencies 1) 0;
          347|       buildInputs                 = lib.elemAt (lib.elemAt dependencies 1) 1;
             |       ^
          348|       depsTargetTarget            = lib.elemAt (lib.elemAt dependencies 2) 0;
    
       (stack trace truncated; use '--show-trace' to show the full trace)
    
       error: Package ‘avr-stage-final-gcc-wrapper-8.5.0’ in /nix/store/0wgcaahfgvf0yr5g65q99qwv6bkxr4xk-nixpkgs/nixpkgs/pkgs/build-support/cc-wrapper/default.nix:657 is not available on the requested hostPlatform:
         hostPlatform.config = "aarch64-apple-darwin"
         package.meta.platforms = [
           "i686-cygwin"
           "x86_64-cygwin"
           "x86_64-darwin"
           "i686-darwin"
           "aarch64-darwin"
           "armv7a-darwin"
           "i686-freebsd13"
           "x86_64-freebsd13"
           "x86_64-solaris"
           "aarch64-linux"
           "armv5tel-linux"
           "armv6l-linux"
           "armv7a-linux"
           "armv7l-linux"
           "i686-linux"
           "loongarch64-linux"
           "m68k-linux"
           "microblaze-linux"
           "microblazeel-linux"
           "mips-linux"
           "mips64-linux"
           "mips64el-linux"
           "mipsel-linux"
           "powerpc64-linux"
           "powerpc64le-linux"
           "riscv32-linux"
           "riscv64-linux"
           "s390-linux"
           "s390x-linux"
           "x86_64-linux"
           "aarch64-netbsd"
           "armv6l-netbsd"
           "armv7a-netbsd"
           "armv7l-netbsd"
           "i686-netbsd"
           "m68k-netbsd"
           "mipsel-netbsd"
           "powerpc-netbsd"
           "riscv32-netbsd"
           "riscv64-netbsd"
           "x86_64-netbsd"
           "i686-openbsd"
           "x86_64-openbsd"
           "x86_64-redox"
         ]
         package.meta.badPlatforms = [
           "aarch64-darwin"
         ]
       , refusing to evaluate.
    
       a) To temporarily allow packages that are unsupported for this system, you can use an environment variable
          for a single invocation of the nix tools.
    
            $ export NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1
    
        Note: For `nix shell`, `nix build`, `nix develop` or any other Nix 2.4+
        (Flake) command, `--impure` must be passed in order to read this
        environment variable.
    
       b) For `nixos-rebuild` you can set
         { nixpkgs.config.allowUnsupportedSystem = true; }
       in configuration.nix to override this.
    
       c) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
         { allowUnsupportedSystem = true; }
       to ~/.config/nixpkgs/config.nix.

### Additional context
Nixpkgs says qmk uses aarch64-darwin which is what I am on, I think that one of the dependent packages uses a host platform of **aarch64-apple-darwin** ( shown in error above) I have never seen this host platform before, shouldn't this just be **aarch64-darwin** as well? 

### Notify maintainers
@bhipple 
@babariviere 
@Ekleog 
<!--
Please @ people who are in the `meta.maintainers` list of the offending package or module.
If in doubt, check `git blame` for whoever last touched something.
-->

### Metadata

Please run `nix-shell -p nix-info --run "nix-info -m"` and paste the result.

```console
 - system: `"aarch64-darwin"`
 - host os: `Darwin 23.1.0, macOS 14.1`
 - multi-user?: `yes`
 - sandbox: `no`
 - version: `nix-env (Nix) 2.17.0`
 - channels(root): `"nixpkgs"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixpkgs`

Priorities

Add a :+1: reaction to issues you find important.

AndersonTorres commented 10 months ago
error: Package ‘avr-stage-final-gcc-wrapper-8.5.0’ in 
/nix/store/0wgcaahfgvf0yr5g65q99qwv6bkxr4xk-nixpkgs/nixpkgs/pkgs/build-support/cc-wrapper/default.nix:657
is not available on the requested hostPlatform:

hostPlatform.config = "aarch64-apple-darwin"

aarch64-apple-darwin ( shown in error above) I have never seen this host platform before, shouldn't this just be aarch64-darwin as well?

This is a target triple machine-vendor-operatingsystem

https://wiki.osdev.org/Target_Triplet

In this case is an ARM64 machine, made by Apple, running Darwin kernel.

In other words, M1 has no support for avr-stage-final-gcc-wrapper-8.5.0 - a GCC "version" that generates code for AVR microcontrollers.


I Googled a bit and found this reddit post from three years ago:

https://www.reddit.com/r/olkb/comments/nh2fk9/guide_installing_qmk_on_m1_macbook/

In other words, it will not work.

emilytrau commented 10 months ago

QMK broke on x86_64-darwin due to evaluation error around the end of October seemingly due to a change in GCC https://hydra.nixos.org/job/nixpkgs/trunk/qmk.x86_64-darwin

cc @amjoseph-nixpkgs

emilytrau commented 10 months ago

This might be the culprit? @reckenrode https://github.com/NixOS/nixpkgs/commit/299c06a0f55e02d41d26035fb0d649ae972bdc37#diff-d1246565164cb461f83e31e05da151af0dc07ee74d45fd2a56d3396739f92ee5R416

reckenrode commented 10 months ago

@emilytrau I think it needs to check targetPlatform.isDarwin there and when determining meta.badPlatforms (instead of hostPlatform.isDarwin). I have a patch for that, but it’s also failing to build due to the clang 16 update. I’m still working on the patch for that.

reckenrode commented 10 months ago

271787 fixes the cross-compiler issues, but fixing the qmk build failure on aarch64-darwin will require updated the qmk derivation to use a newer version of GCC. It’s currently hard-coded to use GCC 8.

ghost commented 10 months ago

QMK broke on x86_64-darwin...

cc @amjoseph-nixpkgs

Ah, it's been nearly a decade since I was a Darwin user; I'm afraid I'm not too much help with that. Fortunately @reckenrode is.

Regarding AVR, it would be awesome if we had a test that ran some kind of AVR binary in an emulator, just as a smoke check. We're never going to have AVR builders (not sure that's even possible), but at least this way we'd notice when things break.

For STM32 we could get this sort of coverage from the gnuk package's test suite, which runs an emulator. I've been meaning to implement that.

emilytrau commented 10 months ago

Regarding AVR, it would be awesome if we had a test that ran some kind of AVR binary in an emulator, just as a smoke check. We're never going to have AVR builders (not sure that's even possible), but at least this way we'd notice when things break.

For STM32 we could get this sort of coverage from the gnuk package's test suite, which runs an emulator. I've been meaning to implement that.

qmk has qmk mass-compile which I believe is to CI test that all keyboard firmware at least builds. I think that could be a good test I can implement.

AndersonTorres commented 10 months ago

I remember that not all firmware was buildable - the code is a dump of the current state of a Git repo.