Skip to content

Conversation

@eklitzke
Copy link
Contributor

@eklitzke eklitzke commented Mar 21, 2018

This completely eliminates our dependency on boost::program_options, including the linking dependency:

$ ldd ./src/bitcoind | grep boost
	libboost_system.so.1.64.0 => /lib64/libboost_system.so.1.64.0 (0x00007f56e99ad000)
	libboost_filesystem.so.1.64.0 => /lib64/libboost_filesystem.so.1.64.0 (0x00007f56e9797000)
	libboost_thread.so.1.64.0 => /lib64/libboost_thread.so.1.64.0 (0x00007f56e956e000)
	libboost_chrono.so.1.64.0 => /lib64/libboost_chrono.so.1.64.0 (0x00007f56e936a000)

The catch is that this branch has two commits: my change from #12713, and then another commit that actually removes boost::program_options (see the second for the interesting part of this change). The only thing holding up that PR is disagreement about what to do about an obscure never-meant-to-be-supported edge case in the old option parser. Hopefully everyone's universal dislike of Boost is sufficient to achieve consensus on that issue.

@eklitzke eklitzke force-pushed the program_options branch 2 times, most recently from 2d68062 to 6ae9530 Compare March 21, 2018 06:58
@practicalswift
Copy link
Contributor

Really nice! Let's get rid of Boost

Strong concept ACK

@fanquake fanquake requested review from laanwj and theuni March 21, 2018 07:16
@Empact
Copy link
Contributor

Empact commented Mar 21, 2018

Another concept ACK

Some nits:

  • Could you run clang-format against your patch, there are some formatting inconsistencies:
    git diff -U0 --no-color bitcoin/master | contrib/devtools/clang-format-diff.py -i -p1
  • It looks like GetNegatedArgs / IsArgNegated are exposed for testing purposes only. I would be in favor of removing those for the sake of simplicity - seems testing can be covered from the existing GetBoolArg interface.

@Empact
Copy link
Contributor

Empact commented Mar 21, 2018

I saw the use of GetNegatedArgs / IsNegatedArgs in your other PRs. IMO best to make each PR minimal / independent and rebase as needed.

@bitcoin bitcoin deleted a comment from ilike2bottom40 Mar 21, 2018
@jnewbery
Copy link
Contributor

One comment: config_file_iterator is able to parse sections: http://www.boost.org/doc/libs/1_66_0/doc/html/program_options/overview.html#id-1.3.31.5.10.2 . That feature isn't currently used in bitcoin but is required for #11862.

How much work would it be to enhance this PR to support INI-like config sections?

courtesy ping @ajtowns

Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

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

utACK 78bc52b

Would be good to add a simple unit test.

setOptions.insert("*");
std::string line;
while (std::getline(config_file, line)) {
size_t eqpos = line.find('=');
Copy link
Contributor

Choose a reason for hiding this comment

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

Current syntax seems to be described here:

http://www.boost.org/doc/libs/1_66_0/doc/html/program_options/overview.html#id-1.3.31.5.10.2

I wonder if for backwards compatibility or convenience the new implementation should be extended to support # comments.

Copy link
Member

Choose a reason for hiding this comment

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

+1

@eklitzke
Copy link
Contributor Author

@jnewbery Seems pretty easy to add sections, INI format is literally just:

foo = 'a global option'
bar = 'another option'

[Section One]
max-file-count = 100

[Section Two]
max-file-count = 150

The option parser needs to be updated to be section-aware anyway, as right now it stuffs everything in a global namespace.

I looked at how Python checks their INI parser (configparser module) and this needs to be updated to handle comments and quoting. I will add a test case. Basically it should be able to parse this file correctly: https://github.com/python/cpython/blob/master/Lib/test/cfgparser.2

@eklitzke eklitzke changed the title Completely eliminate dependency on boost::program_options WIP: eliminate dependency on boost::program_options Mar 21, 2018
@laanwj
Copy link
Member

laanwj commented Mar 22, 2018

One comment: config_file_iterator is able to parse sections:

Concept ACK - though as @jnewbery already mentions, I'd prioritize #11862 first, because adding a per-network configuration mechanism is something we've wanted for a long time.

Removing boost dependencies is what we want on the long run too, but shouldn't get in the way of providing functionality to users.

@Sjors
Copy link
Member

Sjors commented Apr 3, 2018

make check is happy on macOS.

Shouldn't you remove llibboost-program-options-dev from travis.yml and control/debian/control as well?

@theuni
Copy link
Member

theuni commented Apr 4, 2018

very nice! concept ACK. Will review in detail.

if (strValue.empty())
return true;
return (atoi(strValue) != 0);
return val != "0";
Copy link
Member

Choose a reason for hiding this comment

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

Looks like this will miss " 0" (whitespace), and "-0" (negative zero), which could happen as a typo on another argument.

@maflcko
Copy link
Member

maflcko commented Apr 8, 2018

Needs rebase

@laanwj
Copy link
Member

laanwj commented Apr 25, 2018

Removing boost dependencies is what we want on the long run too, but shouldn't get in the way of providing functionality to users.

right - needs rebase now that per-network configuration sections have been introduced.

@luke-jr
Copy link
Member

luke-jr commented May 2, 2018

Using dependencies is strictly better than re-inventing them, but all things considered (minimal size of the code, and future modification code needed for rwconf), I guess this case looks not totally unreasonable... :x

@promag
Copy link
Contributor

promag commented May 30, 2018

Needs rebase.

@ken2812221
Copy link
Contributor

Concept ACK

@maflcko
Copy link
Member

maflcko commented Jun 2, 2018

Closing for now. Let me know when you start working on this again, so I can reopen. Also, this is up for grabs and can be rebased by any other contributor.

@maflcko maflcko closed this Jun 2, 2018
laanwj added a commit that referenced this pull request Jul 20, 2018
f447a0a Remove program options from build system (Chun Kuan Lee)
11588c6 Replace boost program_options (Chun Kuan Lee)

Pull request description:

  Concept from #12744, but without parsing negated options.

Tree-SHA512: 7f418744bb8934e313d77a5f162633746ef5d043de802b9c9cd9f7c1842e7e566eb5f171cd9e2cc13317281b2449c6fbd553fa4f09b837e6af2f5d2b2aabdca2
UdjinM6 pushed a commit to UdjinM6/dash that referenced this pull request Jul 1, 2021
f447a0a Remove program options from build system (Chun Kuan Lee)
11588c6 Replace boost program_options (Chun Kuan Lee)

Pull request description:

  Concept from bitcoin#12744, but without parsing negated options.

Tree-SHA512: 7f418744bb8934e313d77a5f162633746ef5d043de802b9c9cd9f7c1842e7e566eb5f171cd9e2cc13317281b2449c6fbd553fa4f09b837e6af2f5d2b2aabdca2
UdjinM6 pushed a commit to UdjinM6/dash that referenced this pull request Jul 2, 2021
f447a0a Remove program options from build system (Chun Kuan Lee)
11588c6 Replace boost program_options (Chun Kuan Lee)

Pull request description:

  Concept from bitcoin#12744, but without parsing negated options.

Tree-SHA512: 7f418744bb8934e313d77a5f162633746ef5d043de802b9c9cd9f7c1842e7e566eb5f171cd9e2cc13317281b2449c6fbd553fa4f09b837e6af2f5d2b2aabdca2
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.