From 260995cb05a4e84736d240004d0556b0e2368c20 Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Sun, 1 Mar 2020 13:11:36 +1100 Subject: [PATCH] Have fuzz/c programs define WUFFS_CONFIG__MODULES Before: $ time ./build-fuzz.sh fuzz/c/std/json_fuzzer.c real 0m0.822s user 0m0.792s sys 0m0.031s After: $ time ./build-fuzz.sh fuzz/c/std/json_fuzzer.c real 0m0.294s user 0m0.271s sys 0m0.024s --- fuzz/c/std/gif_fuzzer.c | 14 +++++++++++++- fuzz/c/std/json_fuzzer.c | 11 +++++++++++ fuzz/c/std/zlib_fuzzer.c | 13 +++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/fuzz/c/std/gif_fuzzer.c b/fuzz/c/std/gif_fuzzer.c index af67e920..d2fd1e33 100644 --- a/fuzz/c/std/gif_fuzzer.c +++ b/fuzz/c/std/gif_fuzzer.c @@ -42,13 +42,25 @@ It should print "PASS", amongst other information, and exit(0). // compiling it. #define WUFFS_IMPLEMENTATION +// Defining the WUFFS_CONFIG__MODULE* macros are optional, but it lets users of +// release/c/etc.c whitelist which parts of Wuffs to build. That file contains +// the entire Wuffs standard library, implementing a variety of codecs and file +// formats. Without this macro definition, an optimizing compiler or linker may +// very well discard Wuffs code for unused codecs, but listing the Wuffs +// modules we use makes that process explicit. Preprocessing means that such +// code simply isn't compiled. +#define WUFFS_CONFIG__MODULES +#define WUFFS_CONFIG__MODULE__BASE +#define WUFFS_CONFIG__MODULE__GIF +#define WUFFS_CONFIG__MODULE__LZW + // If building this program in an environment that doesn't easily accommodate // relative includes, you can use the script/inline-c-relative-includes.go // program to generate a stand-alone C file. #include "../../../release/c/wuffs-unsupported-snapshot.c" #include "../fuzzlib/fuzzlib.c" -const char* // +const char* // fuzz(wuffs_base__io_buffer* src, uint32_t hash) { const char* ret = NULL; wuffs_base__slice_u8 pixbuf = ((wuffs_base__slice_u8){}); diff --git a/fuzz/c/std/json_fuzzer.c b/fuzz/c/std/json_fuzzer.c index 14774b8c..e00f3ace 100644 --- a/fuzz/c/std/json_fuzzer.c +++ b/fuzz/c/std/json_fuzzer.c @@ -42,6 +42,17 @@ It should print "PASS", amongst other information, and exit(0). // compiling it. #define WUFFS_IMPLEMENTATION +// Defining the WUFFS_CONFIG__MODULE* macros are optional, but it lets users of +// release/c/etc.c whitelist which parts of Wuffs to build. That file contains +// the entire Wuffs standard library, implementing a variety of codecs and file +// formats. Without this macro definition, an optimizing compiler or linker may +// very well discard Wuffs code for unused codecs, but listing the Wuffs +// modules we use makes that process explicit. Preprocessing means that such +// code simply isn't compiled. +#define WUFFS_CONFIG__MODULES +#define WUFFS_CONFIG__MODULE__BASE +#define WUFFS_CONFIG__MODULE__JSON + // If building this program in an environment that doesn't easily accommodate // relative includes, you can use the script/inline-c-relative-includes.go // program to generate a stand-alone C file. diff --git a/fuzz/c/std/zlib_fuzzer.c b/fuzz/c/std/zlib_fuzzer.c index ff673501..f665a66d 100644 --- a/fuzz/c/std/zlib_fuzzer.c +++ b/fuzz/c/std/zlib_fuzzer.c @@ -42,6 +42,19 @@ It should print "PASS", amongst other information, and exit(0). // compiling it. #define WUFFS_IMPLEMENTATION +// Defining the WUFFS_CONFIG__MODULE* macros are optional, but it lets users of +// release/c/etc.c whitelist which parts of Wuffs to build. That file contains +// the entire Wuffs standard library, implementing a variety of codecs and file +// formats. Without this macro definition, an optimizing compiler or linker may +// very well discard Wuffs code for unused codecs, but listing the Wuffs +// modules we use makes that process explicit. Preprocessing means that such +// code simply isn't compiled. +#define WUFFS_CONFIG__MODULES +#define WUFFS_CONFIG__MODULE__BASE +#define WUFFS_CONFIG__MODULE__ADLER32 +#define WUFFS_CONFIG__MODULE__DEFLATE +#define WUFFS_CONFIG__MODULE__ZLIB + // If building this program in an environment that doesn't easily accommodate // relative includes, you can use the script/inline-c-relative-includes.go // program to generate a stand-alone C file.