Page MenuHomeFreeBSD

Import the bc and dc programs developed by Gavin D. Howard
Needs ReviewPublic

Authored by se on Apr 20 2019, 8:15 AM.

Details

Reviewers
None
Group Reviewers
manpages
Summary

These bc and dc programs offer a number of advantages compared to the current version in base:

  • Does not depend on external large number functions (i.e. no dependency on OpenSSL or any large number library)
  • Implements all features found in GNU bc/dc (with the exception of a function that is considered a security issue) but is BSD licensed
  • Is significantly faster than the current code in base (by a factor of 5 in a few large number tests that I have performed)
  • Should be fully compatible with all features and the behavior of the current FreeBSD version (not formally verified)
  • Supports POSIX message catalogs and comes with localized messages in French and German (more to be expected, this is a recently added feature)
  • It comes with a very detailed man-page that provides far more information than the current one

While there is no reason to replace the current code in base from a license point of view, the advantages offered by this version seem significant enough to support this change.

The programs to be imported in base are already available as a port (math/gh-bc) for easy testing.

The attached diff contains an import of the relevant files from upstream version 1.2.7 into contrib/bc, with FreeBSD build infrastructure in usr.bin/gh_bc. There are extensive regression tests that are run by the upstream before each new release is tagged. These tests could be imported into base, but are not included in this review. (They are available in the port.)

This code will only replace the standard versions in base if the world is built and installed with "MK_GH_BC=yes".

Test Plan

Build and install world with "MK_GH_BC=yes".
Perform regression tests for bc and dc.
Build universe with "MK_GH_BC=yes".
Optionally perform exp-run with these tools in base.

Diff Detail

Repository
rS FreeBSD src repository
Lint
Lint Skipped
Unit
Unit Tests Skipped
Build Status
Buildable 24882

Event Timeline

se created this revision.Apr 20 2019, 8:15 AM
se updated this revision to Diff 56452.Apr 21 2019, 3:41 PM

Update to (not yet released) version 1.3.0.

se updated this revision to Diff 56578.Apr 24 2019, 9:13 AM

Multiplication has been optimized and the overall performance of this version is now comparable to that of the GNU bc implementation.

se updated this revision to Diff 58703.Jun 16 2019, 3:18 PM
se edited the summary of this revision. (Show Details)
se edited the test plan for this revision. (Show Details)

This updated diff is for a pre-release version of bc-2.1.0 (expected to be similar to the release, except for possible last minute documentation enhancements or other non-functional changes).
The man-pages have received some updates, e.g. regarding the behavior in error situations.
This version differs from the previous one in a number of optimizations that have further improved the performance which now far exceeds other bc implementations in non-trivial test cases (e.g. the bc and dc currently in FreeBSD, but GNU bc, too).
A lot of regression tests have been added and the sources included in this review have been test-built on FreeBSD with clang-8.0.1, gcc-8.3.0, and gcc-4.2.1.
Run-tests have been performed with the amd64 and i386 versions (with more planned before the commit to FreeBSD).

If there are no arguments against this import, I'd want to commit version 2.1.0 (after the release has been tagged in the GIT upstream repo), replacing the current bc and dc only if MK_GH_BC is defined.
This should allow for easy testing in -CURRENT.
Then, after 1 month, I'd like to make this bc the default in -CURRENT - but I'm not sure whether to keep the current implementation available in -CURRENT, too.
No MFC to STABLE-12 is planned, but this version will be available as a port/package for all FreeBSD versions.