Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{ lib
, python3

, writeTextDir
, substituteAll
, fetchpatch
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--- a/mesonbuild/coredata.py
+++ b/mesonbuild/coredata.py
@@ -506,7 +506,6 @@ class CoreData:
return value
if option.name.endswith('dir') and value.is_absolute() and \
option not in BULITIN_DIR_NOPREFIX_OPTIONS:
- # Value must be a subdir of the prefix
# commonpath will always return a path in the native format, so we
# must use pathlib.PurePath to do the same conversion before
# comparing.
@@ -518,7 +517,7 @@ class CoreData:
try:
value = value.relative_to(prefix)
except ValueError:
- raise MesonException(msg.format(option, value, prefix))
+ pass
if '..' in str(value):
raise MesonException(msg.format(option, value, prefix))
return value.as_posix()
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
diff -Naur meson-0.60.2-old/mesonbuild/dependencies/boost.py meson-0.60.2-new/mesonbuild/dependencies/boost.py
--- meson-0.60.2-old/mesonbuild/dependencies/boost.py 2021-11-02 16:58:07.000000000 -0300
+++ meson-0.60.2-new/mesonbuild/dependencies/boost.py 2021-12-12 19:21:27.895705897 -0300
@@ -682,16 +682,7 @@
else:
tmp = [] # type: T.List[Path]

- # Add some default system paths
- tmp += [Path('/opt/local')]
- tmp += [Path('/usr/local/opt/boost')]
- tmp += [Path('/usr/local')]
- tmp += [Path('/usr')]
-
- # Cleanup paths
- tmp = [x for x in tmp if x.is_dir()]
- tmp = [x.resolve() for x in tmp]
- roots += tmp
+ # Remove such spurious, non-explicit "system" paths for Nix&Nixpkgs

self.check_and_set_roots(roots, use_system=True)

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
diff --git a/mesonbuild/scripts/depfixer.py b/mesonbuild/scripts/depfixer.py
index 4176b9a03..faaabf616 100644
--- a/mesonbuild/scripts/depfixer.py
+++ b/mesonbuild/scripts/depfixer.py
@@ -336,6 +336,15 @@ class Elf(DataSizes):
if not new_rpath:
self.remove_rpath_entry(entrynum)
else:
+ # Clear old rpath to avoid stale references,
+ # not heeding the warning above about de-duplication
+ # since it does not seem to cause issues for us
+ # and not doing so trips up Nix’s reference checker.
+ # See https://github.com/NixOS/nixpkgs/pull/46020
+ # and https://github.com/NixOS/nixpkgs/issues/95163
+ self.bf.seek(rp_off)
+ self.bf.write(b'\0'*len(old_rpath))
+
self.bf.seek(rp_off)
self.bf.write(new_rpath)
self.bf.write(b'\0')
109 changes: 109 additions & 0 deletions pkgs/development/tools/build-managers/meson/0.60/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
{ lib
, fetchpatch
, installShellFiles
, ninja
, pkg-config
, python3
, substituteAll
}:

python3.pkgs.buildPythonApplication rec {
pname = "meson";
version = "0.60.2";

src = python3.pkgs.fetchPypi {
inherit pname version;
hash = "sha256-ZOaWhWW/G4FS9PnWyoFU77nhTKqaq/eyLnHmxdBT6SE=";
};

patches = [
# Upstream insists on not allowing bindir and other dir options
# outside of prefix for some reason:
# https://github.com/mesonbuild/meson/issues/2561
# We remove the check so multiple outputs can work sanely.
./allow-dirs-outside-of-prefix.patch

# Meson is currently inspecting fewer variables than autoconf does, which
# makes it harder for us to use setup hooks, etc. Taken from
# https://github.com/mesonbuild/meson/pull/6827
./more-env-vars.patch

# Unlike libtool, vanilla Meson does not pass any information
# about the path library will be installed to to g-ir-scanner,
# breaking the GIR when path other than ${!outputLib}/lib is used.
# We patch Meson to add a --fallback-library-path argument with
# library install_dir to g-ir-scanner.
./gir-fallback-path.patch

# In common distributions, RPATH is only needed for internal libraries so
# meson removes everything else. With Nix, the locations of libraries
# are not as predictable, therefore we need to keep them in the RPATH.
# At the moment we are keeping the paths starting with /nix/store.
# https://github.com/NixOS/nixpkgs/issues/31222#issuecomment-365811634
(substituteAll {
src = ./fix-rpath.patch;
inherit (builtins) storeDir;
})

# When Meson removes build_rpath from DT_RUNPATH entry, it just writes
# the shorter NUL-terminated new rpath over the old one to reduce
# the risk of potentially breaking the ELF files.
# But this can cause much bigger problem for Nix as it can produce
# cut-in-half-by-\0 store path references.
# Let’s just clear the whole rpath and hope for the best.
./clear-old-rpath.patch

# Patch out default boost search paths to avoid impure builds on
# unsandboxed non-NixOS builds, see:
# https://github.com/NixOS/nixpkgs/issues/86131#issuecomment-711051774
./boost-Do-not-add-system-paths-on-nix.patch
];

setupHook = ./setup-hook.sh;

# Meson included tests since 0.45, however they fail in Nixpkgs because they
# require a typical building environment (including C compiler and stuff).
# Just for the sake of documentation, the next lines are maintained here.
doCheck = false;
checkInputs = [ ninja pkg-config ];
checkPhase = ''
python ./run_project_tests.py
'';

postFixup = ''
pushd $out/bin
# undo shell wrapper as meson tools are called with python
for i in *; do
mv ".$i-wrapped" "$i"
done
popd

# Do not propagate Python
rm $out/nix-support/propagated-build-inputs
'';

nativeBuildInputs = [ installShellFiles ];

postInstall = ''
installShellCompletion --zsh data/shell-completions/zsh/_meson
installShellCompletion --bash data/shell-completions/bash/meson
'';

meta = with lib; {
homepage = "https://mesonbuild.com";
description = "An open source, fast and friendly build system made in Python";
longDescription = ''
Meson is an open source build system meant to be both extremely fast, and,
even more importantly, as user friendly as possible.

The main design point of Meson is that every moment a developer spends
writing or debugging build definitions is a second wasted. So is every
second spent waiting for the build system to actually start compiling
code.
'';
license = licenses.asl20;
maintainers = with maintainers; [ jtojnar mbe AndersonTorres ];
inherit (python3.meta) platforms;
};
}
# TODO: a more Nixpkgs-tailoired test suite
24 changes: 24 additions & 0 deletions pkgs/development/tools/build-managers/meson/0.60/fix-rpath.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
--- a/mesonbuild/backend/backends.py
+++ b/mesonbuild/backend/backends.py
@@ -456,6 +456,21 @@ class Backend:
args.extend(self.environment.coredata.get_external_link_args(target.for_machine, lang))
except Exception:
pass
+
+ nix_ldflags = os.environ.get('NIX_LDFLAGS', '').split()
+ next_is_path = False
+ # Try to add rpaths set by user or ld-wrapper so that they are not removed.
+ # Based on https://github.com/NixOS/nixpkgs/blob/69711a2f5ffe8cda208163be5258266172ff527f/pkgs/build-support/bintools-wrapper/ld-wrapper.sh#L148-L177
+ for flag in nix_ldflags:
+ if flag == '-rpath' or flag == '-L':
+ next_is_path = True
+ elif next_is_path or flag.startswith('-L/'):
+ if flag.startswith('-L/'):
+ flag = flag[2:]
+ if flag.startswith('@storeDir@'):
+ dirs.add(flag)
+ next_is_path = False
+
# Match rpath formats:
# -Wl,-rpath=
# -Wl,-rpath,
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py
index 1c6952df7..9466a0b7d 100644
--- a/mesonbuild/modules/gnome.py
+++ b/mesonbuild/modules/gnome.py
@@ -923,6 +923,16 @@ class GnomeModule(ExtensionModule):
if fatal_warnings:
scan_command.append('--warn-error')

+ if len(set(girtarget.get_custom_install_dir()[0] for girtarget in girtargets if girtarget.get_custom_install_dir())) > 1:
+ raise MesonException('generate_gir tries to build multiple libraries with different install_dir at once: {}'.format(','.join([str(girtarget) for girtarget in girtargets])))
+
+ if girtargets[0].get_custom_install_dir():
+ fallback_libpath = girtargets[0].get_custom_install_dir()[0]
+ else:
+ fallback_libpath = None
+ if fallback_libpath is not None and isinstance(fallback_libpath, str) and len(fallback_libpath) > 0 and fallback_libpath[0] == "/":
+ scan_command += ['--fallback-library-path=' + fallback_libpath]
+
generated_files = [f for f in libsources if isinstance(f, (GeneratedList, CustomTarget, CustomTargetIndex))]

scan_target = self._make_gir_target(state, girfile, scan_command, generated_files, depends, kwargs)
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff -Naur meson-0.60.2-old/mesonbuild/environment.py meson-0.60.2-new/mesonbuild/environment.py
--- meson-0.60.2-old/mesonbuild/environment.py 2021-11-02 16:58:13.000000000 -0300
+++ meson-0.60.2-new/mesonbuild/environment.py 2021-12-12 17:44:00.350499307 -0300
@@ -68,7 +68,7 @@
# compiling we fall back on the unprefixed host version. This
# allows native builds to never need to worry about the 'BUILD_*'
# ones.
- ([var_name + '_FOR_BUILD'] if is_cross else [var_name]),
+ [var_name + '_FOR_BUILD'] + ([] if is_cross else [var_name]),
# Always just the unprefixed host versions
[var_name]
)[for_machine]
37 changes: 37 additions & 0 deletions pkgs/development/tools/build-managers/meson/0.60/setup-hook.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
mesonConfigurePhase() {
runHook preConfigure

if [ -z "${dontAddPrefix-}" ]; then
mesonFlags="--prefix=$prefix $mesonFlags"
fi

# See multiple-outputs.sh and meson’s coredata.py
mesonFlags="\
--libdir=${!outputLib}/lib --libexecdir=${!outputLib}/libexec \
--bindir=${!outputBin}/bin --sbindir=${!outputBin}/sbin \
--includedir=${!outputInclude}/include \
--mandir=${!outputMan}/share/man --infodir=${!outputInfo}/share/info \
--localedir=${!outputLib}/share/locale \
-Dauto_features=${mesonAutoFeatures:-enabled} \
-Dwrap_mode=${mesonWrapMode:-nodownload} \
$mesonFlags"

mesonFlags="${crossMesonFlags+$crossMesonFlags }--buildtype=${mesonBuildType:-plain} $mesonFlags"

echo "meson flags: $mesonFlags ${mesonFlagsArray[@]}"

meson build $mesonFlags "${mesonFlagsArray[@]}"
cd build

if ! [[ -v enableParallelBuilding ]]; then
enableParallelBuilding=1
echo "meson: enabled parallel building"
fi

runHook postConfigure
}

if [ -z "${dontUseMesonConfigure-}" -a -z "${configurePhase-}" ]; then
setOutputFlags=
configurePhase=mesonConfigurePhase
fi
4 changes: 3 additions & 1 deletion pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3366,7 +3366,9 @@ with pkgs;

merriweather-sans = callPackage ../data/fonts/merriweather-sans { };

meson = callPackage ../development/tools/build-managers/meson { };
# TODO: call a sprintable to deprecate Meson 0.57 as soon as possible
meson = callPackage ../development/tools/build-managers/meson/0.57 { };
meson_0_60 = callPackage ../development/tools/build-managers/meson/0.60 { };

meson-tools = callPackage ../misc/meson-tools { };

Expand Down