Skip to content

Commit bb65560

Browse files
committed
Squashme: result of George+Jeff discussion. This may actually fix the
IBM CI (and I may have unfairly been maligning IBM's CI if it was showing an actual problem... oops!). Signed-off-by: Jeff Squyres <[email protected]>
1 parent 7a98e70 commit bb65560

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

config/opal_config_asm.m4

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ dnl Check with:
131131
dnl 1. No compiler/linker flags.
132132
dnl 2. CFLAGS += -mcx16
133133
dnl 3. LIBS += -latomic
134+
dnl 4. Finally, if it links ok with any of #1, #2, or #3, actually try
135+
dnl to run the test code (if we're not cross-compiling) and verify
136+
dnl that it actually gives us the correct result.
134137
dnl
135138
dnl Note that we unfortunately can't use AC SEARCH_LIBS because its
136139
dnl check incorrectly fails (because these functions are special compiler
@@ -150,7 +153,10 @@ dnl $3: action if any of 1, 2, or 3 succeeds
150153
dnl #4: action if all of 1, 2, and 3 fail
151154
dnl
152155
AC_DEFUN([OPAL_ASM_CHECK_ATOMIC_FUNC],[
153-
OPAL_VAR_SCOPE_PUSH([opal_asm_check_func_happy opal_asm_check_func_FLAGS_save])
156+
OPAL_VAR_SCOPE_PUSH([opal_asm_check_func_happy opal_asm_check_func_CFLAGS_save opal_asm_check_func_LIBS_save])
157+
158+
opal_asm_check_func_CFLAGS_save=$CFLAGS
159+
opal_asm_check_func_LIBS_save=$LIBS
154160
155161
dnl Check with no compiler/linker flags
156162
AC_MSG_CHECKING([for $1])
@@ -163,29 +169,45 @@ AC_DEFUN([OPAL_ASM_CHECK_ATOMIC_FUNC],[
163169
dnl If that didn't work, try again with CFLAGS+=mcx16
164170
AS_IF([test $opal_asm_check_func_happy -eq 0],
165171
[AC_MSG_CHECKING([for $1 with -mcx16])
166-
opal_asm_check_func_FLAGS_save=$CFLAGS
167172
CFLAGS="$CFLAGS -mcx16"
168173
AC_LINK_IFELSE([$2],
169174
[opal_asm_check_func_happy=1
170175
AC_MSG_RESULT([yes])],
171176
[opal_asm_check_func_happy=0
172-
CFLAGS=$opal_asm_check_func_FLAGS_save
177+
CFLAGS=$opal_asm_check_func_CFLAGS_save
173178
AC_MSG_RESULT([no])])
174179
])
175180
176181
dnl If that didn't work, try again with LIBS+=-latomic
177182
AS_IF([test $opal_asm_check_func_happy -eq 0],
178183
[AC_MSG_CHECKING([for $1 with -latomic])
179-
opal_asm_check_func_FLAGS_save=$LIBS
180184
LIBS="$LIBS -latomic"
181185
AC_LINK_IFELSE([$2],
182186
[opal_asm_check_func_happy=1
183187
AC_MSG_RESULT([yes])],
184188
[opal_asm_check_func_happy=0
185-
LIBS=$opal_asm_check_func_FLAGS_save
189+
LIBS=$opal_asm_check_func_LIBS_save
186190
AC_MSG_RESULT([no])])
187191
])
188192
193+
dnl If we have it, try it and make sure it gives a correct result.
194+
dnl As of Aug 2018, we know that it links but does *not* work on clang
195+
dnl 6 on ARM64.
196+
AS_IF([test $opal_asm_check_func_happy -eq 1],
197+
[AC_MSG_CHECKING([if $1 gives correct results])
198+
AC_RUN_IFELSE([$2],
199+
[AC_MSG_RESULT([yes])],
200+
[opal_asm_check_func_happy=0
201+
AC_MSG_RESULT([no])],
202+
[AC_MSG_RESULT([cannot test -- assume yes (cross compiling)])])
203+
])
204+
205+
dnl If we were unsuccessful, restore CFLAGS/LIBS
206+
AS_IF([test $opal_asm_check_func_happy -eq 0],
207+
[CFLAGS=$opal_asm_check_func_CFLAGS_save
208+
LIBS=$opal_asm_check_func_LIBS_save])
209+
210+
dnl Run the user actions
189211
AS_IF([test $opal_asm_check_func_happy -eq 1], [$3], [$4])
190212
191213
OPAL_VAR_SCOPE_POP
@@ -204,17 +226,6 @@ AC_DEFUN([OPAL_CHECK_SYNC_BUILTIN_CSWAP_INT128], [
204226
[sync_bool_compare_and_swap_128_result=1],
205227
[sync_bool_compare_and_swap_128_result=0])
206228
207-
# If we have it, try it, and make sure it works. As of Aug 2018, we
208-
# know that it links but does *not* work on clang 6 on ARM64.
209-
AS_IF([test $sync_bool_compare_and_swap_128_result -eq 1],
210-
[AC_MSG_CHECKING([if __sync_bool_compare_and_swap works])
211-
AC_RUN_IFELSE([AC_LANG_SOURCE(OPAL_SYNC_BOOL_COMPARE_AND_SWAP_TEST_SOURCE)],
212-
[AC_MSG_RESULT([yes])],
213-
[sync_bool_compare_and_swap_128_result=0
214-
AC_MSG_RESULT([no])],
215-
[AC_MSG_RESULT([cannot test -- assume yes (cross compiling)])])
216-
])
217-
218229
AC_DEFINE_UNQUOTED([OPAL_HAVE_SYNC_BUILTIN_CSWAP_INT128],
219230
[$sync_bool_compare_and_swap_128_result],
220231
[Whether the __sync builtin atomic compare and swap supports 128-bit values])
@@ -267,17 +278,6 @@ AC_DEFUN([OPAL_CHECK_GCC_BUILTIN_CSWAP_INT128], [
267278
[atomic_compare_exchange_n_128_result=1],
268279
[atomic_compare_exchange_n_128_result=0])
269280
270-
# If we have it, try it, and make sure it works. As of Aug 2018, we
271-
# know that it does *not* work on clang 6 on ARM64.
272-
AS_IF([test $atomic_compare_exchange_n_128_result -eq 1],
273-
[AC_MSG_CHECKING([if __atomic_compare_exchange_n works])
274-
AC_RUN_IFELSE([AC_LANG_SOURCE(OPAL_ATOMIC_COMPARE_EXCHANGE_N_TEST_SOURCE)],
275-
[AC_MSG_RESULT([yes])],
276-
[atomic_compare_exchange_n_128_result=0
277-
AC_MSG_RESULT([no])],
278-
[AC_MSG_RESULT([cannot test -- assume yes (cross compiling)])])
279-
])
280-
281281
# If we have it and it works, check to make sure it is always lock
282282
# free.
283283
AS_IF([test $atomic_compare_exchange_n_128_result -eq 1],

0 commit comments

Comments
 (0)