-
-
Notifications
You must be signed in to change notification settings - Fork 31k
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
gh-128902: Fix check for fallthrough attribute support #128903
Conversation
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.
@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 |
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. |
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. |
Thanks for your fix @jmroot. |
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