Mercurial > hg > toybox
changeset 94:884c03c29f21
Teach build to build only the toys/*.c selected in .config, and teach
CFG_TOYSH_DEBUG to shut up the spurious "gcc can't tell that this is never
actually used uninitialized because gcc is stupid" warnings.
author | Rob Landley <rob@landley.net> |
---|---|
date | Sat, 03 Feb 2007 14:10:00 -0500 |
parents | cc0a6789f92a |
children | a636e4d20f13 |
files | Makefile lib/bunzip.c lib/portability.h toys.h |
diffstat | 4 files changed, 25 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/Makefile Fri Feb 02 10:53:55 2007 -0500 +++ b/Makefile Sat Feb 03 14:10:00 2007 -0500 @@ -37,13 +37,16 @@ bloatcheck: toybox_old toybox_unstripped @scripts/bloat-o-meter toybox_old toybox_unstripped -# Actual build +# Get list of toys/*.c files from .config + +toysfiles = $(shell sed -nre 's/^CONFIG_(.*)=y/\1/;t skip;b;:skip;s/_.*//;p' .config | sort -u | tr A-Z a-z | grep -v '^toybox$$' | sed -r 's@(.*)@toys/\1.c@') -toyfiles = main.c toys/*.c lib/*.c -toybox_unstripped: gen_config.h $(toyfiles) toys/toylist.h lib/lib.h toys.h +# Compile toybox from source + +toyfiles = main.c lib/*.c $(toysfiles) +toybox_unstripped: gen_config.h $(toyfiles) toys/toylist.h lib/*.h toys.h $(CC) $(CFLAGS) -I . $(toyfiles) -o toybox_unstripped \ - -ffunction-sections -fdata-sections -Wl,--gc-sections #\ - #2>&1 | sed -n -e '/may be used uninitialized/{s/.*/\n/;h;b};1{x;b};: print;=;p;x;/\n/b thing;p;: thing;${x;p}' >&2 + -ffunction-sections -fdata-sections -Wl,--gc-sections toybox: toybox_unstripped $(STRIP) toybox_unstripped -o toybox
--- a/lib/bunzip.c Fri Feb 02 10:53:55 2007 -0500 +++ b/lib/bunzip.c Sat Feb 03 14:10:00 2007 -0500 @@ -111,9 +111,9 @@ // Decompress a block of text to intermediate buffer int read_bunzip_data(bunzip_data *bd) { - struct group_data *hufGroup; + struct group_data *hufGroup GCC_BUG; unsigned origPtr; - int dbufCount, nextSym, dbufSize, groupCount, *base, *limit, + int dbufCount, nextSym, dbufSize, groupCount, *base GCC_BUG, *limit GCC_BUG, selector, i, j, k, t, runPos, symCount, symTotal, nSelectors, byteCount[256]; char uc, mtfSymbol[256], symToByte[256], *selectors;
--- a/lib/portability.h Fri Feb 02 10:53:55 2007 -0500 +++ b/lib/portability.h Sat Feb 03 14:10:00 2007 -0500 @@ -25,3 +25,15 @@ #define SWAP_LE32(x) (x) #define SWAP_LE64(x) (x) #endif + +// Some versions of gcc produce spurious "may be uninitialized" warnings in +// cases where it provably can't happen. Unfortunately, although this warning +// is calculated and produced separately from the "is definitely used +// uninitialized" warnings, there's no way to turn off the broken spurious "may +// be" warnings without also turning off the non-broken "is" warnings. + +#if CFG_TOYBOX_DEBUG +#define GCC_BUG =0 +#else +#define GCC_BUG +#endif
--- a/toys.h Fri Feb 02 10:53:55 2007 -0500 +++ b/toys.h Sat Feb 03 14:10:00 2007 -0500 @@ -6,9 +6,12 @@ * Licensed under GPL version 2, see file LICENSE in this tarball for details. */ +#include "gen_config.h" + #include "lib/portability.h" #include <ctype.h> +#include <dirent.h> #include <errno.h> #include <fcntl.h> #include <inttypes.h> @@ -30,7 +33,6 @@ #include <unistd.h> #include "lib/lib.h" -#include "gen_config.h" #include "toys/e2fs.h" #include "toys/toylist.h"