Skip to content

Commit fcbec27

Browse files
committed
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>
1 parent 8462e7c commit fcbec27

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
@@ -424,18 +424,34 @@ AC_DEFUN([_OPAL_START_SETUP_CC],[
424424

425425

426426
AC_DEFUN([_OPAL_PROG_CC],[
427+
dnl It is really easy to accidently call AC_PROG_CC implicitly through
428+
dnl some other test run before OPAL_SETUP_CC. Try to make that harder.
429+
m4_provide_if([AC_PROG_CC],
430+
[m4_fatal([AC_PROG_CC called before OPAL_SETUP_CC])])
431+
427432
#
428433
# Check for the compiler
429434
#
430435
OPAL_VAR_SCOPE_PUSH([opal_cflags_save dummy opal_cc_arvgv0])
436+
437+
# AC_USE_SYSTEM_EXTENSIONS alters CFLAGS (e.g., adds -g -O2)
438+
opal_cflags_save="$CFLAGS"
439+
AC_USE_SYSTEM_EXTENSIONS
440+
# AC_USE_SYSTEM_EXTENSIONS will modify CFLAGS if nothing was in there
441+
# beforehand. We don't want that. So if there was nothing in
442+
# CFLAGS, put nothing back in there.
443+
AS_IF([test -z "$opal_cflags_save"], [CFLAGS=])
444+
431445
opal_cflags_save="$CFLAGS"
432446
AC_PROG_CC
433447
BASECC="`basename $CC`"
434448
CFLAGS="$opal_cflags_save"
435-
AC_DEFINE_UNQUOTED(OPAL_CC, "$CC", [OMPI underlying C compiler])
449+
OPAL_CC="$CC"
450+
AC_DEFINE_UNQUOTED(OPAL_CC, "$OPAL_CC", [OMPI underlying C compiler])
436451
set dummy $CC
437452
opal_cc_argv0=[$]2
438453
OPAL_WHICH([$opal_cc_argv0], [OPAL_CC_ABSOLUTE])
439454
AC_SUBST(OPAL_CC_ABSOLUTE)
455+
440456
OPAL_VAR_SCOPE_POP
441457
])

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
#
@@ -651,6 +659,14 @@ AM_CONDITIONAL(OSHMEM_BUILD_FORTRAN_BINDINGS,
651659
AC_CACHE_SAVE
652660

653661

662+
##################################
663+
# Wrapper compilers.
664+
#
665+
# Must be called before MCA system
666+
##################################
667+
OPAL_SETUP_WRAPPER_INIT
668+
669+
654670
##################################
655671
# Header files
656672
##################################
@@ -904,7 +920,7 @@ OPAL_SEARCH_LIBS_CORE([ceil], [m])
904920
# -lrt might be needed for clock_gettime
905921
OPAL_SEARCH_LIBS_CORE([clock_gettime], [rt])
906922

907-
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])
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 on_exit])
908924

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

964980
opal_show_title "System-specific tests"
965981

982+
OPAL_CHECK_CUDA
983+
OPAL_CHECK_OS_FLAVORS
984+
966985
# Do we have _SC_NPROCESSORS_ONLN? (only going to pass if we also have
967986
# <unistd.h> and sysconf(), which is ok) OS X 10.4 has <unistd.h> and
968987
# sysconf(), but does not have _SC_NPROCESSORS_ONLN. Doh!

0 commit comments

Comments
 (0)