Add -fno-common to all userland/kernel src builds

-fno-common will become the default in GCC10/LLVM11. Plenty of work has been
put in to make sure our world builds are no -fno-common clean, so let's slap
the build with this until it becomes the compiler default to ensure we don't
regress.

At this time, we will not be enforcing -fno-common on ports builds. I
suspect most ports will be or quickly become -fno-common clean as they're
naturally built against compilers that default to it, so this will hopefully
become a non-issue in due time. The exception to this, which is actually the
status quo, is that kmods built from ports will continue to build with
-fno-common.

As of the time of writing, I intend to also make stable/12 -fno-common
clean. What's been done will be MFC'd to stable/11 if it's easily applicable
and/or not much work to massage it into being functional, but I anticipate
adding -fcommon to stable/11 builds to maintain its ability to be built with
newer compilers for the rest of its lifetime instead of putting in a third
branch's worth of effort.
This commit is contained in:
Kyle Evans 2020-04-07 17:04:24 +00:00
parent 723f904176
commit 8eb1a0ce56
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=359702
3 changed files with 17 additions and 1 deletions

View File

@ -34,6 +34,11 @@ __postrcconf_${var}:= ${MK_${var}:U-}${WITHOUT_${var}:Uno:Dyes}${WITH_${var}:Uno
.endif # SRCCONF
.endif
# The following should be removed no earlier than LLVM11 being imported into the
# tree, to ensure we don't regress the build. LLVM11 and GCC10 will switch the
# default over to -fno-common, making this redundant.
CFLAGS+= -fno-common
# tempting, but bsd.compiler.mk causes problems this early
# probably need to remove dependence on bsd.own.mk
#.include "src.opts.mk"

View File

@ -86,7 +86,7 @@ CFLAGS_PARAM_LARGE_FUNCTION_GROWTH?=1000
.if ${MACHINE_CPUARCH} == "mips"
CFLAGS_ARCH_PARAMS?=--param max-inline-insns-single=1000 -DMACHINE_ARCH='"${MACHINE_ARCH}"'
.endif
CFLAGS.gcc+= -fno-common -fms-extensions -finline-limit=${INLINE_LIMIT}
CFLAGS.gcc+= -fms-extensions -finline-limit=${INLINE_LIMIT}
CFLAGS.gcc+= --param inline-unit-growth=${CFLAGS_PARAM_INLINE_UNIT_GROWTH}
CFLAGS.gcc+= --param large-function-growth=${CFLAGS_PARAM_LARGE_FUNCTION_GROWTH}
CFLAGS.gcc+= -fms-extensions
@ -98,6 +98,10 @@ WERROR?= -Wno-error
.else
WERROR?= -Werror
.endif
# The following should be removed no earlier than LLVM11 being imported into the
# tree, to ensure we don't regress the build. LLVM11 and GCC10 will switch the
# default over to -fno-common, making this redundant.
CFLAGS+= -fno-common
# XXX LOCORE means "don't declare C stuff" not "for locore.s".
ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS} ${ASM_CFLAGS.${.IMPSRC:T}}

View File

@ -133,6 +133,13 @@ CFLAGS.gcc+= --param large-function-growth=1000
# Disallow common variables, and if we end up with commons from
# somewhere unexpected, allocate storage for them in the module itself.
#
# -fno-common is the default for src builds, but this should be left in place
# until at least we catch up to GCC10/LLVM11 or otherwise enable -fno-common
# in <bsd.sys.mk> instead. For now, we will have duplicate -fno-common in
# CFLAGS for in-tree module builds as they will also pick it up from
# share/mk/src.sys.mk, but the following is important for out-of-tree modules
# (e.g. ports).
CFLAGS+= -fno-common
LDFLAGS+= -d -warn-common