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

mesa fails to (cross-)compile #88961

Closed
nagisa opened this issue May 26, 2020 · 18 comments
Closed

mesa fails to (cross-)compile #88961

nagisa opened this issue May 26, 2020 · 18 comments
Labels
0.kind: bug 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: cross-compilation Building packages on a different platform than they will be used on

Comments

@nagisa
Copy link
Contributor

nagisa commented May 26, 2020

Describe the bug

Cross-compilation of mesa fails with the following error at configure stage

$ nix build -L -f '<nixpkgs>' pkgsCross.aarch64-multiplatform.mesa
...
mesa> Run-time dependency valgrind found: YES 3.15.0
mesa> Program bison found: YES (/nix/store/ra42sij0cb917p3m90qdnv0vc3kxv1hm-bison-3.5.4/bin/bison)
mesa> Program flex found: YES (/nix/store/q99r9k0py7m2mrdfsif9wfvllvvxfiqi-flex-2.6.4/bin/flex)
mesa> Run-time dependency libunwind found: NO (tried pkgconfig and cmake)
mesa> Found pkg-config: /nix/store/nc3ivxhlqyj2alck8p47srvwzzgkbh2i-pkg-config-0.29.2/bin/pkg-config (0.29.2)
mesa> Did not find CMake 'cmake'
mesa> Found CMake: NO
mesa> Build-time dependency wayland-scanner found: NO (tried pkgconfig)
mesa> meson.build:1553:2: ERROR: Dependency "wayland-scanner" not found, tried pkgconfig
mesa> A full log can be found at /build/mesa-20.0.2/build/meson-logs/meson-log.txt

Though there appear to be other non-fatal, but otherwise concerning issues (especially surrounding LLVM) in the configuration process.

To Reproduce
Steps to reproduce the behavior:

  1. nix build -L -f '<nixpkgs>' pkgsCross.aarch64-multiplatform.mesa

Expected behavior
Build should succeed

Notify maintainers

@vcunat

Metadata

  • system: "x86_64-linux"
  • host os: Linux 5.6.13, NixOS, 20.09pre225898.7319061eef4 (Nightingale)
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.3.4
  • channels(root): "nixos-20.09pre225898.7319061eef4"
  • channels(nagisa): ""
  • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos

Maintainer information:

# a list of nixpkgs attributes affected by the problem
attribute:
# a list of nixos modules affected by the problem
module:
@nagisa
Copy link
Contributor Author

nagisa commented May 26, 2020

Looks like meson is expecting PKG_CONFIG_PATH_FOR_BUILD to be set when looking for wayland-scanner, but the variable is not set.

@nagisa
Copy link
Contributor Author

nagisa commented May 26, 2020

Doing something like this makes it build, but is likely the wrong way to approach the problem?

diff --git a/pkgs/development/libraries/mesa/default.nix b/pkgs/development/libraries/mesa/default.nix
index 7eb18dd31c1..d4556fc2637 100644
--- a/pkgs/development/libraries/mesa/default.nix
+++ b/pkgs/development/libraries/mesa/default.nix
@@ -1,4 +1,5 @@
 { stdenv, lib, fetchurl, fetchpatch
+, pkgsBuildTarget
 , pkgconfig, intltool, ninja, meson
 , file, flex, bison, expat, libdrm, xorg, wayland, wayland-protocols, openssl
 , llvmPackages, libffi, libomxil-bellagio, libva-minimal
@@ -116,8 +117,13 @@ stdenv.mkDerivation {
     pkgconfig meson ninja
     intltool bison flex file
     python3Packages.python python3Packages.Mako
+    wayland
   ];

+  preUnpack = ''
+    export PKG_CONFIG_PATH_FOR_BUILD="${pkgsBuildTarget.wayland}/lib/pkgconfig"
+  '';
+
   propagatedBuildInputs = with xorg; [
     libXdamage libXxf86vm
   ] ++ optional stdenv.isLinux libdrm

@veprbl veprbl added the 6.topic: cross-compilation Building packages on a different platform than they will be used on label May 26, 2020
@matthewbauer
Copy link
Member

I think #87705 will fix this partly. We will still need wayland in nativeBuildInputs.

@nagisa
Copy link
Contributor Author

nagisa commented May 26, 2020

Yeah, looks like the solution in #87705 is indeed partial, because mesa doesn’t build even on origin/master from 2 hours ago (with the nativeBuildInputs change applied).

What really is going on there is way over my head, so I’ll leave this to somebody who understands it better.

@Ericson2314
Copy link
Member

@matthewbauer but wayland-scanner is a possibly-build-specific dev tool (#51176), so I think it shouldn't be using PKG_CONFIG_PATH_FOR_BUILD for this in the first place. Even if the native wayland-scanner really does work, I'd like to do the g-i thing as planned for #88222 where we combine the tools and the rest of the package in a wrapper with a patched pc file.

@Ericson2314
Copy link
Member

CC @dcbaker, do you test cross builds upstream?

@vcunat
Copy link
Member

vcunat commented May 27, 2020

Fixing cross-builds for complex packages like mesa might turn out to be hard, especially in our default feature-ful config. My motivation for aarch64 there isn't high, as we have natively compiled version from Hydra and even https://github.com/nix-community/aarch64-build-box

@nagisa
Copy link
Contributor Author

nagisa commented May 27, 2020

My motivation for aarch64 there isn't high, as we have natively compiled version from Hydra

I’m not sure if its the fact that I'm cross-compiling (and so hashes change for whatever reason) or the fact that I accidentally changed some dependency of mesa, but I’m not able to get it and other dependencies to be pulled from hydra at all (including mesa). Arguably I can still obtain a aarch64 server to do a native build, but that sounds both a subpar experience (to building locally) and a compromise.

@vcunat
Copy link
Member

vcunat commented May 27, 2020

Cross-compiled builds always get different hashes than native builds. EDIT: the thing is that getting the server (or using a local VM) might be way cheaper than fixing such complex builds and keeping them fixed (human work).

@Ericson2314
Copy link
Member

Ericson2314 commented May 27, 2020

Well assuming any wayland-scanner will do, and there are no other issues, this won't be hard to fix.

@matthewbauer
Copy link
Member

matthewbauer commented May 27, 2020

wayland-scanner is cross-compiled by meson (https://github.com/wayland-project/wayland/blob/6d4497371014cacbf0dc4ed9983fd6617ec25c9a/src/meson.build#L38-L45, so I don't think we can treat it like xxx-config (even if that is more correct). wayland itself, even, needs the native wayland-scanner to cross compile (

] ++ lib.optionals isCross [
wayland # For wayland-scanner during the build
). meson makes it pretty hard to not pull native build inputs from PKG_CONFIG_PATH_FOR_BUILD.

@dcbaker
Copy link
Contributor

dcbaker commented May 27, 2020

@Ericson2314, yes we do an x86 -> arm build. Here's the CI results for current master:
https://gitlab.freedesktop.org/mesa/mesa/pipelines/152118

@Ericson2314
Copy link
Member

@dcbaker Thanks!!

@Ericson2314
Copy link
Member

Ericson2314 commented May 27, 2020

@dcbaker so it looks like the cross CI extends the native build to get access to native wayland-scanner? We did something similar in #89036 --- just making sure it isn't intended that one might build wayland-scanner as a separate package from the rest of wayland.

@dcbaker
Copy link
Contributor

dcbaker commented May 29, 2020

Oh don't get me started on wayland scanner, lol. I tried to fix that mess but upstream thinks fixing it makes their build too complicated and wont take patches. So yes, I think you need to build and package wayland scanner separate if you need to cross compile wayland.

@Ericson2314
Copy link
Member

Ericson2314 commented May 29, 2020

Ugh, the classic struggle with cross. Well, I'd be happy to go comment on any issue / PR / mailing list thread you made if it might tip the scales.

@stale
Copy link

stale bot commented Nov 26, 2020

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Nov 26, 2020
@Atemu
Copy link
Member

Atemu commented Dec 13, 2020

FWIW, I was able to cross-compile Mesa with #106804.

@vcunat vcunat closed this as completed Dec 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: cross-compilation Building packages on a different platform than they will be used on
Projects
None yet
Development

No branches or pull requests

7 participants