From 9d5506966a3e27d22cf16aa2cdf20d8ead05e09e Mon Sep 17 00:00:00 2001
From: Albert Graef <aggraef@gmail.com>
Date: Mon, 26 Aug 2019 23:19:13 +0200
Subject: [PATCH] add -fno-strict-aliasing where it's needed to get rid of gcc
 warnings about type-punned pointers

---
 externals/Makefile          |  4 ++--
 externals/OSCx/configure.ac |  4 ++--
 externals/bsaylor/Makefile  |  8 ++++----
 externals/moonlib/Makefile  | 12 ++++++------
 4 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/externals/Makefile b/externals/Makefile
index 220ccb288..68119758f 100644
--- a/externals/Makefile
+++ b/externals/Makefile
@@ -374,7 +374,7 @@ boids_clean:
 #------------------------------------------------------------------------------#
 # BSAYLOR
 bsaylor:
-	make -C $(externals_src)/bsaylor PD_PATH=$(pd_src) CFLAGS="$(CFLAGS)"
+	make -C $(externals_src)/bsaylor PD_PATH=$(pd_src) CFLAGS="$(CFLAGS) -fno-strict-aliasing"
 
 bsaylor_install:
 	make -C $(externals_src)/bsaylor \
@@ -1300,7 +1300,7 @@ moocow_clean:
 #------------------------------------------------------------------------------#
 # MOONLIB
 moonlib:
-	make -C $(externals_src)/moonlib PD_PATH=$(pd_src) CFLAGS="$(CFLAGS)"
+	make -C $(externals_src)/moonlib PD_PATH=$(pd_src) CFLAGS="$(CFLAGS) -fno-strict-aliasing"
 
 moonlib_install:
 	make -C $(externals_src)/moonlib DESTDIR="$(DESTDIR)" objectsdir="$(objectsdir)" install
diff --git a/externals/OSCx/configure.ac b/externals/OSCx/configure.ac
index 99807ac16..683c0d42e 100644
--- a/externals/OSCx/configure.ac
+++ b/externals/OSCx/configure.ac
@@ -78,7 +78,7 @@ if test -z "$GCC"; then
 else
         case $host in 
         *86*-linux*)
-                CFLAGS="$CFLAGS -DUNIX -Wall -Wimplicit -Wunused -Wmissing-prototypes -O2 -fPIC"
+                CFLAGS="$CFLAGS -DUNIX -Wall -Wimplicit -Wunused -Wmissing-prototypes -O2 -fno-strict-aliasing -fPIC"
 					 LDFLAGS="-Wl,--export-dynamic -shared"
 					 dnl we could test for bad glibc here, but don't
 					 pd_suffix=pd_linux
@@ -115,7 +115,7 @@ else
 					 LIBS="-L../../../pd/src -L../../../pd/bin -L../../../pd/obj -lpd -lm -lwsock32"
 					 ;;
         *-*-darwin*)
-                CFLAGS="$CFLAGS -DUNIX -Wall -Wimplicit -Wunused -Wmissing-prototypes -O3 "
+                CFLAGS="$CFLAGS -DUNIX -Wall -Wimplicit -Wunused -Wmissing-prototypes -O3 -fno-strict-aliasing "
 					 LDFLAGS=" -bundle -bundle_loader ../../../pd/bin/pd-l2ork -flat_namespace "
 					 pd_suffix=pd_darwin
 					 LIBS="-lc -lm"
diff --git a/externals/bsaylor/Makefile b/externals/bsaylor/Makefile
index af6209458..bc2d032dc 100644
--- a/externals/bsaylor/Makefile
+++ b/externals/bsaylor/Makefile
@@ -84,7 +84,7 @@ ifeq ($(UNAME),Darwin)
     CXX=$(IPHONE_BASE)/g++
     ISYSROOT = -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk
     IPHONE_CFLAGS = -miphoneos-version-min=3.0 $(ISYSROOT) -arch armv6
-    OPT_CFLAGS = -fast -funroll-loops -fomit-frame-pointer
+    OPT_CFLAGS = -fast -funroll-loops -fomit-frame-pointer -fno-strict-aliasing
 	CFLAGS := $(IPHONE_CFLAGS) $(OPT_CFLAGS) $(CFLAGS)
     LDFLAGS += -arch armv6 -bundle -undefined dynamic_lookup $(ISYSROOT)
     LIBS += -lc 
@@ -120,7 +120,7 @@ ifeq ($(UNAME),Linux)
   EXTENSION = pd_linux
   OS = linux
   PD_PATH = /usr
-  OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer
+  OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer -fno-strict-aliasing
   CFLAGS += -fPIC
   LDFLAGS += -Wl,--export-dynamic  -shared -fPIC
   LIBS += -lc
@@ -133,7 +133,7 @@ ifeq (CYGWIN,$(findstring CYGWIN,$(UNAME)))
   EXTENSION = dll
   OS = cygwin
   PD_PATH = $(cygpath $(PROGRAMFILES))/pd
-  OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer
+  OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer -fno-strict-aliasing
   CFLAGS += 
   LDFLAGS += -Wl,--export-dynamic -shared -L"$(PD_PATH)/src" -L"$(PD_PATH)/bin"
   LIBS += -lc -lpd
@@ -146,7 +146,7 @@ ifeq (MINGW,$(findstring MINGW,$(UNAME)))
   EXTENSION = dll
   OS = windows
   PD_PATH = $(shell cd "$(PROGRAMFILES)"/pd && pwd)
-  OPT_CFLAGS = -O3 -funroll-loops -fomit-frame-pointer
+  OPT_CFLAGS = -O3 -funroll-loops -fomit-frame-pointer -fno-strict-aliasing
   CFLAGS += -mms-bitfields
   LDFLAGS += -s -shared -Wl,--enable-auto-import
   LIBS += -L"$(PD_PATH)/src" -L"$(PD_PATH)/bin" -L"$(PD_PATH)/obj" -lpd -lwsock32 -lkernel32 -luser32 -lgdi32
diff --git a/externals/moonlib/Makefile b/externals/moonlib/Makefile
index 63623f03d..b5ee48d9f 100644
--- a/externals/moonlib/Makefile
+++ b/externals/moonlib/Makefile
@@ -143,7 +143,7 @@ ifeq ($(UNAME),ANDROID)
   NDK_UNAME := $(shell uname -s | tr '[A-Z]' '[a-z]')
   NDK_TOOLCHAIN_BASE=$(NDK_BASE)/toolchains/arm-linux-androideabi-4.4.3/prebuilt/$(NDK_UNAME)-x86
   CC := $(NDK_TOOLCHAIN_BASE)/bin/arm-linux-androideabi-gcc --sysroot=$(NDK_SYSROOT)
-  OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer
+  OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer -fno-strict-aliasing
   CFLAGS += 
   LDFLAGS += -rdynamic -shared
   SHARED_LDFLAGS += -Wl,-soname,$(SHARED_LIB) -shared
@@ -159,7 +159,7 @@ ifeq ($(UNAME),Linux)
   SHARED_EXTENSION = so
   OS = linux
   PD_PATH = /usr
-  OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer
+  OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer -fno-strict-aliasing
   ALL_CFLAGS += -fPIC
   ALL_LDFLAGS += -rdynamic -shared -fPIC
   SHARED_LDFLAGS += -Wl,-soname,$(SHARED_LIB) -shared
@@ -175,7 +175,7 @@ ifeq ($(UNAME),GNU)
   SHARED_EXTENSION = so
   OS = linux
   PD_PATH = /usr
-  OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer
+  OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer -fno-strict-aliasing
   ALL_CFLAGS += -fPIC
   ALL_LDFLAGS += -rdynamic -shared -fPIC
   SHARED_LDFLAGS += -shared -Wl,-soname,$(SHARED_LIB)
@@ -191,7 +191,7 @@ ifeq ($(UNAME),GNU/kFreeBSD)
   SHARED_EXTENSION = so
   OS = linux
   PD_PATH = /usr
-  OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer
+  OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer -fno-strict-aliasing
   ALL_CFLAGS += -fPIC
   ALL_LDFLAGS += -rdynamic -shared -fPIC
   SHARED_LDFLAGS += -shared -Wl,-soname,$(SHARED_LIB)
@@ -206,7 +206,7 @@ ifeq (CYGWIN,$(findstring CYGWIN,$(UNAME)))
   SHARED_EXTENSION = dll
   OS = cygwin
   PD_PATH = $(shell cygpath $$PROGRAMFILES)/pd
-  OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer
+  OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer -fno-strict-aliasing
   ALL_CFLAGS += 
   ALL_LDFLAGS += -rdynamic -shared -L"$(PD_PATH)/src" -L"$(PD_PATH)/bin"
   SHARED_LDFLAGS += -shared -Wl,-soname,$(SHARED_LIB)
@@ -223,7 +223,7 @@ ifeq (MINGW,$(findstring MINGW,$(UNAME)))
   PD_PATH = $(shell cd "$$PROGRAMFILES/pd" && pwd)
   # MinGW doesn't seem to include cc so force gcc
   CC=gcc
-  OPT_CFLAGS = -O3 -funroll-loops -fomit-frame-pointer
+  OPT_CFLAGS = -O3 -funroll-loops -fomit-frame-pointer -fno-strict-aliasing
   ALL_CFLAGS += -mms-bitfields
   ALL_LDFLAGS += -s -shared -Wl,--enable-auto-import -L"$(PD_PATH)/src" -L"$(PD_PATH)/bin" -L"$(PD_PATH)/obj"
   SHARED_LDFLAGS += -shared
-- 
GitLab