From 9699c49f55b1470cdb37348299a77e7f8e3e5297 Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Mon, 4 Oct 2021 12:59:00 +1100 Subject: [PATCH] Have example/crc32 use WUFFS_CONFIG__MODULES Compile time: $ time ./build-example.sh example/crc32 Before: user 10.637s After: user 1.314s Binary size: $ ls -l gen/bin/example-crc32 | awk '{print $5}' Before: 344744 After: 37112 --- example/crc32/crc32.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/example/crc32/crc32.cc b/example/crc32/crc32.cc index e1dc82ce..eb554a03 100644 --- a/example/crc32/crc32.cc +++ b/example/crc32/crc32.cc @@ -52,6 +52,17 @@ for a C++ compiler $CXX, such as clang++ or g++. // https://raw.githubusercontent.com/nothings/stb/master/docs/stb_howto.txt #define WUFFS_CONFIG__STATIC_FUNCTIONS +// Defining the WUFFS_CONFIG__MODULE* macros are optional, but it lets users of +// release/c/etc.c choose 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__CRC32 + // 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.