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
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)
# 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)