summaryrefslogtreecommitdiffstats
path: root/buildtools
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2014-12-18 18:09:15 +0100
committerJeremy Allison <jra@samba.org>2015-01-08 23:38:07 +0100
commitdc808a466ef835535a3d4bb87f19316eeff1c567 (patch)
tree01ce0aeb19c212e7c38928d04f6ace0ff733cbbe /buildtools
parentd744c7c080d81121b84a592a95761e03c2a1090c (diff)
downloadsamba-dc808a466ef835535a3d4bb87f19316eeff1c567.tar.gz
samba-dc808a466ef835535a3d4bb87f19316eeff1c567.tar.xz
samba-dc808a466ef835535a3d4bb87f19316eeff1c567.zip
wafsamba: fix ordering problems with lib-provided and internal RPATHs
When a library or system (like cups) provides an RPATH, e.g. with -Wl,-R or -Wl,-rpath, this was added by waf to the LINKFLAGS, wich was later prepended to our RPATH. But if the path by chance contains an older version of one of our internal libraries like talloc, this would lead to linking the too old talloc into our binaries. This has been observed on, e.g., FreeBSD, but it is a general problem. This patch fixes the problem by specially parsing the RPATH linker options from the pkg-config(, cups-config, ....) output and putting the paths into the RPATH_<lib> container, which is then later correctly appended to our internal RPATH. This is a better fix than commit 64f5e24100a764ec198cab9a8d2c43fa86e7027c as it touches wafsamba only. 64f5e24100a764ec198cab9a8d2c43fa86e7027c is already in waf 1.5 upstream, but has some possible bugs, e.g. it doesn't handle -Wl,-R, (with ',' at the end) or some combinations where the path is given via an additional -Wl,/path argument. Bug: https://bugzilla.samba.org/show_bug.cgi?id=10548 Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> Signed-off-by: Michael Adam <obnox@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'buildtools')
-rw-r--r--buildtools/wafsamba/samba_conftests.py53
1 files changed, 53 insertions, 0 deletions
diff --git a/buildtools/wafsamba/samba_conftests.py b/buildtools/wafsamba/samba_conftests.py
index ec98ba0d7e..07dda2a3f8 100644
--- a/buildtools/wafsamba/samba_conftests.py
+++ b/buildtools/wafsamba/samba_conftests.py
@@ -4,6 +4,7 @@
import os, shutil, re
import Build, Configure, Utils
from Configure import conf
+import config_c
from samba_utils import *
@@ -506,3 +507,55 @@ def CHECK_XSLTPROC_MANPAGES(conf):
if not conf.CONFIG_SET('XSLTPROC_MANPAGES'):
print "A local copy of the docbook.xsl wasn't found on your system" \
" consider installing package like docbook-xsl"
+
+
+waf_config_c_parse_flags = config_c.parse_flags;
+def samba_config_c_parse_flags(line1, uselib, env):
+ #
+ # We do a special treatment of the rpath components
+ # in the linkflags line, because currently the upstream
+ # parse_flags function is incomplete with respect to
+ # treatment of the rpath. The remainder of the linkflags
+ # line is later passed to the original funcion.
+ #
+ lst1 = shlex.split(line1)
+ lst2 = []
+ while lst1:
+ x = lst1.pop(0)
+
+ #
+ # NOTE on special treatment of -Wl,-R and -Wl,-rpath:
+ #
+ # It is important to not put a library provided RPATH
+ # into the LINKFLAGS but in the RPATH instead, since
+ # the provided LINKFLAGS get prepended to our own internal
+ # RPATH later, and hence can potentially lead to linking
+ # in too old versions of our internal libs.
+ #
+ # We do this filtering here on our own because of some
+ # bugs in the real parse_flags() function.
+ #
+ if x == '-Wl,-rpath' or x == '-Wl,-R':
+ linkflags.remove(x)
+ x = lst1.pop(0)
+ if x.startswith('-Wl,'):
+ rpath = x[4:]
+ else:
+ rpath = x
+ elif x.startswith('-Wl,-R,'):
+ rpath = x[7:]
+ elif x.startswith('-Wl,-R'):
+ rpath = x[6:]
+ elif x.startswith('-Wl,-rpath,'):
+ rpath = x[11:]
+ else:
+ lst2.append(x)
+ continue
+
+ env.append_value('RPATH_' + uselib, rpath)
+
+ line2 = ' '.join(lst2)
+ waf_config_c_parse_flags(line2, uselib, env)
+
+ return
+config_c.parse_flags = samba_config_c_parse_flags