blob: 4c9522e65fce255eadba551704f9d8f8fa693af8 [file] [log] [blame] [raw]
Allow the kernel source be compiled with original gcc(1).
diff -ru --exclude-from freebsd-src-diff-exclude-names /usr/src/sys/conf/kern.mk freebsd-11.1/sys/conf/kern.mk
--- /usr/src/sys/conf/kern.mk 2017-07-21 07:41:43.000000000 +0800
+++ freebsd-11.1/sys/conf/kern.mk 2019-12-21 13:05:45.607485672 +0800
@@ -4,7 +4,7 @@
# Warning flags for compiling the kernel and components of the kernel:
#
CWARNFLAGS?= -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes \
- -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual \
+ -Wpointer-arith -Wcast-qual \
-Wundef -Wno-pointer-sign ${FORMAT_EXTENSIONS} \
-Wmissing-include-dirs -fdiagnostics-show-option \
-Wno-unknown-pragmas \
@@ -45,29 +45,33 @@
.endif
.if ${COMPILER_TYPE} == "gcc"
-.if ${COMPILER_VERSION} >= 40800
+.if ${COMPILER_VERSION} >= 40300
# Catch-all for all the things that are in our tree, but for which we're
# not yet ready for this compiler.
-CWARNEXTRA?= -Wno-error=inline -Wno-error=enum-compare -Wno-error=unused-but-set-variable \
- -Wno-error=aggressive-loop-optimizations -Wno-error=maybe-uninitialized \
- -Wno-error=array-bounds -Wno-error=address \
- -Wno-error=cast-qual -Wno-error=sequence-point -Wno-error=attributes \
+.if ${COMPILER_VERSION} >= 40800
+GCC_CWARNEXTRA := -Wno-error=aggressive-loop-optimizations
+.endif
+GCC_CWARNEXTRA += -Wno-error=inline -Wno-unused-but-set-variable \
+ -Wno-error=uninitialized -Wno-error=maybe-uninitialized \
+ -Wno-int-to-pointer-cast -Wno-error=address \
+ -Wno-error=cast-qual \
-Wno-error=strict-overflow -Wno-error=overflow
.else
# For gcc 4.2, eliminate the too-often-wrong warnings about uninitialized vars.
-CWARNEXTRA?= -Wno-uninitialized
+GCC_CWARNEXTRA := -Wno-uninitialized
.endif
+CWARNEXTRA?= ${GCC_CWARNEXTRA}
.endif
# External compilers may not support our format extensions. Allow them
# to be disabled. WARNING: format checking is disabled in this case.
-.if ${MK_FORMAT_EXTENSIONS} == "no"
+#.if ${MK_FORMAT_EXTENSIONS} == "no"
FORMAT_EXTENSIONS= -Wno-format
-.elif ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 30600
-FORMAT_EXTENSIONS= -D__printf__=__freebsd_kprintf__
-.else
-FORMAT_EXTENSIONS= -fformat-extensions
-.endif
+#.elif ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 30600
+#FORMAT_EXTENSIONS= -D__printf__=__freebsd_kprintf__
+#.else
+#FORMAT_EXTENSIONS= -fformat-extensions
+#.endif
#
# On i386, do not align the stack to 16-byte boundaries. Otherwise GCC 2.95
@@ -89,7 +93,8 @@
# Setting -mno-sse implies -mno-sse2, -mno-sse3, -mno-ssse3, -mno-sse41 and -mno-sse42
#
.if ${MACHINE_CPUARCH} == "i386"
-CFLAGS.gcc+= -mno-align-long-strings -mpreferred-stack-boundary=2
+#CFLAGS.gcc+= -mno-align-long-strings
+CFLAGS.gcc+= -mpreferred-stack-boundary=2
CFLAGS.clang+= -mno-aes -mno-avx
CFLAGS+= -mno-mmx -mno-sse -msoft-float
INLINE_LIMIT?= 8000
diff -ru --exclude-from freebsd-src-diff-exclude-names /usr/src/sys/conf/kern.pre.mk freebsd-11.1/sys/conf/kern.pre.mk
--- /usr/src/sys/conf/kern.pre.mk 2017-07-21 07:41:43.000000000 +0800
+++ freebsd-11.1/sys/conf/kern.pre.mk 2019-12-20 18:14:21.632390555 +0800
@@ -76,6 +76,10 @@
.if ${MACHINE_CPUARCH} == "mips"
CFLAGS_ARCH_PARAMS?=--param max-inline-insns-single=1000
.endif
+
+# Some codes currently assuming 'sizeof(enum ...) == sizeof(unsigned int)'
+CFLAGS += -fno-short-enums
+
CFLAGS.gcc+= -fno-common -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}
diff -ru --exclude-from freebsd-src-diff-exclude-names /usr/src/sys/conf/kmod.mk freebsd-11.1/usr/src/sys/conf/kmod.mk
--- /usr/src/sys/conf/kmod.mk 2017-07-21 07:41:43.000000000 +0800
+++ freebsd-11.1/usr/src/sys/conf/kmod.mk 2019-03-22 13:00:52.690920000 +0800
@@ -98,7 +98,7 @@
.if !empty(CFLAGS:M-O[23s]) && empty(CFLAGS:M-fno-strict-aliasing)
CFLAGS+= -fno-strict-aliasing
.endif
-WERROR?= -Werror
+#WERROR?= -Werror
CFLAGS+= ${WERROR}
CFLAGS+= -D_KERNEL
CFLAGS+= -DKLD_MODULE