From: Szilárd Páll Date: Tue, 15 Jan 2013 01:27:10 +0000 (-0800) Subject: disable OpenMP with all OS X gcc 4.2-based compilers X-Git-Url: http://biod.pnpi.spb.ru/gitweb/?a=commitdiff_plain;h=a6fee0ba5e9075411d4dadfab8a8684c4f9632d6;p=alexxy%2Fgromacs.git disable OpenMP with all OS X gcc 4.2-based compilers 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 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index fc6c65851f..c33fdce9cb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/cmake/gmxCFlags.cmake b/cmake/gmxCFlags.cmake index ce8552fa06..bd979871f9 100644 --- a/cmake/gmxCFlags.cmake +++ b/cmake/gmxCFlags.cmake @@ -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)