GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — BLD: Add clang `-ftrapping-math` also for `compiler_so` by seberg · Pull Request #19479 · numpy/numpy

Conversation

@seberg

@seberg seberg commented Jul 14, 2021

Copy link
Copy Markdown
Member

Apparently, there is a second compiler_so that is actually the
main compiler being used, and modifying only the first one is just
futile.

Closes gh-19427 in theory. In practice, I somewhat expect that clang only decided that warning flags are worth any consideration so recently, that this will just break old clang versions


I have tested that this works: gh-19476 passes with this. What is the minimum clang version we actually support? I expect this needs at least version 10 (which is fairly new), but I can't compile locally on version 9. (I guess the CI run will tell me that this won't actually work :/)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@github-actions github-actions Bot added the 36 - Build Build related PR label Jul 14, 2021
@seberg

seberg commented Jul 14, 2021

Copy link
Copy Markdown
Member Author

I somewhat expected this would fail, but I don't understand it. The mac CI build uses Clang 11.0.0, my local build uses Debian clang version 11.0.1-2, which doesn't really sound like 11.0.0 should reject a flag that my version is happy to accept.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@seberg seberg changed the title BLD: Add clang -ffp-exception-behavior=strict also for _so BLD: Add clang -ftrapping-math also for _so Jul 15, 2021
@seberg
BLD: Use -ftrapping-math for clang and for _so
e7d1841
Apparently, there is a second `compiler_so` that is actually the
main compiler being used, and modifying only the first one is just
futile.

The old try was `-ffp-exception-behavior=strict`, but that seems to
be a fairly new addition (and doesn't even work on MacOS with 10.0)

`-ftrapping-math` seems to be the older, equivalent option.
@seberg
seberg force-pushed the fixup-clang-flag-try branch from 7eae81e to e7d1841 Compare July 15, 2021 01:58
@seberg
DOC: Modify comment to note that the volatile can eventually be removed
3b564f7
@seberg

seberg commented Jul 15, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

I also confirmed that it does indeed fix gh-18005 for my clang version, so changing that comment.

I expect the -ftrapping-math will now work correctly (and the docs mention that flag at least for clang 5.0 – that is the furthest back I checked)

EDIT: But, this probably needs a release note. And I am not sure what to do about the 1.21 release notes being incorrect...

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@seberg seberg added the 56 - Needs Release Note. Needs an entry in doc/release/upcoming_changes label Jul 15, 2021
@seberg seberg closed this Jul 15, 2021
@seberg seberg reopened this Jul 15, 2021
@seberg
DOC: Add release note for -ftrapping-math on clang
f1d082c
@seberg

seberg commented Jul 15, 2021

Copy link
Copy Markdown
Member Author

So for those checking this: https://clang.llvm.org/docs/UsersManual.html#cmdoption-ffp-exception-behavior explains that -ffp-excetion-behaviour=strict should be good for us while: https://clang.llvm.org/docs/UsersManual.html#cmdoption-fdenormal-fp-math (go slightly lower, the anchor is missing), says:

Control floating point exception behavior. -fno-trapping-math allows optimizations that assume that floating point operations cannot generate traps such as divide-by-zero, overflow and underflow.

and

The option -ftrapping-math behaves identically to -ffp-exception-behavior=strict.


I think the main question is basically the old question: Is modifying self.compiler and self.compiler_so reasonable? The self.compiler_so does work and gets used.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@seberg seberg removed the 56 - Needs Release Note. Needs an entry in doc/release/upcoming_changes label Jul 15, 2021
@seberg seberg changed the title BLD: Add clang -ftrapping-math also for _so BLD: Add clang -ftrapping-math also for compiler_so Jul 15, 2021
@mattip

mattip commented Jul 18, 2021

Copy link
Copy Markdown
Member

I think we should put this PR in. @charris, thoughts?

Is modifying self.compiler and self.compiler_so reasonable? The self.compiler_so does work and gets used.

Well, this PR does not add a new modification, it fixes the current one.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@charris

charris commented Jul 18, 2021

Copy link
Copy Markdown
Member

I don't have a problem putting this in. What is the question about 1.21.x release notes?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@seberg

seberg commented Jul 18, 2021

Copy link
Copy Markdown
Member Author

@charris my question was whether we should do something about them being incorrect?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@charris

charris commented Jul 18, 2021

Copy link
Copy Markdown
Member

my question was whether we should do something about them being incorrect?

I tend to regard release notes as history, flaws and all, after the release. We could backport this change if you wish and mention that in a later release note.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@seberg

seberg commented Jul 18, 2021

Copy link
Copy Markdown
Member Author

OK, sounds good. I am hesitant about backporting, since I have no idea if this may have side-effects for some.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mattip
mattip merged commit 6388471 into numpy:main Jul 18, 2021
@mattip

mattip commented Jul 18, 2021

Copy link
Copy Markdown
Member

Thanks @seberg

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@seberg
seberg deleted the fixup-clang-flag-try branch July 18, 2021 20:27
@seberg

This comment was marked as outdated.

Sign in to view
This was referenced Feb 9, 2022
pot installation fails with numpy < 1.20 PythonOT/POT#308
Closed
Change pyproject.toml to require the oldest possible numpy version to prevent future backwards-breaking numpy ABI changes PythonOT/POT#346
Closed
rgommers added a commit to rgommers/numpy that referenced this pull request Jun 27, 2023
@rgommers
BLD: use -ftrapping-math with Clang on macOS
4d26f3d
The distutils build also uses this flag, and it avoids some problems
with `floor_divide` and similar functions (xref numpygh-19479).
rgommers added a commit to rgommers/numpy that referenced this pull request Jun 27, 2023
@rgommers
BLD: use -ftrapping-math with Clang on macOS
928cd74
The distutils build also uses this flag, and it avoids some problems
with `floor_divide` and similar functions (xref numpygh-19479).

For older macOS arm64 Clang versions, the flag does get accepted, but then
gets overridden because it's not actually supported - which yields these
warnings:
```
warning: overriding currently unsupported use of floating point exceptions on this target [-Wunsupported-floating-point-opt]
```
Since they're a little annoying to suppress and will go away when updating to
the latest XCode version, we'll ignore these warnings.
@rgommers rgommers mentioned this pull request Jun 27, 2023
BLD: use -ftrapping-math with Clang on macOS in Meson build #24060
Merged
charris pushed a commit to charris/numpy that referenced this pull request Jul 14, 2023
@rgommers @charris
BLD: use -ftrapping-math with Clang on macOS
621390f
The distutils build also uses this flag, and it avoids some problems
with `floor_divide` and similar functions (xref numpygh-19479).

For older macOS arm64 Clang versions, the flag does get accepted, but then
gets overridden because it's not actually supported - which yields these
warnings:
```
warning: overriding currently unsupported use of floating point exceptions on this target [-Wunsupported-floating-point-opt]
```
Since they're a little annoying to suppress and will go away when updating to
the latest XCode version, we'll ignore these warnings.
@charris charris mentioned this pull request Jul 14, 2023
BLD: use -ftrapping-math with Clang on macOS #24182
Merged
@mattip mattip mentioned this pull request Jul 3, 2025
BLD: use github to build macos-arm64 wheels with OpenBLAS and update to 0.3.30 #29069
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

36 - Build Build related PR

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

(distutils) The -ffp-exception-behavior=strict setting does not actually work (reliably)

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@seberg @mattip @charris
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.