aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorW. J. van der Laan <laanwj@protonmail.com>2021-08-18 17:16:02 +0200
committerW. J. van der Laan <laanwj@protonmail.com>2021-08-18 17:16:11 +0200
commit90499358e91e03cf2946eb996f6102cb46cde330 (patch)
treea987a59063acca4d0b217d5f31965f2c64e3da09
parente35c4a3d80578e8feff1f1ae5db81d3c0992a865 (diff)
parent5449d44e37982fcd5251fd47873c5f7d34c39fc9 (diff)
downloadbitcoin-90499358e91e03cf2946eb996f6102cb46cde330.tar.xz
Merge bitcoin/bitcoin#22645: scripts: prevent GCC optimising test symbols in test-symbol-check
5449d44e37982fcd5251fd47873c5f7d34c39fc9 scripts: prevent GCC optimising test symbols in test-symbol-check (fanquake) Pull request description: I noticed in #22381 that when the test-symbol-check target was being built with Clang and run in the CI it would fail due to using a too-new version of `pow` (used [here](https://github.com/bitcoin/bitcoin/blob/d67330d11245b11fbdd5e2dd5343ee451186931e/contrib/devtools/test-symbol-check.py#L85)). Our CIs use Focal (glibc 2.31) and the version of `pow` was the optimized version introduced in [glibc 2.29](https://lwn.net/Articles/778286/): ```bash * Optimized generic exp, exp2, log, log2, pow, sinf, cosf, sincosf and tanf. ``` This made sense, except for that if it was failing when built using Clang, why hadn't it also been failing when being built with GCC? Turns out GCC is optimizing away that call to `pow` at all optimization levels, including `-O0`, see: https://godbolt.org/z/53MhzMxT7, and this has been the case forever, or at least since GCC 5.x. Clang on the other hand, will only optimize away the `pow` call at `-O1` and `-O2`, not `-O0`: https://godbolt.org/z/Wbnqj3q6c. Thus when this test was built with Clang (we don't pass `-O` so we default to `-O0`) it was failing in the CI environment, because it would actually have a call to the "new" `pow`. Avoid this issue by using a symbol that won't be optimized away, or that we are unlikely to ever have versioning issues with. ACKs for top commit: laanwj: ACK 5449d44e37982fcd5251fd47873c5f7d34c39fc9 Tree-SHA512: 3a26c5c3a5f2905fd0dd90892470e241ba625c0af3be2629d06d5da3a97534c1d6a55b796bbdd41e2e6a26a8fab7d981b98c45d4238565b0eb7edf3c5da02007
-rwxr-xr-xcontrib/devtools/test-symbol-check.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/contrib/devtools/test-symbol-check.py b/contrib/devtools/test-symbol-check.py
index 7d83c5f751..2da7ae793d 100755
--- a/contrib/devtools/test-symbol-check.py
+++ b/contrib/devtools/test-symbol-check.py
@@ -73,20 +73,21 @@ class TestSymbolChecks(unittest.TestCase):
(1, executable + ': NEEDED library libutil.so.1 is not allowed\n' +
executable + ': failed LIBRARY_DEPENDENCIES'))
- # finally, check a conforming file that simply uses a math function
+ # finally, check a simple conforming binary
source = 'test3.c'
executable = 'test3'
with open(source, 'w', encoding="utf8") as f:
f.write('''
- #include <math.h>
+ #include <stdio.h>
int main()
{
- return (int)pow(2.0, 4.0);
+ printf("42");
+ return 0;
}
''')
- self.assertEqual(call_symbol_check(cc, source, executable, ['-lm']),
+ self.assertEqual(call_symbol_check(cc, source, executable, []),
(0, ''))
def test_MACHO(self):