Add optimization option to Makefile. (#283)

This commit is contained in:
Prince Frizzy 2023-02-19 03:40:49 -05:00 committed by GitHub
parent 3bc0b13e20
commit eac1683754
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -57,6 +57,9 @@ DISCORDRPC ?= 0
DISCORD_SDK ?= 1
# Enable docker build workarounds
DOCKERBUILD ?= 0
# Sets your optimization level for building.
# A choose is chosen by default for you.
OPT_LEVEL ?= -1
# Enable compiling with more debug info.
DEBUG_INFO_LEVEL ?= 2
# Enable profiling
@ -199,16 +202,37 @@ else ifeq ($(VERSION),sh)
endif
# Determine our optimization level.
ifeq ($(DEBUG),0)
# Can't use O2 or higher right now for auto-builders, coop-compiler produces strange graphical errors
# likely due to undefined behavior somewhere
#ifeq ($(WINDOWS_AUTO_BUILDER),1)
# OPT_FLAGS := -O1
#else
OPT_FLAGS := -O2
#endif
else
# Optimization Levels 0 through 5 optimize for speed,
# While optimization levels 6, and 7 optimize for size.
# If no optimization is specified, A default is chosen.
ifeq ($(OPT_LEVEL),0) # No optimization
OPT_FLAGS := -O0
else ifeq ($(OPT_LEVEL),1) # Debugging optimization
OPT_FLAGS := -Og
else ifeq ($(OPT_LEVEL),2) # Level 1 Optimization
OPT_FLAGS := -O1
else ifeq ($(OPT_LEVEL),3) # Level 2 Optimization
OPT_FLAGS := -O2
else ifeq ($(OPT_LEVEL),4) # Level 3 Optimization
OPT_FLAGS := -O3
else ifeq ($(OPT_LEVEL),5) # Fastest Optimization
OPT_FLAGS := -Ofast
else ifeq ($(OPT_LEVEL),6) # Size Optimization
OPT_FLAGS := -Os
else ifeq ($(OPT_LEVEL),7) # Aggresive Size Optimization
OPT_FLAGS := -Oz
else
ifeq ($(DEBUG),0)
# Can't use O2 or higher right now for auto-builders, coop-compiler produces strange graphical errors
# likely due to undefined behavior somewhere
#ifeq ($(WINDOWS_AUTO_BUILDER),1)
# OPT_FLAGS := -O1
#else
OPT_FLAGS := -O2
#endif
else
OPT_FLAGS := -O0
endif
endif
# Set our level of debug symbol info,