Skip to content

Conversation

fanquake
Copy link
Member

@fanquake fanquake commented Aug 6, 2021

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). Our CIs use Focal (glibc 2.31) and the version of pow was the optimized version introduced in glibc 2.29:

* 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.

@hebasto
Copy link
Member

hebasto commented Aug 6, 2021

Looks like the following comment should be updated as well

# finally, check a conforming file that simply uses a math function

@hebasto
Copy link
Member

hebasto commented Aug 6, 2021

In

self.assertEqual(call_symbol_check(cc, source, executable, ['-lm']),
why -lm, if pow has been dropped?

@fanquake fanquake force-pushed the gcc_optimising_pow branch from b6f32d0 to 7bcc3a0 Compare August 9, 2021 05:51
@fanquake fanquake force-pushed the gcc_optimising_pow branch from 7bcc3a0 to 5449d44 Compare August 9, 2021 06:00
@fanquake
Copy link
Member Author

fanquake commented Aug 9, 2021

why -lm, if pow has been dropped?
Looks like the following commit should be updated as well

Addressed.

@fanquake
Copy link
Member Author

Guix builds:

a9f14075ec8c67df4a09b07f40a9e3669376e33955c9759c0b09627979d137e9  guix-build-5449d44e3798/output/aarch64-linux-gnu/SHA256SUMS.part
2c1ca56f4c7761ea016d2ccc3ddc0f05a7bbcd5d2a8a166142a7e7294508c633  guix-build-5449d44e3798/output/aarch64-linux-gnu/bitcoin-5449d44e3798-aarch64-linux-gnu-debug.tar.gz
1ec17bc8017c2ee9cd3b23739db3ae180ed34cbea4dad925cd52e44c70e0271a  guix-build-5449d44e3798/output/aarch64-linux-gnu/bitcoin-5449d44e3798-aarch64-linux-gnu.tar.gz
2e3413803c4f2e461e13e0027b5c9dcedb256e5857074d651225680803771031  guix-build-5449d44e3798/output/arm-linux-gnueabihf/SHA256SUMS.part
b8c7b375eda6155cd3652c7986a26983191fac3c244aedf39bdd216bc0c967b2  guix-build-5449d44e3798/output/arm-linux-gnueabihf/bitcoin-5449d44e3798-arm-linux-gnueabihf-debug.tar.gz
3fb84540a214b504c38fe854db7f88ba5bb39fec78894b731a07b18ffc3f1480  guix-build-5449d44e3798/output/arm-linux-gnueabihf/bitcoin-5449d44e3798-arm-linux-gnueabihf.tar.gz
b4c1b9a2de37ac95fc03d12cb592740c78279ba7ef1ae8d89f90e9c91a24de06  guix-build-5449d44e3798/output/dist-archive/bitcoin-5449d44e3798.tar.gz
9f4dc2f282d1cc7cb05f3240d0ef0cceae5c827da5b2f1e9943f98e5a40fbac7  guix-build-5449d44e3798/output/powerpc64-linux-gnu/SHA256SUMS.part
051714775d3d03f131603698f26f70f633f5deda14b5ef440f47d3af81db7e59  guix-build-5449d44e3798/output/powerpc64-linux-gnu/bitcoin-5449d44e3798-powerpc64-linux-gnu-debug.tar.gz
f0ea3b294687ce3b6d39ff9a1c1ad74fc22a7d3c30ab10170a2da8b998c405d9  guix-build-5449d44e3798/output/powerpc64-linux-gnu/bitcoin-5449d44e3798-powerpc64-linux-gnu.tar.gz
074d54eeadd72413c4bc806c48ee4333712bed1b8220fcb155ae9a61e6d474a6  guix-build-5449d44e3798/output/powerpc64le-linux-gnu/SHA256SUMS.part
bccd331b452157223324d71444b9da13d855a180742fd7be124c99b9da006a93  guix-build-5449d44e3798/output/powerpc64le-linux-gnu/bitcoin-5449d44e3798-powerpc64le-linux-gnu-debug.tar.gz
da474c6adb99c412111afa2559b1d91233f7ee3922b00863a65b0335aa70fa61  guix-build-5449d44e3798/output/powerpc64le-linux-gnu/bitcoin-5449d44e3798-powerpc64le-linux-gnu.tar.gz
4049e8fce4cd411d0894301b777b37fcb4f3a790821e8d803e40aacbf0a27da9  guix-build-5449d44e3798/output/riscv64-linux-gnu/SHA256SUMS.part
b9468dac4321f223b67517b846c2b49f2740674078404a94e8612e198c30685b  guix-build-5449d44e3798/output/riscv64-linux-gnu/bitcoin-5449d44e3798-riscv64-linux-gnu-debug.tar.gz
cf053f309c675b9758ad8e639b587c450d47216d76e1e642aa7c4fcb83f6d097  guix-build-5449d44e3798/output/riscv64-linux-gnu/bitcoin-5449d44e3798-riscv64-linux-gnu.tar.gz
633a4b62a66dcbaa4bcde89d0531a963f41719c2171e0893d4fc1118c0877286  guix-build-5449d44e3798/output/x86_64-apple-darwin18/SHA256SUMS.part
bc058999df5d52bbdb10441e1229099828bf5e045b1d174ee704184bdbf956f2  guix-build-5449d44e3798/output/x86_64-apple-darwin18/bitcoin-5449d44e3798-osx-unsigned.dmg
f1e686b4b1f470899488d366eeff4cb39818295b3c43041d21fff1b4d8c81a8e  guix-build-5449d44e3798/output/x86_64-apple-darwin18/bitcoin-5449d44e3798-osx-unsigned.tar.gz
3bf71b5d3f52383be4e6cc387a469ef35d985a687d2cee61b65f536805a2944c  guix-build-5449d44e3798/output/x86_64-apple-darwin18/bitcoin-5449d44e3798-osx64.tar.gz
1149a6873737094da169642f0b6ddb7422d2fb68f3f4bfe742f36d152c0c4b41  guix-build-5449d44e3798/output/x86_64-linux-gnu/SHA256SUMS.part
8ba196a5fa992367a0ac79323dc61bd0939829e7d0749da8406ed0ee27775a09  guix-build-5449d44e3798/output/x86_64-linux-gnu/bitcoin-5449d44e3798-x86_64-linux-gnu-debug.tar.gz
910b9464f376c6cf92d67d459918b3b625a989469cbdfbc3b56ca1c55e4c6146  guix-build-5449d44e3798/output/x86_64-linux-gnu/bitcoin-5449d44e3798-x86_64-linux-gnu.tar.gz
6726d63017cc78f274988be2feaffc5de084d6c61a40abcb96e87fa5eda03de5  guix-build-5449d44e3798/output/x86_64-w64-mingw32/SHA256SUMS.part
2f851792c71053dac82fb3fae0a4074c07dc5f01f8614bce9a5cf6e79dbb2692  guix-build-5449d44e3798/output/x86_64-w64-mingw32/bitcoin-5449d44e3798-win-unsigned.tar.gz
45c79b7d48f131a0f53478b10cbc23db947148bc0991465b90c0665a6ce3e3c9  guix-build-5449d44e3798/output/x86_64-w64-mingw32/bitcoin-5449d44e3798-win64-debug.zip
187ab548c07ca849df62220f777dd83f25c200d89227276c3d852af181957602  guix-build-5449d44e3798/output/x86_64-w64-mingw32/bitcoin-5449d44e3798-win64-setup-unsigned.exe
2070ad765d21e17bbcf67f14ce2df664283653ca63ce41689362317a92917749  guix-build-5449d44e3798/output/x86_64-w64-mingw32/bitcoin-5449d44e3798-win64.zip

@laanwj laanwj added the Tests label Aug 18, 2021
@laanwj
Copy link
Member

laanwj commented Aug 18, 2021

ACK 5449d44

@laanwj laanwj merged commit 9049935 into bitcoin:master Aug 18, 2021
@fanquake fanquake deleted the gcc_optimising_pow branch August 18, 2021 23:43
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Aug 20, 2021
…test-symbol-check

5449d44 scripts: prevent GCC optimising test symbols in test-symbol-check (fanquake)

Pull request description:

  I noticed in bitcoin#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
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Aug 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants