-
Notifications
You must be signed in to change notification settings - Fork 38.7k
refactor: Work around gcc compiler bug 90348 #15959
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
Conversation
|
Wouldn't it be better to just add |
The one doesn't rule out the other, though I would personally feel more comfortable with that solution. It's unclear to me what else this bug might potentially affect. |
|
Concept ACK on working around the GCC issue but I agree with @luke-jr and @laanwj that introducing I think we should add |
|
Ok, marking up for grabs for someone to change the build system. |
|
I would expect -fno-inline-small-functions to be devastating for performance and I also believe would not completely work around the bug. I believe -fstack-reuse=none would be a more correct, and less impacting, workaround. |
|
I wonder if there's a reliable compile test we could have configure run to detect the actual bug? |
|
The test case from the gcc bug wouldn't work? And if disabling fstack-reuse isn't too expensive, we might just do it unconditionally? |
|
I would also expect that -fstack-reuse=none has less impact than -fno-inline-small-functions, but benchmarks would be nice. I'll PR the reproduction bug as a unit test. |
|
stack-reuse=none also has the advantage of turning some lifetime management bugs into less-bugs (which is AFAICT why the option exists). I would expect it to increase stack usage, which right now we're not currently particularly careful with. |
|
@luke-jr on reliability, I think we'd be better off detecting versions than trying to use the test case. Unfortunately, it's unclear what versions this will be fixed in: (so far) it appears that this is actually hard for GCC to fix without severely gimping optimization. FWIW, the test case does not fail on PPC but I am moderately confident that bug exists there (it might be just that the larger redzone on PPC results in a different stack layout). |
|
Yes, |
|
Thanks everyone for the input, closing in favour of
|
faf38bc build with -fstack-reuse=none (MarcoFalke) Pull request description: All versions of gcc that we commonly use for building are subject to bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90348. To work around that, set `-fstack-reuse=none` for all builds. See #15959 (comment) This option does not exist for clang https://clang.llvm.org/docs/ClangCommandLineReference.html#target-independent-compilation-options, but it does for gcc https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html ACKs for commit faf38b: Tree-SHA512: f5597583402d31ea7b89ac358a6f4a537bbb82a1dde2bd41bac65ee0fd88c7af75ee4c24c6b8eed6b139bf4dbf07ab2987f8fc30fb3eab179cd2d753a8a2a47d
faf38bc build with -fstack-reuse=none (MarcoFalke) Pull request description: All versions of gcc that we commonly use for building are subject to bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90348. To work around that, set `-fstack-reuse=none` for all builds. See bitcoin#15959 (comment) This option does not exist for clang https://clang.llvm.org/docs/ClangCommandLineReference.html#target-independent-compilation-options, but it does for gcc https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html ACKs for commit faf38b: Tree-SHA512: f5597583402d31ea7b89ac358a6f4a537bbb82a1dde2bd41bac65ee0fd88c7af75ee4c24c6b8eed6b139bf4dbf07ab2987f8fc30fb3eab179cd2d753a8a2a47d
faf38bc build with -fstack-reuse=none (MarcoFalke) Pull request description: All versions of gcc that we commonly use for building are subject to bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90348. To work around that, set `-fstack-reuse=none` for all builds. See bitcoin#15959 (comment) This option does not exist for clang https://clang.llvm.org/docs/ClangCommandLineReference.html#target-independent-compilation-options, but it does for gcc https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html ACKs for commit faf38b: Tree-SHA512: f5597583402d31ea7b89ac358a6f4a537bbb82a1dde2bd41bac65ee0fd88c7af75ee4c24c6b8eed6b139bf4dbf07ab2987f8fc30fb3eab179cd2d753a8a2a47d
The gcc compiler creates "optimized" code (
-finline-small-functions) that modifiesina second time after it has been initialized with random bits.Working around the bug can be achieved in different ways: Moving
ininto a newconstarray, rearranging the loop to break the optimization, or moving the array into the outer scope, ...This fix is needed to release 0.18.1 on 32 bit platforms, thus needs backport.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90348
Fixes #14580