From 810e33125bafc955d2efcb69b73e9a3842ffacd1 Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Sun, 20 Dec 2020 11:16:31 +0700 Subject: [PATCH] Update how we configure gcc / clang command lines. (#103) * Move clang/gcc options into makefile-header. This puts all of the shared options into a single place so that we can easily update it. * Add -fwrapv to the clang/gcc command lines. This is a step along the way to fixing interlisp/medley#90. Enabling `-fwrapv` will let overflow checks that rely upon undefined behavior to work correctly. Without this, with modern versions of clang and gcc, the overflow checks in the C code are eliminated by the compiler, resulting in incorrect behavior on the part of Maiko. See the linked bug for details and discussion. Hopefully, this usage of `-fwrapv` will go away once we're using the correct compiler builtins to detect and handle overflow correctly. --- bin/makefile-darwin.386-x | 2 +- bin/makefile-darwin.aarch64-x | 2 +- bin/makefile-darwin.x86_64-x | 2 +- bin/makefile-header | 4 ++++ bin/makefile-init.386 | 2 +- bin/makefile-linux.386-x | 4 ++-- bin/makefile-linux.armv7l-x | 4 ++-- bin/makefile-linux.x86_64-x | 4 ++-- bin/makefile-sunos5.386-x | 2 +- bin/makefile-sunos5.sparc-x | 2 +- bin/makefile-sunos5.x86_64-x | 2 +- 11 files changed, 17 insertions(+), 13 deletions(-) diff --git a/bin/makefile-darwin.386-x b/bin/makefile-darwin.386-x index 11ab431..c365249 100644 --- a/bin/makefile-darwin.386-x +++ b/bin/makefile-darwin.386-x @@ -1,6 +1,6 @@ # Options for MacOS, x86 processor, X windows -CC = clang -m32 -std=gnu89 -funsigned-char -fno-strict-aliasing +CC = clang -m32 $(CLANG_CFLAGS) OEXT=.o XFILES = $(OBJECTDIR)xmkicon.o \ diff --git a/bin/makefile-darwin.aarch64-x b/bin/makefile-darwin.aarch64-x index 80ff0e3..44463ea 100644 --- a/bin/makefile-darwin.aarch64-x +++ b/bin/makefile-darwin.aarch64-x @@ -1,6 +1,6 @@ # Options for MacOS, x86 processor, X windows -CC = clang -std=gnu89 -funsigned-char -fno-strict-aliasing +CC = clang $(CLANG_CFLAGS) OEXT=.o XFILES = $(OBJECTDIR)xmkicon.o \ diff --git a/bin/makefile-darwin.x86_64-x b/bin/makefile-darwin.x86_64-x index aeda485..1692894 100644 --- a/bin/makefile-darwin.x86_64-x +++ b/bin/makefile-darwin.x86_64-x @@ -1,6 +1,6 @@ # Options for MacOS, x86 processor, X windows -CC = clang -m64 -std=gnu89 -funsigned-char -fno-strict-aliasing +CC = clang -m64 $(CLANG_CFLAGS) OEXT=.o XFILES = $(OBJECTDIR)xmkicon.o \ diff --git a/bin/makefile-header b/bin/makefile-header index 2180d62..0756251 100755 --- a/bin/makefile-header +++ b/bin/makefile-header @@ -13,6 +13,10 @@ RANLIB = ranlib AR = ar rcv ANSICC = $(CC) +# Compiler flags +CLANG_CFLAGS = -std=gnu89 -funsigned-char -fno-strict-aliasing -fwrapv +GCC_CFLAGS = -std=gnu89 -funsigned-char -fno-strict-aliasing -fwrapv + # for the files that need to be included in byte-swapped implementations: BYTESWAPFILES = SXHASHFILE = diff --git a/bin/makefile-init.386 b/bin/makefile-init.386 index 77b1dbe..4237dfc 100644 --- a/bin/makefile-init.386 +++ b/bin/makefile-init.386 @@ -1,6 +1,6 @@ # Options for MacOS, x86 processor, X windows, for INIT processing -CC = clang -m32 -std=gnu89 -Wimplicit-function-declaration +CC = clang -m32 $(CLANG_CFLAGS) OEXT=.o XFILES = $(OBJECTDIR)xmkicon.o \ diff --git a/bin/makefile-linux.386-x b/bin/makefile-linux.386-x index 8c15583..d85f8ab 100644 --- a/bin/makefile-linux.386-x +++ b/bin/makefile-linux.386-x @@ -1,7 +1,7 @@ # Options for Linux, Intel 386/486 and X-Window -#CC = gcc -m32 -std=gnu89 -fno-omit-frame-pointer -Wall -Wextra -fwrapv -fno-aggressive-loop-optimizations -fno-strict-aliasing -CC = clang -m32 -std=gnu89 -funsigned-char -fno-strict-aliasing +#CC = gcc -m32 $(GCC_CFLAGS) -fno-omit-frame-pointer -Wall -Wextra -fno-aggressive-loop-optimizations +CC = clang -m32 $(CLANG_CFLAGS) XFILES = $(OBJECTDIR)xmkicon.o \ $(OBJECTDIR)xbbt.o \ $(OBJECTDIR)dspif.o \ diff --git a/bin/makefile-linux.armv7l-x b/bin/makefile-linux.armv7l-x index 8c15583..d85f8ab 100644 --- a/bin/makefile-linux.armv7l-x +++ b/bin/makefile-linux.armv7l-x @@ -1,7 +1,7 @@ # Options for Linux, Intel 386/486 and X-Window -#CC = gcc -m32 -std=gnu89 -fno-omit-frame-pointer -Wall -Wextra -fwrapv -fno-aggressive-loop-optimizations -fno-strict-aliasing -CC = clang -m32 -std=gnu89 -funsigned-char -fno-strict-aliasing +#CC = gcc -m32 $(GCC_CFLAGS) -fno-omit-frame-pointer -Wall -Wextra -fno-aggressive-loop-optimizations +CC = clang -m32 $(CLANG_CFLAGS) XFILES = $(OBJECTDIR)xmkicon.o \ $(OBJECTDIR)xbbt.o \ $(OBJECTDIR)dspif.o \ diff --git a/bin/makefile-linux.x86_64-x b/bin/makefile-linux.x86_64-x index 23232a7..51c7581 100644 --- a/bin/makefile-linux.x86_64-x +++ b/bin/makefile-linux.x86_64-x @@ -1,7 +1,7 @@ # Options for Linux, Intel x86_64 and X-Window -#CC = gcc -m64 -std=gnu89 -fno-omit-frame-pointer -Wall -Wextra -fwrapv -fno-aggressive-loop-optimizations -fno-strict-aliasing -CC = clang -m64 -std=gnu89 -funsigned-char -fno-strict-aliasing +#CC = gcc -m64 $(GCC_CFLAGS) -fno-omit-frame-pointer -Wall -Wextra -fno-aggressive-loop-optimizations +CC = clang -m64 $(CLANG_CFLAGS) XFILES = $(OBJECTDIR)xmkicon.o \ $(OBJECTDIR)xbbt.o \ diff --git a/bin/makefile-sunos5.386-x b/bin/makefile-sunos5.386-x index 474f10a..c51a531 100644 --- a/bin/makefile-sunos5.386-x +++ b/bin/makefile-sunos5.386-x @@ -10,7 +10,7 @@ #* */ #************************************************************************/ -CC = clang -m32 -std=gnu89 -funsigned-char -fno-strict-aliasing +CC = clang -m32 $(CLANG_CFLAGS) XFILES = $(OBJECTDIR)xmkicon.o \ $(OBJECTDIR)xbbt.o \ diff --git a/bin/makefile-sunos5.sparc-x b/bin/makefile-sunos5.sparc-x index 86108c3..d2fc0c9 100644 --- a/bin/makefile-sunos5.sparc-x +++ b/bin/makefile-sunos5.sparc-x @@ -13,7 +13,7 @@ #************************************************************************/ # Setup for using gcc -# CC = gcc -std=gnu89 -funsigned-char +# CC = gcc $(GCC_CFLAGS) # Setup for using Solaris Developer Studio 12.6 cc # CC = cc -m32 -funsigned-char diff --git a/bin/makefile-sunos5.x86_64-x b/bin/makefile-sunos5.x86_64-x index 966f970..67c01e8 100644 --- a/bin/makefile-sunos5.x86_64-x +++ b/bin/makefile-sunos5.x86_64-x @@ -10,7 +10,7 @@ #* */ #************************************************************************/ -CC = clang -std=gnu89 -funsigned-char -fno-strict-aliasing +CC = clang $(CLANG_CFLAGS) XFILES = $(OBJECTDIR)xmkicon.o \ $(OBJECTDIR)xbbt.o \