From 2fe47af9772d8a751f0efe4aa75a83f418f5a3ab Mon Sep 17 00:00:00 2001
From: fbrosson <fbrosson@localhost>
Date: Wed, 28 Mar 2018 16:51:49 +0000
Subject: Drop gcc options unknown to gcc2.


diff --git a/lib/Makefile b/lib/Makefile
index 7c6dff0..f562ae6 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -35,10 +35,10 @@ CPPFLAGS+= -DXXH_NAMESPACE=ZSTD_
 ifeq ($(TARGET_SYSTEM),Windows_NT)   # MinGW assumed
 CPPFLAGS   += -D__USE_MINGW_ANSI_STDIO   # compatibility with %zu formatting
 endif
-DEBUGFLAGS= -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow \
+DEBUGFLAGS= -Wall          -Wcast-qual -Wcast-align -Wshadow \
             -Wstrict-aliasing=1 -Wswitch-enum -Wdeclaration-after-statement \
             -Wstrict-prototypes -Wundef -Wpointer-arith \
-            -Wvla -Wformat=2 -Winit-self -Wfloat-equal -Wwrite-strings \
+            -Wvla -Wformat=2                           -Wwrite-strings \
             -Wredundant-decls -Wmissing-prototypes -Wc++-compat
 CFLAGS  += $(DEBUGFLAGS) $(MOREFLAGS)
 FLAGS    = $(CPPFLAGS) $(CFLAGS)
@@ -204,7 +204,7 @@ $(LIBZSTD): $(ZSTD_FILES)
 else
 
 LIBZSTD = libzstd.$(SHARED_EXT_VER)
-$(LIBZSTD): LDFLAGS += -shared -fPIC -fvisibility=hidden
+$(LIBZSTD): LDFLAGS += -shared -fPIC
 $(LIBZSTD): $(ZSTD_FILES)
 	@echo compiling dynamic library $(LIBVER)
 	$(Q)$(CC) $(FLAGS) $^ $(LDFLAGS) $(SONAME_FLAGS) -o $@
diff --git a/programs/Makefile b/programs/Makefile
index 418ad4e..f413fe0 100644
--- a/programs/Makefile
+++ b/programs/Makefile
@@ -48,10 +48,10 @@ ifeq ($(OS),Windows_NT)   # MinGW assumed
 CPPFLAGS   += -D__USE_MINGW_ANSI_STDIO   # compatibility with %zu formatting
 endif
 CFLAGS  ?= -O3
-DEBUGFLAGS+=-Wall -Wextra -Wcast-qual -Wcast-align -Wshadow \
+DEBUGFLAGS+=-Wall         -Wcast-qual -Wcast-align -Wshadow \
             -Wstrict-aliasing=1 -Wswitch-enum -Wdeclaration-after-statement \
             -Wstrict-prototypes -Wundef -Wpointer-arith \
-            -Wvla -Wformat=2 -Winit-self -Wfloat-equal -Wwrite-strings \
+            -Wvla -Wformat=2                           -Wwrite-strings \
             -Wredundant-decls -Wmissing-prototypes -Wc++-compat
 CFLAGS  += $(DEBUGFLAGS) $(MOREFLAGS)
 FLAGS    = $(CPPFLAGS) $(CFLAGS) $(LDFLAGS)
-- 
2.24.0


From 5a875715d5e58fc257f8661fb3751280c0854157 Mon Sep 17 00:00:00 2001
From: fbrosson <fbrosson@localhost>
Date: Mon, 29 Oct 2018 19:39:46 +0000
Subject: Remove "-Werror" from MOREFLAGS to fix "make test" with gcc2.


diff --git a/Makefile b/Makefile
index 2c1d346..ff1cf6d 100644
--- a/Makefile
+++ b/Makefile
@@ -75,7 +75,7 @@ zlibwrapper: lib
 ## test: run long-duration tests
 .PHONY: test
 DEBUGLEVEL ?= 1
-test: MOREFLAGS += -g -DDEBUGLEVEL=$(DEBUGLEVEL) -Werror
+test: MOREFLAGS += -g -DDEBUGLEVEL=$(DEBUGLEVEL)
 test:
 	MOREFLAGS="$(MOREFLAGS)" $(MAKE) -j -C $(PRGDIR) allVariants
 	$(MAKE) -C $(TESTDIR) $@
-- 
2.24.0


From 26ade9ffb085e6d158febfe1cc45441957954df5 Mon Sep 17 00:00:00 2001
From: fbrosson <fbrosson@localhost>
Date: Tue, 30 Oct 2018 11:07:16 +0000
Subject: Drop gcc options unknown to gcc2 in tests/Makefile.


diff --git a/tests/Makefile b/tests/Makefile
index d347a94..b388642 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -32,10 +32,10 @@ ifeq ($(OS),Windows_NT)   # MinGW assumed
 CPPFLAGS   += -D__USE_MINGW_ANSI_STDIO   # compatibility with %zu formatting
 endif
 CFLAGS     ?= -O3
-CFLAGS     += -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow                 \
+CFLAGS     += -Wall         -Wcast-qual -Wcast-align -Wshadow                 \
               -Wstrict-aliasing=1 -Wswitch-enum -Wdeclaration-after-statement \
               -Wstrict-prototypes -Wundef                                     \
-              -Wvla -Wformat=2 -Winit-self -Wfloat-equal -Wwrite-strings      \
+              -Wvla -Wformat=2                           -Wwrite-strings      \
               -Wredundant-decls -Wmissing-prototypes
 CFLAGS     += $(DEBUGFLAGS) $(MOREFLAGS)
 FLAGS       = $(CPPFLAGS) $(CFLAGS) $(LDFLAGS)
-- 
2.24.0


From c4d44669d6801adf7a1e255b81819346725ffe4a Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Fri, 22 May 2020 16:40:27 +0200
Subject: Haiku: older GCCs don't support some pragmas and builtins.


diff --git a/lib/common/compiler.h b/lib/common/compiler.h
index 95e9483..8d6110d 100644
--- a/lib/common/compiler.h
+++ b/lib/common/compiler.h
@@ -139,7 +139,7 @@
 
 /* vectorization
  * older GCC (pre gcc-4.3 picked as the cutoff) uses a different syntax */
-#if !defined(__INTEL_COMPILER) && !defined(__clang__) && defined(__GNUC__)
+#if !defined(__INTEL_COMPILER) && !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 3)
 #  if (__GNUC__ == 4 && __GNUC_MINOR__ > 3) || (__GNUC__ >= 5)
 #    define DONT_VECTORIZE __attribute__((optimize("no-tree-vectorize")))
 #  else
@@ -154,7 +154,7 @@
  * If you can remove a LIKELY/UNLIKELY annotation without speed changes in gcc
  * and clang, please do.
  */
-#if defined(__GNUC__)
+#if defined(__GNUC__) && (__GNUC__ >= 3)
 #define LIKELY(x) (__builtin_expect((x), 1))
 #define UNLIKELY(x) (__builtin_expect((x), 0))
 #else
-- 
2.24.0


From 628a21607747ef5c8eb8a30a3b7f7aeb94388ca1 Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Fri, 22 May 2020 16:48:49 +0200
Subject: remove gcc options unsupported by gcc2


diff --git a/lib/Makefile b/lib/Makefile
index f562ae6..0f0a1d8 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -36,10 +36,9 @@ ifeq ($(TARGET_SYSTEM),Windows_NT)   # MinGW assumed
 CPPFLAGS   += -D__USE_MINGW_ANSI_STDIO   # compatibility with %zu formatting
 endif
 DEBUGFLAGS= -Wall          -Wcast-qual -Wcast-align -Wshadow \
-            -Wstrict-aliasing=1 -Wswitch-enum -Wdeclaration-after-statement \
             -Wstrict-prototypes -Wundef -Wpointer-arith \
-            -Wvla -Wformat=2                           -Wwrite-strings \
-            -Wredundant-decls -Wmissing-prototypes -Wc++-compat
+                  -Wformat=2                           -Wwrite-strings \
+            -Wredundant-decls -Wmissing-prototypes
 CFLAGS  += $(DEBUGFLAGS) $(MOREFLAGS)
 FLAGS    = $(CPPFLAGS) $(CFLAGS)
 
-- 
2.24.0
