-
-
Notifications
You must be signed in to change notification settings - Fork 34.4k
[3.14] gh-148284: Block inlining of gigantic functions in ceval.c for clang 22 #148326
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Fix high stack consumption in Python's interpreter loop on Clang 22 by setting function limits for inlining. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -7244,6 +7244,34 @@ if test "$have_glibc_memmove_bug" = yes; then | |||||||||||||
| for memmove and bcopy.]) | ||||||||||||||
| fi | ||||||||||||||
|
|
||||||||||||||
| AC_MSG_CHECKING([if we need to manually block large inlining in ceval.c]) | ||||||||||||||
| AC_RUN_IFELSE([AC_LANG_SOURCE([[ | ||||||||||||||
| int main(void) { | ||||||||||||||
| // See gh-148284: | ||||||||||||||
| // Clang 22 seems to have interactions with inlining and the stackref buffer | ||||||||||||||
| // which cause 40kB of stack usage on x86-64 in buggy versions of _PyEval_EvalFrameDefault | ||||||||||||||
| // in computed goto interpreter. The normal usage seen is normally 1-2kB. | ||||||||||||||
| #if defined(__clang__) && (__clang_major__ == 22) | ||||||||||||||
| return 1; | ||||||||||||||
| #else | ||||||||||||||
| return 0; | ||||||||||||||
| #endif | ||||||||||||||
| } | ||||||||||||||
| ]])], | ||||||||||||||
| [block_huge_inlining_in_ceval=no], | ||||||||||||||
| [block_huge_inlining_in_ceval=yes], | ||||||||||||||
| [block_huge_inlining_in_ceval=undefined]) | ||||||||||||||
| AC_MSG_RESULT([$block_huge_inlining_in_ceval]) | ||||||||||||||
|
|
||||||||||||||
| if test "$block_huge_inlining_in_ceval" = yes && test "$ac_cv_computed_gotos" = yes; then | ||||||||||||||
| // This number should be tuned to follow the C stack consumption | ||||||||||||||
| // in _PyEval_EvalFrameDefault on computed goto interpreter. | ||||||||||||||
|
Comment on lines
+7267
to
+7268
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest adding "Suppress inlining of functions whose stack size exceeds 512 bytes." to explain the purpose of this option:
Suggested change
The Clang option is documented at: https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-finline-max-stacksize |
||||||||||||||
| CFLAGS_CEVAL="-finline-max-stacksize=512" | ||||||||||||||
| else | ||||||||||||||
| CFLAGS_CEVAL="" | ||||||||||||||
| fi | ||||||||||||||
| AC_SUBST([CFLAGS_CEVAL]) | ||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you document this new variable in https://docs.python.org/dev/using/configure.html#envvar-CFLAGS_ALIASING ?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a way to make this a private variable? I don't feel good exposing it for now. |
||||||||||||||
|
|
||||||||||||||
| if test "$ac_cv_gcc_asm_for_x87" = yes; then | ||||||||||||||
| # Some versions of gcc miscompile inline asm: | ||||||||||||||
| # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46491 | ||||||||||||||
|
|
||||||||||||||
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.
Reformat to 80 columns and minor cleanup: