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
build: Pass sanitize flags to instrument libsecp256k1
code
#28875
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code CoverageFor detailed information about the code coverage, see the test coverage report. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. 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. |
Concept ACK Thanks! will review soon |
a6de1d1
to
9937fcb
Compare
Converted to a draft, |
9937fcb
to
9065c11
Compare
9065c11
to
a041915
Compare
The CI has been fixed and this PR is ready for review now. Friendly ping @dergoegge :) |
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.
tACK a041915
It might be better to reverse the order of the commits or squash them to avoid bisect failures in between.
a041915
to
e39bae1
Compare
Squashed. |
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.
reACK e39bae1
Also a new UBSan suppression has been added.
e39bae1
to
cbea49c
Compare
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.
ACK cbea49c
@@ -1946,6 +1947,9 @@ CPPFLAGS_TEMP="$CPPFLAGS" | |||
unset CPPFLAGS | |||
CPPFLAGS="$CPPFLAGS_TEMP" | |||
|
|||
if test -n "$use_sanitizers"; then | |||
export SECP_CFLAGS="$SECP_CFLAGS $SANITIZER_CFLAGS" |
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.
My take on SECP_CFLAGS
is that it's an internal of the libsecp256k1 build system, and users are not supposed to set it (and are not guaranteed that it does anything meaningful). The proper user variable is just CFLAGS
.
You could either export CFLAGS="-g $SANITIZER_CFLAGS"
temporarily, or perhaps add a CFLAGS arg to ac_configure_args
.
We could also expose the SECP_CFLAGS
"officially" in the lib. Then it should probably be renamed to SECP256K1_CFLAGS
. But I think it's a bit arbitrary, given there's an official way to set CFLAGS (namely setting CFLAGS ;)).
There's also this, which may be an elegant solution or overkill, depending on your taste... https://www.gnu.org/software/autoconf-archive/ax_subdirs_configure.html
Sorry for noticing this only now in a second review...
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 was thinking about the best way to handle this, and my current take was that given this is only when we are using sanitizers, and we are a somewhat non-standard/more-tightly-coupled users of secp in any case, I wasn't too worried. Happy for any other approach that achieves the same thing, but also don't want secp to expose additional (non-standard) flags just for us.
edit: we have looked at the subdirs_configure before, and iirc it didn't work quite how we wanted for various reasons.
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 wasn't too worried.
Yep, I agree, any approach is ok in the end. My feeling is just that setting SECP_CFLAGS
is not the cleanest choice and more likely than my other suggestions to cause breaks in the future.
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.
My feeling is just that setting SECP_CFLAGS is not the cleanest choice and more likely than my other suggestions to cause breaks in the future.
We can accept that possibility for now, and at the next subtree update (if/when things break), we'll take another look.
@@ -2006,7 +2010,7 @@ echo " target os = $host_os" | |||
echo " build os = $build_os" | |||
echo | |||
echo " CC = $CC" | |||
echo " CFLAGS = $PTHREAD_CFLAGS $CFLAGS" | |||
echo " CFLAGS = $PTHREAD_CFLAGS $SANITIZER_CFLAGS $CFLAGS" |
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.
Serious question: What is this line supposed to print, given that there are also ZMQ_CFLAGS
, BDB_CFLAGS
and EVENT_CFLAGS
? One could say that the libsecp256k1 configure output already prints its CFLAGS, so there's no need to cover that here, but I don't know because I don't know what the purpose of this line is. Where else do we need CFLAGS?
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.
These lines have never been super consistent, but are meant to be a rough overview of the (interesting) flags being used for compilation. I think you're correct in that printing secp flags (again) here would be overkill. For any other flags, I don't think they are very meaningful for most builders. I think it's also unlikely we'll significantly change anything here too much further, given that this is going to be completely redone with CMake.
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.
reACK cbea49c
This PR is a revived #27991 with an addressed comment.
Fixes #27990.
Might be tested as follows: