Skip to content

Commit 3d66942

Browse files
xclaessenirbheek
andcommitted
devenv: DYLD_LIBRARY_PATH does not work in subshell
Copied from GStreamer: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/9107 Co-authored-by: Nirbheek Chauhan <[email protected]>
1 parent 2542fbf commit 3d66942

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

mesonbuild/mdevenv.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from pathlib import Path
1212
from . import build, minstall
1313
from .mesonlib import (EnvironmentVariables, MesonException, join_args, is_windows, setup_vsenv,
14-
get_wine_shortpath, MachineChoice, relpath)
14+
get_wine_shortpath, MachineChoice, relpath, is_osx)
1515
from .options import OptionKey
1616
from . import mlog
1717

@@ -151,6 +151,14 @@ def write_gdb_script(privatedir: Path, install_data: 'InstallData', workdir: Pat
151151
mlog.log(' - Change current workdir to', mlog.bold(str(rel_path.parent)),
152152
'or use', mlog.bold(f'--init-command {rel_path}'))
153153

154+
def macos_sip_enabled() -> bool:
155+
if not is_osx():
156+
return False
157+
ret = subprocess.run(["csrutil", "status"], text=True, capture_output=True, encoding='utf-8')
158+
if not ret.stdout:
159+
return True
160+
return 'enabled' in ret.stdout
161+
154162
def dump(devenv: T.Dict[str, str], varnames: T.Set[str], dump_format: T.Optional[str], output: T.Optional[T.TextIO] = None) -> None:
155163
for name in varnames:
156164
print(f'{name}="{devenv[name]}"', file=output)
@@ -221,6 +229,10 @@ def run(options: argparse.Namespace) -> int:
221229
tmprc.flush()
222230
args.append("--rcfile")
223231
args.append(tmprc.name)
232+
if 'DYLD_LIBRARY_PATH' in devenv and macos_sip_enabled():
233+
mlog.warning('macOS System Integrity Protection is enabled: DYLD_LIBRARY_PATH cannot be set in the subshell')
234+
mlog.warning('To fix that, use `meson devenv --dump dev.env && source dev.env`')
235+
del devenv['DYLD_LIBRARY_PATH']
224236
else:
225237
# Try to resolve executable using devenv's PATH
226238
abs_path = shutil.which(args[0], path=devenv.get('PATH', None))

0 commit comments

Comments
 (0)