-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Use preprocessor macros instead of autoconf to detect endianness #787
Use preprocessor macros instead of autoconf to detect endianness #787
Conversation
5f1ee37
to
ac43320
Compare
I like this approach. |
Travis has a zero log apparently unexplained failure on s390 ... the only test that really mattered for this pr. :) I tested it by hand on s390 and it works. sooo ?! |
I checked this PR a few hours ago, and all tests had finished, except the s390x one, which hadn't started. So I think there may be some provisioning issue that prevents travis from assigning an s390x worker, and it somehow timed out? |
This is also the case on Bitcoin Core right now too :/ |
Yeah, first I felt brave when I squashed #696 and then merged it immediately. And then I got a notification from Travis that I broke master... :/ But yes, it's an issue on their side... |
Opened a PR for Bitcoin Core bitcoin/bitcoin#19695 to test if this may impact any of the systems tested by its CI (which includes an MSVC based one). |
It's _MSC_VER not _MSVC_VER (thanks to sipa abusing bitcoin's CI setup to test this.) |
This does not fix any particular issue but it's preferable to not rely on autoconf. This avoids endianness mess for users on BE hosts if they use their build without autoconf. The macros are carefully written to err on the side of the caution, e.g., we #error if the user manually configures a different endianness than what we detect.
ac43320
to
0dccf98
Compare
Fixed. @sipa can you retest on Core? |
@real-or-random Updated it. |
It works. 🎉 |
# define SECP256K1_LITTLE_ENDIAN | ||
#endif | ||
#if defined(SECP256K1_LITTLE_ENDIAN) == defined(SECP256K1_BIG_ENDIAN) | ||
# error Please make sure that either SECP256K1_LITTLE_ENDIAN or SECP256K1_BIG_ENDIAN is set, see src/util.h. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I never knew that you could put an error message after #error
without quotes around it.
In retrospect, not sure what I'd expect it to do. Give an error?
ACK 0dccf98 |
1 similar comment
ACK 0dccf98 |
This broke the build on GCC 2.95 on Debian i386 for me and on Haiku (BeOS). |
@gmaxwell Can you give the list of preprocessor defines on those? |
From the haiku I can't easily copy and paste, but it includes,
among other less relevant ones. |
…s + SHA256 selftest 8bc6aef Add SHA256 selftest (Pieter Wuille) 5e5fb28 Use additional system macros to figure out endianness (Pieter Wuille) Pull request description: These are all the architecture macros I could find with known endianness. Use those as a fallback when __BYTE_ORDER__ isn't available. See #787 (comment) It also adds a SHA256 selftest, so that improperly overriding the endianness detection will be detected at runtime. ACKs for top commit: real-or-random: ACK 8bc6aef I read the diff, and tested that the self-test passes/fails with/without the correct endianness setting gmaxwell: ACK 8bc6aef looks good and I also ran the tests on MIPS-BE and verified that forcing it to LE makes the runtime test fail. Tree-SHA512: aca4cebcd0715dcf5b58f5763cb4283af238987f43bd83a650e38e127f348131692b2eed7ae5b2ae96046d9b971fc77c6ab44467689399fe470a605c3458ecc5
Summary: This does not fix any particular issue but it's preferable to not rely on autoconf. This avoids endianness mess for users on BE hosts if they use their build without autoconf. The macros are carefully written to err on the side of the caution, e.g., we #error if the user manually configures a different endianness than what we detect. This is a backport of secp256k1 [[bitcoin-core/secp256k1#787 | PR787]] Test Plan: ninja check-secp256k1 Reviewers: #bitcoin_abc, majcosta Reviewed By: #bitcoin_abc, majcosta Differential Revision: https://reviews.bitcoinabc.org/D7600
Summary: This does not fix any particular issue but it's preferable to not rely on autoconf. This avoids endianness mess for users on BE hosts if they use their build without autoconf. The macros are carefully written to err on the side of the caution, e.g., we #error if the user manually configures a different endianness than what we detect. This is a backport of secp256k1 [[bitcoin-core/secp256k1#787 | PR787]] Test Plan: ninja check-secp256k1 Reviewers: #bitcoin_abc, majcosta Reviewed By: #bitcoin_abc, majcosta Differential Revision: https://reviews.bitcoinabc.org/D7600
This does not fix any particular issue but it's preferable to not
rely on autoconf. This avoids endianness mess for users on BE hosts
if they use their build without autoconf.
The macros are carefully written to err on the side of the caution,
e.g., we #error if the user manually configures a different endianness
than what we detect.
Supersedes #770 .