1 --- a/mesonbuild/backend/backends.py
2 +++ b/mesonbuild/backend/backends.py
5 def get_rpath_dirs_from_link_args(args: T.List[str]) -> T.Set[str]:
6 dirs: T.Set[str] = set()
8 + nix_ldflags = os.environ.get('NIX_LDFLAGS', '').split()
10 + # Try to add rpaths set by user or ld-wrapper so that they are not removed.
11 + # Based on https://github.com/NixOS/nixpkgs/blob/69711a2f5ffe8cda208163be5258266172ff527f/pkgs/build-support/bintools-wrapper/ld-wrapper.sh#L148-L177
12 + for flag in nix_ldflags:
13 + if flag == '-rpath' or flag == '-L':
15 + elif next_is_path or flag.startswith('-L/'):
16 + if flag.startswith('-L/'):
18 + if flag.startswith('@storeDir@'):
20 + next_is_path = False
22 # Match rpath formats: