From 2cf9ad5752c4a5949409fd7fad986552d1bc6a99 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Mon, 18 Aug 2008 09:42:17 +0000 Subject: [PATCH] 2008-08-18 Roland McGrath * configure.in (--with-cpu): Check compiler support for -march/-mcpu. * configure: Regenerated. * config.make.in (cflags-cpu): New substituted variable. (with-cpu): Variable removed. * Makeconfig (+cflags): Use $(cflags-cpu), not $(with-cpu). --- Makeconfig | 2 +- config.make.in | 2 +- configure | 34 ++++++++++++++++++++++++++++++++-- configure.in | 17 ++++++++++++++++- 4 files changed, 50 insertions(+), 5 deletions(-) diff --git a/Makeconfig b/Makeconfig index a78615eb6a..83e14094c4 100644 --- a/Makeconfig +++ b/Makeconfig @@ -643,7 +643,7 @@ ifeq "$(strip $(+cflags))" "" +cflags := $(default_cflags) endif # $(+cflags) == "" -+cflags += $(addprefix -mcpu=,$(with-cpu)) $(+gccwarn) $(+merge-constants) ++cflags += $(cflags-cpu) $(+gccwarn) $(+merge-constants) +gcc-nowarn := -w # Don't duplicate options if we inherited variables from the parent. diff --git a/config.make.in b/config.make.in index 3fd0abc65c..aa73466713 100644 --- a/config.make.in +++ b/config.make.in @@ -31,7 +31,7 @@ base-machine = @base_machine@ config-vendor = @host_vendor@ config-os = @host_os@ config-sysdirs = @sysnames@ -with-cpu = @submachine@ +cflags-cpu = @libc_cv_cc_submachine@ defines = @DEFINES@ sysincludes = @SYSINCLUDES@ diff --git a/configure b/configure index 6ffe5e64da..73f199689e 100755 --- a/configure +++ b/configure @@ -730,6 +730,7 @@ libc_cv_gnu89_inline libc_cv_have_initfini no_whole_archive exceptions +libc_cv_cc_submachine LIBGD have_libaudit have_libcap @@ -2329,7 +2330,6 @@ echo "$as_me: error: --with-cpu requires an argument" >&2;} fi - # An add-on can set this when it wants to disable the sanity check below. libc_config_ok=no @@ -7097,6 +7097,35 @@ _ACEOF fi fi +if test -n "$submachine"; then + { echo "$as_me:$LINENO: checking for compiler option for CPU variant" >&5 +echo $ECHO_N "checking for compiler option for CPU variant... $ECHO_C" >&6; } +if test "${libc_cv_cc_submachine+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + libc_cv_cc_submachine=no + for opt in "-march=$submachine" "-mcpu=$submachine"; do + if { ac_try='${CC-cc} $opt -xc /dev/null -S -o /dev/null' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + libc_cv_cc_submachine="$opt" + break + fi + done +fi +{ echo "$as_me:$LINENO: result: $libc_cv_cc_submachine" >&5 +echo "${ECHO_T}$libc_cv_cc_submachine" >&6; } + if test "x$libc_cv_cc_submachine" = xno; then + { { echo "$as_me:$LINENO: error: ${CC-cc} does not support $submachine" >&5 +echo "$as_me: error: ${CC-cc} does not support $submachine" >&2;} + { (exit 1); exit 1; }; } + fi +fi + + { echo "$as_me:$LINENO: checking for libgd" >&5 echo $ECHO_N "checking for libgd... $ECHO_C" >&6; } if test "$with_gd" != "no"; then @@ -9264,6 +9293,7 @@ libc_cv_gnu89_inline!$libc_cv_gnu89_inline$ac_delim libc_cv_have_initfini!$libc_cv_have_initfini$ac_delim no_whole_archive!$no_whole_archive$ac_delim exceptions!$exceptions$ac_delim +libc_cv_cc_submachine!$libc_cv_cc_submachine$ac_delim LIBGD!$LIBGD$ac_delim have_libaudit!$have_libaudit$ac_delim have_libcap!$have_libcap$ac_delim @@ -9301,7 +9331,7 @@ LIBOBJS!$LIBOBJS$ac_delim LTLIBOBJS!$LTLIBOBJS$ac_delim _ACEOF - if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 52; then + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 53; then break elif $ac_last_try; then { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 diff --git a/configure.in b/configure.in index cd08a23e29..1651d38c10 100644 --- a/configure.in +++ b/configure.in @@ -326,7 +326,6 @@ AC_ARG_WITH([cpu], esac ]) - # An add-on can set this when it wants to disable the sanity check below. libc_config_ok=no @@ -1973,6 +1972,22 @@ EOF fi fi +if test -n "$submachine"; then + AC_CACHE_CHECK([for compiler option for CPU variant], + libc_cv_cc_submachine, [dnl + libc_cv_cc_submachine=no + for opt in "-march=$submachine" "-mcpu=$submachine"; do + if AC_TRY_COMMAND([${CC-cc} $opt -xc /dev/null -S -o /dev/null]); then + libc_cv_cc_submachine="$opt" + break + fi + done]) + if test "x$libc_cv_cc_submachine" = xno; then + AC_MSG_ERROR([${CC-cc} does not support $submachine]) + fi +fi +AC_SUBST(libc_cv_cc_submachine) + dnl Check whether we have the gd library available. AC_MSG_CHECKING(for libgd) if test "$with_gd" != "no"; then