modelon-community / Assimulo

Assimulo is a simulation package for solving ordinary differential equations.
https://jmodelica.org/assimulo/index.html
GNU Lesser General Public License v3.0
70 stars 17 forks source link

setup.py: separate fortran flags #46

Closed jschueller closed 2 years ago

jschueller commented 2 years ago

Avoid including fortran flags into c flags It fixes compilation with clang which does not know how to ignore the gcc fortran flags and returns an error.

modelonrobinandersson commented 2 years ago

@jschueller I think the changes look good, I propose adding changelog before merging this.

jschueller commented 2 years ago

done

PeterMeisrimelModelon commented 2 years ago

This actually breaks building on mac, would require an extra if to get the old behavior for platform == 'mac'

jschueller commented 2 years ago

what's the error ? I actually got this error and fixed it for mac specifically

modelonrobinandersson commented 2 years ago

what's the error ? I actually got this error and fixed it for mac specifically

It looks like this removes the flag -pthread to gcc

build/src.macosx-10.15-x86_64-3.9/assimulo/thirdparty/hairer/dopri5module.c:84:10: fatal error: threads.h: No such file or directory
   84 | #include <threads.h>
      |          ^~~~~~~~~~~
compilation terminated.

When I compare the gcc command, the flag -pthread is no longer there.

jschueller commented 2 years ago

maybe you passed -pthread via --extra-fortran-compile-flags, in that case indeed it should be passed via --extra-c-flags

modelonrobinandersson commented 2 years ago

extra-fortran-compile-flags

Looked at this more in detail I noticed I don't pass pthread at all but this is how I usually invoke the build on mac python setup.py bdist_wheel --superlu-home=<a local path>/superlu_install --sundials-home=<a local path>/sundials --sundials-with-superlu=True --blas-home=<a local path>/blas --lapack-home=<a local path>/lapack --extra-fortran-compile-flags="-DF2PY_THREAD_LOCAL_DECL=__thread -std=legacy" --with_openmp=True

But I cant see why your changes make the build system unable to find pthread

jschueller commented 2 years ago

its the F2PY_THREAD_LOCAL_DECL define, it should be passed via c flags now

PeterMeisrimelModelon commented 2 years ago

You are correct, thanks! Changing it on our end fixes the issue.