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

Add section on configuration flags to README #1142

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ZenulAbidin
Copy link
Contributor

This change eases the use of alternate build systems by moving the variables in src/libsecp256k1-config.h to compiler macros for each invocation, preventing duplication of these variables for each build system.

This does not include documentation for each configure option, and would need to be added in a separate commit.

@real-or-random
Copy link
Contributor

Hi, thanks for the PR.

The reason why CI doesn't like this is that the files precomputed_ecmult[_gen].c are generated via precompute_ecmult[_gen].c. You'll also need to change the generating code in the latter to not generate the #include lines. Actually this suffices and then make clean-precomp && make precomp should generate the files.

For the change itself, I think I'm in favor of this because it's in line with what I said here: #1113 (comment).

@ZenulAbidin
Copy link
Contributor Author

Hi, thanks for the PR.

The reason why CI doesn't like this is that the files precomputed_ecmult[_gen].c are generated via precompute_ecmult[_gen].c. You'll also need to change the generating code in the latter to not generate the #include lines. Actually this suffices and then make clean-precomp && make precomp should generate the files.

For the change itself, I think I'm in favor of this because it's in line with what I said here: #1113 (comment).

Alright, I updated the precompute_ files, and also added the SECP_ prefix to DEFINE_FLAGS.

I am wondering if it's a good idea to put the configure option descriptions in the README or in a separate docs file.

@apoelstra
Copy link
Contributor

I am wondering if it's a good idea to put the configure option descriptions in the README or in a separate docs file.

My inclination is that they should be beside the options themselves, maybe with some sentinel like BUILD-DEFINE: that the README would tell people to grep for. If the docs are in a separate file I'm sure they'll come out of sync.

@ZenulAbidin
Copy link
Contributor Author

ZenulAbidin commented Oct 5, 2022

My inclination is that they should be beside the options themselves, maybe with some sentinel like BUILD-DEFINE: that the README would tell people to grep for. If the docs are in a separate file I'm sure they'll come out of sync.

Will single-line comments in configure.ac with the docstring suffice, such as this?

SECP_DEFINE_FLAGS="$SECP_DEFINE_FLAGS -DUSE_ASM_X86_64=1"
dnl Define this symbol to enable x86_64 assembly optimizations

But then this raises an issue with duplication. Assuming CMake functionality will be merged, and DRY principles apply, we should make the Autoconf file the source of truth for these docstrings?

@real-or-random
Copy link
Contributor

I think there's no straight answer where to put the docs if we want to support multiple build systems, and that decision shouldn't block this PR. Note that this PR doesn't really remove docs, the doc strings are still in the configure.ac macros and are presented to the user in a nice way in ./configure --help.


Entering that discussion about where to put the docs:

Quoting myself from #1113 (comment):

In the end, we need a least one place (and as few as possible) places where the options are listed and documented, and some duplication will be unavoidable if we want to support more than one of building even if it's just "autotools" and "manual".

Will single-line comments in configure.ac with the docstring suffice, such as this?

SECP_DEFINE_FLAGS="$SECP_DEFINE_FLAGS -DUSE_ASM_X86_64=1"
dnl Define this symbol to enable x86_64 assembly optimizations

But then this raises an issue with duplication.

Indeed, I think this will make the problem worse. And once we have autotools and cmake, it's not clear where the canonical source is, and also the command line arguments will look different...

I still lean towards what I suggested in #1113 (comment): A table in the README, or maybe in a file referenced from the README, that has a row for every option (see mockup there). If people are motivated, it would be nice to see a worked out PR for this suggestion.

If we have this table, we could either remove the strings from ./configure --help entirely and leave them in very brief form like "enable ECDH module". I think either possibility is ok. We'll anyway have to live with some coupling and duplication: Every time we add/change/remove an option, we need to perform that change at least i) in the actual source, ii) in autotools, iii) and in cmake.

Copy link
Contributor

@real-or-random real-or-random left a comment

Choose a reason for hiding this comment

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

ACK mod bikeshedding

Makefile.am Outdated Show resolved Hide resolved
@ZenulAbidin
Copy link
Contributor Author

I still lean towards what I suggested in #1113 (comment): A table in the README, or maybe in a file referenced from the README, that has a row for every option (see mockup there). If people are motivated, it would be nice to see a worked out PR for this suggestion.

If we have this table, we could either remove the strings from ./configure --help entirely and leave them in very brief form like "enable ECDH module". I think either possibility is ok. We'll anyway have to live with some coupling and duplication: Every time we add/change/remove an option, we need to perform that change at least i) in the actual source, ii) in autotools, iii) and in cmake.

I suggest reserving the table for the autoconf/CMake option specifiers, because we can just make the short option description as a heading above it, and the long description as a paragraph below it, so 1) the long description has more reading space, and 2) it embeds in the autogenerated Table of Contents for Markdown files. However, I advise keeping at least a simple option description in the ./configure --help output, like the way it is for --enable-test, --enable-benchmark and many others.

So basically, instead of this:

Autotools CMake Manual Description
--enable-tests -DENABLE_TESTS -DENABLE_TESTS compile tests [default=yes]
--enable-examples -DENABLE_EXAMPLES -DENABLE_EXAMPLES compile the examples [default=no]

We can have something like this:

Configuration options

-DENABLE_TESTS

Autotools
--enable-tests

Compile tests. (Default: yes)

-DENABLE_EXAMPLES

Autotools
--enable-examples

Compile the examples. (Default: yes)


Of course, I did not list CMake entries because that has not been merged yet, but for now, it will be an autotools list, and the manual options will be in the markdown titles.

This change eases the use of alternate build systems by moving
the variables in src/libsecp256k1-config.h to compiler macros
for each invocation, preventing duplication of these variables
for each build system.
@ZenulAbidin
Copy link
Contributor Author

@real-or-random Config options have been added to the README.

@ZenulAbidin
Copy link
Contributor Author

Also, do you think that the ./configure docs should be trimmed, considering they are a duplicate of the README?

@hebasto
Copy link
Member

hebasto commented Oct 28, 2022

Concept ACK.

@hebasto
Copy link
Member

hebasto commented Oct 28, 2022

It is possible now to cleanup the .gitignore file:

--- a/.gitignore
+++ b/.gitignore
@@ -44,8 +44,6 @@ coverage.*.html
 *.gcno
 *.gcov
 
-src/libsecp256k1-config.h
-src/libsecp256k1-config.h.in
 build-aux/ar-lib
 build-aux/config.guess
 build-aux/config.sub
@@ -60,5 +58,4 @@ build-aux/m4/ltversion.m4
 build-aux/missing
 build-aux/compile
 build-aux/test-driver
-src/stamp-h1
 libsecp256k1.pc

@sipa
Copy link
Contributor

sipa commented Dec 6, 2022

Concept ACK, and ACK the first commit.

I'm not really a fan of the current documentation changes, with a dozen tiny tables and subsections added to the readme, which isn't very readable. I don't think that should hold up the changes here, though.

We can merge it as-is, or drop the documentation changes. I'm happy to work on documenting the flags in a follow-up.

@hebasto
Copy link
Member

hebasto commented Dec 6, 2022

... drop the documentation changes. I'm happy to work on documenting the flags in a follow-up.

+1

@ZenulAbidin
Copy link
Contributor Author

Agreed.

Perhaps the flags could be documented separately in a separate Markdown file in the sparsely-populated docs folder.

@sipa
Copy link
Contributor

sipa commented Dec 7, 2022

I've included the first commit from here in #1169, as it simplifies things a bit there, but I'm happy for this PR to settle first.

@real-or-random
Copy link
Contributor

@ZenulAbidin Can you drop the commit that changes the README for now, and (optional, if you want) make the changes to .gitignore proposed here? #1142 (comment)

Then we could get this merged and work on the doc stuff in a separate issue/PR.

@hebasto
Copy link
Member

hebasto commented Dec 14, 2022

Can you drop the commit that changes the README for now, and (optional, if you want) make the changes to .gitignore proposed here? #1142 (comment)

See #1178.

@ZenulAbidin
Copy link
Contributor Author

ZenulAbidin commented Dec 14, 2022

@hebasto Thanks for that. I was busy with other stuff last week so couldn't get to this PR in a timely manner.

I'm going to leave this open for now in case anyone has more feedback about the flags & docs.

sipa added a commit that referenced this pull request Dec 20, 2022
9c5a4d2 Do not define unused `HAVE_VALGRIND` macro (Hennadii Stepanov)
ad8647f Drop no longer relevant files from `.gitignore` (Hennadii Stepanov)
b627ba7 Remove dependency on `src/libsecp256k1-config.h` (Hennadii Stepanov)

Pull request description:

  Cherry-picked the first commit from #1142 and addressed a [comment](#1142 (comment)).

ACKs for top commit:
  sipa:
    utACK 9c5a4d2
  real-or-random:
    utACK 9c5a4d2

Tree-SHA512: c6f268261fc5edee855a7e69fdf9f6c5f4b859eb1e078e3c44c3ee4c9c445738af3de9fc2fbcca90db9b9e38681da8217faaeb0735201052b16ea397a7817db9
@hebasto
Copy link
Member

hebasto commented Dec 20, 2022

@ZenulAbidin

I'm going to leave this open for now in case anyone has more feedback about the flags & docs.

As #1178 has been recently merged, maybe update this PR description and title?

@real-or-random real-or-random changed the title Remove dependency on src/libsecp256k1-config.h Add section on configuration flags to README Dec 20, 2022
@hebasto
Copy link
Member

hebasto commented Jul 14, 2023

The changes to the documentation have been incorporated in #1372.

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

5 participants