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

Meson no longer able to pick up Boost #86131

Open
emilazy opened this issue Apr 27, 2020 · 28 comments
Open

Meson no longer able to pick up Boost #86131

emilazy opened this issue Apr 27, 2020 · 28 comments

Comments

@emilazy
Copy link
Member

emilazy commented Apr 27, 2020

(originally about pulseeffects build)

Broken on Hydra for a few days now; going by the log it seems to be a boost issue:

Run-time dependency Boost (missing: filesystem, system) found: NO 

src/meson.build:97:0: ERROR: Dependency "boost" not found

but removing the boost version override introduced in 470b916 didn't fix it (and wwmm/easyeffects#645 suggests it's required anyway). Unfortunately I'm not very familiar with boost or meson so I'm not sure what to poke at next, but I'll update this issue if I figure anything out.

cc @jtojnar @matthiasbeyer

@jtojnar
Copy link
Contributor

jtojnar commented Apr 27, 2020

Possibly a meson bump changed boost detection?

@jtojnar
Copy link
Contributor

jtojnar commented Apr 27, 2020

Yeah, looks like it touched boost: mesonbuild/meson@0.53...0.54.0
And mesonbuild/meson@0.54.0...0.54.1 did too so maybe we just need to update.

@emilazy
Copy link
Member Author

emilazy commented Apr 27, 2020

Makes sense. Bisecting the build to see exactly what nixpkgs commit broke things; would try with a bumped meson afterwards but I guess that would need a stdenv rebootstrap?

@jtojnar
Copy link
Contributor

jtojnar commented Apr 27, 2020

I think creating a directory containing meson.build file with

project(
	'pulseeffects',
	'c',
	'cpp',
	default_options : ['cpp_std=c++17','buildtype=debugoptimized'],
	version: '4.7.2',
	meson_version: '>= 0.40.0'
)
dependency('boost', version: '>=1.65', modules:['system','filesystem'])

and changing the pulseeffects src to point to that and removing all dependencies except for meson, ninja and boost from the pulseeffects expression might avoid that.

Or you can clone meson, update that and use it for pulseeffects. That should limit the fallback even more (if boost or ninja depend on meson transitively).

@emilazy
Copy link
Member Author

emilazy commented Apr 27, 2020

Unfortunately, same error even with:

diff --git a/pkgs/applications/audio/pulseeffects/default.nix b/pkgs/applications/audio/pulseeffects/default.nix
index 2972849a2d4..a93fb6c48fe 100644
--- a/pkgs/applications/audio/pulseeffects/default.nix
+++ b/pkgs/applications/audio/pulseeffects/default.nix
@@ -32,6 +32,7 @@
 , rubberband
 , mda_lv2
 , lsp-plugins
+, python3Packages
 }:
 
 let
@@ -56,7 +57,15 @@ in stdenv.mkDerivation rec {
   };
 
   nativeBuildInputs = [
-    meson
+    (meson.overrideAttrs (_: rec {
+      pname = "meson";
+      version = "0.54.1";
+      name = "${pname}-${version}";
+      src = python3Packages.fetchPypi {
+        inherit pname version;
+        hash = "sha256-L3b7RXJ2K+E+5HkpJhAJG0UJr1eIvM6zkf4iK80Cltw=";
+      };
+    }))
     ninja
     pkgconfig
     libxml2

Not entirely sure this is enough to get the right version of meson used, though.

@jtojnar
Copy link
Contributor

jtojnar commented Apr 27, 2020

Yeah, that should be enough.

Hmm. That is unfortunate. Reverting back to 0.53.2 seems to fix the issue:

--- a/pkgs/applications/audio/pulseeffects/default.nix
+++ b/pkgs/applications/audio/pulseeffects/default.nix
@@ -1,5 +1,6 @@
 { stdenv
 , fetchFromGitHub
+, pkgs
 , meson
 , ninja
 , pkgconfig
@@ -56,7 +57,14 @@ in stdenv.mkDerivation rec {
   };
 
   nativeBuildInputs = [
-    meson
+    (let
+      nixpkgs = pkgs.fetchzip {
+        name = "nixpkgs-with-meson-0.53.2";
+        url = "https://github.com/NixOS/nixpkgs/archive/9073a0cb8b2f419785a60969e11e96733f29b200%5E.tar.gz";
+        hash = "sha256-oC94cOmB7dxpWzSXlLNt2OyhEt20qX9murBWUh52HLo=";
+      };
+    in
+      pkgs.callPackage "${nixpkgs}/pkgs/development/tools/build-managers/meson/default.nix" {})
     ninja
     pkgconfig
     libxml2

We will need to analyze the commits that touched boost and fix them.

@emilazy
Copy link
Member Author

emilazy commented Apr 27, 2020

I'm guessing mesonbuild/meson@08224da is the place to start looking.

@jtojnar
Copy link
Contributor

jtojnar commented Apr 27, 2020

Looking at https://github.com/mesonbuild/meson/pull/6602/files#diff-69d98b8292053a53f88d3015eab2d5daL87, they no longer seem to use compiler.find_library() and instead try to find boost installation roots.

We pass -isystem /nix/store/zyrg127fd6sk40dx576mcsr4a2jxcxqq-boost-1.72.0-dev/include to the compiler and -L/nix/store/97smy1b58mq6n9kaha4icfz7gqq8pyx6-boost-1.72.0/lib to the linker so compiler.find_library() was able to find boost but the new mechanism no longer subscribes to that.

@jtojnar jtojnar changed the title pulseeffects: broken build meson no longer able to pick up Boost Apr 27, 2020
@jtojnar jtojnar changed the title meson no longer able to pick up Boost Meson no longer able to pick up Boost Apr 27, 2020
@jtojnar
Copy link
Contributor

jtojnar commented Apr 27, 2020

Setting the following environment variables fixes the Meson’s Boost detection:

  # Meson is no longer able to pick up Boost automatically.
  # https://github.com/NixOS/nixpkgs/issues/86131
  BOOST_INCLUDEDIR = "${stdenv.lib.getDev boost}/include";
  BOOST_LIBRARYDIR = "${stdenv.lib.getLib boost}/lib";

Not sure if we should do that in Boost setup hook or make Meson support find_library again.

@emilazy
Copy link
Member Author

emilazy commented Apr 27, 2020

The setup hook seems like a good solution to me. Weirdly, setting BOOST_ROOT doesn't seem to work (maybe because of the split packages setup?).

@jtojnar
Copy link
Contributor

jtojnar commented Apr 27, 2020

jtojnar added a commit that referenced this issue Apr 27, 2020
Meson 0.54 is no longer able to find Boost:

See #86131
@jtojnar
Copy link
Contributor

jtojnar commented Apr 27, 2020

For now, I have added the variables to pulseeffects.

@emilazy
Copy link
Member Author

emilazy commented Apr 27, 2020

Thanks!

Maybe we should ask meson upstream what the preferred way to handle this would be?

@jtojnar
Copy link
Contributor

jtojnar commented Apr 27, 2020

Yeah, I am chatting with the PR author on IRC right now.

@jtojnar
Copy link
Contributor

jtojnar commented Apr 28, 2020

They do not want to extract the paths from compiler/linker so it was suggested to me to add a generic method for letting meson know where headers/libraries are stored in lieu of FHS. I will track that in #86159.

In the short term, we should add a setup hook to boost, that sets the two environment variables.

@jtojnar jtojnar added this to To Do in Meson breakages via automation Jul 5, 2020
@wucke13
Copy link
Contributor

wucke13 commented Sep 15, 2020

Setting the two environment variables still seems to be not enough:

Run-time dependency Boost (found: chrono, filesystem, program_options, system, thread | missing: python3) found: NO

despite having

    boost = boost.override { enablePython = true; };

Any idea how to fix this?

@jtojnar
Copy link
Contributor

jtojnar commented Sep 15, 2020

Boost currently defaults to Python 2, you would also need to override python argument (see calamares in all-packages.nix) or better, use python3.pkgs.boost.

@nh2
Copy link
Contributor

nh2 commented Oct 16, 2020

Setting the following environment variables fixes the Meson’s Boost detection:

@jtojnar Thanks, that workaround worked for our Meson project as well.

@nh2
Copy link
Contributor

nh2 commented Oct 17, 2020

I'm guessing mesonbuild/meson@08224da is the place to start looking.

We probably want to patch these bits out:

mesonbuild/meson@08224da#diff-1b19eec47488c9254b2b24c85f61969816cae32b77a4fddd359c11ef97250c95R510-R519

@nh2
Copy link
Contributor

nh2 commented Oct 17, 2020

We probably want to patch these bits out:

PR #100850

nh2 added a commit to nh2/nixpkgs that referenced this issue Oct 17, 2020
Avoids impure builds on unsandboxed non-NixOS builds, see:
NixOS#86131 (comment)
@jtojnar
Copy link
Contributor

jtojnar commented Oct 18, 2020

0.56 will support setting the boost directories in cross file, in addition to env vars: https://github.com/mesonbuild/meson/pull/7210/files

FRidh pushed a commit that referenced this issue Oct 20, 2020
Avoids impure builds on unsandboxed non-NixOS builds, see:
#86131 (comment)
mpoquet added a commit to oar-team/nur-kapack that referenced this issue Nov 10, 2020
Not fixed in master nixpkgs yet, tracked on NixOS/nixpkgs#86131
@stale
Copy link

stale bot commented Apr 18, 2021

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 Apr 18, 2021
@emilazy
Copy link
Member Author

emilazy commented Apr 18, 2021

@jtojnar is the cross file used now?

@jtojnar
Copy link
Contributor

jtojnar commented Apr 18, 2021

No. We would have to update the setup hook to generate the cross file.

@dschrempf
Copy link
Contributor

Sorry to bump this, but I am unsure now, is the workaround (setting BOOST_INCLUDEDIR, and BOOST_LIBRARYDIR) still required? Thank you!

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Mar 9, 2022
@tfc
Copy link
Contributor

tfc commented Mar 30, 2022

I also bumped into this and it still seems to be necessary... it would be nice to not need that.

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Oct 1, 2022
@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/boost-no-found-building-a-meson-project-with-boost-dependency/29256/2

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 18, 2023
@nixos-discourse

This comment was marked as duplicate.

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

No branches or pull requests

7 participants