From b1bbb0eb4c91d8e5d170b0cf732daacd0252e459 Mon Sep 17 00:00:00 2001 From: Qiongsi Wu <274595+qiongsiwu@users.noreply.github.com> Date: Fri, 29 Jul 2022 15:21:59 -0400 Subject: [PATCH] [AIX] Fix Compiler Flags and Bugs on AIX to Pass All Tests (#3219) * Fixing compiler warnings * Replace the old -s flag with the -Wl,-s flag * Fixing compiler warnings * Fixing the linker strip flag and tests/code not working as expected on AIX --- programs/Makefile | 2 +- programs/dibio.c | 2 +- programs/fileio.c | 2 +- programs/util.c | 3 +++ tests/playTests.sh | 2 +- 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/programs/Makefile b/programs/Makefile index 16763e493..a5f5b45f2 100644 --- a/programs/Makefile +++ b/programs/Makefile @@ -242,7 +242,7 @@ zstd-pgo : $(MAKE) zstd MOREFLAGS=-fprofile-use ## zstd-small: minimal target, supporting only zstd compression and decompression. no bench. no legacy. no other format. -zstd-small: CFLAGS = -Os -s +zstd-small: CFLAGS = -Os -Wl,-s zstd-frugal zstd-small: $(ZSTDLIB_CORE_SRC) zstdcli.c util.c timefn.c fileio.c fileio_asyncio.c $(CC) $(FLAGS) -DZSTD_NOBENCH -DZSTD_NODICT -DZSTD_NOTRACE -UZSTD_LEGACY_SUPPORT -DZSTD_LEGACY_SUPPORT=0 $^ -o $@$(EXT) diff --git a/programs/dibio.c b/programs/dibio.c index f6757dd34..8643bc378 100644 --- a/programs/dibio.c +++ b/programs/dibio.c @@ -355,7 +355,7 @@ int DiB_trainFromFiles(const char* dictFileName, size_t maxDictSize, } /* Checks */ - if ((!sampleSizes) || (!srcBuffer) || (!dictBuffer)) + if ((fs.nbSamples && !sampleSizes) || (!srcBuffer) || (!dictBuffer)) EXM_THROW(12, "not enough memory for DiB_trainFiles"); /* should not happen */ if (fs.oneSampleTooLarge) { DISPLAYLEVEL(2, "! Warning : some sample(s) are very large \n"); diff --git a/programs/fileio.c b/programs/fileio.c index b8b2818bc..a83b8064a 100644 --- a/programs/fileio.c +++ b/programs/fileio.c @@ -219,7 +219,7 @@ static void ABRThandler(int sig) { } #endif -void FIO_addAbortHandler() +void FIO_addAbortHandler(void) { #if BACKTRACE_ENABLE signal(SIGABRT, ABRThandler); diff --git a/programs/util.c b/programs/util.c index f53eb03fb..50db70fd4 100644 --- a/programs/util.c +++ b/programs/util.c @@ -1378,6 +1378,9 @@ int UTIL_countCores(int logical) int UTIL_countCores(int logical) { + /* suppress unused parameter warning */ + (void)logical; + /* assume 1 */ return 1; } diff --git a/tests/playTests.sh b/tests/playTests.sh index 50aef5df5..0e2b0fbb2 100755 --- a/tests/playTests.sh +++ b/tests/playTests.sh @@ -317,7 +317,7 @@ zstd -d -f tmp_corrupt.zst --no-check zstd -d -f tmp_corrupt.zst --check --no-check # final flag overrides zstd -d -f tmp.zst --no-check -if [ "$isWindows" = false ]; then +if [ "$isWindows" = false ] && [ "$UNAME" != "AIX" ]; then if [ -n "$(which readelf)" ]; then println "test: check if binary has executable stack (#2963)" readelf -lW "$ZSTD_BIN" | grep 'GNU_STACK .* RW ' || die "zstd binary has executable stack!"