From 955e85ae8a98b11af765ed7e4192001523305605 Mon Sep 17 00:00:00 2001 From: Szilard Pall Date: Thu, 17 Jun 2010 03:08:07 +0200 Subject: [PATCH] Implemented (buggy) gcc 4.1.x check in cmake. --- CMakeLists.txt | 4 ++++ cmake/gmxCheckGCCVersion.cmake | 47 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 cmake/gmxCheckGCCVersion.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 12ac0ef2be..1cf3068622 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,6 +44,7 @@ enable_language(C) option(GMX_IA32_ASM "Add SSE assembly files for IA32" OFF) option(GMX_X86_64_ASM "Add SSE assembly files for X86_64" OFF) option(USE_VERSION_H "Generate development version string/information" ON) +option(GMX_DISABLE_GCC41_CHECK "Disable check for (buggy) gcc 4.1.x" OFF) ####################################################################### # Check for options incompatible with OpenMM build # @@ -292,6 +293,9 @@ endif (GMX_DLOPEN) include(CheckCCompilerFlag) include(CheckCXXCompilerFlag) +# check for buggy GCC 4.1.x +include(gmxCheckGCCVersion) + include(gmxCFlags) gmx_c_flags() diff --git a/cmake/gmxCheckGCCVersion.cmake b/cmake/gmxCheckGCCVersion.cmake new file mode 100644 index 0000000000..0e386381d0 --- /dev/null +++ b/cmake/gmxCheckGCCVersion.cmake @@ -0,0 +1,47 @@ +# Check GCC version and if any of the 4.1.x family compiler suites is found +# quit the build system generating process. +# +# The GCC 4.1.x compilers contain an optimization related bug which might +# results in code that exhibits incorrect behaviour and often leads to +# exploding systems or crashes. +# +# For further details see e.g. +# https://bugs.launchpad.net/ubuntu/+source/gcc-4.1/+bug/158799 +# +# Szilard Pall (pszilard@cbr.su.se) +# + +if(NOT GMX_DISABLE_GCC41_CHECK) + +if(CMAKE_COMPILER_IS_GNUCC) + # if we have -dumpversion flag use that, otherwise try the --version + execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion + RESULT_VARIABLE _gcc_dumpversion_res + OUTPUT_VARIABLE _gcc_dumpversion_out + OUTPUT_STRIP_TRAILING_WHITESPACE) + # if gcc returned with error the -dumpversion is not available + if(${_gcc_dumpversion_res} EQUAL 0) + if(${_gcc_dumpversion_out} MATCHES ".*4\\.1.*") + message(FATAL_ERROR " The GCC compiler in use seems to belong to the 4.1.x + family (detected version: ${_gcc_dumpversion_out}). These compilers + contain an optimization related bug which might results in code that + exhibits incorrect behaviour and often leads to exploding systems or + crashes. To disable this check set GMX_DISABLE_GCC41_CHECK=YES.") + endif() + else() + message(WARNING " The GCC compiler in use does not support the -dumpversion flag. + Will attempt parsing the version from the \"gcc --version\" output.") + execute_process(COMMAND ${CMAKE_C_COMPILER} --version + OUTPUT_VARIABLE _gcc_version_out + OUTPUT_STRIP_TRAILING_WHITESPACE) + if("${_gcc_version_out}" MATCHES ".*4\\.1.*") + message(FATAL_ERROR " The GCC compiler in use seems to belong to the 4.1.x + family. These compiler compilers contain an optimization related bug + which might results in code that exhibits incorrect behaviour and + often leads to exploding systems or crashes. To disable this check set + GMX_DISABLE_GCC41_CHECK=YES.") + endif() + endif() +endif() + +endif() -- 2.11.4.GIT