This causes modern glibc to unset math_errhandling MATH_ERRNO. gcc 12 also sets some other macros, but most of them are associated with flags ignored by clang, so without library examples, it is difficult to determine whether they should be set. I think setting this one macro is OK for now.
Details
Diff Detail
Event Timeline
Thanks for this! I'm adding some more reviewers to the list to help get this reviewed.
The patch doesn't seem to apply cleanly, so precommit CI isn't running on it. Can you rectify that? Also, the change needs test coverage of some kind.
clang/lib/Frontend/InitPreprocessor.cpp | ||
---|---|---|
1022 ↗ | (On Diff #396416) | Does GCC gate on -ffast-math? My testing suggests that -fno-math-errno alone is what sets this macro in GCC. |
GNU patch applies the patch with offset 20 and no fuzz on llvm-project main. However, I have included a rebase from llvm 13 to llvm main along with the tests in the new patch.
Also, the change needs test coverage of some kind.
Added.
clang/lib/Frontend/InitPreprocessor.cpp | ||
---|---|---|
1022 ↗ | (On Diff #396416) | I thought that MathErrno was not set if -ffast-math is specified, but that is apparently not true. It looks like lib/Driver/ToolChains/Clang.cpp should set FiniteMathOnly for -ffast-math, and the check below should be adjusted; otherwise it is wrong for -ffast-math -fno-finite-math-only. |
It looks like precommit CI is still failing on Clang :: Preprocessor/predefined-macros.c on Windows (the Debian failures look unrelated, but you should double-check just to be sure).
https://buildkite.com/llvm-project/premerge-checks/builds/72399#4ba61c84-15ff-462e-b861-8b7be5b09eb4
Also, when you submit the patch, can you use -U9999 to provide a bunch of context in the patch file? That makes code review easier within Phab.
Getting closer! Now there are new CI pipeline failures (some tests look like they need updating).
I don't have commit access; can someone commit this for me? Please use author "Alex Xu (Hello71) <alex_y_xu@yahoo.ca>". Thanks!
Thanks for the patch! I've landed on your behalf in f282b6809105075b65974989459ee420ecd406e9.