Work around broken Apple compilers in Mac OS 10.15
authorErik Lindahl <erik@kth.se>
Wed, 6 Nov 2019 13:00:37 +0000 (14:00 +0100)
committerPaul Bauer <paul.bauer.q@gmail.com>
Wed, 6 Nov 2019 13:22:09 +0000 (14:22 +0100)
The Xcode compiler in Mac OS Catalina checks and enforces
stack alignment by default, but embarrasingly enough the
C library provided by Apple fails to adhere to the
aligned stack for AVX despite bug reports being filed during
their beta cycle. We work around this sloppiness by removing
the check, since AVX does not require the alignment.

Fixes #3199.

Change-Id: I9c16b156cc5b3a5d9fc542335cbf63a6caf6fb1b

cmake/gmxCFlags.cmake
docs/release-notes/2019/2019.5.rst

index b0dee1dcd160d282fdb07b1b0c4ccb18782fca1c..75e2176868547874645753821d01955aed7b3e2b 100644 (file)
@@ -415,6 +415,25 @@ GMX_TEST_CFLAG(CFLAGS_WARN "/W3;/wd161;/wd177;/wd411;/wd593;/wd981;/wd1418;/wd14
         endif()
     endif()
 
+    # Apple bastardized version of Clang
+    if(${CMAKE_C_COMPILER_ID} MATCHES "AppleClang")
+        if(${CMAKE_C_COMPILER_VERSION} VERSION_GREATER 11.0)
+            # Mac OS Catalina ships with a horribly broken compiler (version 11.0.0.11000033)
+            # that checks stack alignment by default, but their own C library
+            # does not align the stack properly. Embarrassing, Apple...
+            GMX_TEST_CFLAG(CFLAG_NO_STACK_CHECK "-fno-stack-check" GMXC_CFLAGS)
+        endif()
+    endif()
+
+    if(${CMAKE_CXX_COMPILER_ID} MATCHES "AppleClang")
+        if(${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER 11.0)
+            # Mac OS Catalina ships with a horribly broken compiler (version 11.0.0.11000033)
+            # that checks stack alignment by default, but their own C library
+            # does not align the stack properly. Embarrassing, Apple...
+            GMX_TEST_CXXFLAG(CXXFLAG_NO_STACK_CHECK "-fno-stack-check" GMXC_CXXFLAGS)
+        endif()
+    endif()
+
     # Fujitsu compilers on PrimeHPC/Sparc64
     if(${CMAKE_C_COMPILER_ID} MATCHES Fujitsu OR
        (${CMAKE_C_COMPILER_ID} MATCHES unknown AND ${CMAKE_C_COMPILER} MATCHES ^fcc))
index a34b88e85b88aea2bb82dfce0139d22a808088c8..1017afb17ff1ef5d864520d3357e1c3bb2b243d1 100644 (file)
@@ -42,7 +42,16 @@ We don't expect this to have caused incorrect results, but
 a memory checker would complain.
 
 :issue:`3173`
+
+Work around broken Apple Clang compiler in Mac OS Catalina
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+In Mac OS Catalina, the default XCode compilers checks and
+enforces stack alignment. This would have been a good idea
+if Apple itself did not ship a C library that violates the
+stack alignment with AVX instructions are enabled.
+
+:issue:`3199`
+       
 Fixes for ``gmx`` tools
 ^^^^^^^^^^^^^^^^^^^^^^^