diff --git a/README.md b/README.md index 215c9d0..d70d917 100644 --- a/README.md +++ b/README.md @@ -919,6 +919,10 @@ The following environment variables can be used to control the build process: * `CC` – specifies the C compiler (default is `cc`) +* `STRIP` – set to a non-zero value in order to *strip* the generated binaries + +* `STATIC` – set to a non-zero value in order to enable *static* linking + * `FLTO` – set to a non-zero value in order to enable *link-time optimizer* (`-flto`) * `DEBUG` – set to a non-zero value in order to enable "debug" build diff --git a/config.mk b/config.mk index 200f2af..69a815c 100644 --- a/config.mk +++ b/config.mk @@ -11,17 +11,14 @@ ifneq ($(ASAN),) XLDFLAGS += -static-libasan else XCFLAGS = -Ofast -DNDEBUG +endif +endif + ifneq ($(firstword $(filter x86_64-%,$(DUMPMACHINE))),) XCFLAGS += -march=x86-64 -mtune=nocona else ifneq ($(firstword $(filter i686-%,$(DUMPMACHINE))),) XCFLAGS += -march=pentiumpro -mtune=intel endif -ifneq ($(FLTO),) - XCFLAGS += -flto -endif - XLDFLAGS += -s -static -endif -endif ifeq ($(firstword $(filter %-mingw32 %-windows-gnu %-cygwin,$(DUMPMACHINE))),) DLL_LDFLAGS = -shared @@ -34,3 +31,16 @@ ifneq ($(firstword $(filter i686-%,$(DUMPMACHINE))),) XLDFLAGS += -Wl,--large-address-aware endif endif + +ifneq ($(STATIC),) + XLDFLAGS += -static +endif + +ifneq ($(FLTO),) + XCFLAGS += -flto +endif + +ifneq ($(STRIP),) + XLDFLAGS += -Wl,--strip-all + DLL_LDFLAGS += -Wl,--strip-all +endif diff --git a/etc/utils/build-cygwin.sh b/etc/utils/build-cygwin.sh index eebd50f..7643706 100755 --- a/etc/utils/build-cygwin.sh +++ b/etc/utils/build-cygwin.sh @@ -7,8 +7,7 @@ cp -rfv "libhashset/include/"*.h "out/_next/include" target="$(gcc -dumpmachine)" echo -e "--------------------------------\n${target}\n--------------------------------" -make CC="gcc" clean -make CC="gcc" +make CC="gcc" STATIC=1 STRIP=1 rm -rf "out/_next/lib/${target}" "out/_next/bin/${target}" mkdir -pv "out/_next/lib/${target}" "out/_next/bin/${target}" cp -rv "libhashset/lib/"* "out/_next/lib/${target}" diff --git a/etc/utils/build-linux.sh b/etc/utils/build-linux.sh index 3fe8c2a..bbace4c 100755 --- a/etc/utils/build-linux.sh +++ b/etc/utils/build-linux.sh @@ -18,8 +18,7 @@ case "${mode}" in compiler="${target}-linux-gnu-gcc" target="$("${compiler}" -dumpmachine)" echo -e "--------------------------------\n${target}\n--------------------------------" - make CC="${compiler}" clean - make CC="${compiler}" + make CC="${compiler}" STRIP=1 mkdir -pv "out/lib/${target}" "out/bin/${target}" cp -rv "libhashset/lib/"* "out/lib/${target}" for i in example test; do @@ -34,8 +33,7 @@ case "${mode}" in compiler="/usr/local/musl/${target}/bin/musl-gcc" target="$("${compiler}" -dumpmachine | sed 's/-gnu/-musl/i')" echo -e "--------------------------------\n${target}\n--------------------------------" - make CC="${compiler}" clean - make CC="${compiler}" + make CC="${compiler}" STATIC=1 STRIP=1 mkdir -pv "out/lib/${target}" "out/bin/${target}" cp -rv "libhashset/lib/"* "out/lib/${target}" for i in example test; do diff --git a/test/shared/src/random_in.c b/test/shared/src/random_in.c index c26ff96..3362828 100644 --- a/test/shared/src/random_in.c +++ b/test/shared/src/random_in.c @@ -8,6 +8,9 @@ #ifndef _WIN32 # include +# if defined(__APPLE__) && defined(__MACH__) +# include +# endif #endif #define ARRAY_SIZE(X) (sizeof(X) / sizeof((X)[0U]))