Skip to content

Commit

Permalink
Fixed flag selection misfire via CC (vs CC_VENDOR).
Browse files Browse the repository at this point in the history
Details:
- Fixed an issue (#27) where providing a compiler path via the CC
  environment variable resulted in configure being unable to select
  appropriate OpenMP flags (pursuant to --enable-multithreading=openmp).
  (It may be that this affected submission of compilers via the
  --with-cc option as well.) The problem was traced to the fact that
  the conditional branches that handled not only OpenMP flag selection
  but also selection for optimization, warning, preprocessor, and other
  kinds of flags were using CC instead of something like CC_VENDOR
  (which was only recently introduced). Obviously, configure cannot
  predict all of the various ways/paths of requesting gcc (and other
  compilers), and thus it must compare against a standardized variable
  such as CC_VENDOR instead. Thanks to Phuong Nguyen for reporting this
  issue.
- Changed all branching on $CC to use ${CC_VENDOR} instead.
- Spun off the querying of CC_VENDOR into a separate autoconf macro
  file, fla_require_cc_vendor.m4.
  • Loading branch information
fgvanzee committed Oct 21, 2019
1 parent b0936fb commit 1188aa4
Show file tree
Hide file tree
Showing 12 changed files with 87 additions and 54 deletions.
5 changes: 3 additions & 2 deletions build/ac-macros/fla_require_cc.m4
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ AC_DEFUN([FLA_REQUIRE_CC],
fi
dnl Ascertain the compiler "vendor".
CC_VENDOR=$(echo "$CC" | egrep -o 'icc|gcc|clang|emcc|pnacl|IBM' | { read first rest ; echo $first ; })
dnl CC_VENDOR=$(echo "$CC" | egrep -o 'icc|gcc|clang|emcc|pnacl|IBM' | { read first rest ; echo $first ; })
dnl AC_MSG_NOTICE([[CC_VENDOR environment variable is set to ${CC_VENDOR}.]])
dnl Substitute the user-defined CFLAGS into the autoconf output files.
AC_SUBST(fla_userdef_cflags)
AC_SUBST(CC_VENDOR)
dnl AC_SUBST(CC_VENDOR)
])
16 changes: 16 additions & 0 deletions build/ac-macros/fla_require_cc_vendor.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
AC_DEFUN([FLA_REQUIRE_CC_VENDOR],
[
AC_REQUIRE([FLA_REQUIRE_CC])
dnl Ascertain the compiler "vendor".
CC_VENDOR=$(echo "$CC" | egrep -o 'icc|gcc|clang|emcc|pnacl|IBM' | { read first rest ; echo $first ; })
if test "${CC_VENDOR}" = "" ; then
AC_MSG_ERROR([configure can't determine the compiler vendor for $CC. Please submit a bug report to the FLAME developers.])
else
AC_MSG_NOTICE([[setting the CC_VENDOR environment variable to ${CC_VENDOR}.]])
fi
dnl Substitute the user-defined CFLAGS into the autoconf output files.
AC_SUBST(CC_VENDOR)
])
6 changes: 3 additions & 3 deletions build/ac-macros/fla_set_c_debug_flags.m4
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ AC_DEFUN([FLA_SET_C_DEBUG_FLAGS],
[
AC_REQUIRE([FLA_OBSERVE_HOST_CPU_TYPE])
AC_MSG_CHECKING([for (guessing) appropriate $CC debug flags])
AC_MSG_CHECKING([for (guessing) appropriate ${CC_VENDOR} debug flags])
if test "$1" == "yes" ; then
dnl Set C compiler flags assuming we found...
case $CC in
case ${CC_VENDOR} in
dnl GNU gcc.
gcc)
fla_c_debug_flags='-g'
Expand Down Expand Up @@ -44,7 +44,7 @@ AC_DEFUN([FLA_SET_C_DEBUG_FLAGS],
else
dnl Set C compiler flags assuming we found...
case $CC in
case ${CC_VENDOR} in
dnl GNU gcc.
gcc)
fla_c_debug_flags='-g0'
Expand Down
4 changes: 2 additions & 2 deletions build/ac-macros/fla_set_c_lang_flags.m4
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ AC_DEFUN([FLA_SET_C_LANG_FLAGS],
[
AC_REQUIRE([FLA_OBSERVE_HOST_CPU_TYPE])
AC_MSG_CHECKING([for (guessing) appropriate $CC language flags])
AC_MSG_CHECKING([for (guessing) appropriate ${CC_VENDOR} language flags])
dnl Set C compiler flags assuming we found...
case $CC in
case ${CC_VENDOR} in
dnl GNU gcc.
gcc)
fla_c_lang_flags='-std=c99 -Wall -Wno-unused-function -Wno-parentheses -Wfatal-errors'
Expand Down
6 changes: 3 additions & 3 deletions build/ac-macros/fla_set_c_openmp_flags.m4
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ AC_DEFUN([FLA_SET_C_OPENMP_FLAGS],
AC_REQUIRE([FLA_OBSERVE_HOST_CPU_TYPE])
dnl Echo C OpenMP flags to user.
AC_MSG_CHECKING([for (guessing) OpenMP flags for $CC])
AC_MSG_CHECKING([for (guessing) OpenMP flags for ${CC_VENDOR}])
dnl Set the OpenMP compiler flags based on which C compiler we're going to use.
case $CC in
case ${CC_VENDOR} in
dnl Intel icc.
icc)
fla_c_openmp_flags='-openmp'
Expand Down Expand Up @@ -45,7 +45,7 @@ AC_DEFUN([FLA_SET_C_OPENMP_FLAGS],
dnl Tell the user we can't continue unless we know what flags
dnl to pass to the C compiler to enable OpenMP.
AC_MSG_ERROR([configure doesn't know what flag to give $CC in order to enable OpenMP support. Please submit a bug report to the FLAME developers.])
AC_MSG_ERROR([configure doesn't know what flag to give ${CC_VENDOR} in order to enable OpenMP support. Please submit a bug report to the FLAME developers.])
fi
dnl Output the C OpenMP flags variable.
Expand Down
6 changes: 3 additions & 3 deletions build/ac-macros/fla_set_c_opt_flags.m4
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ AC_DEFUN([FLA_SET_C_OPT_FLAGS],
[
AC_REQUIRE([FLA_OBSERVE_HOST_CPU_TYPE])
AC_MSG_CHECKING([for (guessing) appropriate $CC optimization flags])
AC_MSG_CHECKING([for (guessing) appropriate ${CC_VENDOR} optimization flags])
if test "$1" == "yes" ; then
dnl Set C compiler flags assuming we found...
case $CC in
case ${CC_VENDOR} in
dnl GNU gcc.
gcc)
fla_c_opt_flags='-O3'
Expand Down Expand Up @@ -44,7 +44,7 @@ AC_DEFUN([FLA_SET_C_OPT_FLAGS],
else
dnl Set C compiler flags assuming we found...
case $CC in
case ${CC_VENDOR} in
dnl GNU gcc.
gcc)
fla_c_opt_flags='-O0'
Expand Down
2 changes: 1 addition & 1 deletion build/ac-macros/fla_set_c_preproc_flags.m4
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ AC_DEFUN([FLA_SET_C_PREPROC_FLAGS],
AC_REQUIRE([FLA_OBSERVE_HOST_CPU_TYPE])
dnl Set C preprocessor flags assuming we found...
case $CC in
case ${CC_VENDOR} in
dnl GNU gcc.
gcc)
dnl Define the _GNU_SOURCE macro.
Expand Down
6 changes: 3 additions & 3 deletions build/ac-macros/fla_set_c_prof_flags.m4
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ AC_DEFUN([FLA_SET_C_PROF_FLAGS],
[
AC_REQUIRE([FLA_OBSERVE_HOST_CPU_TYPE])
AC_MSG_CHECKING([for (guessing) appropriate $CC profiling flags])
AC_MSG_CHECKING([for (guessing) appropriate ${CC_VENDOR} profiling flags])
if test "$1" == "yes" ; then
dnl Set C compiler flags assuming we found...
case $CC in
case ${CC_VENDOR} in
dnl GNU gcc.
gcc)
fla_c_prof_flags='-pg'
Expand Down Expand Up @@ -44,7 +44,7 @@ AC_DEFUN([FLA_SET_C_PROF_FLAGS],
else
dnl Set C compiler flags assuming we found...
case $CC in
case ${CC_VENDOR} in
dnl GNU gcc.
gcc)
fla_c_prof_flags=''
Expand Down
8 changes: 4 additions & 4 deletions build/ac-macros/fla_set_c_sse_flags.m4
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ AC_DEFUN([FLA_SET_C_SSE_FLAGS],
AC_REQUIRE([FLA_OBSERVE_HOST_CPU_TYPE])
dnl Echo C SSE flags to user.
AC_MSG_CHECKING([for (guessing) SSE flags for $CC])
AC_MSG_CHECKING([for (guessing) SSE flags for ${CC_VENDOR}])
dnl Set the SSE compiler flags based on which C compiler we're going to use.
case $CC in
case ${CC_VENDOR} in
dnl Intel icc.
icc)
fla_c_sse_flags='-msse3'
Expand Down Expand Up @@ -49,15 +49,15 @@ AC_DEFUN([FLA_SET_C_SSE_FLAGS],
dnl Tell the user we can't continue because he asked for SSE flags
dnl for a compiler that (probably) does not support them.
AC_MSG_ERROR([configure can't continue because the $CC compiler (probably) does not support SSE.])
AC_MSG_ERROR([configure can't continue because the ${CC_VENDOR} compiler (probably) does not support SSE.])
fi
dnl Check string in case C SSE flags are unknown.
if test "$fla_c_sse_flags" = "unknown" ; then
dnl Tell the user we can't continue unless we know what flags
dnl to pass to the C compiler to enable SSE support.
AC_MSG_ERROR([configure doesn't know what flag to give $CC in order to enable SSE. Please submit a bug report to the FLAME developers.])
AC_MSG_ERROR([configure doesn't know what flag to give ${CC_VENDOR} in order to enable SSE. Please submit a bug report to the FLAME developers.])
fi
dnl Output the C SSE flags variable.
Expand Down
6 changes: 3 additions & 3 deletions build/ac-macros/fla_set_c_warning_flags.m4
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ AC_DEFUN([FLA_SET_C_WARNING_FLAGS],
[
AC_REQUIRE([FLA_OBSERVE_HOST_CPU_TYPE])
AC_MSG_CHECKING([for (guessing) appropriate $CC warning flags])
AC_MSG_CHECKING([for (guessing) appropriate ${CC_VENDOR} warning flags])
if test "$1" == "yes" ; then
dnl Set C compiler flags assuming we found...
case $CC in
case ${CC_VENDOR} in
dnl GNU gcc.
gcc)
fla_c_warning_flags='-Wall -Wno-comment'
Expand Down Expand Up @@ -44,7 +44,7 @@ AC_DEFUN([FLA_SET_C_WARNING_FLAGS],
else
dnl Set C compiler flags assuming we found...
case $CC in
case ${CC_VENDOR} in
dnl GNU gcc.
gcc)
fla_c_warning_flags='-w'
Expand Down
71 changes: 42 additions & 29 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -3474,8 +3474,21 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
as_fn_error 1 "Could not locate any of the following C compilers: $CC $fla_requested_cc $fla_c_compiler_list. Cannot continue without a C compiler." "$LINENO" 5
fi








CC_VENDOR=$(echo "$CC" | egrep -o 'icc|gcc|clang|emcc|pnacl|IBM' | { read first rest ; echo $first ; })

if test "${CC_VENDOR}" = "" ; then
as_fn_error $? "configure can't determine the compiler vendor for $CC. Please submit a bug report to the FLAME developers." "$LINENO" 5
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: setting the CC_VENDOR environment variable to ${CC_VENDOR}." >&5
$as_echo "$as_me: setting the CC_VENDOR environment variable to ${CC_VENDOR}." >&6;}
fi



Expand Down Expand Up @@ -6042,7 +6055,7 @@ $as_echo "no" >&6; }



case $CC in
case ${CC_VENDOR} in
gcc)

$as_echo "#define _GNU_SOURCE 1" >>confdefs.h
Expand All @@ -6068,10 +6081,10 @@ $as_echo "#define _GNU_SOURCE 1" >>confdefs.h



{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for (guessing) appropriate $CC language flags" >&5
$as_echo_n "checking for (guessing) appropriate $CC language flags... " >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for (guessing) appropriate ${CC_VENDOR} language flags" >&5
$as_echo_n "checking for (guessing) appropriate ${CC_VENDOR} language flags... " >&6; }

case $CC in
case ${CC_VENDOR} in
gcc)
fla_c_lang_flags='-std=c99 -Wall -Wno-unused-function -Wno-parentheses -Wfatal-errors'
;;
Expand Down Expand Up @@ -6490,10 +6503,10 @@ $as_echo "#define FLA_ENABLE_MULTITHREADING 1" >>confdefs.h



{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for (guessing) OpenMP flags for $CC" >&5
$as_echo_n "checking for (guessing) OpenMP flags for $CC... " >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for (guessing) OpenMP flags for ${CC_VENDOR}" >&5
$as_echo_n "checking for (guessing) OpenMP flags for ${CC_VENDOR}... " >&6; }

case $CC in
case ${CC_VENDOR} in
icc)
fla_c_openmp_flags='-openmp'
;;
Expand Down Expand Up @@ -6522,7 +6535,7 @@ $as_echo "$fla_c_openmp_flags" >&6; }

if test "$fla_c_openmp_flags" = "unknown" ; then

as_fn_error $? "configure doesn't know what flag to give $CC in order to enable OpenMP support. Please submit a bug report to the FLAME developers." "$LINENO" 5
as_fn_error $? "configure doesn't know what flag to give ${CC_VENDOR} in order to enable OpenMP support. Please submit a bug report to the FLAME developers." "$LINENO" 5
fi


Expand Down Expand Up @@ -6747,10 +6760,10 @@ $as_echo "#define FLA_ENABLE_VECTOR_INTRINSICS 1" >>confdefs.h



{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for (guessing) SSE flags for $CC" >&5
$as_echo_n "checking for (guessing) SSE flags for $CC... " >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for (guessing) SSE flags for ${CC_VENDOR}" >&5
$as_echo_n "checking for (guessing) SSE flags for ${CC_VENDOR}... " >&6; }

case $CC in
case ${CC_VENDOR} in
icc)
fla_c_sse_flags='-msse3'
;;
Expand Down Expand Up @@ -6782,12 +6795,12 @@ $as_echo "$fla_c_sse_flags" >&6; }

if test "$fla_c_sse_flags" = "notvalid" ; then

as_fn_error $? "configure can't continue because the $CC compiler (probably) does not support SSE." "$LINENO" 5
as_fn_error $? "configure can't continue because the ${CC_VENDOR} compiler (probably) does not support SSE." "$LINENO" 5
fi

if test "$fla_c_sse_flags" = "unknown" ; then

as_fn_error $? "configure doesn't know what flag to give $CC in order to enable SSE. Please submit a bug report to the FLAME developers." "$LINENO" 5
as_fn_error $? "configure doesn't know what flag to give ${CC_VENDOR} in order to enable SSE. Please submit a bug report to the FLAME developers." "$LINENO" 5
fi


Expand Down Expand Up @@ -6972,12 +6985,12 @@ $as_echo "no" >&6; }



{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for (guessing) appropriate $CC optimization flags" >&5
$as_echo_n "checking for (guessing) appropriate $CC optimization flags... " >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for (guessing) appropriate ${CC_VENDOR} optimization flags" >&5
$as_echo_n "checking for (guessing) appropriate ${CC_VENDOR} optimization flags... " >&6; }

if test "$fla_enable_compiler_optimizations" == "yes" ; then

case $CC in
case ${CC_VENDOR} in
gcc)
fla_c_opt_flags='-O3'
;;
Expand Down Expand Up @@ -7005,7 +7018,7 @@ $as_echo_n "checking for (guessing) appropriate $CC optimization flags... " >&6;
esac
else

case $CC in
case ${CC_VENDOR} in
gcc)
fla_c_opt_flags='-O0'
;;
Expand Down Expand Up @@ -7090,12 +7103,12 @@ $as_echo "no" >&6; }



{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for (guessing) appropriate $CC warning flags" >&5
$as_echo_n "checking for (guessing) appropriate $CC warning flags... " >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for (guessing) appropriate ${CC_VENDOR} warning flags" >&5
$as_echo_n "checking for (guessing) appropriate ${CC_VENDOR} warning flags... " >&6; }

if test "$fla_enable_compiler_warnings" == "yes" ; then

case $CC in
case ${CC_VENDOR} in
gcc)
fla_c_warning_flags='-Wall -Wno-comment'
;;
Expand Down Expand Up @@ -7123,7 +7136,7 @@ $as_echo_n "checking for (guessing) appropriate $CC warning flags... " >&6; }
esac
else

case $CC in
case ${CC_VENDOR} in
gcc)
fla_c_warning_flags='-w'
;;
Expand Down Expand Up @@ -7207,12 +7220,12 @@ $as_echo "no" >&6; }



{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for (guessing) appropriate $CC debug flags" >&5
$as_echo_n "checking for (guessing) appropriate $CC debug flags... " >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for (guessing) appropriate ${CC_VENDOR} debug flags" >&5
$as_echo_n "checking for (guessing) appropriate ${CC_VENDOR} debug flags... " >&6; }

if test "$fla_enable_compiler_debug" == "yes" ; then

case $CC in
case ${CC_VENDOR} in
gcc)
fla_c_debug_flags='-g'
;;
Expand Down Expand Up @@ -7240,7 +7253,7 @@ $as_echo_n "checking for (guessing) appropriate $CC debug flags... " >&6; }
esac
else

case $CC in
case ${CC_VENDOR} in
gcc)
fla_c_debug_flags='-g0'
;;
Expand Down Expand Up @@ -7325,12 +7338,12 @@ $as_echo "no" >&6; }



{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for (guessing) appropriate $CC profiling flags" >&5
$as_echo_n "checking for (guessing) appropriate $CC profiling flags... " >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for (guessing) appropriate ${CC_VENDOR} profiling flags" >&5
$as_echo_n "checking for (guessing) appropriate ${CC_VENDOR} profiling flags... " >&6; }

if test "$fla_enable_compiler_profiling" == "yes" ; then

case $CC in
case ${CC_VENDOR} in
gcc)
fla_c_prof_flags='-pg'
;;
Expand Down Expand Up @@ -7358,7 +7371,7 @@ $as_echo_n "checking for (guessing) appropriate $CC profiling flags... " >&6; }
esac
else

case $CC in
case ${CC_VENDOR} in
gcc)
fla_c_prof_flags=''
;;
Expand Down
Loading

0 comments on commit 1188aa4

Please sign in to comment.