Skip to content
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 the secp256k1 C files separately #23

Merged
merged 7 commits into from
Jul 15, 2021

Conversation

jvff
Copy link
Contributor

@jvff jvff commented Jul 15, 2021

Clang currently warns that building C files using C++ mode is deprecated. This happens because the secp256k1 C files are built together with the C++ files. This will get worse in the future because when updating the zcash dependency, the C files will lead to compiler errors due to subtle language version differences.

This PR solves both issues by building the secp245k1 C files separately from the other Zcash C++ files. The resulting libsecp256k1.a and libzcash_script.a binaries are then available to be linked into the final Rust binary.

The PR also includes a few refactors to make the main function more concise and easier to read and update.

jvff added 6 commits July 14, 2021 20:33
Simplify the `main` function a little by moving out some code.
Move some more code out from the `main` function to keep it easier to
read. Also renamed the function so that it better conveys that it's a
check returning a `bool`.
Make setting them more consistent.
A helper function to configure the build's language standard and to
automatically enable or disable C++ support. This allows moving some
more code out of `main`, but it is also preparing for running more than
one build, for splitting the `secp256k1` library.
This just moves the code that configures the build for `secp256k1p`, but
the plan is to have this function perform an independent build.
Remove the current Clang warning about compiling C code using C++ mode,
and also avoid errors in the future when the `zcash` dependency is
updated.
@jvff jvff force-pushed the split-off-secp256k1-build branch from bb3eb45 to 357a889 Compare July 15, 2021 00:29
@jvff jvff requested a review from teor2345 July 15, 2021 00:36
build.rs Show resolved Hide resolved
.include("depend/zcash/src/secp256k1")
// Some ecmult stuff is defined but not used upstream
.flag_if_supported("-Wno-unused-function")
.flag_if_supported("-Wno-unused-parameter");
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need /wd4100 here as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think so. At least there wasn't anything from CI 🤷‍♂️

Copy link
Contributor

@teor2345 teor2345 left a comment

Choose a reason for hiding this comment

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

This looks good to me, but I'd like @oxarbitrage to do the final check.

Make it easy to understand what it is without having the reader to look
it up.

Co-authored-by: teor <teor@riseup.net>
Copy link
Contributor

@oxarbitrage oxarbitrage left a comment

Choose a reason for hiding this comment

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

It looks good to me too.

@jvff jvff merged commit ffb4c0c into ZcashFoundation:master Jul 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants