Change #275160
| Category | gcoreutils |
| Changed by | Collin Funk <collin.funk1@gmail.com> |
| Changed at | Sat 18 Jul 2026 20:14:46 |
| Repository | git://git.savannah.gnu.org/coreutils.git |
| Project | gcoreutils |
| Branch | master |
| Revision | 664b8663dd926cafb99dc0351bb787b156419311 |
Comments
build: reduce size of multi-call binary by reusing test logic
Map the '[' command to which selects appropriate behavior at runtime,
rather than separate binaries for each closely related utility.
$ size src/coreutils-prev
text data bss dec hex filename
1485188 7348 2191968 3684504 383898 src/coreutils-prev
$ size src/coreutils
text data bss dec hex filename
1476092 7348 2191936 3675376 3814f0 src/coreutils
* src/local.mk (noinst_HEADERS): Add src/test.h.
(src___SOURCES): Remove src/lbracket.c. Add src/test.c and
src/test-lbracket.c.
(src_test_SOURCES): New variable.
(src/coreutils.h): Adjust the function name to be
single_binary_main_lbracket instead of single_binary_main__.
* build-aux/gen-single-binary.sh: Likewise. Map '[' to 'test'.
(override_single): Adjust the file name to be coreutils-lbracket.c
instead of coreutils-_.c.
* src/lbracket.c: Remove file.
* cfg.mk (_src): Don't match src/lbracket.c in the regular
expression. Match src/test-lbracket.c and src/test-test.c.
* src/coreutils-lbracket.c: New file.
* src/test-lbracket.c: Likewise.
* src/test-test.c: Likewise.
* src/test.h: Likewise.
* src/test.c: Include test.h.
(LBRACKET): Remove macro.
(PROGRAM_NAME): Use the variable TEST_MODE to determine the program
name.
(main): Use the variable TEST_MODE instead of the LBRACKET macro to
implement behavior specific to '['.
* NEWS: Mention the improvement.
Changed files
- NEWS
- build-aux/gen-single-binary.sh
- cfg.mk
- src/coreutils-lbracket.c
- src/lbracket.c
- src/local.mk
- src/test-lbracket.c
- src/test-test.c
- src/test.c
- src/test.h