Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

also test cross build #6344

Merged
merged 3 commits into from
Sep 26, 2024
Merged

also test cross build #6344

merged 3 commits into from
Sep 26, 2024

Conversation

Mic92
Copy link
Contributor

@Mic92 Mic92 commented Jun 6, 2024

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
Copy link
Contributor Author

Mic92 commented Jun 6, 2024

cc @fufexan

@vaxerski vaxerski requested a review from fufexan June 6, 2024 09:11
@fufexan
Copy link
Member

fufexan commented Jun 6, 2024

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

@Mic92
Copy link
Contributor Author

Mic92 commented Jun 6, 2024

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

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

@fufexan
Copy link
Member

fufexan commented Jun 11, 2024

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.

@github-actions github-actions bot added the Nix NixOS issue label Jun 11, 2024
@fufexan
Copy link
Member

fufexan commented Jun 11, 2024

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

@Mic92
Copy link
Contributor Author

Mic92 commented Jun 11, 2024

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.

@fufexan
Copy link
Member

fufexan commented Jun 11, 2024

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

@Mic92
Copy link
Contributor Author

Mic92 commented Jun 11, 2024

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.

@fufexan
Copy link
Member

fufexan commented Jun 11, 2024

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.

@Mic92
Copy link
Contributor Author

Mic92 commented Jun 12, 2024

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;

@fufexan
Copy link
Member

fufexan commented Jun 12, 2024

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

@fufexan
Copy link
Member

fufexan commented Jul 27, 2024

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.

@Mic92
Copy link
Contributor Author

Mic92 commented Jul 27, 2024

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

@fufexan
Copy link
Member

fufexan commented Jul 28, 2024

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.

@vaxerski
Copy link
Member

I still would want to drop meson

@fufexan
Copy link
Member

fufexan commented Sep 18, 2024

@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
Copy link
Member

fufexan commented Sep 22, 2024

Got the patch merged in Nixpkgs NixOS/nixpkgs#343074. Will wait a few days for it to propagate to unstable, and then merge this PR.

Copy link
Member

@fufexan fufexan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you @Mic92

@fufexan fufexan merged commit 77f2a01 into hyprwm:main Sep 26, 2024
12 checks passed
@Mic92 Mic92 deleted the cross-build branch September 26, 2024 18:25
@Mic92
Copy link
Contributor Author

Mic92 commented Sep 26, 2024

@fufexan thank you as well!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants