also test cross build
Describe your PR, what does it fix/add?
We noticed that a recent update broken cross compilation in nixpkgs and therefore added tests for this upstream - I saw that this project uses the magic-nix-cache so hopefully all cross-build dependencies will be cached.
CMake Error at /nix/store/q1nssraba326p2kp6627hldd2bhg254c-cmake-3.29.2/share/cmake-3.29/Modules/FindPkgConfig.cmake:634 (message): The following required packages were not found:
- hwdata
Adding hwdata and hyprwayland-scanner seems to make the pkg-config happy, but than it looks like it's pulling hyprwayland-scanner for the wrong architecture. I saw that your meson build seems to be somewhat cross-compiling aware, so I am not quite sure what is going on here.
Is there anything you want to mention? (unchecked code, possible bugs, found problems, breaking compatibility, etc.)
Is it ready for merging, or does it need work?
cc @fufexan
Great addition! We should also add the cross build to the CI matrix.
Great addition! We should also add the cross build to the CI matrix.
Maybe, but first I would appreciate help with the issue. Thanks!
Adding
hwdataandhyprwayland-scannerseems to make the pkg-config happy, but than it looks like it's pullinghyprwayland-scannerfor the wrong architecture.
Sorry, adding those packages where? I've added hwdata and basically mimicked the (native)BuildInputs from the Nixpkgs derivation, yet CMake still can't find hwdata.
Managed to fix the hwdata error, and I've updated hyprwayland-scanner to work in aarch64 as well.
However, wayland-scanner now fails to generate proper headers.
hyprland-aarch64-unknown-linux-gnu> FAILED: /build/source/protocols/linux-dmabuf-unstable-v1-protocol.h
hyprland-aarch64-unknown-linux-gnu> cd /build/source && /nix/store/xq1l3m0fsrb6ql8qbii4fg9cbkwz5gvi-wayland-aarch64-unknown-linux-gnu-1.22.0-bin/bin/wayland-scanner server-header //nix/store/r8aqyska88lfiimrppvi6qz1nnh52yvq-wayland-protocols-aarch64-unknown-linux-gnu-1.35/share/wayland-protocols/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml protocols/linux-dmabuf-unstable-v1-protocol.h
hyprland-aarch64-unknown-linux-gnu> /nix/store/xq1l3m0fsrb6ql8qbii4fg9cbkwz5gvi-wayland-aarch64-unknown-linux-gnu-1.22.0-bin/bin/wayland-scanner: line 1: syntax error: unexpected word (expecting ")")
This is the same issue I also ended up having:
/nix/store/xq1l3m0fsrb6ql8qbii4fg9cbkwz5gvi-wayland-aarch64-unknown-linux-gnu-1.22.0-bin/bin/wayland-scanner shouldn't be used because its build for aarch64, we want the native version here. meson seems to have some native: true flag for their pkg-config integration, which indicates that you could request native binaries, but I don't know how it works out here.
Looks like building with Meson worked, but I can't get CMake to select the right wayland-scanner.
Do we need both to build hyprland? I wouldn't mind if cross-compiling would work with one of the two as a good first step.
Hyprland can build fine in Meson it seems, so assuming we can override only the pkgsCross derivation, we can introduce Meson before CMake (so its configure hook takes priority) in nativeBuildInputs.
Hyprland can build fine in Meson it seems, so assuming we can override only the pkgsCross derivation, we can introduce Meson before CMake (so its configure hook takes priority) in
nativeBuildInputs.
Can we not also just disable cmake everywhere like this?
dontUseCmakeConfigure = true;
We can, I was just not aware of that option.
I've removed hwdata as it is no longer needed in Hyprland itself, but in aquamarine. So I fixed aquamarine's cross build.
However, the new problem is that CMake doesn't seem to pick up the correct wayland-scanner. It should pick the host architecture, but instead it picks the target system architecture, which leads to errors like this:
hyprland-aarch64-unknown-linux-gnu> FAILED: /build/source/protocols/text-input-unstable-v1-protocol.c
hyprland-aarch64-unknown-linux-gnu> cd /build/source && /nix/store/q0396wa1xyhcwbzv0m7vv5bssnq3diab-wayland-aarch64-unknown-linux-gnu-1.22.0-bin/bin/wayland-scanner private-code //nix/store/swrc0afg0ppby4xamsx37m8diswdf4si-wayland-protocols-aarch64-unknown-linux-gnu-1.35/share/wayland-protocols/unstable/text-input/text-input-unstable-v1.xml protocols/text-input-unstable-v1-protocol.c
hyprland-aarch64-unknown-linux-gnu> /nix/store/q0396wa1xyhcwbzv0m7vv5bssnq3diab-wayland-aarch64-unknown-linux-gnu-1.22.0-bin/bin/wayland-scanner: line 1: syntax error: unexpected word (expecting ")")
@Mic92 do you have a clue why this happens or how to fix it?
EDIT: we'll also have to create a toggle for udis, since it only works on x86.
Do we still need cmake? I thought we could just use meson instead.
Sure, we can use meson for the cross build. However I wanted to make sure CMake can also cross-compile as it's the prevalent build system used throughout hyprwm.
I still would want to drop meson
@Mic92 I've managed to fix this (along with the previously-failing aquamarine). We're currently building Hyprland with Meson, but when testing, the cross compilation also worked with CMake. This is relevant as we may (once again) go back to using CMake.
When building I've also been noticing that hyprcursor couldn't cross-compile due to xcur2png failing due to malloc issues. I've found a way to fix that, but I'm unsure whether that's a suitable fix for nixpkgs inclusion.
Got the patch merged in Nixpkgs https://github.com/NixOS/nixpkgs/pull/343074. Will wait a few days for it to propagate to unstable, and then merge this PR.
@fufexan thank you as well!