[PATCH] Fix code bloat caused by zcat's seamless magic
Kang-Che Sung
explorer09 at gmail.com
Sat Jan 7 17:41:15 UTC 2017
(I discovered this when personally experimenting the make_single_applets script)
This example single-applet configuration would trigger the bloat:
CONFIG_FEATURE_SEAMLESS_XZ=y
CONFIG_FEATURE_SEAMLESS_LZMA=y
CONFIG_FEATURE_SEAMLESS_BZ2=y
CONFIG_FEATURE_SEAMLESS_GZ=y
CONFIG_BUNZIP2=y
# CONFIG_ZCAT is not set
# All other applets disabled
Here, the resulting "busybox-bunzip2" binary would contain
unpack_gz_stream, unpack_lzma_stream and unpack_xz_stream functions
code. In other words, the gzip, lzma and xz decompressors' code are
linked into the binary unnecessarily.
Fix this by disabling SEAMLESS_MAGIC option flag (setting its value
to 0) when zcat is disabled. This will help the compiler optimize out
bbunpack() and no longer generate open_zipped() function call.
Signed-off-by: Kang-Che Sung <explorer09 at gmail.com>
---
archival/bbunzip.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/archival/bbunzip.c b/archival/bbunzip.c
index 60a837e22..a8d8a9872 100644
--- a/archival/bbunzip.c
+++ b/archival/bbunzip.c
@@ -25,7 +25,7 @@ enum {
OPT_QUIET = 1 << 3,
OPT_DECOMPRESS = 1 << 4,
OPT_TEST = 1 << 5,
- SEAMLESS_MAGIC = (1 << 31) * SEAMLESS_COMPRESSION,
+ SEAMLESS_MAGIC = (1 << 31) * (ENABLE_ZCAT && SEAMLESS_COMPRESSION),
};
static
@@ -385,7 +385,7 @@ int gunzip_main(int argc UNUSED_PARAM, char **argv)
return bbunpack(argv, unpack_gz_stream, make_new_name_gunzip,
/*unused:*/ NULL);
}
-#endif
+#endif /* GUNZIP || ZCAT */
/*
--
2.11.0
More information about the busybox
mailing list