Opened 7 years ago
Closed 7 years ago
#56373 closed update (fixed)
pymol: fix lack of optimization in compiling pymol on clang compilers
Reported by: | jwhowarth | Owned by: | jwhowarth |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | ports | Version: | |
Keywords: | Cc: | mojca (Mojca Miklavec) | |
Port: | pymol |
Description
The attached Portfile diff and new clang_opt_fix.diff restores the previous -O3 optimization of pymol on darwin by passing -fno-strict-aliasing. Upstream stopped passing any optimization flags at all to pymol due to a compiler segfault in compiling layer2/RepCylBond.cpp starting with OS X 10.9 and later.
Attachments (2)
Change History (15)
Changed 7 years ago by jwhowarth
Attachment: | Portfile.diff added |
---|
Changed 7 years ago by jwhowarth
Attachment: | clang_opt_fix.diff added |
---|
clang_opt_fix.diff to restore -O3 optimization on darwin
comment:1 Changed 7 years ago by jwhowarth
Tested on 10.13 with Xcode 9.3. Without the use of -fno-strict-aliasing, a build with -O3 produces the compiler segfault...
fatal error: error in backend: Unsupported expression in static initializer: fsub (float 1.000000e+00, float undef) clang: error: clang frontend command failed with exit code 70 (use -v to see invocation)
comment:2 Changed 7 years ago by jwhowarth
Note that this fix has been proposed upstream in https://sourceforge.net/p/pymol/bugs/205/
comment:3 Changed 7 years ago by pmetzger (Perry E. Metzger)
Can you submit this as a Pull Request on GitHub? It will then get much faster attention. Instructions are located in the MacPorts guide.
comment:4 Changed 7 years ago by jwhowarth
comment:5 Changed 7 years ago by jwhowarth
As an interesting aside, I noticed that we only automatically append -fno-strict-aliasing to clang compiles for c code on Darwin in python's compile-all but not for c++ code. This differs from Ubuntu linux's python-2.7 which emits -fno-strict-aliasing for both c and c++ code.
comment:6 Changed 7 years ago by mojca (Mojca Miklavec)
I see that lots of port add this flag manually. Where is this flag appended automatically? If there's a reasonable place where this could be done, maybe we should do it.
comment:7 Changed 7 years ago by jwhowarth
The origin of the usage of -fno-strict-aliasing in python-2.7's /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/_sysconfigdata.py, is described in this web page
https://wiki.gentoo.org/wiki/Project:Python/Strict_aliasing
However, this differs from the reason we are using it now in pymol which is due to a clang bug causing one of the source files to crash the compiler when -fstricti-aliasing Is invoked. In general, one would like to avoid -fno-strict-aliasing as it can limit optimization options for the compiler. However considering that the alternative is to compile with no optimization at all, it is a reasonable trade-off here.
A reasonable explanation of strict aliasing can be found at https://cellperformance.beyond3d.com/articles/2006/06/understanding-strict-aliasing.html
comment:8 Changed 7 years ago by jwhowarth
Also I would note that python up to 3.6 still uses -fno-strict-aliasing because, while its own code may have been cleaned up to be strict aliasing safe, it can't depend for that to be true for all the python modules for which it sets the compile flags. Again, all of this is entirely orthogonal to why we are using it in pymol which is an unrelated clang compiler bug in that case.
comment:9 Changed 7 years ago by mojca (Mojca Miklavec)
Summary: | fix lack of optimization in compiling pymol on clang compilers → pymol: fix lack of optimization in compiling pymol on clang compilers |
---|
comment:10 Changed 7 years ago by mojca (Mojca Miklavec)
Keywords: | science removed |
---|
comment:11 Changed 7 years ago by mojca (Mojca Miklavec)
Cc: | mojca added |
---|
comment:12 Changed 7 years ago by mojca (Mojca Miklavec)
One question. Given that the latest commit seems no newer than the released version: is there any reason to stick with fetching from SVN? Would it perhaps make sense to switch to fetching the tarball from https://sourceforge.net/projects/pymol/files/pymol/2/ perhaps?
This doesn't need to be done right now, but fetching from SVN is slightly more annoying and I would only do it if there's a good reason for it, in most cases that's done when there's no release for a very long time and you need to get the latest version to even be able to compile the software.
comment:13 Changed 7 years ago by jwhowarth
Owner: | set to jwhowarth |
---|---|
Resolution: | → fixed |
Status: | new → closed |
Portfile diff to restore -O3 optimization to pymol build on darwin