diff options
author | Ting-Wei Lan <lantw@src.gnome.org> | 2017-12-18 20:58:29 +0800 |
---|---|---|
committer | Ting-Wei Lan <lantw@src.gnome.org> | 2018-01-07 01:56:05 +0800 |
commit | 9ec950c4ae5281336d4f7804dcf52943860d5d32 (patch) | |
tree | 5fac57355939f76f0f89b705902c0a88d052abee /mesonbuild/scripts/gtkdochelper.py | |
parent | 7b4bcdf21e80b1040e88293c0020386994757bc2 (diff) | |
download | meson-9ec950c4ae5281336d4f7804dcf52943860d5d32.zip meson-9ec950c4ae5281336d4f7804dcf52943860d5d32.tar.gz meson-9ec950c4ae5281336d4f7804dcf52943860d5d32.tar.bz2 |
gtkdochelper: Set LD_LIBRARY_PATH from -Wl,-rpath arguments
gnome.gtkdoc uses -Wl,-rpath to ensure the scanner executable built by
gtkdoc-scangobj will load shared libraries from the correct directories.
However, FreeBSD configures its linker to use --enable-new-dtags by
default, which converts RPATH to RUNPATH. If users have LD_LIBRARY_PATH
environment variable set, RUNPATH will be overrided by LD_LIBRARY_PATH
and libraries will be loaded from wrong directories, causing undefined
symbol error when running the executable.
In order to solve the problem, we have to prepend directories specified
with -Wl,-rpath to LD_LIBRARY_PATH to avoid relying on the deprecated
RPATH attribute.
Diffstat (limited to 'mesonbuild/scripts/gtkdochelper.py')
-rw-r--r-- | mesonbuild/scripts/gtkdochelper.py | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/mesonbuild/scripts/gtkdochelper.py b/mesonbuild/scripts/gtkdochelper.py index 4406b28..2a5ee8b 100644 --- a/mesonbuild/scripts/gtkdochelper.py +++ b/mesonbuild/scripts/gtkdochelper.py @@ -14,6 +14,7 @@ import sys, os import subprocess +import shlex import shutil import argparse from ..mesonlib import MesonException, Popen_safe @@ -45,10 +46,13 @@ parser.add_argument('--namespace', dest='namespace', default='') parser.add_argument('--mode', dest='mode', default='') parser.add_argument('--installdir', dest='install_dir') -def gtkdoc_run_check(cmd, cwd): +def gtkdoc_run_check(cmd, cwd, library_path=None): + env = dict(os.environ) + if library_path: + env['LD_LIBRARY_PATH'] = library_path # Put stderr into stdout since we want to print it out anyway. # This preserves the order of messages. - p, out = Popen_safe(cmd, cwd=cwd, stderr=subprocess.STDOUT)[0:2] + p, out = Popen_safe(cmd, cwd=cwd, env=env, stderr=subprocess.STDOUT)[0:2] if p.returncode != 0: err_msg = ["{!r} failed with status {:d}".format(cmd[0], p.returncode)] if out: @@ -115,7 +119,15 @@ def build_gtkdoc(source_root, build_root, doc_subdir, src_subdirs, '--ldflags=' + ldflags, '--ld=' + ld] - gtkdoc_run_check(scanobjs_cmd, abs_out) + library_paths = [] + for ldflag in shlex.split(ldflags): + if ldflag.startswith('-Wl,-rpath,'): + library_paths.append(ldflag[11:]) + if 'LD_LIBRARY_PATH' in os.environ: + library_paths.append(os.environ['LD_LIBRARY_PATH']) + library_path = ':'.join(library_paths) + + gtkdoc_run_check(scanobjs_cmd, abs_out, library_path) # Make docbook files if mode == 'auto': |