Skip to content

Commit 9c1573c

Browse files
bwbarrettawlauria
authored andcommitted
build: Avoid accidental calls to AC_PROG_CC
Reorder some of the early configure tests to avoid accidently calling AC_PROG_CC before the C compiler section, which will also ensure those tests are run with the same option flags as the rest of the tests. Reorder the wrapper compiler initialization, as it depended on these accidental calls to AC_PROG_CC. To make the late call to the wrapper compiler code work, save the "bare" CC (before Autoconf macros add stuff to it) in the env variable OPAL_CC, similar to the AC_DEFINE of the same name. To keep this from happening again, cause an Autoconf error if Autoconf expands AC_PROG_CC before the call to OPAL_SETUP_CC, and put in some AC_REQUIRE statements to better state dependencies. Signed-off-by: Brian Barrett <bbarrett@amazon.com> (cherry picked from commit fcbec27)
1 parent 4d816c6 commit 9c1573c

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
@@ -341,29 +341,6 @@ AC_DEFINE_UNQUOTED([OPAL_ENABLE_HETEROGENEOUS_SUPPORT],
341341
[Enable features required for heterogeneous support])
342342

343343

344-
if test "$opal_want_heterogeneous" = 1; then
345-
ompi_cv_c_word_size_align=yes
346-
else
347-
AC_CACHE_CHECK([if word-sized integers must be word-size aligned],
348-
[ompi_cv_c_word_size_align],
349-
[AC_LANG_PUSH(C)
350-
AC_RUN_IFELSE([AC_LANG_PROGRAM([dnl
351-
#include <stdlib.h>], [[ long data[2] = {0, 0};
352-
long *lp;
353-
int *ip;
354-
ip = (int*) data;
355-
ip++;
356-
lp = (long*) ip;
357-
return lp[0]; ]])],
358-
[ompi_cv_c_word_size_align=no],
359-
[ompi_cv_c_word_size_align=yes],
360-
[ompi_cv_c_word_size_align=yes])])
361-
fi
362-
AS_IF([test $ompi_cv_c_word_size_align = yes], [results=1], [results=0])
363-
AC_DEFINE_UNQUOTED([OPAL_ALIGN_WORD_SIZE_INTEGERS], [$results],
364-
[set to 1 if word-size integers must be aligned to word-size padding to prevent bus errors])
365-
366-
367344
#
368345
# Cross-compile data
369346
#

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
@@ -94,15 +94,6 @@ AS_IF([test "$host" != "$target"],
9494
AC_MSG_WARN([Cross-compiling is only partially supported])
9595
AC_MSG_WARN([Proceed at your own risk!])])
9696

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

10798
#
10899
# Init automake
@@ -291,8 +282,6 @@ m4_ifdef([project_oshmem],
291282
############################################################################
292283

293284
OPAL_CONFIGURE_OPTIONS
294-
OPAL_CHECK_OS_FLAVORS
295-
OPAL_CHECK_CUDA
296285

297286
m4_ifdef([project_ompi], [OMPI_CONFIGURE_OPTIONS])
298287
m4_ifdef([project_oshmem], [OSHMEM_CONFIGURE_OPTIONS])
@@ -347,10 +336,6 @@ m4_ifdef([project_ompi],
347336
AC_ENABLE_SHARED
348337
AC_DISABLE_STATIC
349338

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

548533
OPAL_CHECK_ALT_SHORT_FLOAT
549534

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

666674

675+
##################################
676+
# Wrapper compilers.
677+
#
678+
# Must be called before MCA system
679+
##################################
680+
OPAL_SETUP_WRAPPER_INIT
681+
682+
667683
##################################
668684
# Header files
669685
##################################
@@ -917,7 +933,7 @@ OPAL_SEARCH_LIBS_CORE([ceil], [m])
917933
# -lrt might be needed for clock_gettime
918934
OPAL_SEARCH_LIBS_CORE([clock_gettime], [rt])
919935

920-
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])
936+
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])
921937

922938
# Sanity check: ensure that we got at least one of statfs or statvfs.
923939
if test $ac_cv_func_statfs = no && test $ac_cv_func_statvfs = no; then
@@ -976,6 +992,9 @@ AC_CACHE_SAVE
976992

977993
opal_show_title "System-specific tests"
978994

995+
OPAL_CHECK_CUDA
996+
OPAL_CHECK_OS_FLAVORS
997+
979998
# Do we have _SC_NPROCESSORS_ONLN? (only going to pass if we also have
980999
# <unistd.h> and sysconf(), which is ok) OS X 10.4 has <unistd.h> and
9811000
# sysconf(), but does not have _SC_NPROCESSORS_ONLN. Doh!

0 commit comments

Comments
 (0)