tpwrules / nixos-apple-silicon

Resources to install NixOS bare metal on Apple Silicon Macs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mesa build failure

minego opened this issue · comments

I just did a nix flake update and nixos-rebuild switch --flake ./#$(hostname) to update my macbook pro, and got a failure building mesa:

The failure is:

❯ nix log /nix/store/axzm7rxbdz1xvz25hgxlc27rv1wck626-mesa-24.0.0.drv                                                                                                2 
warning: The interpretation of store paths arguments ending in `.drv` recently changed. If this command is now failing try again with '/nix/store/axzm7rxbdz1xvz25hgxlc27rv1wck626-mesa-24.0.0.drv^*'
@nix { "action": "setPhase", "phase": "unpackPhase" }
Running phase: unpackPhase
unpacking source archive /nix/store/wnn0j555mi9s2aj5dx8f7svz2y4bg5wh-source
source root is source
@nix { "action": "setPhase", "phase": "patchPhase" }
Running phase: patchPhase
applying patch /nix/store/q6a122idzfix30ffb10jfzl9p3h9793z-musl.patch
patching file src/amd/vulkan/winsys/amdgpu/radv_amdgpu_winsys.h
patching file src/gallium/drivers/freedreno/freedreno_util.h
Hunk #1 succeeded at 114 (offset 6 lines).
patching file src/gallium/frontends/nine/nine_debug.c
Hunk #1 succeeded at 65 with fuzz 2.
patching file src/util/rand_xor.c
applying patch /nix/store/j85q1lxb62khdmjj1kgilib8w7kvpc78-opencl.patch
patching file meson.build
patching file meson_options.txt
patching file src/gallium/targets/opencl/meson.build
patching file src/gallium/targets/rusticl/meson.build
applying patch /nix/store/0f62mdlb7bnrnryhkddy2lxr9il82flp-disk_cache-include-dri-driver-path-in-cache-key.patch
patching file meson_options.txt
Hunk #1 succeeded at 519 (offset 6 lines).
patching file src/util/disk_cache.c
Hunk #1 succeeded at 218 (offset -8 lines).
Hunk #2 succeeded at 242 (offset -8 lines).
patching file src/util/meson.build
Hunk #1 succeeded at 286 (offset 18 lines).
applying patch /nix/store/2y1l3alwq7sgdqjpjf99l579ms9317zn-0001-dri-added-build-dependencies-for-systems-using-non-s.patch
patching file src/gallium/targets/dri/meson.build
Reversed (or previously applied) patch detected!  Assume -R? [n] 
Apply anyway? [n] 
Skipping patch.
1 out of 1 hunk ignored -- saving rejects to file src/gallium/targets/dri/meson.build.rej
patching file src/glx/meson.build
Reversed (or previously applied) patch detected!  Assume -R? [n] 
Apply anyway? [n] 
Skipping patch.
1 out of 1 hunk ignored -- saving rejects to file src/glx/meson.build.rej
patching file src/loader/meson.build
Reversed (or previously applied) patch detected!  Assume -R? [n] 
Apply anyway? [n] 
Skipping patch.
1 out of 1 hunk ignored -- saving rejects to file src/loader/meson.build.rej

Details about my system:

❯ nix-shell -p nix-info --run "nix-info -m"                          
 - system: `"aarch64-linux"`
 - host os: `Linux 6.6.0-asahi, NixOS, 24.05 (Uakari), 24.05.20240108.317484b`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.1`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

Could you check if #142 fixes it for you? I was having mesa issues as well and that fixed it for me.

Yes, I switched my flake url to ```
url = "github:yu-re-ka/nixos-m1/nixos-unstable-fixes";

and switched again and the build was successful. (I haven't rebooted yet though. I'll update here if I run into any issues.)

I just rebooted after applying that PR and now it appears I do NOT have working graphics acceleration. I am not sure what is wrong yet (and may not be able to investigate until after work). I can't launch kitty or alacrity at all, and everything in wayland is VERY sluggish.

This should be fixed in the latest release. Not sure what is up with the acceleration. Please try the latest known good nixpkgs and version of this repo and file a new issue if problems remain. Also make sure your session manager selects a Wayland session if appropriate.

I just rebuilt with the latest now that #142 has been merged, and that builds just fine but I am still not getting graphics acceleration after applying it. Here is the log when I start wayland:

SSH_AGENT_PID not set, cannot kill agent
Agent pid 3568
00:00:00.006 [ERROR] [EGL] command: eglQueryDeviceStringEXT, error: EGL_BAD_PARAMETER (0x300c), message: "eglQueryDeviceStringEXT"
00:00:00.006 [ERROR] [EGL] command: eglQueryDeviceStringEXT, error: EGL_BAD_PARAMETER (0x300c), message: "eglQueryDeviceStringEXT"
did not find extension DRI_Core version 1
did not find extension DRI_IMAGE_DRIVER version 1
failed to bind extensions
did not find extension DRI_Core version 1
did not find extension DRI_IMAGE_DRIVER version 1
failed to bind extensions
did not find extension DRI_Core version 1
did not find extension DRI_SWRast version 4
failed to bind extensions
00:00:00.018 [ERROR] [render/egl.c:556] Failed to create GBM device
00:00:00.018 [ERROR] [render/egl.c:572] Failed to initialize EGL context
00:00:00.018 [ERROR] [render/gles2/renderer.c:804] Could not initialize EGL
00:00:00.032 [ERROR] [backend/drm/util.c:66] Failed to parse EDID
eDP-1 title 
eDP-1 appid 
eDP-1 fullscreen 
eDP-1 floating 
eDP-1 selmon 0
eDP-1 tags 0 1 0 0
eDP-1 layout =O=
*** BUG ***
In pixman_region32_init_rect: Invalid rectangle passed
Set a breakpoint on '_pixman_log_error' to debug

dbus-daemon[3581]: [session uid=1000 pid=3581] Activating service name='org.freedesktop.portal.Desktop' requested by ':1.0' (uid=1000 pid=3597 comm="/etc/profiles/per-user/m/bin/kitty")
dbus-daemon[3581]: [session uid=1000 pid=3581] Activating service name='org.freedesktop.portal.Documents' requested by ':1.1' (uid=1000 pid=3599 comm="/nix/store/z4s3k2p6akkgbsqhbz6anx4wyn5nkpcf-xdg-de")
dbus-daemon[3581]: [session uid=1000 pid=3581] Activating service name='org.freedesktop.impl.portal.PermissionStore' requested by ':1.2' (uid=1000 pid=3605 comm="/nix/store/z4s3k2p6akkgbsqhbz6anx4wyn5nkpcf-xdg-de")
dbus-daemon[3581]: [session uid=1000 pid=3581] Successfully activated service 'org.freedesktop.impl.portal.PermissionStore'
dbus-daemon[3581]: [session uid=1000 pid=3581] Successfully activated service 'org.freedesktop.portal.Documents'
fusermount3: failed to access mountpoint /run/user/1000/doc: Permission denied
error: fuse init failed: Can't mount path /run/user/1000/doc

(/nix/store/z4s3k2p6akkgbsqhbz6anx4wyn5nkpcf-xdg-desktop-portal-1.18.2/libexec/xdg-desktop-portal:3599): xdg-desktop-portal-WARNING **: 17:49:33.564: No skeleton to export
dbus-daemon[3581]: [session uid=1000 pid=3581] Activating service name='org.freedesktop.impl.portal.desktop.wlr' requested by ':1.1' (uid=1000 pid=3599 comm="/nix/store/z4s3k2p6akkgbsqhbz6anx4wyn5nkpcf-xdg-de")
libEGL warning: MESA-LOADER: failed to open zink: /run/opengl-driver/lib/dri/zink_dri.so: cannot open shared object file: No such file or directory (search paths /run/opengl-driver/lib/dri, suffix _dri)

dbus-daemon[3581]: [session uid=1000 pid=3581] Successfully activated service 'org.freedesktop.impl.portal.desktop.wlr'
dbus-daemon[3581]: [session uid=1000 pid=3581] Successfully activated service 'org.freedesktop.portal.Desktop'
libEGL fatal: did not find extension DRI_Core version 1

libEGL warning: MESA-LOADER: failed to open zink: /run/opengl-driver/lib/dri/zink_dri.so: cannot open shared object file: No such file or directory (search paths /run/opengl-driver/lib/dri, suffix _dri)

libEGL fatal: did not find extension DRI_Core version 1

Read 19 .desktop files, found 15 apps.
User input is: Terminal emulator 
/run/current-system/sw/bin/zsh -c 'kitty'
libEGL warning: MESA-LOADER: failed to open zink: /run/opengl-driver/lib/dri/zink_dri.so: cannot open shared object file: No such file or directory (search paths /run/opengl-driver/lib/dri, suffix _dri)

libEGL fatal: did not find extension DRI_Core version 1

Same symptom as #136 please try the steps indicated in that issue if applicable.

hmmm my config works perfectly:

{ inputs, ... }: {
  imports = [
    ../common
    ./hardware.nix
    inputs.nixos-apple-silicon.nixosModules.apple-silicon-support
  ];

  nixpkgs.overlays = [
    inputs.nixos-apple-silicon.overlays.apple-silicon-overlay
    (final: prev: { mesa = final.mesa-asahi-edge; })
  ];

  hardware = {
    asahi = {
      addEdgeKernelConfig = true;
      peripheralFirmwareDirectory = ./firmware;
      useExperimentalGPUDriver = true;
      experimentalGPUInstallMode = "driver";
      withRust = true;
    };
    opengl.enable = true;
  };

  boot = {
    consoleLogLevel = 0;
    kernelParams = [ "apple_dcp.show_notch=1" ];
  };

  networking.hostName = "kitaro";
  system.stateVersion = "23.05";
}

Same symptom as #136 please try the steps indicated in that issue if applicable.

I tried everything listed there with no luck ...

(Sorry for the slow reply, I was out of town for the last few days)

hmmm my config works perfectly:

{ inputs, ... }: {
  imports = [
    ../common
    ./hardware.nix
    inputs.nixos-apple-silicon.nixosModules.apple-silicon-support
  ];

  nixpkgs.overlays = [
    inputs.nixos-apple-silicon.overlays.apple-silicon-overlay
    (final: prev: { mesa = final.mesa-asahi-edge; })
  ];

  hardware = {
    asahi = {
      addEdgeKernelConfig = true;
      peripheralFirmwareDirectory = ./firmware;
      useExperimentalGPUDriver = true;
      experimentalGPUInstallMode = "driver";
      withRust = true;
    };
    opengl.enable = true;
  };

  boot = {
    consoleLogLevel = 0;
    kernelParams = [ "apple_dcp.show_notch=1" ];
  };

  networking.hostName = "kitaro";
  system.stateVersion = "23.05";
}

I haven't tried the edge stuff... I didn't see that in the docs anywhere. I am building it now, so fingers crossed. Is there documentation anywhere on that?

I also didn't know bout the kernel option to show the notch. I assume those are documented by the asahi project? Guess I'd better go read up on some of those options too.

I am not sure why, but applying changes based on @idm1try 's config has caused it to rebuild gtk-webkit and chromium...

So, that is taking a while. I'll report success or failure when that is done.

@minego because we replacing mesa package with (final: prev: { mesa = final.mesa-asahi.edge; }) but its works in 100% cases
if you don't have any webkit app
webkit usually building from networkmanager(openconnect dependency) (i use iwd)

@minego because we replacing mesa package with (final: prev: { mesa = final.mesa-asahi.edge; }) but its works in 100% cases if you don't have any webkit app webkit usually building from networkmanager(openconnect dependency) (i use iwd)

Ah, yeah I do use network manager. I use chromium as well, but that isn't vital so I removed it for now.

I will try to be patient and let this build :-)

No dice. After letting that all build I still get the error about zink_dri.so not being found and libEGL fails to initialize. The entire gui is very laggy and things like kitty won't launch.

No dice. After letting that all build I still get the error about zink_dri.so not being found and libEGL fails to initialize. The entire gui is very laggy and things like kitty won't launch.

what your window manager? i using sway

This is my config at the moment btw... I'm pretty certain I have it matching what you suggested...

https://github.com/minego/nixos-config/blob/apple-gpu/hosts/zaphod2/default.nix

@idm1try

Is it possible that my firmware needs to be updated? I can't think of anything else to try. It seems like this should be working...

I tried with sway as well, and I am getting the same results with sway.

As I said this seems to be the same issue as the one I linked. Home manager is the cause, or rather nix flakes + home manager. I think you are using the home manager packages and not the nixpkgs including the mesa override. I bet it works if you stop using home manager and just use the packages given from the nix flake in this repo.

As I said this seems to be the same issue as the one I linked. Home manager is the cause, or rather nix flakes + home manager. I think you are using the home manager packages and not the nixpkgs including the mesa override. I bet it works if you stop using home manager and just use the packages given from the nix flake in this repo.

I've experimented with moving where I install things, and have been trying with install dwl, sway and HyperLand all from the main config and not home-manager... And, I've had home-manager.useGlobalPkgs = true; set...

But, to be sure I am now trying to rip out home manager entirely, at least as a test. I'll reply here after trying that.

@rowanG077 Okay, I removed home-manager from my config and switched, and it looks like the error message changed...

m@zaphod2:~/ > kitty
libEGL warning: MESA-LOADER: failed to open zink: /run/opengl-driver/lib/dri/zink_dri.so: cannot open shared object file: No such file or directory (search paths /run/opengl-driver/lib/dri, suffix _dri)

libEGL fatal: did not find extension DRI_Core version 1

This is now using the default kitty config (since I had been using the home-manager module) but I don't see any related options that were removed.

For some reason kitty tries to use zink which it shouldn't. Please first try to get glinfo to work and it showing the driver.

Is it possible that my firmware needs to be updated? I can't think of anything else to try. It seems like this should be working...

yes asahi needs firmware updates

Is it possible that my firmware needs to be updated? I can't think of anything else to try. It seems like this should be working...

yes asahi needs firmware updates

Is there an easy way to tell if my firmware is out of date? It looks like the process to update it is... not simple.

If I am understanding correctly I need to:

  1. Boot into the installer image
  2. Mount my / and /boot
  3. Rerun the generate command, and copy the resulting files to the right place?

Or, it looks like there is an asahi tool that the installer uses to extract the firmware. Maybe it is easier to just use that? If I need to boot the installer image then I will probably have to wait a day or two before I have time.

Is it possible that my firmware needs to be updated? I can't think of anything else to try. It seems like this should be working...

yes asahi needs firmware updates

@idm1try
I haven't been able to update my firmware yet, but I grabbed your dotfiles from git@github.com:idm1try/dotfiles.git and modified a few bits in the hardware config, changed username, copied my firmware, etc and applied that as a test.

The result was the same errors I had been seeing, which suggests to me that the firmware or something else specific to my machine is at fault.

I'm going to try to go through the process to update the firmware tonight, but I may not be able to find time due to work stuff today.

Is it possible that my firmware needs to be updated? I can't think of anything else to try. It seems like this should be working...

yes asahi needs firmware updates

Is there an easy way to tell if my firmware is out of date? It looks like the process to update it is... not simple.

If I am understanding correctly I need to:

  1. Boot into the installer image
  2. Mount my / and /boot
  3. Rerun the generate command, and copy the resulting files to the right place?

Or, it looks like there is an asahi tool that the installer uses to extract the firmware. Maybe it is easier to just use that? If I need to boot the installer image then I will probably have to wait a day or two before I have time.

update macos and what your macos version? and what your machine?(my is m1 pro mbp)

update macos and what your macos version? and what your machine?(my is m1 pro mbp)

I have all macOS updates installed. I have to use macOS for work from time to time, so I keep it updated.

It is a macbook Pro 16" M2 Max.

This morning I tried the following:

  1. Rebooted into macOS, and checked for updates (it was already up to date with the latest)
  2. Ran through the install from scratch. I kept my partitions, but did everything else as normal for a fresh setup.
  3. Copied the firmware files from the boot volume into my config (but they hadn't changed)
  4. Applied my config again, and rebooted and...

I'm seeing the same results:

  1. The entire UI is VERY sluggish. Just moving the mouse pointer with the trackpad is enough to see this. It is so sluggish that keypresses get dropped when typing.
  2. libEGL fatal: did not find extension DRI_Core version 1 whenever starting anything that requires acceleration.
  3. XWayland seems to have issues that started at the same time. When I try to run something like glxinfo I get Error: unable to open display :0 and I am not sure why yet. I will try in a bit here to switch to an X11 based desktop to test so I can run glxinfo

Before the big recent mesa changes everything was working perfectly on this machine, including acceleration.

Okay, I installed xfce so I can run X, so I can run glxinfo and this is the result:

❯ nix run nixpkgs#glxinfo          
name of display: :0.0
Error: couldn't find RGB GLX visual or fbconfig

I'm running out of ideas of things to debug or try... So, this morning I decided to try HyperLand since I've seen that a number of other people here seem to be based on the comments in other issues..

So, I added programs.hyperland.enable = true;, switched my config and ran it only to see it crash on startup. I am not certain if this is helpful, but here is the crash:

coredumpctl info
           PID: 454215 (.Hyprland-wrapp)
           UID: 1000 (m)
           GID: 100 (users)
        Signal: 6 (ABRT)
     Timestamp: Thu 2024-01-25 11:52:13 MST (1min 19s ago)
  Command Line: /run/current-system/sw/bin/Hyprland
    Executable: /nix/store/zs2zbcaaq3ijb9dxhc398ncakgjxvkvd-hyprland-0.34.0/bin/.Hyprland-wrapped
 Control Group: /user.slice/user-1000.slice/session-3.scope
          Unit: session-3.scope
         Slice: user-1000.slice
       Session: 3
     Owner UID: 1000 (m)
       Boot ID: e23a886017454d8797b4c910c7b9ec12
    Machine ID: a3a703f8ff154afebea77eb09bf7ccad
      Hostname: zaphod2
       Storage: /var/lib/systemd/coredump/core.\x2eHyprland-wrapp.1000.e23a886017454d8797b4c910c7b9ec12.454215.1706208733000000.zst (present)
  Size on Disk: 2.2M
       Message: Process 454215 (.Hyprland-wrapp) of user 1000 dumped core.
                
                Module libxml2.so.2 without build-id.
                Module libncursesw.so.6 without build-id.
                Module libxshmfence.so.1 without build-id.
                Module libxcb-sync.so.1 without build-id.
                Module libxcb-dri2.so.0 without build-id.
                Module libX11-xcb.so.1 without build-id.
                Module libpcre.so.1 without build-id.
                Module libbrotlicommon.so.1 without build-id.
                Module libgraphite2.so.3 without build-id.
                Module libdatrie.so.1 without build-id.
                Module libselinux.so.1 without build-id.
                Module libpcre2-8.so.0 without build-id.
                Module libgudev-1.0.so.0 without build-id.
                Module libbrotlidec.so.1 without build-id.
                Module libbz2.so.1 without build-id.
                Module libxcb-randr.so.0 without build-id.
                Module libexpat.so.1 without build-id.
                Module libpangoft2-1.0.so.0 without build-id.
                Module libharfbuzz.so.0 without build-id.
                Module libthai.so.0 without build-id.
                Module libfribidi.so.0 without build-id.
                Module libGLX.so.0 without build-id.
                Module libcap.so.2 without build-id.
                Module libXdmcp.so.6 without build-id.
                Module libXau.so.6 without build-id.
                Module libwacom.so.9 without build-id.
                Module libevdev.so.2 without build-id.
                Module libmtdev.so.1 without build-id.
                Module libGLdispatch.so.0 without build-id.
                Module libXrender.so.1 without build-id.
                Module libXext.so.6 without build-id.
                Module libX11.so.6 without build-id.
                Module libfreetype.so.6 without build-id.
                Module libfontconfig.so.1 without build-id.
                Module libpng16.so.16 without build-id.
                Module libz.so.1 without build-id.
                Module libxcb-errors.so.0 without build-id.
                Module libxcb-res.so.0 without build-id.
                Module libxcb-icccm.so.4 without build-id.
                Module libxcb-ewmh.so.2 without build-id.
                Module libxcb-composite.so.0 without build-id.
                Module libxcb-xinput.so.0 without build-id.
                Module libxcb-xfixes.so.0 without build-id.
                Module libxcb-shm.so.0 without build-id.
                Module libxcb-render-util.so.0 without build-id.
                Module libxcb-render.so.0 without build-id.
                Module libxcb-present.so.0 without build-id.
                Module libxcb-dri3.so.0 without build-id.
                Module libliftoff.so.0 without build-id.
                Module libdisplay-info.so.1 without build-id.
                Module libseat.so.1 without build-id.
                Module libudev.so.1 without build-id.
                Module libvulkan.so.1 without build-id.
                Module libGLESv2.so.2 without build-id.
                Module libffi.so.8 without build-id.
                Module libgcc_s.so.1 without build-id.
                Module libstdc++.so.6 without build-id.
                Module libpangocairo-1.0.so.0 without build-id.
                Module libpango-1.0.so.0 without build-id.
                Module libGL.so.1 without build-id.
                Module libudis86.so.0 without build-id.
                Module libsystemd.so.0 without build-id.
                Module libxcb.so.1 without build-id.
                Module libinput.so.10 without build-id.
                Module libxkbcommon.so.0 without build-id.
                Module libEGL.so.1 without build-id.
                Module libdrm.so.2 without build-id.
                Module libwlroots.so.13 without build-id.
                Module .Hyprland-wrapped without build-id.
                Stack trace of thread 454215:
                #0  0x0000ffff9a645470 __pthread_kill_implementation (libc.so.6 + 0x85470)
                #1  0x0000ffff9a5feeac raise (libc.so.6 + 0x3eeac)
                #2  0x0000ffff9a5eaefc abort (libc.so.6 + 0x2aefc)
                #3  0x0000000000483c78 _Z25handleUnrecoverableSignali (.Hyprland-wrapped + 0x83c78)
                #4  0x0000ffff9b4ac80c n/a (linux-vdso.so.1 + 0x80c)
                #5  0x0000ffff9b4ac80c n/a (linux-vdso.so.1 + 0x80c)
                #6  0x0000ffff9a64545c __pthread_kill_implementation (libc.so.6 + 0x8545c)
                #7  0x0000ffff9b2fe080 n/a (n/a + 0x0)
                ELF object binary architecture: AARCH64