-
Notifications
You must be signed in to change notification settings - Fork 279
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix GCC 5 Builds #2939
Fix GCC 5 Builds #2939
Conversation
Hi @matthewturk @cphyc, I saw your PRs in #2575 and #2610 and am not an expert in the places I touch here. Help & hints welcome :) |
ce27c43
to
b7e178d
Compare
@RevathiJambunathan does this PR work for you, with respect to #2892? python3 -m pip uninstall yt
python3 -m pip install -U pip
python3 -m pip install git+https://github.com/ax3l/yt.git@fix-gcc5 |
tests/travis_install.sh
Outdated
@@ -42,4 +43,4 @@ fi | |||
# Step 3: install yt | |||
$PIP install -e . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I didn't know that! I believe a simple fix would be to use $PIP install .
instead, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just found out as well.
Even more complicated. According to my understanding, PEP517 packages should be installed locally like this:
python3 -m pip wheel .
python3 -m pip install *whl
brave new world, I guess.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wow. Sorry for asking the naive question, but by "PEP517 project" you mean any project with a pyproject.toml
file, right ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep... I know...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for bringing this up, I was the person who introduced pyproject.toml to the project but wasn't aware of this :/
5fd256b
to
a231da6
Compare
It seems the bug triggered on OSX may be fixed by replacing |
I am sorry, I pushed onto your branch by mistake. I meant to push on my fork instead… |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The compiler flags are wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix compiler flags for OpenMP and C++ std.
@cphyc can you please add the |
setup.py
Outdated
@@ -36,8 +37,20 @@ | |||
with open("README.md") as file: | |||
long_description = file.read() | |||
|
|||
OMP_CONFIG = defaultdict( | |||
lambda: ["-fopenmp"], {"unix": ["-fopenmp"], "msvc": ["/openmp"]} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment on @cphyc's change here:
unix: this is a bit optimistic but will work as before for GCC and Clang at least
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
furthermore: AppleClang does not support OpenMP on a vanilla macOS.
If you want to unconditionally add an OpenMP prerequisite, you could install brew install libomp
on CI (and need to document this new dependency on macOS). with AppleClang, this will still not be a -fopenmp
flag then, but another set of flags.
Practically, one might want to implement a compiler check and keep OpenMP optional. Maybe instead of duplicating and guessing -fopenmp
here, refactor check_for_openmp()
in setupext.py
to return the OpenMP flags (compiler and linker) it found to be working?
@cphyc if compile errors occur in the yt cythonization process then the overall build process does not always abort. I am no cython / distutils expert, but ideally this should be addressed as well, in an independent PR: users get faulty installs because such errors are not aborting the build process and get lost between many build output messages. Ideally, abort on first build error. |
@ax3l Thank you for this PR!
|
setup.py
Outdated
) | ||
|
||
_COMPILER = get_default_compiler() | ||
|
||
if check_for_openmp(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check_for_openmp()
makes some assumptions about openmp flags. As a result your code will only be called only if -fopenmp
works, otherwise it will default to []
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, the assumption about flags (tested and applied) should be in one place, e.g. check_for_openmp
. we currently duplicate the flags (and tested assumptions).
note that I did not put this into the change set.
Hi there, @ax3l! Thanks for updating this PR. There are currently no PEP 8 issues detected in this Pull Request. Hooray! 🎆 Comment last updated at 2020-12-02 16:19:36 UTC |
@cphyc I simplified and fixed the compiler logic changes you pushed on this PR. If you don't mind, I would love to not add features in this bugfix PR. If you like to widen the support for compilers and OpenMP to more platforms, can we do so in a follow-up PR? I would suggest to improve the compile tests performed in |
f0a7b1e
to
9647efd
Compare
Oh my goodness, thank you for taking such a close look at this. C++ ABIs
and whatnot are things I had not even considered when I was looking at the
level of C++ support we needed.
(Although, maybe I'm also a bit oversensitive on this because I remember
the endless discussion of C++ ABI breakages back in the early 2000s... ;-)
…On Fri, Oct 9, 2020 at 3:19 PM Axel Huebl ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In setup.py
<#2939 (comment)>:
> @@ -65,6 +70,7 @@
"FIXED_INTERP": "yt/utilities/lib/fixed_interpolator.cpp",
"ARTIO_SOURCE": glob.glob("yt/frontends/artio/artio_headers/*.c"),
"CPP14_FLAG": CPP14_FLAG,
+ "CPP03_FLAG": CPP03_FLAG,
If possible, build all binaries with the same C++ standard. Especially
between C++03 and C++11 were ABI breaks in the STL and with MSVC the math
libs and STL will also cause problems.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2939 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAVXO624F6MPWL7MEKRIRTSJ5V4HANCNFSM4SJICCGA>
.
|
According to storpipfugl/pykdtree#51, this is an issue on pykdtree's side. One solution is to not use openmp when compiling on MacOSX. This can be done by setting I have tried that in cphyc@2ad8d1b, and it seems to do the trick, but then yt's build fails on OSX... I am still investigating. |
Good news, with the HEAD of https://github.com/cphyc/yt/tree/fix-gcc5 (cphyc@af550d9), the OSX job now builds! Note that it still doesn't work with Windows. [EDIT]: now working with Windows |
I've issued my fixes in another PR (#2943), which hopefully should contribute to make the tests pass on this one. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Provided the tests pass, I would be happy to merge this!
cdef extern from "<cmath>" namespace "std": | ||
bint isnormal(double x) nogil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: for some reason, Visual Studio doesn't happy about this. However, if we replace by
cdef extern from "<cmath>" namespace "std": | |
bint isnormal(double x) nogil | |
from libc.math cimport isnormal |
or
cdef extern from "<cmath>" namespace "std": | |
bint isnormal(double x) nogil | |
cdef extern from "<math.h>": | |
bint isnormal(double) nogil |
it compiles.
/isort |
@neutrinoceros @Xarthisius @ax3l I have pushed some more commits to make the Windows build build, do you think this is ready to go? I have added some code myself so I don't feel like pushing the merge button ;) [EDIT]: I just realized b181ee4 may cancel the effect of 3347196 (esp. the [EDIT2]: I have now checked locally that the gcc-5 build works, so this is ready to go on my side |
adf26db
to
5adf61f
Compare
.travis.yml
Outdated
@@ -17,6 +17,8 @@ addons: | |||
- proj-bin | |||
- libgeos-dev | |||
- libopenmpi-dev | |||
- gcc-5 | |||
- g++-5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our testing setup change a bit with the merge of #2963, so this will need to be updated. However, I don't think we want to exclusively use gcc-5 in all our builds. Instead it would be worthwhile to set up a separate, compile-only test.
CPP03_CONFIG = defaultdict( | ||
lambda: ["-std=c++03"], {"unix": ["-std=c++03"], "msvc": ["/std:c++03"]} | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's used anywhere. At least git grep
doesn't show anything. If I'm not missing anything, let's not add things that might be used, but are not.
yt/utilities/lib/cykdtree/kdtree.pyx
Outdated
@@ -3,7 +3,7 @@ | |||
# distutils: sources = yt/utilities/lib/cykdtree/c_utils.cpp | |||
# distutils: depends = yt/utilities/lib/cykdtree/c_kdtree.hpp, yt/utilities/lib/cykdtree/c_utils.hpp | |||
# distutils: language = c++ | |||
# distutils: extra_compile_args = -std=c++03 | |||
# distutils: extra_compile_args = CPP14_FLAG |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it be CPP03_FLAG
that I couldn't find in previous comment ?
yt/utilities/lib/cykdtree/utils.pyx
Outdated
@@ -2,7 +2,7 @@ | |||
# distutils: sources = yt/utilities/lib/cykdtree/c_utils.cpp | |||
# distutils: depends = yt/utilities/lib/cykdtree/c_utils.hpp | |||
# distutils: language = c++ | |||
# distutils: extra_compile_args = -std=c++03 | |||
# distutils: extra_compile_args = CPP14_FLAG |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it be CPP03_FLAG that I couldn't find in previous comment ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It depends, this was changed assuming that one flag was better than two. In this approach, the default C++ language version is C++14. If we want to make minimal changes, then this should be replaced by CPP03_FLAG
. What do you think is best?
|
||
_COMPILER = get_default_compiler() | ||
|
||
omp_args, _ = check_for_openmp() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are distinguishing between compile and link flags inside check_for_openmp()
, shouldn't we do the same thing during cythonization, i.e. use two separate aliases? Otherwise, why return two variables?
These files includes C++11 features and GCC<6 does still default to C++98/03.
Co-authored-by: Corentin Cadiou <[email protected]>
/isort |
Thank you everyone for getting this PR done and merged. @RevathiJambunathan just a last check, does the yt |
Thank you so much for the fix!! We really appreciate your contribution. |
PR Summary
Use GCC 5 to trigger compiler errors with non-default C++14 compilers.
Follow-up to regressions from #2575 and #2610
Fix #2892
PR Checklist
black --check yt/
isort . --check --diff
flake8 yt/
flynt yt/ --fail-on-change --dry-run -e yt/extern