-
Notifications
You must be signed in to change notification settings - Fork 38.7k
build: fix sysctl() detection on macOS #18359
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
|
ACK 155ce7f7b30a800b7b21f1965ee21967ffc18422 |
|
Concept ACK |
|
Can someone on MacOS test this please and post results? (e.g. relevant configure output) |
|
ACK after verifying that this is a no-op for MacOS. |
|
Ran Before: After: |
|
Concept ACK. Shouldn't the actual usage in random.cpp be switched the more generic non-const version as well? |
|
Actually... for the test, how about bypassing the issue: sysctl(nullptr, 2, nullptr, nullptr, nullptr, 0);? |
sysctl() on *BSD takes a "const int *name", whereas sysctl() on macOS it takes an "int *name". So our configure check and sysctl() detection on macOS currently fails: ```bash /usr/include/sys/sysctl.h:759:9: note: candidate function not viable: no known conversion from 'const int [2]' to 'int *' for 1st argument int sysctl(int *, u_int, void *, size_t *, void *, size_t); ``` This change removes the name argument from the sysctl() detection check, meaning we will detect correctly on macOS and *BSD. For consistency we also switch to using the more generic, non-const version of the name parameter in the rest of our usage.
|
@theuni Thanks for the comments / suggestions. I've pushed some changes.
I've tested
There are two places we are using In randomenv.cpp we are already using the non-const version: Lines 166 to 171 in a421e0a
In random.cpp we are currently using the Lines 323 to 331 in a421e0a
Note that only FreeBSD and NetBSD should fall in here. We already special case macOS and OpenBSD for calls to Saying that, to be consistent in our I've tested e90e3e6 on the following platforms:
|
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
|
That simplification is good though it does change the functionality of the test. Do we care whether Edit: the check for |
This has already been used to find one bug (bitcoin#18359), so turn it on by default.
e90e3e6 build: fix sysctl() detection on macOS (fanquake) Pull request description: [`sysctl()` on *BSD](https://www.unix.com/man-page/FreeBSD/3/sysctl/) takes a "const int *name", whereas [`sysctl()` on macOS](https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/sysctl.3.html) it takes an "int *name". So our configure check and `sysctl()` detection on macOS currently fails: ```bash /usr/include/sys/sysctl.h:759:9: note: candidate function not viable: no known conversion from 'const int [2]' to 'int *' for 1st argument int sysctl(int *, u_int, void *, size_t *, void *, size_t); ``` The simplest change seems to be to change the param to a "int *name", which will work during configure on macOS and *BSD systems. For consistency I've changed both calls, but note that macOS doesn't have `KERN_ARND`, so that check will always fail regardless. We can revert/add documentation if preferred. ACKs for top commit: laanwj: Re-ACK e90e3e6 Tree-SHA512: 29e9348136fc72882f63079bf10d2490e845d7656aae2c003e282bea49dd2778204a7776a67086bd88c2852af9a07dd04ba358eede7e37029e1c10f73c85d6a5
sysctl()on *BSD takes a "const int *name", whereassysctl()on macOSit takes an "int *name". So our configure check and
sysctl()detection onmacOS currently fails:
The simplest change seems to be to change the param to a "int *name", which
will work during configure on macOS and *BSD systems.
For consistency I've changed both calls, but note that macOS doesn't
have
KERN_ARND, so that check will always fail regardless. We can revert/adddocumentation if preferred.