From 39d33c4cc9059b2d1a18162763bf1151befe32e5 Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Wed, 2 Nov 2022 12:19:55 -1000 Subject: [PATCH] makefile: Add WARNINGS=ALLOWED make option and change default optimize to -O2 The CI build specifies OPTIMIZE=-O3 and runs with the default where warnings are converted to errors. --- .github/workflows/build.yml | 2 +- makefile | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2190f428..9311800d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -32,4 +32,4 @@ jobs: - name: Build env: SIM: ${{matrix.simulators}} - run: make LTO=1 $SIM + run: make LTO=1 OPTIMIZE=-O3 $SIM diff --git a/makefile b/makefile index b0d1d7ea..705d4aa4 100644 --- a/makefile +++ b/makefile @@ -50,10 +50,16 @@ # the results. Link Time Optimization can report errors which aren't # otherwise detected and will also take significantly longer to # complete. Additionally, non debug builds default to build with an -# optimization level of -O3. This optimization level can be changed -# by invoking GNU OPTIMIZE=-O2 (or whatever optimize value you want) +# optimization level of -O2. This optimization level can be changed +# by invoking GNU OPTIMIZE=-O3 (or whatever optimize value you want) # on the command line if desired. # +# The default setup will fail simulator build(s) if the compile +# produces any warnings. These should be cleaned up before new +# or changd code is accepted into the code base. This option +# can be overridden if GNU make is invoked with WARNINGS=ALLOWED +# on the command line. +# # The default build will run per simulator tests if they are # available. If building without running tests is desired, # then GNU make should be invoked with TESTS=0 on the command @@ -267,7 +273,7 @@ ifeq (${WIN32},) #*nix Environments (&& cygwin) endif endif else - OS_CCDEFS += -Werror + OS_CCDEFS += $(if $(findstring ALLOWED,$(WARNINGS)),,-Werror) ifeq (,$(findstring ++,${GCC})) CC_STD = -std=gnu99 else @@ -275,7 +281,7 @@ ifeq (${WIN32},) #*nix Environments (&& cygwin) endif endif else - OS_CCDEFS += -Werror + OS_CCDEFS += $(if $(findstring ALLOWED,$(WARNINGS)),,-Werror) ifeq (Apple,$(shell ${GCC} -v /dev/null 2>&1 | grep 'Apple' | awk '{ print $$1 }')) COMPILER_NAME = $(shell ${GCC} -v /dev/null 2>&1 | grep 'Apple' | awk '{ print $$1 " " $$2 " " $$3 " " $$4 }') CLANG_VERSION = $(word 4,$(COMPILER_NAME)) @@ -1266,7 +1272,7 @@ endif ifneq (,$(UNSUPPORTED_BUILD)) CFLAGS_GIT += -DSIM_BUILD=Unsupported=$(UNSUPPORTED_BUILD) endif -OPTIMIZE ?= -O3 +OPTIMIZE ?= -O2 ifneq ($(DEBUG),) CFLAGS_G = -g -ggdb -g3 CFLAGS_O = -O0