summaryrefslogtreecommitdiffstats
path: root/source3/wscript
diff options
context:
space:
mode:
authorRalph Boehme <slow@samba.org>2014-10-11 20:50:46 +0200
committerVolker Lendecke <vl@samba.org>2014-10-20 14:41:09 +0200
commitdbc41a5451fcd2001d43558bf5ade9828296a497 (patch)
treef41e9e7fab0c91f971744731c62d151f1b9f7d83 /source3/wscript
parent8ccf5f66691e2bbf0883afa658282ef2ac60b015 (diff)
downloadsamba-dbc41a5451fcd2001d43558bf5ade9828296a497.tar.gz
samba-dbc41a5451fcd2001d43558bf5ade9828296a497.tar.xz
samba-dbc41a5451fcd2001d43558bf5ade9828296a497.zip
build: lib/util/string_wrappers.h: fix optimisation check for clang
Building with clang resulted in an error with undefined symbols ___unsafe_string_function_usage_here_size_t__ etc. Turns out the existing check whether the compiler optimizes out functions doesn't match the use case, ie the check said yes, but the functions were not optimized out. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org> Autobuild-User(master): Volker Lendecke <vl@samba.org> Autobuild-Date(master): Mon Oct 20 14:41:09 CEST 2014 on sn-devel-104
Diffstat (limited to 'source3/wscript')
-rw-r--r--source3/wscript26
1 files changed, 21 insertions, 5 deletions
diff --git a/source3/wscript b/source3/wscript
index 4f182bf748..2083f01a8d 100644
--- a/source3/wscript
+++ b/source3/wscript
@@ -349,12 +349,28 @@ int main(int argc, char **argv)
# Check if the compiler will optimize out functions
conf.CHECK_CODE('''
-if (0) {
- this_function_does_not_exist();
-} else {
- return 1;
+#include <sys/types.h>
+size_t __unsafe_string_function_usage_here_size_t__(void);
+#define CHECK_STRING_SIZE(d, len) (sizeof(d) != (len) && sizeof(d) != sizeof(char *))
+static size_t push_string_check_fn(void *dest, const char *src, size_t dest_len) {
+ return 0;
+}
+
+#define push_string_check(dest, src, dest_len) \
+ (CHECK_STRING_SIZE(dest, dest_len) \
+ ? __unsafe_string_function_usage_here_size_t__() \
+ : push_string_check_fn(dest, src, dest_len))
+
+int main(int argc, char **argv) {
+ char outbuf[1024];
+ char *p = outbuf;
+ const char *foo = "bar";
+ p += 31 + push_string_check(p + 31, foo, sizeof(outbuf) - (p + 31 - outbuf));
+ return 0;
}''', 'HAVE_COMPILER_WILL_OPTIMIZE_OUT_FNS',
- msg="Checking if the compiler will optimize out functions")
+ addmain=False,
+ add_headers=False,
+ msg="Checking if the compiler will optimize out functions")
# Check if the compiler supports the LL suffix on long long integers
# AIX needs this