From 9bbf9fdc10520be632e4a4637f1ddde841a84c4b Mon Sep 17 00:00:00 2001
From: Tsukasa OI
Date: Mon, 25 Aug 2014 12:31:27 +0900
Subject: [PATCH] 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.
---
m4/ax_gcc_archflag.m4 | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/m4/ax_gcc_archflag.m4 b/m4/ax_gcc_archflag.m4
index f8f892e..9886afd 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=], [use architecture 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
--
2.1.0