Skip to content

Commit 855b523

Browse files
authored
Merge pull request #9448 from bwbarrett/cleanup/avoid-early-ac-prog-cc-calls
build: Avoid accidental calls to AC_PROG_CC
2 parents defc260 + fcbec27 commit 855b523

File tree

6 files changed

+73
-53
lines changed

6 files changed

+73
-53
lines changed

config/opal_configure_options.m4

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -356,29 +356,6 @@ AC_DEFINE_UNQUOTED([OPAL_ENABLE_HETEROGENEOUS_SUPPORT],
356356
[Enable features required for heterogeneous support])
357357

358358

359-
if test "$opal_want_heterogeneous" = 1; then
360-
ompi_cv_c_word_size_align=yes
361-
else
362-
AC_CACHE_CHECK([if word-sized integers must be word-size aligned],
363-
[ompi_cv_c_word_size_align],
364-
[AC_LANG_PUSH(C)
365-
AC_RUN_IFELSE([AC_LANG_PROGRAM([dnl
366-
#include <stdlib.h>], [[ long data[2] = {0, 0};
367-
long *lp;
368-
int *ip;
369-
ip = (int*) data;
370-
ip++;
371-
lp = (long*) ip;
372-
return lp[0]; ]])],
373-
[ompi_cv_c_word_size_align=no],
374-
[ompi_cv_c_word_size_align=yes],
375-
[ompi_cv_c_word_size_align=yes])])
376-
fi
377-
AS_IF([test $ompi_cv_c_word_size_align = yes], [results=1], [results=0])
378-
AC_DEFINE_UNQUOTED([OPAL_ALIGN_WORD_SIZE_INTEGERS], [$results],
379-
[set to 1 if word-size integers must be aligned to word-size padding to prevent bus errors])
380-
381-
382359
#
383360
# Cross-compile data
384361
#

config/opal_mca.m4

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ AC_DEFUN([OPAL_EVAL_ARG], [$1])
4343
AC_DEFUN([OPAL_MCA],[
4444
dnl for OPAL_CONFIGURE_USER env variable
4545
AC_REQUIRE([OPAL_CONFIGURE_SETUP])
46+
dnl For all the path management
47+
AC_REQUIRE([OPAL_SETUP_WRAPPER_INIT])
4648
4749
# Set a special flag so that we can detect if the user calls
4850
# OPAL_WRAPPER_FLAGS_ADD and error.

config/opal_setup_cc.m4

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,18 +420,34 @@ AC_DEFUN([_OPAL_START_SETUP_CC],[
420420

421421

422422
AC_DEFUN([_OPAL_PROG_CC],[
423+
dnl It is really easy to accidently call AC_PROG_CC implicitly through
424+
dnl some other test run before OPAL_SETUP_CC. Try to make that harder.
425+
m4_provide_if([AC_PROG_CC],
426+
[m4_fatal([AC_PROG_CC called before OPAL_SETUP_CC])])
427+
423428
#
424429
# Check for the compiler
425430
#
426431
OPAL_VAR_SCOPE_PUSH([opal_cflags_save dummy opal_cc_arvgv0])
432+
433+
# AC_USE_SYSTEM_EXTENSIONS alters CFLAGS (e.g., adds -g -O2)
434+
opal_cflags_save="$CFLAGS"
435+
AC_USE_SYSTEM_EXTENSIONS
436+
# AC_USE_SYSTEM_EXTENSIONS will modify CFLAGS if nothing was in there
437+
# beforehand. We don't want that. So if there was nothing in
438+
# CFLAGS, put nothing back in there.
439+
AS_IF([test -z "$opal_cflags_save"], [CFLAGS=])
440+
427441
opal_cflags_save="$CFLAGS"
428442
AC_PROG_CC
429443
BASECC="`basename $CC`"
430444
CFLAGS="$opal_cflags_save"
431-
AC_DEFINE_UNQUOTED(OPAL_CC, "$CC", [OMPI underlying C compiler])
445+
OPAL_CC="$CC"
446+
AC_DEFINE_UNQUOTED(OPAL_CC, "$OPAL_CC", [OMPI underlying C compiler])
432447
set dummy $CC
433448
opal_cc_argv0=[$]2
434449
OPAL_WHICH([$opal_cc_argv0], [OPAL_CC_ABSOLUTE])
435450
AC_SUBST(OPAL_CC_ABSOLUTE)
451+
436452
OPAL_VAR_SCOPE_POP
437453
])

config/opal_setup_wrappers.m4

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,16 @@ AC_DEFUN([OPAL_WRAPPER_FLAGS_ADD], [
7979
# <flag>_prefix, configure is not. There's no known use case for
8080
# doing so, and we'd like to force the issue.
8181
AC_DEFUN([OPAL_SETUP_WRAPPER_INIT],[
82+
dnl for OPAL_CC
83+
AC_REQUIRE([OPAL_SETUP_CC])
84+
85+
opal_show_subtitle "Wrapper compiler setup"
86+
8287
OPAL_VAR_SCOPE_PUSH([wrapper_cc_tmp])
83-
# AC_PROG_CC_C99 changes CC (instead of CFLAGS) so this method
84-
# must be called before OPAL_SETUP_CC.
8588
AC_ARG_WITH([wrapper_cc],
8689
[AS_HELP_STRING([--with-wrapper-cc=path],
8790
[Set a different wrapper C compiler than the one used to build Open MPI])],
88-
[], [with_wrapper_cc="$CC"])
91+
[], [with_wrapper_cc="$OPAL_CC"])
8992

9093
AC_MSG_CHECKING([for wrapper C compiler])
9194

config/oshmem_configure_options.m4

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,30 @@ AC_MSG_CHECKING([if want oshmem])
2828
AC_ARG_ENABLE([oshmem],
2929
[AS_HELP_STRING([--enable-oshmem],
3030
[Enable building the OpenSHMEM interface (available on Linux only, where it is enabled by default)])])
31+
3132
if test "$enable_oshmem" = "no"; then
3233
AC_MSG_RESULT([no])
3334
elif test "$enable_oshmem" = ""; then
34-
if test "$opal_found_linux" = "yes"; then
35+
case $host_os in
36+
linux*)
3537
AC_MSG_RESULT([yes])
36-
else
38+
;;
39+
*)
3740
enable_oshmem=no
3841
AC_MSG_RESULT([not supported on this platform])
39-
fi
42+
;;
43+
esac
4044
else
4145
AC_MSG_RESULT([yes])
42-
if test "$opal_found_linux" != "yes"; then
46+
case $host_os in
47+
linux*)
48+
;;
49+
*)
4350
AC_MSG_WARN([OpenSHMEM support was requested, but currently])
4451
AC_MSG_WARN([only supports Linux.])
4552
AC_MSG_ERROR([Cannot continue])
46-
fi
53+
;;
54+
esac
4755
fi
4856

4957
#
@@ -91,11 +99,6 @@ fi
9199
AC_DEFINE_UNQUOTED(OSHMEM_PARAM_CHECK, $shmem_param_check,
92100
[Whether we want to check OSHMEM parameters always or never])
93101

94-
#
95-
# check for on_exit
96-
#
97-
AC_CHECK_FUNCS([on_exit])
98-
99102
#
100103
# OSHMEM profiling support
101104
#

configure.ac

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,6 @@ AS_IF([test "$host" != "$target"],
9393
AC_MSG_WARN([Cross-compiling is only partially supported])
9494
AC_MSG_WARN([Proceed at your own risk!])])
9595

96-
# AC_USE_SYSTEM_EXTENSIONS alters CFLAGS (e.g., adds -g -O2)
97-
OPAL_VAR_SCOPE_PUSH([CFLAGS_save])
98-
CFLAGS_save=$CFLAGS
99-
AC_USE_SYSTEM_EXTENSIONS
100-
# AC_USE_SYSTEM_EXTENSIONS will modify CFLAGS if nothing was in there
101-
# beforehand. We don't want that. So if there was nothing in
102-
# CFLAGS, put nothing back in there.
103-
AS_IF([test -z "$CFLAGS_save"], [CFLAGS=])
104-
OPAL_VAR_SCOPE_POP
10596

10697
#
10798
# Init automake
@@ -290,8 +281,6 @@ m4_ifdef([project_oshmem],
290281
############################################################################
291282

292283
OPAL_CONFIGURE_OPTIONS
293-
OPAL_CHECK_OS_FLAVORS
294-
OPAL_CHECK_CUDA
295284

296285
m4_ifdef([project_ompi], [OMPI_CONFIGURE_OPTIONS])
297286
m4_ifdef([project_oshmem], [OSHMEM_CONFIGURE_OPTIONS])
@@ -346,10 +335,6 @@ m4_ifdef([project_ompi],
346335
AC_ENABLE_SHARED
347336
AC_DISABLE_STATIC
348337

349-
# Must be called before OPAL_SETUP_CC to get the value of CC
350-
# before it is modified by the C99/C11 checks.
351-
OPAL_SETUP_WRAPPER_INIT
352-
353338
##################################
354339
# Check for known incompatibility
355340
##################################
@@ -550,6 +535,29 @@ OPAL_C_GET_ALIGNMENT(size_t, OPAL_ALIGNMENT_SIZE_T)
550535

551536
OPAL_CHECK_ALT_SHORT_FLOAT
552537

538+
# Check system alignment requirements
539+
if test "$opal_want_heterogeneous" = 1; then
540+
ompi_cv_c_word_size_align=yes
541+
else
542+
AC_CACHE_CHECK([if word-sized integers must be word-size aligned],
543+
[ompi_cv_c_word_size_align],
544+
[AC_LANG_PUSH(C)
545+
AC_RUN_IFELSE([AC_LANG_PROGRAM([dnl
546+
#include <stdlib.h>], [[ long data[2] = {0, 0};
547+
long *lp;
548+
int *ip;
549+
ip = (int*) data;
550+
ip++;
551+
lp = (long*) ip;
552+
return lp[0]; ]])],
553+
[ompi_cv_c_word_size_align=no],
554+
[ompi_cv_c_word_size_align=yes],
555+
[ompi_cv_c_word_size_align=yes])])
556+
fi
557+
AS_IF([test $ompi_cv_c_word_size_align = yes], [results=1], [results=0])
558+
AC_DEFINE_UNQUOTED([OPAL_ALIGN_WORD_SIZE_INTEGERS], [$results],
559+
[set to 1 if word-size integers must be aligned to word-size padding to prevent bus errors])
560+
553561
#
554562
# Check for other compiler characteristics
555563
#
@@ -667,6 +675,14 @@ AM_CONDITIONAL(OSHMEM_BUILD_FORTRAN_BINDINGS,
667675
AC_CACHE_SAVE
668676

669677

678+
##################################
679+
# Wrapper compilers.
680+
#
681+
# Must be called before MCA system
682+
##################################
683+
OPAL_SETUP_WRAPPER_INIT
684+
685+
670686
##################################
671687
# Header files
672688
##################################
@@ -920,7 +936,7 @@ OPAL_SEARCH_LIBS_CORE([ceil], [m])
920936
# -lrt might be needed for clock_gettime
921937
OPAL_SEARCH_LIBS_CORE([clock_gettime], [rt])
922938

923-
AC_CHECK_FUNCS([asprintf snprintf vasprintf vsnprintf openpty isatty getpwuid fork waitpid execve pipe ptsname setsid mmap tcgetpgrp posix_memalign strsignal sysconf syslog vsyslog regcmp regexec regfree _NSGetEnviron socketpair usleep mkfifo dbopen dbm_open statfs statvfs setpgid setenv __malloc_initialize_hook __clear_cache])
939+
AC_CHECK_FUNCS([asprintf snprintf vasprintf vsnprintf openpty isatty getpwuid fork waitpid execve pipe ptsname setsid mmap tcgetpgrp posix_memalign strsignal sysconf syslog vsyslog regcmp regexec regfree _NSGetEnviron socketpair usleep mkfifo dbopen dbm_open statfs statvfs setpgid setenv __malloc_initialize_hook __clear_cache on_exit])
924940

925941
# Sanity check: ensure that we got at least one of statfs or statvfs.
926942
if test $ac_cv_func_statfs = no && test $ac_cv_func_statvfs = no; then
@@ -979,6 +995,9 @@ AC_CACHE_SAVE
979995

980996
opal_show_title "System-specific tests"
981997

998+
OPAL_CHECK_CUDA
999+
OPAL_CHECK_OS_FLAVORS
1000+
9821001
# Do we have _SC_NPROCESSORS_ONLN? (only going to pass if we also have
9831002
# <unistd.h> and sysconf(), which is ok) OS X 10.4 has <unistd.h> and
9841003
# sysconf(), but does not have _SC_NPROCESSORS_ONLN. Doh!

0 commit comments

Comments
 (0)