]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Detect and use -march=natuve when possible
authorAmos Jeffries <squid3@treenet.co.nz>
Tue, 21 May 2013 05:39:18 +0000 (23:39 -0600)
committerAmos Jeffries <squid3@treenet.co.nz>
Tue, 21 May 2013 05:39:18 +0000 (23:39 -0600)
Clang++ 3.2 fails to detect some CPUs correctly and requires the
additional checks enabled by this option to build working executables.

This option supported by GCC 4.3 and later enables additional CPU
detection and enables CPU-specific optimizations. In the interests of
better performance this patch enables it whenever is it available and
possible to use (cross-compilers cannot use it).

configure.ac

index f2e45c0a7c7b0e29e11deb75a68afcaf4b94bb52..3108ea7062dc5ad570cd6d7ca81993b4f5a80c62 100644 (file)
@@ -35,9 +35,20 @@ AC_PROG_CXX
 AC_LANG([C++])
 AC_CANONICAL_HOST
 
-# might be cross-compiling
+# Clang 3.2 on some CPUs requires -march-native to detect correctly
+# GCC 4.3+ can also produce faster executables when its used
+SQUID_CC_CHECK_ARGUMENT([squid_cv_check_marchnative],[-march=native])
+
+# might be cross-compiling.
 if test "x$HOSTCXX" = "x"; then
   HOSTCXX="$CXX"
+  if test "x$squid_cv_check_marchnative" = "xyes"; then
+    CXXFLAGS="$CXXFLAGS -march=native"
+  fi
+fi
+if test "x$squid_cv_check_marchnative" = "xyes"; then
+  # always valid for the Host compiler.
+  HOSTCXX="$HOSTCXX -march=native"
 fi
 AC_SUBST(HOSTCXX)