Build debug kernels with -O2.

LLVM 11 changed the meaning of '-O' from '-O2' to '-O1', which resulted
in debug kernels (with 'makeoptions DEBUG=-g') being built with inlining
disabled, causing severe performance hit.

The -O2 was already being used for building amd64, powerpc, and powerpcspe.

Discussed with:	jrtc27, arichardson, bdragon, jhibbits
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D26471
This commit is contained in:
Edward Tomasz Napierala 2020-09-29 11:48:22 +00:00
parent 3409864922
commit 39e75a5a79
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=366251

View File

@ -51,25 +51,14 @@ OBJCOPY?= objcopy
SIZE?= size
.if defined(DEBUG)
.if ${MACHINE_ARCH} == "powerpc" || ${MACHINE_ARCH} == "powerpcspe"
# Work around clang 11 miscompile on 32 bit powerpc.
_MINUS_O= -O2
.else
_MINUS_O= -O
.endif
CTFFLAGS+= -g
.else
_MINUS_O= -O2
.endif
.if ${MACHINE_CPUARCH} == "amd64"
.if ${COMPILER_TYPE} == "clang"
COPTFLAGS?=-O2 -pipe
.if ${MACHINE_CPUARCH} == "amd64" && ${COMPILER_TYPE} != "clang"
_COPTFLAGS_EXTRA=-frename-registers
.else
COPTFLAGS?=-O2 -frename-registers -pipe
.endif
.else
COPTFLAGS?=${_MINUS_O} -pipe
_COPTFLAGS_EXTRA=
.endif
COPTFLAGS?=-O2 -pipe ${_COPTFLAGS_EXTRA}
.if !empty(COPTFLAGS:M-O[23s]) && empty(COPTFLAGS:M-fno-strict-aliasing)
COPTFLAGS+= -fno-strict-aliasing
.endif