Menu

#205 modules not built with -O3 like main pymol files

v1.6.2.0
closed-fixed
None
5
2018-05-03
2018-04-25
No

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

Discussion

  • Jack Howarth

    Jack Howarth - 2018-04-25

    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.

     
  • Jack Howarth

    Jack Howarth - 2018-04-28

    This issue can be fixed far more gracefully with the following change to setup.py...

    Index: setup.py
    ===================================================================
    --- setup.py    (revision 4187)
    +++ setup.py    (working copy)
    @@ -392,12 +392,12 @@
         libs += ["GLEW"]
         libs += pyogl_libs
    
    -    ext_comp_args += ["-ffast-math", "-funroll-loops", "-fcommon"]
    +    ext_comp_args += ["-ffast-math", "-funroll-loops", "-fcommon", "-O3"]
    
         # optimization currently causes a clang segfault on OS X 10.9 when
         # compiling layer2/RepCylBond.cpp
    -    if sys.platform != 'darwin':
    -        ext_comp_args += ["-O3"]
    +    if sys.platform == 'darwin':
    +        ext_comp_args += ["-fno-strict-aliasing"]
    
     def get_pymol_version():
         return re.findall(r'_PyMOL_VERSION "(.*)"', open('layer0/Version.h').read())[0]
    
     
  • Jack Howarth

    Jack Howarth - 2018-04-28

    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.

    /usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -pipe -Os -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -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 build/generated/ShaderText.c -o build/temp.macosx-10.13-x86_64-2.7/build/generated/ShaderText.o -Wno-write-strings -Wno-unused-function -Wno-char-subscripts -ffast-math -funroll-loops -fcommon -O3
    

    vs

    /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 contrib/uiuc/plugins/molfile_plugin/src/cubeplugin.cpp -o build/temp.macosx-10.13-x86_64-2.7/contrib/uiuc/plugins/molfile_plugin/src/cubeplugin.o -Wno-write-strings -Wno-unused-function -Wno-char-subscripts -ffast-math -funroll-loops -fcommon -O3
    
     

    Last edit: Jack Howarth 2018-04-28
  • Jack Howarth

    Jack Howarth - 2018-04-28

    Note that I opened https://bugs.llvm.org/show_bug.cgi?id=37280 with the upstream llvm clang developers.

     
  • Thomas Holder

    Thomas Holder - 2018-04-29
    • assigned_to: Thomas Holder
     
  • Thomas Holder

    Thomas Holder - 2018-04-29

    Thanks Jack for figuring this out! Your patch looks good.

     
    • Jack Howarth

      Jack Howarth - 2018-04-29

      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.

       
  • Jack Howarth

    Jack Howarth - 2018-05-01

    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.

     
  • Thomas Holder

    Thomas Holder - 2018-05-03
    • status: open --> closed-fixed
     
  • Thomas Holder

    Thomas Holder - 2018-05-03

    -fno-strict-aliasing patch applied in svn rev 4189

     

Log in to post a comment.