From d110158b4d027609c5800b5077f9443916ae2432 Mon Sep 17 00:00:00 2001 From: oparviai Date: Wed, 4 Apr 2012 15:37:39 +0000 Subject: [PATCH] Fix cpuid.h detection in configure.ac Only gcc in the x86 architectures contain cpuid.h. Therefore this would not compile in other architectures. . To fix this: 1) Pass a warning instead of an error saying that the header file is missing. 2) Disable optimizations if cpuid.h was not found. . Behaviour: 1) In non-x86 architectures we have no cpuid.h. We give a warning which I hope makes sense and is basically saying this is normal in non-x86 architectures and and we will ALWAYS disable the optimizations. 2) In x86 architectures with cpuid.h we get the desired behaviour and check if the user request optimizations and if they are supported by the cpu. 3) In x86 architectures w/o cpuid.h we give a warning basically telling the user to upgrade gcc and we ALWAYS disable optimizations since we can only tell there is sse/mmx support at build time but not at runtime. 4) In non-x86 architectures with some unexpected cpuid.h the sse/mmx checks should fail and these optimizations will get disabled. . Tested in: amd64, i386: x86 + cpuid.h armel, armhf: non-x86 + no cpuid.h armel, armhf: non-x86 + dummy cpuid.h to pass test . The last test should simulate the case of an x86 with no mmx/sse (old i386). The 2nd test should be equal to x86 + no cpuid.h. Author: Miguel Colon --- configure.ac | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/configure.ac b/configure.ac index eaf2827..709d078 100644 --- a/configure.ac +++ b/configure.ac @@ -56,12 +56,14 @@ dnl ############################################################################ AC_HEADER_STDC #AC_HEADER_SYS_WAIT # add any others you want to check for here -AC_CHECK_HEADERS([cpuid.h],,[AC_MSG_ERROR([cpuid.h not found, install gcc >= 4.3])]) - - - - +AC_CHECK_HEADERS([cpuid.h]) +if test "x$ac_cv_header_cpuid_h" = "xno"; then + AC_MSG_WARN([The cpuid.h file was not found therefore the x86 optimizations will be disabled.]) + AC_MSG_WARN([If using a x86 architecture and optimizations are desired then please install gcc (>= 4.3).]) + AC_MSG_WARN([If using a non-x86 architecture then this is expected and can be ignored.]) +fi + dnl ############################################################################ dnl # Checks for typedefs, structures, and compiler characteristics $ @@ -103,7 +105,7 @@ fi # Check if optimizations are supported in the system at build time. -if test "x$enable_x86_optimizations" = "xyes"; then +if test "x$enable_x86_optimizations" = "xyes" -a "x$ac_cv_header_cpuid_h" = "xyes"; then echo "****** x86 optimizations enabled ******" original_saved_CXXFLAGS=$CXXFLAGS