disable OpenMP with all OS X gcc 4.2-based compilers
authorSzilárd Páll <pszilard@cbr.su.se>
Tue, 15 Jan 2013 01:27:10 +0000 (17:27 -0800)
committerSzilárd Páll <pszilard@cbr.su.se>
Tue, 15 Jan 2013 08:47:15 +0000 (00:47 -0800)
Although gcc 4.2 should have OpenMP support, the gcc 4.2.1-based
compilers on Mac OS X (defaults in 10.6.x) all claim to support OpenMP,
but generates segfaulting code.

This change reworks the llvm-specific check and moves it out from the
C/CXX flag generation module.

This compiler is the default on many BSD os-es, but as no other gcc
4.2.x has been tested yet (to my knowledge), for now the limitation is
introduced only for the Mac OS X and gcc 4.2.x.

Refs #900

Change-Id: I1c2a27f6fc1162cf8999c65ff6173121109cfbad

CMakeLists.txt
cmake/gmxCFlags.cmake

index fc6c65851f11d5717df87c41fb299d5a44ebe280..c33fdce9cb60a0bd6407bfbf724a0679173247e3 100644 (file)
@@ -233,6 +233,17 @@ if(CMAKE_CXX_COMPILER_LOADED)
     include(CheckCXXCompilerFlag)
 endif()
 
+# First exclude compilers known to not work with OpenMP although claim to support it:
+# gcc 4.2.1 and gcc-llvm 4.2.1 (also claims to be 4.2.1) on Mac OS X
+# This fixes redmine 900 and needs to run before OpenMP flags are set below.
+message("CMAKE_COMPILER_IS_GNUCC: ${CMAKE_COMPILER_IS_GNUCC}")
+if (CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND
+    CMAKE_COMPILER_IS_GNUCC AND C_COMPILER_VERSION VERSION_LESS 4.3)
+    message(STATUS "OpenMP multithreading not supported with gcc/llvm-gcc 4.2 on Mac OS X, disabled")
+    set(GMX_OPENMP OFF CACHE BOOL
+        "OpenMP multithreading not not supported with gcc/llvm-gcc 4.2 on Mac OS X, disabled!" FORCE)
+endif()
+
 # OpenMP check must come before other CFLAGS!
 if(GMX_OPENMP)
     find_package(OpenMP)
index ce8552fa061287dcacd71d68e3166439f79c4150..bd979871f96db17a9292da7193045bf9b1e20274 100644 (file)
@@ -64,17 +64,6 @@ MACRO(gmx_c_flags)
 
     # gcc
     if(CMAKE_COMPILER_IS_GNUCC)
-
-        #Fix for LLVM OpenMP bug (redmine 900). Needs to run before OpenMP flags are set below.
-        if(GMX_OPENMP)
-            exec_program(${CMAKE_C_COMPILER} ARGS --version OUTPUT_VARIABLE _compiler_output)
-            if(_compiler_output MATCHES "llvm.*4\\.2")
-                message(STATUS "OpenMP multithreading not supported with llvm-gcc 4.2, disabled")
-                set(GMX_OPENMP OFF CACHE BOOL
-                    "OpenMP multithreading not not supported with llvm-gcc 4.2, disabled!" FORCE)
-            endif()
-        endif()
-
         #flags are added in reverse order and -Wno* need to appear after -Wall
         if(NOT GMX_OPENMP)
             GMX_TEST_CFLAG(CFLAGS_PRAGMA "-Wno-unknown-pragmas" GMXC_CFLAGS)