From 53e0860122c3fa6b9fe80b5693c7b1eee2ad605d Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Courr=C3=A8ges-Anglas?= Date: Mon, 25 Apr 2016 16:10:03 +0200 Subject: [PATCH] Fix CHECK_CODE usage in atomics builtin detection MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit CHECK_CODE already wraps the code with main(). Adding another layer results in a nested function, eg int main(void) { int main(void) { __sync_fetch_and_add(); } } Since the inner function isn't called it is optimized out at cc -O2, thus the linker doesn't fail if __sync_fetch_and_add() isn't available. Issue noticed on OpenBSD/hppa. Signed-off-by: Jérémie Courrèges-Anglas Reviewed-by: Jeremy Allison Reviewed-by: Ralph Boehme Autobuild-User(master): Jeremy Allison Autobuild-Date(master): Tue Apr 26 01:19:40 CEST 2016 on sn-devel-144 --- lib/replace/wscript | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/lib/replace/wscript b/lib/replace/wscript index 37cbbb7dc23..5efd86cd232 100644 --- a/lib/replace/wscript +++ b/lib/replace/wscript @@ -202,23 +202,15 @@ def configure(conf): # Check for atomic builtins. */ conf.CHECK_CODE(''' - int main(void) { - int i; - (void)__sync_fetch_and_add(&i, 1); - return 0; - } + int i; + (void)__sync_fetch_and_add(&i, 1); ''', 'HAVE___SYNC_FETCH_AND_ADD', msg='Checking for __sync_fetch_and_add compiler builtin') conf.CHECK_CODE(''' - #include - #include - int main(void) { - int32_t i; - atomic_add_32(&i, 1); - return 0; - } + int32_t i; + atomic_add_32(&i, 1); ''', 'HAVE_ATOMIC_ADD_32', headers='stdint.h sys/atomic.h', -- 2.34.1