-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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
Consider adding -Werror=unguarded-availability-new
to compiler flags for Apple platforms
#100384
Comments
Ignore my comment about 3.8. 3.8 doesn't have properly weak linking support at all (at least not in |
3.9 and later should have weak linking support in posixmodule, this was introduced while working on support for arm64 and Universal 2 binaries. That said, newer SDKs can introduce new APIs that require changes to that. |
Copying over some of my commentary from #128135 Here's an initial patch 36c7da4
|
What we could do is integrate this new flag as part of our CI without necessarily making it part of the |
Instead of |
Ah cool, thanks @ned-deily. I was hoping there was something like that. Do you have any other concerns before I post the patch as a pull request? I think my most important open question is
Is |
The Xcode C toolchain is clang. There are an extremely small number of people not using clang when targeting Apple platforms. I'm pretty sure CPython's build system implicitly requires clang for Apple targets. |
We use clang on build bots sanitizers (UBSan, TSan and ASan) so yes we use |
Like with this tooling? |
I think the concern about it affecting users is addressed by using |
If I understand the implications correctly, I think we should stick with Also we specifically now check and report on supported platform / compiler combinations (see |
Generate a build error on ``unguarded-availability`` in portable macOS builds (i.e. using MACOSX_DEPLOYMENT_TARGET), preventing invalid use of symbols that are not available in older versions of the OS.
…ython#128155) Generate a build error on ``unguarded-availability`` in portable macOS builds (i.e. using MACOSX_DEPLOYMENT_TARGET), preventing invalid use of symbols that are not available in older versions of the OS.
Feature or enhancement
Runtime crashes like #97897 could be prevented by turning clang's
unguaded-availability-new
warning into a fatal compile error. This can be done by adding-Werror=unguarded-availability-new
to compiler flags.Essentially what this warning does is cross reference undefined symbols against symbols defined in the targeted Apple SDK. If it sees a symbol introduced in a newer SDK version and that symbol isn't weakly referenced/linked, you get a warning.
-Werror
upconverts it to a fatal compiler error.If you add this flag to release builds, the compiler prevents you from shipping binaries that ship unguarded symbol usage for targeted SDK versions. i.e. it prevents run-time crashes when binaries run on older Apple OS versions.
If you enable this setting today, you may find the 3.8 branch isn't properly gating use of
mkfifoat
andmknodat
. (Although this may be an oddity from python-build-standalone and not a CPython bug.)cc @ned-deily
The advantages of having this additional warning is to catch regressions such as:
ptsname_r
is not checked at runtime on macOS #123797Linked PRs
unguarded-availability
in Darwin builds #128155The text was updated successfully, but these errors were encountered: