The current build machinery for pymol only compiles the main pymol files with the -O3 optimization flag set in setup.py but not the source files in the modules and plugin subdirectories. This should be more uniformly handled.
/usr/bin/clang++ -std=c++0x -D_PYMOL_LIBPNG -D_PYMOL_INLINE -D_PYMOL_VMD_PLUGINS -D_HAVE_LIBXML -D_PYMOL_FREETYPE -DNO_MMLIBS -D_PYMOL_NUMPY -D_PYMOL_OSX -Iov/src -Ilayer0 -Ilayer1 -Ilayer2 -Ilayer3 -Ilayer4 -Ilayer5 -Imodules/cealign/src -Ibuild/generated -Icontrib/uiuc/plugins/include -Icontrib/uiuc/plugins/molfile_plugin/src -Icontrib/mmtf-c -I/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/include -I/opt/local/include -I/opt/local/include/freetype2 -I/opt/local/include/libxml2 -I/opt/local/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c layer0/Tetsurf.cpp -o build/temp.macosx-10.13-x86_64-2.7/layer0/Tetsurf.o -Wno-write-strings -Wno-unused-function -Wno-char-subscripts -ffast-math -funroll-loops -fcommon
Opps. I missed that you are disabling -O3 on darwin. It would be better to enhance that with a check the offending compiler version of clang instead of all versions of clang.
This issue can be fixed far more gracefully with the following change to setup.py...
I would also note that, on darwin, we seem to automatically get -fno-strict-aliasing appended to compilations of c code through setup.py but not c++ code. Hence the need to explicitly pass -fno-strict-aliasing in setup.py on darwin.
vs
Last edit: Jack Howarth 2018-04-28
Note that I opened https://bugs.llvm.org/show_bug.cgi?id=37280 with the upstream llvm clang developers.
Thanks Jack for figuring this out! Your patch looks good.
FYI, the preprocessed failing test case doesn't trigger on ubuntu bionic using the same clang 6.0.0 release so the issue appears to be entirely darwin specific. The proposed fix of restricting the addition of -fno-strict-aliasing to darwin should be appropriate.
FYI, the issue appears to be either fixed or latent in current clang/llvm trunk for the 7.0 release. However Apple is conservative about absorbing changes from llvm.org so we need to file a radar to make sure they test that this issue if fixed in the next major Xcode release.
-fno-strict-aliasing patch applied in svn rev 4189