GeezerVison is showing github.com — gh-128902: Fix check for fallthrough attribute support by jmroot · Pull Request #128903 · python/cpython
Conversation
jmroot
commented
Jan 16, 2025
•
edited by bedevere-app
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Clang versions prior to 10 (which corresponds to Apple Clang 12) do not support the GCC extension syntax __attribute__((fallthrough)), but do evaluate __has_attribute(fallthrough) to 1 because they support the C++11 style syntax [[fallthrough]]. The only way to tell if the GCC style syntax is supported is thus to check the clang version.
Ref: llvm/llvm-project@1e0affb
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Clang versions prior to 10 (which corresponds to Apple Clang 12) do not
support the GCC extension syntax __attribute__((fallthrough)), but do
evaluate __has_attribute(fallthrough) to 1 because they support the
C++11 style syntax [[fallthrough]]. The only way to tell if the GCC
style syntax is supported is thus to check the clang version.
Ref: llvm/llvm-project@1e0affb
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.
LGTM.
@pablogsal @ambv @ned-deily: I would appreciate if one of you can also review this change, since I don't have access to macOS.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
@jmroot Thanks for the PR, as always. On the surface it looks OK to me but I was not successful in creating a failing test environment to check the fix. Following the comment in the PR, I tested with the current HEAD of cpython main (3.14) on macOS 10.14.6 with both the relevant Apple Command Line Tools - LLVM version 10.0.1 (clang-1001.0.46.4) - and then with MacPorts clang version 9.0.1 by removing a _Py_FALLTHROUGH guard and with ./configure --enable-safety to enable -Wimplicit-fallthrough. No fallthrough warnings were generated with either compiler with or without the PR. However, on a current macOS / Xcode configuration (macOS 15.2 / Apple clang version 16.0.0 (clang-1600.0.26.6)), the unguarded fallthrough is warned with or without the PR, as expected. I may be doing something wrong in my testing but it would be good to ensure the comment is accurate. Can you say how this issue arose and how to reproduce?
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Can you say how this issue arose and how to reproduce?
It arose in routine builds of the 3.14 alphas on our buildbots. Here's the first log I found demonstrating the issue: https://build.macports.org/builders/ports-10.9_x86_64-builder/builds/299390/steps/install-port/logs/stdio
I think unknown attributes are supposed to be ignored, so there may be another bug in the mix causing the build failures. It seems pretty clear from the LLVM commit that clang versions less than 10 don't support the attribute, but perhaps only some are harmed by it.
|
ned-deily reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Thanks for the buildbot log which shows the failure when building on macOS 10.9 with the default Command Line Tools for that version. I am able to reproduce the failure on 10.9 and can verify that the PR does fix that failure. So it may be that the comments about particular clang versions are overly restrictive but, given that these older OS and compiler versions are no longer supported upstream and, more importantly, that the fallthrough warnings will show up on builds of the same source with newer compilers, let's not worry about the exact wording.
BTW, while this PR gets past this problem when building on macOS 10.9, there appears to be other build issues using this compiler and SDK on 10.9 (i.e. SSE4.1 instruction set not enabled in Modules/_hacl) that may require you to move to a newer version of clang for 3.14.
|
jmroot reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
vstinner
vstinner approved these changes
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|