From: Stefan Metzmacher Date: Thu, 18 Dec 2014 17:09:15 +0000 (+0100) Subject: wafsamba: fix ordering problems with lib-provided and internal RPATHs X-Git-Url: http://git.samba.org/?p=obnox%2Fsamba%2Fsamba-obnox.git;a=commitdiff_plain;h=edf0c22b422e4fa6e948b36a015c27fb2e80941c 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_ container, which is then later correctly appended to our internal RPATH. This is a better fix than commit 64f5e24100a764ec198cab9a8d2c43fa86e7027c as it touches wafsamba only. We can revert 64f5e24100a764ec198cab9a8d2c43fa86e7027c in the following commit. Bug: https://bugzilla.samba.org/show_bug.cgi?id=10548 Signed-off-by: Stefan Metzmacher --- diff --git a/buildtools/wafsamba/samba_conftests.py b/buildtools/wafsamba/samba_conftests.py index ec98ba0d7ee..f94b0b7ca8c 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,37 @@ 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(line, uselib, env): + waf_config_c_parse_flags(line, uselib, env) + + try: + linkflags = env['LINKFLAGS_' + uselib] + except KeyError: + linkflags = [] + for x in linkflags: + # + # 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. + # + if x.startswith('-Wl,-R,'): + rpath = x[7:] + elif x.startswith('-Wl,-R'): + rpath = x[6:] + elif x.startswith('-Wl,-rpath,'): + rpath = x[11:] + else: + continue + + env.append_value('RPATH_' + uselib, rpath) + linkflags.remove(x) + + return +config_c.parse_flags = samba_config_c_parse_flags