3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/development/tools/build-managers/meson/0.57/fix-rpath.patch
AndersonTorres 1a53eeda71 meson: put 0.57 in a subdirectory
Meson is a delicate package. It needs some patches to properly work in Nixpkgs
and many packages have it as a dependency, from many small applications to
systemd (yay, mass rebuilds in sight!). Updating it is not a trivial and
harmless task.

Therefore, I took the paranoid way and encapsulate the current version in a
subdir, instead of the regular write-over procedure. This way, at the best we
can just remove the whole dir in the future, and at the worse we just maintain
duplicated code.
2021-12-14 16:37:25 -03:00

25 lines
1 KiB
Diff

--- 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,