summaryrefslogtreecommitdiff
path: root/m4/ax_gcc_archflag.m4
diff options
context:
space:
mode:
authorTsukasa OI <li@livegrid.org>2014-08-25 12:31:27 +0900
committerPeter Simons <simons@cryp.to>2014-10-15 11:07:25 +0200
commit570de782487f3f01a8f9eae48891509e01d288bc (patch)
treebaf681b3f132f41c04b1600490db3a6efeea69be /m4/ax_gcc_archflag.m4
parent7354d36876d85610b456150f7c1f87aba34463a3 (diff)
downloadautoconf-archive-570de782487f3f01a8f9eae48891509e01d288bc.tar.gz
AX_GCC_ARCHFLAG: add workaround for Clang
LLVM Clang does not fail if -mcpu=UNKNOWN or -mtune=UNKNOWN is specified. This will result in "no CPU tuning". This commit resolves the issue by adding workaround for Clang.
Diffstat (limited to 'm4/ax_gcc_archflag.m4')
-rw-r--r--m4/ax_gcc_archflag.m410
1 files changed, 8 insertions, 2 deletions
diff --git a/m4/ax_gcc_archflag.m4 b/m4/ax_gcc_archflag.m4
index f8f892e..0d0bf43 100644
--- a/m4/ax_gcc_archflag.m4
+++ b/m4/ax_gcc_archflag.m4
@@ -64,12 +64,13 @@
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
-#serial 16
+#serial 17
AC_DEFUN([AX_GCC_ARCHFLAG],
[AC_REQUIRE([AC_PROG_CC])
AC_REQUIRE([AC_CANONICAL_HOST])
AC_REQUIRE([AC_PROG_SED])
+AC_REQUIRE([AX_COMPILER_VENDOR])
AC_ARG_WITH(gcc-arch, [AS_HELP_STRING([--with-gcc-arch=<arch>], [use architecture <arch> for gcc -march/-mtune, instead of guessing])],
ax_gcc_arch=$withval, ax_gcc_arch=yes)
@@ -207,6 +208,7 @@ fi # guess arch
if test "x$ax_gcc_arch" != x -a "x$ax_gcc_arch" != xno; then
if test "x[]m4_default([$1],yes)" = xyes; then # if we require portable code
flag_prefixes="-mtune="
+ if test "x$ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor" = xclang; then flag_prefixes="-march="; fi
# -mcpu=$arch and m$arch generate nonportable code on every arch except
# x86. And some other arches (e.g. Alpha) don't accept -mtune. Grrr.
case $host_cpu in i*86|x86_64*|amd64*) flag_prefixes="$flag_prefixes -mcpu= -m";; esac
@@ -216,7 +218,11 @@ fi
for flag_prefix in $flag_prefixes; do
for arch in $ax_gcc_arch; do
flag="$flag_prefix$arch"
- AX_CHECK_COMPILE_FLAG($flag, [ax_cv_gcc_archflag=$flag; break])
+ AX_CHECK_COMPILE_FLAG($flag, [if test "x$ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor" = xclang; then
+ if test "x[]m4_default([$1],yes)" = xyes; then
+ if test "x$flag" = "x-march=$arch"; then flag=-mtune=$arch; fi
+ fi
+ fi; ax_cv_gcc_archflag=$flag; break])
done
test "x$ax_cv_gcc_archflag" = xunknown || break
done