Hyprland icon indicating copy to clipboard operation
Hyprland copied to clipboard

also test cross build

Open Mic92 opened this issue 1 year ago • 11 comments

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?

Mic92 avatar Jun 06 '24 08:06 Mic92

cc @fufexan

Mic92 avatar Jun 06 '24 08:06 Mic92

Great addition! We should also add the cross build to the CI matrix.

fufexan avatar Jun 06 '24 09:06 fufexan

Great addition! We should also add the cross build to the CI matrix.

Maybe, but first I would appreciate help with the issue. Thanks!

Mic92 avatar Jun 06 '24 10:06 Mic92

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.

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.

fufexan avatar Jun 11 '24 14:06 fufexan

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 ")")

fufexan avatar Jun 11 '24 15:06 fufexan

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.

Mic92 avatar Jun 11 '24 15:06 Mic92

Looks like building with Meson worked, but I can't get CMake to select the right wayland-scanner.

fufexan avatar Jun 11 '24 16:06 fufexan

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.

Mic92 avatar Jun 11 '24 16:06 Mic92

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.

fufexan avatar Jun 11 '24 17:06 fufexan

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;

Mic92 avatar Jun 12 '24 07:06 Mic92

We can, I was just not aware of that option.

fufexan avatar Jun 12 '24 12:06 fufexan

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.

fufexan avatar Jul 27 '24 17:07 fufexan

Do we still need cmake? I thought we could just use meson instead.

Mic92 avatar Jul 27 '24 21:07 Mic92

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.

fufexan avatar Jul 28 '24 09:07 fufexan

I still would want to drop meson

vaxerski avatar Jul 28 '24 11:07 vaxerski

@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.

fufexan avatar Sep 18 '24 14:09 fufexan

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 avatar Sep 22 '24 09:09 fufexan

@fufexan thank you as well!

Mic92 avatar Sep 26 '24 18:09 Mic92