Skip to content

Conversation

jonasschnelli
Copy link
Contributor

PR #20358 made use of the two preprocessor symbols HAVE_STRONG_GETAUXVAL as well as HAVE_WEAK_GETAUXVAL.

These symbols have not been defined in configure.ac. They where only passed selective as CRC32 CPPFLAGS in https://github.com/bitcoin/bitcoin/blob/master/src/Makefile.crc32c.include#L16.

PR #20358 would have broken the macOS build since getauxval is not supported on macOS (but weak-linking does pass).

This PR defines the two symbols correctly and reduces calls to getauxval to linux.

@laanwj
Copy link
Member

laanwj commented Dec 7, 2020

Code review ACK 836a3dc
Agree with making the weak link check Linux specific. It will pretty much pass on every platform with weak linking otherwise, redundantly.

@jonatack
Copy link
Member

jonatack commented Dec 7, 2020

utACK 836a3dc

@maflcko
Copy link
Member

maflcko commented Dec 8, 2020

#20358 is marked for backport, so should this be marked as well or neither?

@jonasschnelli
Copy link
Contributor Author

I don't think this qualifies a backport.

@laanwj
Copy link
Member

laanwj commented Dec 10, 2020

I don't think we're going to backport #20594, so this one shouldn't be needed to be backported either.

@DrahtBot
Copy link
Contributor

Guix builds

File commit c8fdbb4
(master)
commit b7b41d9
(master and this pull)
*-aarch64-linux-gnu-debug.tar.gz 3deed2da45b62eec... f8b7be38ce2bd0fe...
*-aarch64-linux-gnu.tar.gz 40167786770050a7... 1c480ba919ed20b9...
*-arm-linux-gnueabihf-debug.tar.gz 2bab3e6fb6bc6c5e... 00a0e88eb84de3e6...
*-arm-linux-gnueabihf.tar.gz 348f41fdf8bb3296... a73847976a2eaf74...
*-riscv64-linux-gnu-debug.tar.gz bcdd2745fa674043... 30d02b411ddb05a1...
*-riscv64-linux-gnu.tar.gz c51f7b7430d46c11... 675851eb1d2a5e85...
*-win-unsigned.tar.gz b217da27a48616f0... 6f6a7f8f518f1dc6...
*-win64-debug.zip 738531e96954514f... 93f8f92fc8f5d8b7...
*-win64-setup-unsigned.exe d002790eae6ad9cf... e3fba8230cb3dca6...
*-win64.zip 88b762cf6d5e790b... cddd04ca26f97c64...
*-x86_64-linux-gnu-debug.tar.gz a7ae27f4a44a4417... 4dc76fd7958c1b00...
*-x86_64-linux-gnu.tar.gz 9d215d854f7c0486... 92ca9f0b6bdc3220...
*.tar.gz 77f0547c1d498b1d... 1924def56271327d...
guix_build.log 20eaab73a8ea65e0... 8e895c0575b3ac98...
guix_build.log.diff e20b3ec664bfc7ff...

@DrahtBot
Copy link
Contributor

Gitian builds

File commit 736eb4d
(master)
commit 1dca774
(master and this pull)
*-aarch64-linux-gnu-debug.tar.gz 2be2a11a222f573c... 0caa707037884abe...
*-aarch64-linux-gnu.tar.gz aa6be788b43c77ab... 30bccc2fc34223d3...
*-arm-linux-gnueabihf-debug.tar.gz bc084de532268d02... 9d9024b854110579...
*-arm-linux-gnueabihf.tar.gz 8bf8847238bbb772... 21bd213dfcf405a6...
*-osx-unsigned.dmg 0e0b5353ad614bc4... 66fce95a8f9629bf...
*-osx64.tar.gz 138e5e00bfec397f... deccb18151ae7afd...
*-riscv64-linux-gnu-debug.tar.gz f77b9fc97e1691c7... 83890c884c7a9a06...
*-riscv64-linux-gnu.tar.gz 45248a9a8de4982e... 115770bb6696689e...
*-win64-debug.zip 09d982b554816f6b... e60536ae9a0db672...
*-win64-setup-unsigned.exe 3c905f96f0f756e0... a7ce72522d6b2737...
*-win64.zip 8c7fc6e3a8ea93fe... 1695e977e953c730...
*-x86_64-linux-gnu-debug.tar.gz e47b5bfa0a774d6b... 7534216299cd8565...
*-x86_64-linux-gnu.tar.gz fe3f8b7e4e601768... aa9278300d67768e...
*.tar.gz 12158696afd16c3a... e7916754ec0700b3...
bitcoin-core-linux-22-res.yml 70d8be4a51bc67f7... 3c3ff0a3ba6d40eb...
bitcoin-core-osx-22-res.yml 97d889ba103beac9... 3381e980d259abc4...
bitcoin-core-win-22-res.yml 169a1d1fafcb841e... b7c8bd94cdbbd7f7...
linux-build.log 46b0db1f12f1fed8... 4e0c9a0d1bde535c...
osx-build.log 42dd0c03e04b575f... 8a34df29be5e5926...
win-build.log 9a4cfdc2af2389a0... 9eb1ff5f519b0932...
bitcoin-core-linux-22-res.yml.diff 3be13530bb24beac...
bitcoin-core-osx-22-res.yml.diff ab4154baf5c66882...
bitcoin-core-win-22-res.yml.diff 94c7a5ecc8329205...
linux-build.log.diff f09b079e31e940b2...
osx-build.log.diff 06af4a15f2a13bf7...
win-build.log.diff 0b8a4f2d28c8dab6...

[ AC_MSG_RESULT(no); HAVE_STRONG_GETAUXVAL=0 ]
)

AC_MSG_CHECKING(for weak getauxval support in the compiler)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#ifdef __linux__
unsigned long getauxval(unsigned long type) __attribute__((weak));
#define AT_HWCAP 16
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems very fragile. On what target is getauxval only weak?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would it be (more) fragile? Weak linking is already pretty fragile AFAIK.
IMO this weak linking passes always. See masters Win64 build as an example.

AFAIK this check is part of googles crc32c suite.
Limiting it to linux makes absolute sense to me since getauxval (it doesn't exists on Mac/win).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I do mean the weak linking entirely. What do we lose, if we only check for strong linking?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a valid question.
AFAIK the google crc32c getauxval weak linking check is for android (< API level 20).
Crc32c is an upstream upstream subtree. I guess if we don't want to check for the weak linking, we might want to PR that there.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume if we just don't define it, that code block simply won't be used?

Copy link
Member

@laanwj laanwj Dec 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems very fragile. On what target is getauxval only weak?

a) getauxval only exists on Linux (OSes with the Linux kernel, I mean)
b) by nature of weak linking, it could weakly link on every platform, this makes no sense though

@laanwj
Copy link
Member

laanwj commented Dec 14, 2020

I think this fix is fine. Removing the weak check completely is something that could be considered, but might interfere with Android. It doesn't need to be decided in this PR.

@laanwj laanwj merged commit 94a9cd2 into bitcoin:master Dec 14, 2020
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Dec 15, 2020
836a3dc Avoid weak-linked getauxval support on non-linux platforms (like macOS) (Jonas Schnelli)
41a413b Define correct symbols for getauxval (Jonas Schnelli)

Pull request description:

  PR bitcoin#20358 made use of the two preprocessor symbols `HAVE_STRONG_GETAUXVAL` as well as `HAVE_WEAK_GETAUXVAL`.

  These symbols have not been defined in configure.ac. They where only passed selective as CRC32 CPPFLAGS in https://github.com/bitcoin/bitcoin/blob/master/src/Makefile.crc32c.include#L16.

  PR bitcoin#20358 would have broken the macOS build since `getauxval` is not supported on macOS (but weak-linking does pass).

  This PR defines the two symbols correctly and reduces calls to `getauxval` to linux.

ACKs for top commit:
  laanwj:
    Code review ACK 836a3dc
  jonatack:
    utACK 836a3dc

Tree-SHA512: 6527f4a617b937f4c368a3cb1c162f1ac38a6f5e6341295554961eaf322906e9b27398a6f7b00819854ceebb5c828d3e6ce0a779edd769adc4053ce8beda3739
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Sep 17, 2021
836a3dc Avoid weak-linked getauxval support on non-linux platforms (like macOS) (Jonas Schnelli)
41a413b Define correct symbols for getauxval (Jonas Schnelli)

Pull request description:

  PR bitcoin#20358 made use of the two preprocessor symbols `HAVE_STRONG_GETAUXVAL` as well as `HAVE_WEAK_GETAUXVAL`.

  These symbols have not been defined in configure.ac. They where only passed selective as CRC32 CPPFLAGS in https://github.com/bitcoin/bitcoin/blob/master/src/Makefile.crc32c.include#L16.

  PR bitcoin#20358 would have broken the macOS build since `getauxval` is not supported on macOS (but weak-linking does pass).

  This PR defines the two symbols correctly and reduces calls to `getauxval` to linux.

ACKs for top commit:
  laanwj:
    Code review ACK 836a3dc
  jonatack:
    utACK 836a3dc

Tree-SHA512: 6527f4a617b937f4c368a3cb1c162f1ac38a6f5e6341295554961eaf322906e9b27398a6f7b00819854ceebb5c828d3e6ce0a779edd769adc4053ce8beda3739
thelazier pushed a commit to thelazier/dash that referenced this pull request Sep 25, 2021
836a3dc Avoid weak-linked getauxval support on non-linux platforms (like macOS) (Jonas Schnelli)
41a413b Define correct symbols for getauxval (Jonas Schnelli)

Pull request description:

  PR bitcoin#20358 made use of the two preprocessor symbols `HAVE_STRONG_GETAUXVAL` as well as `HAVE_WEAK_GETAUXVAL`.

  These symbols have not been defined in configure.ac. They where only passed selective as CRC32 CPPFLAGS in https://github.com/bitcoin/bitcoin/blob/master/src/Makefile.crc32c.include#L16.

  PR bitcoin#20358 would have broken the macOS build since `getauxval` is not supported on macOS (but weak-linking does pass).

  This PR defines the two symbols correctly and reduces calls to `getauxval` to linux.

ACKs for top commit:
  laanwj:
    Code review ACK 836a3dc
  jonatack:
    utACK 836a3dc

Tree-SHA512: 6527f4a617b937f4c368a3cb1c162f1ac38a6f5e6341295554961eaf322906e9b27398a6f7b00819854ceebb5c828d3e6ce0a779edd769adc4053ce8beda3739
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Feb 15, 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.

6 participants