@@ -11,7 +11,7 @@ dnl Copyright (c) 2004-2005 The Regents of the University of California.
11
11
dnl All rights reserved.
12
12
dnl Copyright (c) 2008-2018 Cisco Systems, Inc. All rights reserved.
13
13
dnl Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved.
14
- dnl Copyright (c) 2015-2018 Research Organization for Information Science
14
+ dnl Copyright (c) 2015-2021 Research Organization for Information Science
15
15
dnl and Technology (RIST). All rights reserved.
16
16
dnl Copyright (c) 2014-2018 Los Alamos National Security, LLC. All rights
17
17
dnl reserved.
@@ -178,15 +178,39 @@ int main(int argc, char** argv)
178
178
dnl ------------------------------------------------------------------
179
179
180
180
dnl
181
- dnl Check to see if a specific function is linkable .
181
+ dnl Helper to Check if a specific function is usable .
182
182
dnl
183
- dnl Check with:
183
+ dnl
184
+ dnl $1: function name to print
185
+ dnl $2: program to test
186
+ dnl $3: action if success
187
+ dnl #4: action if fail
188
+ dnl
189
+ AC_DEFUN ( [ _OPAL_ASM_CHECK_ATOMIC_FUNC] ,[
190
+ AC_LINK_IFELSE ( [ $2 ] ,
191
+ [ AC_MSG_RESULT ( [ yes] )
192
+ dnl make sure it works
193
+ AC_MSG_CHECKING ( [ if $1 () gives correct results] )
194
+ AC_RUN_IFELSE ( [ $2 ] ,
195
+ [ $3
196
+ AC_MSG_RESULT ( [ yes] ) ] ,
197
+ [ $4
198
+ AC_MSG_RESULT ( [ no] ) ] ,
199
+ [ $3
200
+ AC_MSG_RESULT ( [ cannot test -- assume yes (cross compiling)] ) ] ) ] ,
201
+ [ $4
202
+ AC_MSG_RESULT ( [ no] ) ] )
203
+ ] )
204
+
205
+ dnl
206
+ dnl Check to see if a specific function is usable.
207
+ dnl
208
+ dnl Check compilation and actually try ro run the test code
209
+ dnl (if we're not cross-compiling) in order to verify that
210
+ dnl it actually gives us the correct result:
184
211
dnl 1. No compiler/linker flags.
185
- dnl 2. CFLAGS += -mcx16
212
+ dnl 2. CFLAGS += -mcx16 (unless --disable-cx16-atomics is used)
186
213
dnl 3. LIBS += -latomic
187
- dnl 4. Finally, if it links ok with any of #1, #2, or #3, actually try
188
- dnl to run the test code (if we're not cross-compiling) and verify
189
- dnl that it actually gives us the correct result.
190
214
dnl
191
215
dnl Note that we unfortunately can't use AC SEARCH_LIBS because its
192
216
dnl check incorrectly fails (because these functions are special compiler
@@ -213,47 +237,27 @@ AC_DEFUN([OPAL_ASM_CHECK_ATOMIC_FUNC],[
213
237
214
238
dnl Check with no compiler/linker flags
215
239
AC_MSG_CHECKING ( [ for $1 ] )
216
- AC_LINK_IFELSE ( [ $2 ] ,
217
- [ opal_asm_check_func_happy=1
218
- AC_MSG_RESULT ( [ yes] ) ] ,
219
- [ opal_asm_check_func_happy=0
220
- AC_MSG_RESULT ( [ no] ) ] )
221
-
240
+ _OPAL_ASM_CHECK_ATOMIC_FUNC([ $1 ] , [ $2 ] , [ opal_asm_check_func_happy=1] , [ opal_asm_check_func_happy=0] )
222
241
dnl If that didn't work, try again with CFLAGS+=mcx16
223
242
AS_IF ( [ test $opal_asm_check_func_happy -eq 0] ,
224
- [ AC_MSG_CHECKING ( [ for $1 with -mcx16] )
225
- CFLAGS="$CFLAGS -mcx16"
226
- AC_LINK_IFELSE ( [ $2 ] ,
227
- [ opal_asm_check_func_happy=1
228
- AC_MSG_RESULT ( [ yes ] ) ] ,
229
- [ opal_asm_check_func_happy=0
230
- CFLAGS=$opal_asm_check_func_CFLAGS_save
231
- AC_MSG_RESULT ( [ no ] ) ] )
232
- ] )
243
+ [ AC_MSG_CHECKING ( [ for $1 with -mcx16] )
244
+ AS_IF ( [ test "$enable_cx16_atomics" = "no" ] ,
245
+ [ AC_MSG_RESULT ( [ skipped ] ) ] ,
246
+ [ CFLAGS="$CFLAGS -mcx16"
247
+ _OPAL_ASM_CHECK_ATOMIC_FUNC( [ $1 ] , [ $2 ] ,
248
+ [ opal_asm_check_func_happy=1 ] ,
249
+ [ opal_asm_check_func_happy=0
250
+ CFLAGS=$opal_asm_check_func_CFLAGS_save ] )] )
251
+ ] )
233
252
234
253
dnl If that didn't work, try again with LIBS+=-latomic
235
254
AS_IF ( [ test $opal_asm_check_func_happy -eq 0] ,
236
- [ AC_MSG_CHECKING ( [ for $1 with -latomic] )
237
- LIBS="$LIBS -latomic"
238
- AC_LINK_IFELSE ( [ $2 ] ,
239
- [ opal_asm_check_func_happy=1
240
- AC_MSG_RESULT ( [ yes] ) ] ,
241
- [ opal_asm_check_func_happy=0
242
- LIBS=$opal_asm_check_func_LIBS_save
243
- AC_MSG_RESULT ( [ no] ) ] )
244
- ] )
245
-
246
- dnl If we have it, try it and make sure it gives a correct result.
247
- dnl As of Aug 2018, we know that it links but does *not* work on clang
248
- dnl 6 on ARM64.
249
- AS_IF ( [ test $opal_asm_check_func_happy -eq 1] ,
250
- [ AC_MSG_CHECKING ( [ if $1 () gives correct results] )
251
- AC_RUN_IFELSE ( [ $2 ] ,
252
- [ AC_MSG_RESULT ( [ yes] ) ] ,
253
- [ opal_asm_check_func_happy=0
254
- AC_MSG_RESULT ( [ no] ) ] ,
255
- [ AC_MSG_RESULT ( [ cannot test -- assume yes (cross compiling)] ) ] )
256
- ] )
255
+ [ AC_MSG_CHECKING ( [ for $1 with -latomic] )
256
+ LIBS="$LIBS -latomic"
257
+ _OPAL_ASM_CHECK_ATOMIC_FUNC([ $1 ] , [ $2 ] ,
258
+ [ opal_asm_check_func_happy=1] ,
259
+ [ opal_asm_check_func_happy=0
260
+ LIBS=$opal_asm_check_func_LIBS_save] )] )
257
261
258
262
dnl If we were unsuccessful, restore CFLAGS/LIBS
259
263
AS_IF ( [ test $opal_asm_check_func_happy -eq 0] ,
@@ -1049,6 +1053,10 @@ AC_DEFUN([OPAL_CONFIG_ASM],[
1049
1053
[ AS_HELP_STRING ( [ --enable-builtin-atomics] ,
1050
1054
[ Enable use of GCC built-in atomics (default: autodetect)] ) ] )
1051
1055
1056
+ AC_ARG_ENABLE ( [ cx16-atomics] ,
1057
+ [ AS_HELP_STRING ( [ --enable-cx16-atomics] ,
1058
+ [ Try using -mcx16 flag if needed (default: autodetect)] ) ] )
1059
+
1052
1060
OPAL_CHECK_C11_CSWAP_INT128
1053
1061
opal_cv_asm_builtin="BUILTIN_NO"
1054
1062
OPAL_CHECK_GCC_ATOMIC_BUILTINS
0 commit comments