Compiler flags detection in setup.py is incorrect
Detection of compiler flags is performed by running distutils.ccompiler.new_compiler()
which is not necessarily the correct one used for actual compilation of FFC and JITing.
This is a show-stopper for some hashdist installs with custom compiler and appeared already as https://bitbucket.org/fenics-project/dolfin/issue/449 and http://fenicsproject.org/pipermail/fenics-support/2015-February/001277.html.
Comments (9)
-
-
reporter The following patch could do the job on FFC side
diff --git a/INSTALL b/INSTALL index df0423c..0cb5648 100644 --- a/INSTALL +++ b/INSTALL @@ -5,6 +5,10 @@ To install FFC, type This will install FFC in the default Python path of your system, something like /usr/lib/python2.6/site-packages/. +To specify C++ compiler and/or compiler flags used for compiling UFC +and JITing, set environment variables CXX, CXXFLAGS respectively +before invoking setup.py. + The installation script requires the Python module distutils, which for Debian users is available with the python-dev package. Other dependencies are listed in the file README. diff --git a/setup.py b/setup.py index 9dd02e1..21bfde9 100644 --- a/setup.py +++ b/setup.py @@ -231,6 +231,9 @@ def run_install(): # Check that compiler supports C++11 features cc = new_compiler() + CXX = os.environ.get("CXX") + if CXX: + cc.set_executables(compiler_so=CXX) CXX_FLAGS = os.environ.get("CXXFLAGS", "") if has_cxx_flag(cc, "-std=c++11"): CXX_FLAGS += " -std=c++11"
@johannes_ring, could you try it?
Note the tricky thing in
distutils/unixccompiler.py:_compile
, it usescompiler_so
, notcompiler
norcompiler_cxx
.The rest would be to export CXX on hashdist side.
-
reporter @johannes_ring, any progress here?
-
Just to chime in from MacPorts but this was a surprising (perhaps more surprising that this isn't automatically solved within distutils) bug.
-
Thanks @blechta, this looks good to me. Can you make a pull request?
-
reporter @johannes_ring Ok. Can I have write access to FFC repo so that we don't have to deal with other repo?
-
Yes @blechta, I assume that is fine since you already have write access to the DOLFIN repository. I have given you write access to the FFC repository now.
-
- changed status to resolved
Fixed in d7523e79bddb4544526570207e55dff5ac109505.
-
- removed milestone
Removing milestone: 1.6 (automated comment)
- Log in to comment
Exporting
CXXFLAGS='-std=c++11’
before running a python fenics script is an effective workaround but the issue remains valid.