Skip to content

Commit 9049935

Browse files
committed
Merge bitcoin/bitcoin#22645: scripts: prevent GCC optimising test symbols in test-symbol-check
5449d44 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 5449d44 Tree-SHA512: 3a26c5c3a5f2905fd0dd90892470e241ba625c0af3be2629d06d5da3a97534c1d6a55b796bbdd41e2e6a26a8fab7d981b98c45d4238565b0eb7edf3c5da02007
2 parents e35c4a3 + 5449d44 commit 9049935

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

contrib/devtools/test-symbol-check.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,20 +73,21 @@ def test_ELF(self):
7373
(1, executable + ': NEEDED library libutil.so.1 is not allowed\n' +
7474
executable + ': failed LIBRARY_DEPENDENCIES'))
7575

76-
# finally, check a conforming file that simply uses a math function
76+
# finally, check a simple conforming binary
7777
source = 'test3.c'
7878
executable = 'test3'
7979
with open(source, 'w', encoding="utf8") as f:
8080
f.write('''
81-
#include <math.h>
81+
#include <stdio.h>
8282
8383
int main()
8484
{
85-
return (int)pow(2.0, 4.0);
85+
printf("42");
86+
return 0;
8687
}
8788
''')
8889

89-
self.assertEqual(call_symbol_check(cc, source, executable, ['-lm']),
90+
self.assertEqual(call_symbol_check(cc, source, executable, []),
9091
(0, ''))
9192

9293
def test_MACHO(self):

0 commit comments

Comments
 (0)