wafsamba patches...
Stefan (metze) Metzmacher
metze at samba.org
Wed Jan 7 12:31:42 MST 2015
Hi,
here are some patches I pair-programmed with Ralph and Michael.
They should fix a couple of bug reports mostly for non-linux platforms.
Please have a look and push.
Thanks!
metze
-------------- next part --------------
From afd75507e4ef0dadecb4330d349e82c530524245 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Wed, 7 Jan 2015 09:41:02 +0100
Subject: [PATCH 01/15] wafsamba: let TO_LIST(mylist) return a copy of mylist
In most cases we have TO_LIST(mystring) which returns an independent
list.
newlist = TO_LIST(mylist) returned just a reference to mylist.
Which means newlist.append("end") would also modify mylist.
TO_LIST() should always return an independent list.
Signed-off-by: Stefan Metzmacher <metze at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
---
buildtools/wafsamba/samba_utils.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/buildtools/wafsamba/samba_utils.py b/buildtools/wafsamba/samba_utils.py
index 0b0bb48..9ac1066 100644
--- a/buildtools/wafsamba/samba_utils.py
+++ b/buildtools/wafsamba/samba_utils.py
@@ -214,7 +214,8 @@ def TO_LIST(str, delimiter=None):
if str is None:
return []
if isinstance(str, list):
- return str
+ # we need to return a new independent list...
+ return list(str)
if len(str) == 0:
return []
lst = str.split(delimiter)
--
1.9.1
From ac47d6151e9f9bde71c5a0c0a769e745f5aab2be Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Wed, 7 Jan 2015 09:48:38 +0100
Subject: [PATCH 02/15] wafsamba: move compiler / cflags related stuff from
lib/replace to wafsamba
We should have this just in one central place.
Signed-off-by: Stefan Metzmacher <metze at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
---
buildtools/wafsamba/wscript | 21 +++++++++++++++++++++
lib/replace/wscript | 21 ---------------------
2 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/buildtools/wafsamba/wscript b/buildtools/wafsamba/wscript
index 1a30d2f..917a692 100755
--- a/buildtools/wafsamba/wscript
+++ b/buildtools/wafsamba/wscript
@@ -363,6 +363,27 @@ def configure(conf):
conf.DEFINE('_GNU_SOURCE', 1, add_to_cflags=True)
conf.DEFINE('_XOPEN_SOURCE_EXTENDED', 1, add_to_cflags=True)
+ # on Tru64 certain features are only available with _OSF_SOURCE set to 1
+ # and _XOPEN_SOURCE set to 600
+ if conf.env['SYSTEM_UNAME_SYSNAME'] == 'OSF1':
+ conf.DEFINE('_OSF_SOURCE', 1, add_to_cflags=True)
+ conf.DEFINE('_XOPEN_SOURCE', 600, add_to_cflags=True)
+
+ # SCM_RIGHTS is only avail if _XOPEN_SOURCE iѕ defined on IRIX
+ if conf.env['SYSTEM_UNAME_SYSNAME'] == 'IRIX':
+ conf.DEFINE('_XOPEN_SOURCE', 600, add_to_cflags=True)
+ conf.DEFINE('_BSD_TYPES', 1, add_to_cflags=True)
+
+ # Try to find the right extra flags for C99 initialisers
+ for f in ["", "-AC99", "-qlanglvl=extc99", "-qlanglvl=stdc99", "-c99"]:
+ if conf.CHECK_CFLAGS([f], '''
+struct foo {int x;char y;};
+struct foo bar = { .y = 'X', .x = 1 };
+'''):
+ if f != "":
+ conf.ADD_CFLAGS(f)
+ break
+
# get the base headers we'll use for the rest of the tests
conf.CHECK_HEADERS('stdio.h sys/types.h sys/stat.h stdlib.h stddef.h memory.h string.h',
add_headers=True)
diff --git a/lib/replace/wscript b/lib/replace/wscript
index 7bbe1d6..0f29514 100644
--- a/lib/replace/wscript
+++ b/lib/replace/wscript
@@ -32,27 +32,6 @@ def configure(conf):
conf.DEFINE('HAVE_LIBREPLACE', 1)
conf.DEFINE('LIBREPLACE_NETWORK_CHECKS', 1)
- # on Tru64 certain features are only available with _OSF_SOURCE set to 1
- # and _XOPEN_SOURCE set to 600
- if conf.env['SYSTEM_UNAME_SYSNAME'] == 'OSF1':
- conf.DEFINE('_OSF_SOURCE', 1, add_to_cflags=True)
- conf.DEFINE('_XOPEN_SOURCE', 600, add_to_cflags=True)
-
- # SCM_RIGHTS is only avail if _XOPEN_SOURCE iѕ defined on IRIX
- if conf.env['SYSTEM_UNAME_SYSNAME'] == 'IRIX':
- conf.DEFINE('_XOPEN_SOURCE', 600, add_to_cflags=True)
- conf.DEFINE('_BSD_TYPES', 1, add_to_cflags=True)
-
- # Try to find the right extra flags for C99 initialisers
- for f in ["", "-AC99", "-qlanglvl=extc99", "-qlanglvl=stdc99", "-c99"]:
- if conf.CHECK_CFLAGS([f], '''
-struct foo {int x;char y;};
-struct foo bar = { .y = 'X', .x = 1 };
-'''):
- if f != "":
- conf.ADD_CFLAGS(f)
- break
-
if conf.CHECK_CFLAGS(['-fstack-protector']) and conf.CHECK_LDFLAGS(['-fstack-protector']):
conf.ADD_CFLAGS('-fstack-protector')
conf.ADD_LDFLAGS('-fstack-protector')
--
1.9.1
From 7c0f35451d3853830d46114a000229ac6850496e Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Wed, 7 Jan 2015 09:52:53 +0100
Subject: [PATCH 03/15] wafsamba: move WERROR_CFLAGS checks from lib/replace to
wafsamba
Signed-off-by: Stefan Metzmacher <metze at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
---
buildtools/wafsamba/wscript | 13 +++++++++++++
lib/replace/wscript | 13 -------------
2 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/buildtools/wafsamba/wscript b/buildtools/wafsamba/wscript
index 917a692..0e2afe1 100755
--- a/buildtools/wafsamba/wscript
+++ b/buildtools/wafsamba/wscript
@@ -295,6 +295,19 @@ def configure(conf):
headers='stdio.h',
msg='Checking simple C program')
+ # Try to find the right extra flags for -Werror behaviour
+ for f in ["-Werror", # GCC
+ "-errwarn=%all", # Sun Studio
+ "-qhalt=w", # IBM xlc
+ "-w2", # Tru64
+ ]:
+ if conf.CHECK_CFLAGS([f], '''
+'''):
+ if not 'WERROR_CFLAGS' in conf.env:
+ conf.env['WERROR_CFLAGS'] = []
+ conf.env['WERROR_CFLAGS'].extend([f])
+ break
+
# check which compiler/linker flags are needed for rpath support
if not conf.CHECK_LDFLAGS(['-Wl,-rpath,.']) and conf.CHECK_LDFLAGS(['-Wl,-R,.']):
conf.env['RPATH_ST'] = '-Wl,-R,%s'
diff --git a/lib/replace/wscript b/lib/replace/wscript
index 0f29514..60b714a 100644
--- a/lib/replace/wscript
+++ b/lib/replace/wscript
@@ -36,19 +36,6 @@ def configure(conf):
conf.ADD_CFLAGS('-fstack-protector')
conf.ADD_LDFLAGS('-fstack-protector')
- # Try to find the right extra flags for -Werror behaviour
- for f in ["-Werror", # GCC
- "-errwarn=%all", # Sun Studio
- "-qhalt=w", # IBM xlc
- "-w2", # Tru64
- ]:
- if conf.CHECK_CFLAGS([f], '''
-'''):
- if not 'WERROR_CFLAGS' in conf.env:
- conf.env['WERROR_CFLAGS'] = []
- conf.env['WERROR_CFLAGS'].extend([f])
- break
-
conf.CHECK_HEADERS('linux/types.h crypt.h locale.h acl/libacl.h compat.h')
conf.CHECK_HEADERS('acl/libacl.h attr/xattr.h compat.h ctype.h dustat.h')
conf.CHECK_HEADERS('fcntl.h fnmatch.h glob.h history.h krb5.h langinfo.h')
--
1.9.1
From 5473826948b9b790f937538b668bbd6aef1ced43 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Wed, 7 Jan 2015 09:54:43 +0100
Subject: [PATCH 04/15] wafsamba: move '-fstack-protector' checks from
lib/replace to wafsamba
This moves the check to the end of the configure run,
which means we no longer use this on configure checks,
but only for the real build.
This behavior is similar than our developer cflags.
Signed-off-by: Stefan Metzmacher <metze at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
---
buildtools/wafsamba/samba_autoconf.py | 4 ++++
lib/replace/wscript | 4 ----
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/buildtools/wafsamba/samba_autoconf.py b/buildtools/wafsamba/samba_autoconf.py
index 9e50ee5..ca1eac2 100644
--- a/buildtools/wafsamba/samba_autoconf.py
+++ b/buildtools/wafsamba/samba_autoconf.py
@@ -646,6 +646,10 @@ def SAMBA_CONFIG_H(conf, path=None):
if not IN_LAUNCH_DIR(conf):
return
+ if conf.CHECK_CFLAGS(['-fstack-protector']) and conf.CHECK_LDFLAGS(['-fstack-protector']):
+ conf.ADD_CFLAGS('-fstack-protector')
+ conf.ADD_LDFLAGS('-fstack-protector')
+
if Options.options.debug:
conf.ADD_CFLAGS('-g', testflags=True)
diff --git a/lib/replace/wscript b/lib/replace/wscript
index 60b714a..4693a79 100644
--- a/lib/replace/wscript
+++ b/lib/replace/wscript
@@ -32,10 +32,6 @@ def configure(conf):
conf.DEFINE('HAVE_LIBREPLACE', 1)
conf.DEFINE('LIBREPLACE_NETWORK_CHECKS', 1)
- if conf.CHECK_CFLAGS(['-fstack-protector']) and conf.CHECK_LDFLAGS(['-fstack-protector']):
- conf.ADD_CFLAGS('-fstack-protector')
- conf.ADD_LDFLAGS('-fstack-protector')
-
conf.CHECK_HEADERS('linux/types.h crypt.h locale.h acl/libacl.h compat.h')
conf.CHECK_HEADERS('acl/libacl.h attr/xattr.h compat.h ctype.h dustat.h')
conf.CHECK_HEADERS('fcntl.h fnmatch.h glob.h history.h krb5.h langinfo.h')
--
1.9.1
From 887beec9c873ca9336ed0ebe503e619a0d893707 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Wed, 7 Jan 2015 09:56:56 +0100
Subject: [PATCH 05/15] wafsamba: move -fvisibility=hidden checks from
lib/replace to wafsamba
Signed-off-by: Stefan Metzmacher <metze at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
---
buildtools/wafsamba/wscript | 7 +++++++
lib/replace/wscript | 7 -------
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/buildtools/wafsamba/wscript b/buildtools/wafsamba/wscript
index 0e2afe1..0a1cd1c 100755
--- a/buildtools/wafsamba/wscript
+++ b/buildtools/wafsamba/wscript
@@ -341,6 +341,13 @@ def configure(conf):
else:
conf.env.HAVE_LD_VERSION_SCRIPT = False
+ if conf.CHECK_CFLAGS('-fvisibility=hidden'):
+ conf.env.VISIBILITY_CFLAGS = '-fvisibility=hidden'
+ conf.CHECK_CODE('''int main(void) { return 0; }
+ __attribute__((visibility("default"))) void vis_foo2(void) {}''',
+ cflags=conf.env.VISIBILITY_CFLAGS,
+ define='HAVE_VISIBILITY_ATTR', addmain=False)
+
if sys.platform.startswith('aix'):
conf.DEFINE('_ALL_SOURCE', 1, add_to_cflags=True)
# Might not be needed if ALL_SOURCE is defined
diff --git a/lib/replace/wscript b/lib/replace/wscript
index 4693a79..4d4d182 100644
--- a/lib/replace/wscript
+++ b/lib/replace/wscript
@@ -599,13 +599,6 @@ removeea setea
execute=True,
mandatory=True) # lets see if we get a mandatory failure for this one
- if conf.CHECK_CFLAGS('-fvisibility=hidden'):
- conf.env.VISIBILITY_CFLAGS = '-fvisibility=hidden'
- conf.CHECK_CODE('''int main(void) { return 0; }
- __attribute__((visibility("default"))) void vis_foo2(void) {}''',
- cflags=conf.env.VISIBILITY_CFLAGS,
- define='HAVE_VISIBILITY_ATTR', addmain=False)
-
# look for a method of finding the list of network interfaces
for method in ['HAVE_IFACE_GETIFADDRS', 'HAVE_IFACE_AIX', 'HAVE_IFACE_IFCONF', 'HAVE_IFACE_IFREQ']:
if conf.CHECK_CODE('''
--
1.9.1
From 55e1167991fee555f44f20bb1c9d8b009ec55ffa Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Wed, 7 Jan 2015 09:58:38 +0100
Subject: [PATCH 06/15] wafsamba: let CURRENT_CFLAGS() use
bld.env.VISIBILITY_CFLAGS
This is better than a hardcoded value in multiple places.
Signed-off-by: Stefan Metzmacher <metze at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
---
buildtools/wafsamba/samba_autoconf.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/buildtools/wafsamba/samba_autoconf.py b/buildtools/wafsamba/samba_autoconf.py
index ca1eac2..043a9f4 100644
--- a/buildtools/wafsamba/samba_autoconf.py
+++ b/buildtools/wafsamba/samba_autoconf.py
@@ -781,7 +781,7 @@ def CURRENT_CFLAGS(bld, target, cflags, allow_warnings=False, hide_symbols=False
list = bld.env['PICKY_CFLAGS'];
ret.extend(list)
if hide_symbols and bld.env.HAVE_VISIBILITY_ATTR:
- ret.append('-fvisibility=hidden')
+ ret.append(bld.env.VISIBILITY_CFLAGS)
return ret
--
1.9.1
From d125ecff670fa74281e6034cd2184c7da528d256 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Wed, 7 Jan 2015 09:16:57 +0100
Subject: [PATCH 07/15] wafsamba: improve -fvisibility=hidden, we should check
it together this WERROR_CFLAGS
GCC ignores -fvisibility=hidden with a warning instead of failing
om some platforms (e.g. Solaris).
Bug: https://bugzilla.samba.org/show_bug.cgi?id=11031
Based on a patch from Tom Schulz <schulz at adi.com>.
Signed-off-by: Stefan Metzmacher <metze at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
---
buildtools/wafsamba/wscript | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/buildtools/wafsamba/wscript b/buildtools/wafsamba/wscript
index 0a1cd1c..c49b20e 100755
--- a/buildtools/wafsamba/wscript
+++ b/buildtools/wafsamba/wscript
@@ -341,7 +341,7 @@ def configure(conf):
else:
conf.env.HAVE_LD_VERSION_SCRIPT = False
- if conf.CHECK_CFLAGS('-fvisibility=hidden'):
+ if conf.CHECK_CFLAGS(['-fvisibility=hidden'] + conf.env.WERROR_CFLAGS):
conf.env.VISIBILITY_CFLAGS = '-fvisibility=hidden'
conf.CHECK_CODE('''int main(void) { return 0; }
__attribute__((visibility("default"))) void vis_foo2(void) {}''',
--
1.9.1
From 5b9b7a73fc56a217345bbff6761b71ea8e0aaf51 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Wed, 7 Jan 2015 11:13:04 +0100
Subject: [PATCH 08/15] wafsamba: make it possible to specify
ADDITIONAL_{CFLAGS,LDFLAGS} as env var to ./configure
CFLAGS and LDFLAGS are also used during the configure checks and might impact
their results.
Signed-off-by: Stefan Metzmacher <metze at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
---
buildtools/wafsamba/samba_autoconf.py | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/buildtools/wafsamba/samba_autoconf.py b/buildtools/wafsamba/samba_autoconf.py
index 043a9f4..8d84a5e 100644
--- a/buildtools/wafsamba/samba_autoconf.py
+++ b/buildtools/wafsamba/samba_autoconf.py
@@ -703,6 +703,19 @@ int main(void) {
if Options.options.pedantic:
conf.ADD_CFLAGS('-W', testflags=True)
+
+ # Let people pass an additional ADDITIONAL_{CFLAGS,LDFLAGS}
+ # environment variables which are only used the for final build.
+ #
+ # The CFLAGS and LDFLAGS environment variables are also
+ # used for the configure checks which might impact their results.
+ conf.add_os_flags('ADDITIONAL_CFLAGS')
+ if conf.env.ADDITIONAL_CFLAGS and conf.CHECK_CFLAGS(conf.env['ADDITIONAL_CFLAGS']):
+ conf.env['EXTRA_CFLAGS'].extend(conf.env['ADDITIONAL_CFLAGS'])
+ conf.add_os_flags('ADDITIONAL_LDFLAGS')
+ if conf.env.ADDITIONAL_LDFLAGS and conf.CHECK_LDFLAGS(conf.env['ADDITIONAL_LDFLAGS']):
+ conf.env['EXTRA_LDFLAGS'].extend(conf.env['ADDITIONAL_LDFLAGS'])
+
if path is None:
conf.write_config_header('config.h', top=True)
else:
--
1.9.1
From 2e3edb693996e0f9033e76d95ace1d794a421d35 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Thu, 18 Dec 2014 18:09:15 +0100
Subject: [PATCH 09/15] 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 at samba.org>
Signed-off-by: Michael Adam <obnox at samba.org>
Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
buildtools/wafsamba/samba_conftests.py | 53 ++++++++++++++++++++++++++++++++++
1 file changed, 53 insertions(+)
diff --git a/buildtools/wafsamba/samba_conftests.py b/buildtools/wafsamba/samba_conftests.py
index ec98ba0..07dda2a 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
--
1.9.1
From 63877e2a8deb56c7d7bbe44e721f60f86dafa42c Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Thu, 18 Dec 2014 21:36:07 +0100
Subject: [PATCH 10/15] wafsamba: filter out standard library paths from RPATH
and LIBPATH
We should avoid passing them explicitly to the compiler/linker.
We ask the compiler with the '-print-search-dirs' argument
or fallback to [ '/usr/lib', '/usr/lib64' ].
Pair-Programmed-With: Stefan Metzmacher <metze at samba.org>
Signed-off-by: Michael Adam <obnox at samba.org>
Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
buildtools/wafsamba/samba_conftests.py | 29 +++++++++++++++++++++++++++++
buildtools/wafsamba/samba_optimisation.py | 25 ++++++++++++++++++++++++-
buildtools/wafsamba/wscript | 2 ++
3 files changed, 55 insertions(+), 1 deletion(-)
diff --git a/buildtools/wafsamba/samba_conftests.py b/buildtools/wafsamba/samba_conftests.py
index 07dda2a..1afc6c9 100644
--- a/buildtools/wafsamba/samba_conftests.py
+++ b/buildtools/wafsamba/samba_conftests.py
@@ -508,6 +508,35 @@ def CHECK_XSLTPROC_MANPAGES(conf):
print "A local copy of the docbook.xsl wasn't found on your system" \
" consider installing package like docbook-xsl"
+#
+# Determine the standard libpath for the used compiler,
+# so we can later use that to filter out these standard
+# library paths when some tools like cups-config or
+# python-config report standard lib paths with their
+# ldflags (-L...)
+#
+ at conf
+def CHECK_STANDARD_LIBPATH(conf):
+ # at least gcc and clang support this:
+ try:
+ cmd = conf.env.CC + ['-print-search-dirs']
+ out = Utils.cmd_output(cmd).split('\n')
+ except ValueError:
+ # option not supported by compiler - use a standard list of directories
+ dirlist = [ '/usr/lib', '/usr/lib64' ]
+ except:
+ raise Utils.WafError('Unexpected error running "%s"' % (cmd))
+ else:
+ dirlist = []
+ for line in out:
+ line = line.strip()
+ if line.startswith("libraries: ="):
+ dirliststr = line[len("libraries: ="):]
+ dirlist = [ os.path.normpath(x) for x in dirliststr.split(':') ]
+ break
+
+ conf.env.STANDARD_LIBPATH = dirlist
+
waf_config_c_parse_flags = config_c.parse_flags;
def samba_config_c_parse_flags(line1, uselib, env):
diff --git a/buildtools/wafsamba/samba_optimisation.py b/buildtools/wafsamba/samba_optimisation.py
index 1333f8b..583a651 100644
--- a/buildtools/wafsamba/samba_optimisation.py
+++ b/buildtools/wafsamba/samba_optimisation.py
@@ -6,8 +6,9 @@
# overall this makes some build tasks quite a bit faster
+import os
import Build, Utils, Node
-from TaskGen import feature, after
+from TaskGen import feature, after, before
import preproc, Task
@feature('cc', 'cxx')
@@ -308,3 +309,25 @@ def apply_lib_vars(self):
val = self.env[v + '_' + x]
if val:
self.env.append_value(v, val)
+
+ at feature('cprogram', 'cshlib', 'cstaticlib')
+ at after('apply_lib_vars')
+ at before('apply_obj_vars')
+def samba_before_apply_obj_vars(self):
+ """before apply_obj_vars for uselib, this removes the standard pathes"""
+
+ def is_standard_libpath(env, path):
+ for _path in env.STANDARD_LIBPATH:
+ if _path == os.path.normpath(path):
+ return True
+ return False
+
+ v = self.env
+
+ for i in v['RPATH']:
+ if is_standard_libpath(v, i):
+ v['RPATH'].remove(i)
+
+ for i in v['LIBPATH']:
+ if is_standard_libpath(v, i):
+ v['LIBPATH'].remove(i)
diff --git a/buildtools/wafsamba/wscript b/buildtools/wafsamba/wscript
index c49b20e..c81a7b3 100755
--- a/buildtools/wafsamba/wscript
+++ b/buildtools/wafsamba/wscript
@@ -211,6 +211,8 @@ def configure(conf):
conf.check_tool('compiler_cc')
+ conf.CHECK_STANDARD_LIBPATH()
+
# we need git for 'waf dist'
conf.find_program('git', var='GIT')
--
1.9.1
From 4f01a0cc79aaa31da680a9f898863de8b6eeab99 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Fri, 19 Dec 2014 09:05:33 +0100
Subject: [PATCH 11/15] wafsamba: flags from enviroment are put before our own
internal versions
Ensure user provided CPPFLAGS and LDFLAGS are put *behind* our
internally computed compiler and linker flags.
Bug: https://bugzilla.samba.org/show_bug.cgi?id=10877
Pair-Programmed-With: Michael Adam <obnox at samba.org>
Pair-Programmed-With: Stefan Metzmacher <metze at samba.org>
Signed-off-by: Ralph Boehme <slow at samba.org>
Signed-off-by: Michael Adam <obnox at samba.org>
Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
buildtools/wafsamba/samba_optimisation.py | 42 +++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/buildtools/wafsamba/samba_optimisation.py b/buildtools/wafsamba/samba_optimisation.py
index 583a651..1e7a57f 100644
--- a/buildtools/wafsamba/samba_optimisation.py
+++ b/buildtools/wafsamba/samba_optimisation.py
@@ -331,3 +331,45 @@ def samba_before_apply_obj_vars(self):
for i in v['LIBPATH']:
if is_standard_libpath(v, i):
v['LIBPATH'].remove(i)
+
+ at feature('cc')
+ at before('apply_incpaths', 'apply_obj_vars_cc')
+def samba_stash_cppflags(self):
+ """Fix broken waf ordering of CPPFLAGS"""
+
+ self.env.SAVED_CPPFLAGS = self.env.CPPFLAGS
+ self.env.CPPFLAGS = []
+
+ at feature('cc')
+ at after('apply_incpaths', 'apply_obj_vars_cc')
+def samba_pop_cppflags(self):
+ """append stashed user CPPFLAGS after our internally computed flags"""
+
+ #
+ # Note that we don't restore the values to 'CPPFLAGS',
+ # but to _CCINCFLAGS instead.
+ #
+ # buildtools/wafadmin/Tools/cc.py defines the 'cc' task generator as
+ # '${CC} ${CCFLAGS} ${CPPFLAGS} ${_CCINCFLAGS} ${_CCDEFFLAGS} ${CC_SRC_F}${SRC} ${CC_TGT_F}${TGT}'
+ #
+ # Our goal is to effectively invert the order of ${CPPFLAGS} and
+ # ${_CCINCFLAGS}.
+ self.env.append_value('_CCINCFLAGS', self.env.SAVED_CPPFLAGS)
+ self.env.SAVED_CPPFLAGS = []
+
+ at feature('cprogram', 'cshlib', 'cstaticlib')
+ at before('apply_obj_vars', 'add_extra_flags')
+def samba_stash_linkflags(self):
+ """stash away LINKFLAGS in order to fix waf's broken ordering wrt or
+ user LDFLAGS"""
+
+ self.env.SAVE_LINKFLAGS = self.env.LINKFLAGS
+ self.env.LINKFLAGS = []
+
+ at feature('cprogram', 'cshlib', 'cstaticlib')
+ at after('apply_obj_vars', 'add_extra_flags')
+def samba_pop_linkflags(self):
+ """after apply_obj_vars append saved LDFLAGS"""
+
+ self.env.append_value('LINKFLAGS', self.env.SAVE_LINKFLAGS)
+ self.env.SAVE_LINKFLAGS = []
--
1.9.1
From 8bd309d00eb8cd805b1fb164aed52ece9df6f01a Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Fri, 19 Dec 2014 13:10:30 +0100
Subject: [PATCH 12/15] wafsamba: generate an empty.c file if a
SAMBA_{LIBRARY,SUBSYSTEM} doesn't have any source files
This is better than passing '-' as filename to the compiler/linker.
This replaces commit 65743f932b511db009655847e77288c95c0aa525.
Bug: https://bugzilla.samba.org/show_bug.cgi?id=9334
Bug: https://bugzilla.samba.org/show_bug.cgi?id=10315
Signed-off-by: Stefan Metzmacher <metze at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
Reviewed-by: Michael Adam <obnox at samba.org>
---
buildtools/wafsamba/wafsamba.py | 29 +++++++++++++++++++++++------
1 file changed, 23 insertions(+), 6 deletions(-)
diff --git a/buildtools/wafsamba/wafsamba.py b/buildtools/wafsamba/wafsamba.py
index 5fef9be..82a9d6f 100644
--- a/buildtools/wafsamba/wafsamba.py
+++ b/buildtools/wafsamba/wafsamba.py
@@ -94,6 +94,11 @@ def ADD_INIT_FUNCTION(bld, subsystem, target, init_function):
Build.BuildContext.ADD_INIT_FUNCTION = ADD_INIT_FUNCTION
+def generate_empty_file(task):
+ target_fname = installed_location=task.outputs[0].bldpath(task.env)
+ target_file = open(installed_location, 'w')
+ target_file.close()
+ return 0
#################################################################
def SAMBA_LIBRARY(bld, libname, source,
@@ -149,9 +154,15 @@ def SAMBA_LIBRARY(bld, libname, source,
source = bld.SUBDIR(subdir, source)
# remember empty libraries, so we can strip the dependencies
- if ((source == '') or (source == [])) and deps == '' and public_deps == '':
- SET_TARGET_TYPE(bld, libname, 'EMPTY')
- return
+ if ((source == '') or (source == [])):
+ if deps == '' and public_deps == '':
+ SET_TARGET_TYPE(bld, libname, 'EMPTY')
+ return
+ empty_c = libname + '.empty.c'
+ bld.SAMBA_GENERATOR('%s_empty_c' % libname,
+ rule=generate_empty_file,
+ target=empty_c)
+ source=empty_c
if BUILTIN_LIBRARY(bld, libname):
obj_target = libname
@@ -537,9 +548,15 @@ def SAMBA_SUBSYSTEM(bld, modname, source,
return
# remember empty subsystems, so we can strip the dependencies
- if ((source == '') or (source == [])) and deps == '' and public_deps == '':
- SET_TARGET_TYPE(bld, modname, 'EMPTY')
- return
+ if ((source == '') or (source == [])):
+ if deps == '' and public_deps == '':
+ SET_TARGET_TYPE(bld, modname, 'EMPTY')
+ return
+ empty_c = modname + '.empty.c'
+ bld.SAMBA_GENERATOR('%s_empty_c' % modname,
+ rule=generate_empty_file,
+ target=empty_c)
+ source=empty_c
if not SET_TARGET_TYPE(bld, modname, 'SUBSYSTEM'):
return
--
1.9.1
From 7ec4d5c5904b09032d4edd215b8693ac1f819e24 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Mon, 22 Dec 2014 11:27:40 +0100
Subject: [PATCH 13/15] Revert "waf: added suncc_wrap"
This reverts commit 65743f932b511db009655847e77288c95c0aa525.
Conflicts:
buildtools/wafsamba/samba_optimisation.py
Signed-off-by: Michael Adam <obnox at samba.org>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
---
buildtools/wafsamba/samba_optimisation.py | 19 +------------------
1 file changed, 1 insertion(+), 18 deletions(-)
diff --git a/buildtools/wafsamba/samba_optimisation.py b/buildtools/wafsamba/samba_optimisation.py
index 1e7a57f..8bd4dd6 100644
--- a/buildtools/wafsamba/samba_optimisation.py
+++ b/buildtools/wafsamba/samba_optimisation.py
@@ -9,7 +9,7 @@
import os
import Build, Utils, Node
from TaskGen import feature, after, before
-import preproc, Task
+import preproc
@feature('cc', 'cxx')
@after('apply_type_vars', 'apply_lib_vars', 'apply_core')
@@ -151,23 +151,6 @@ Task.TaskBase.hash_constraints = hash_constraints
# return task
-def suncc_wrap(cls):
- '''work around a problem with cc on solaris not handling module aliases
- which have empty libs'''
- if getattr(cls, 'solaris_wrap', False):
- return
- cls.solaris_wrap = True
- oldrun = cls.run
- def run(self):
- if self.env.CC_NAME == "sun" and not self.inputs:
- self.env = self.env.copy()
- self.env.append_value('LINKFLAGS', '-')
- return oldrun(self)
- cls.run = run
-suncc_wrap(Task.TaskBase.classes['cc_link'])
-
-
-
def hash_env_vars(self, env, vars_lst):
idx = str(id(env)) + str(vars_lst)
try:
--
1.9.1
From 859d82277e565a4d766a20f4e6d5892fb2357e9a Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Mon, 22 Dec 2014 11:30:21 +0100
Subject: [PATCH 14/15] wafsamba: remove commented out code.
This code has only ever been there as commented out...
Pair-Programmed-With: Stefan Metzmacher <metze at samba.org>
Signed-off-by: Michael Adam <obnox at samba.org>
Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
buildtools/wafsamba/samba_optimisation.py | 27 ---------------------------
1 file changed, 27 deletions(-)
diff --git a/buildtools/wafsamba/samba_optimisation.py b/buildtools/wafsamba/samba_optimisation.py
index 8bd4dd6..5def580 100644
--- a/buildtools/wafsamba/samba_optimisation.py
+++ b/buildtools/wafsamba/samba_optimisation.py
@@ -124,33 +124,6 @@ def hash_constraints(self):
return sum
Task.TaskBase.hash_constraints = hash_constraints
-
-# import cc
-# from TaskGen import extension
-# import Utils
-
-# @extension(cc.EXT_CC)
-# def c_hook(self, node):
-# task = self.create_task('cc', node, node.change_ext('.o'))
-# try:
-# self.compiled_tasks.append(task)
-# except AttributeError:
-# raise Utils.WafError('Have you forgotten to set the feature "cc" on %s?' % str(self))
-
-# bld = self.bld
-# try:
-# dc = bld.dc
-# except AttributeError:
-# dc = bld.dc = {}
-
-# if task.outputs[0].id in dc:
-# raise Utils.WafError('Samba, you are doing it wrong %r %s %s' % (task.outputs, task.generator, dc[task.outputs[0].id].generator))
-# else:
-# dc[task.outputs[0].id] = task
-
-# return task
-
-
def hash_env_vars(self, env, vars_lst):
idx = str(id(env)) + str(vars_lst)
try:
--
1.9.1
From 7608dfa137adef6432c99c53d1eca02fc2132ead Mon Sep 17 00:00:00 2001
From: Thomas Nagy <tnagy2pow10 at gmail.com>
Date: Tue, 17 Sep 2013 00:00:40 +0200
Subject: [PATCH 15/15] wafadmin: backported the openbsd fixes from waf 1.7
This is a backport from waf 1.5...
Reviewed-by: Michael Adam <obnox at samba.org>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
---
buildtools/wafadmin/Tools/ccroot.py | 18 ++++++++++++------
buildtools/wafadmin/Tools/gcc.py | 4 ++++
buildtools/wafadmin/Tools/gxx.py | 4 ++++
3 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/buildtools/wafadmin/Tools/ccroot.py b/buildtools/wafadmin/Tools/ccroot.py
index 264bdc7..d59cf26 100644
--- a/buildtools/wafadmin/Tools/ccroot.py
+++ b/buildtools/wafadmin/Tools/ccroot.py
@@ -177,10 +177,14 @@ def get_target_name(self):
dir, name = os.path.split(self.target)
- if self.env.DEST_BINFMT == 'pe' and getattr(self, 'vnum', None) and 'cshlib' in self.features:
- # include the version in the dll file name,
- # the import lib file name stays unversionned.
- name = name + '-' + self.vnum.split('.')[0]
+ if 'cshlib' in self.features and getattr(self, 'vnum', None):
+ nums = self.vnum.split('.')
+ if self.env.DEST_BINFMT == 'pe':
+ # include the version in the dll file name,
+ # the import lib file name stays unversionned.
+ name = name + '-' + nums[0]
+ elif self.env.DEST_OS == 'openbsd':
+ pattern = '%s.%s.%s' % (pattern, nums[0], nums[1])
return os.path.join(dir, pattern % name)
@@ -598,14 +602,16 @@ def apply_vnum(self):
if not path: return
if self.env.DEST_OS == 'openbsd':
- bld.install_as(path + os.sep + name2, node, env=self.env, chmod=self.link_task.chmod)
+ libname = self.link_task.outputs[0].name
+ bld.install_as('%s%s%s' % (path, os.sep, libname), node, env=self.env)
else:
bld.install_as(path + os.sep + name3, node, env=self.env)
bld.symlink_as(path + os.sep + name2, name3)
bld.symlink_as(path + os.sep + libname, name3)
# the following task is just to enable execution from the build dir :-/
- self.create_task('vnum', node, [node.parent.find_or_declare(name2), node.parent.find_or_declare(name3)])
+ if self.env.DEST_OS != 'openbsd':
+ self.create_task('vnum', node, [node.parent.find_or_declare(name2), node.parent.find_or_declare(name3)])
def exec_vnum_link(self):
for x in self.outputs:
diff --git a/buildtools/wafadmin/Tools/gcc.py b/buildtools/wafadmin/Tools/gcc.py
index 420b44f..a6be0b2 100644
--- a/buildtools/wafadmin/Tools/gcc.py
+++ b/buildtools/wafadmin/Tools/gcc.py
@@ -114,6 +114,10 @@ def gcc_modifier_aix(conf):
v['SHLIB_MARKER'] = ''
@conftest
+def gcc_modifier_openbsd(conf):
+ conf.env['SONAME_ST'] = []
+
+ at conftest
def gcc_modifier_platform(conf):
# * set configurations specific for a platform.
# * the destination platform is detected automatically by looking at the macros the compiler predefines,
diff --git a/buildtools/wafadmin/Tools/gxx.py b/buildtools/wafadmin/Tools/gxx.py
index 8f4a0bf..4984122 100644
--- a/buildtools/wafadmin/Tools/gxx.py
+++ b/buildtools/wafadmin/Tools/gxx.py
@@ -112,6 +112,10 @@ def gxx_modifier_aix(conf):
v['SHLIB_MARKER'] = ''
@conftest
+def gxx_modifier_openbsd(conf):
+ conf.env['SONAME_ST'] = []
+
+ at conftest
def gxx_modifier_platform(conf):
# * set configurations specific for a platform.
# * the destination platform is detected automatically by looking at the macros the compiler predefines,
--
1.9.1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: OpenPGP digital signature
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20150107/e2091471/attachment.pgp>
More information about the samba-technical
mailing list