From owner-dev-commits-src-branches@freebsd.org Fri Sep 3 17:05:03 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C9746678C29; Fri, 3 Sep 2021 17:05:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4H1PL73x6pz3k7C; Fri, 3 Sep 2021 17:05:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6E15B2FCE3; Fri, 3 Sep 2021 17:05:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 183H53an088875; Fri, 3 Sep 2021 17:05:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 183H5347088874; Fri, 3 Sep 2021 17:05:03 GMT (envelope-from git) Date: Fri, 3 Sep 2021 17:05:03 GMT Message-Id: <202109031705.183H5347088874@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dimitry Andric Subject: git: edc7b289b2b2 - stable/12 - Revert the changes that removed support for old gcc, as stable/12 still uses gcc 4.2.1 for mips, powerpc and sparc64. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: edc7b289b2b2681ec65c80011540fa17e1799936 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Sep 2021 17:05:03 -0000 The branch stable/12 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=edc7b289b2b2681ec65c80011540fa17e1799936 commit edc7b289b2b2681ec65c80011540fa17e1799936 Author: Dimitry Andric AuthorDate: 2021-09-03 10:41:44 +0000 Commit: Dimitry Andric CommitDate: 2021-09-03 17:03:47 +0000 Revert the changes that removed support for old gcc, as stable/12 still uses gcc 4.2.1 for mips, powerpc and sparc64. Revert "Revert part of r360964" This reverts commit 2ebf10e7a1ced5d3dc4059d0595743277464d915. Revert "Remove tests for obsolete compilers in the build system" This reverts commit a606cb388f975561c37dbabc2fee82c27ef09929. --- lib/libclang_rt/Makefile.inc | 2 +- lib/libthr/Makefile | 3 +++ lib/msun/Makefile | 4 +-- libexec/rtld-elf/Makefile | 4 +++ libexec/tftpd/tests/Makefile | 3 +++ share/mk/bsd.compiler.mk | 14 +++++++--- share/mk/bsd.sys.mk | 59 ++++++++++++++++++++++++------------------- stand/arm/uboot/Makefile | 2 +- stand/defs.mk | 4 +++ stand/efi/Makefile | 6 +++++ stand/efi/boot1/Makefile | 4 +++ stand/efi/loader/Makefile | 4 +++ stand/i386/boot2/Makefile | 3 +++ stand/i386/isoboot/Makefile | 3 +++ stand/libsa/Makefile | 4 +++ sys/conf/Makefile.arm | 4 +++ sys/conf/kern.mk | 35 +++++++++++++++++-------- sys/conf/kern.post.mk | 3 +++ sys/conf/kern.pre.mk | 4 +++ sys/conf/kmod.mk | 11 ++++++++ sys/modules/Makefile | 2 ++ usr.sbin/acpi/acpidb/Makefile | 2 +- usr.sbin/trpt/Makefile | 6 +++++ usr.sbin/zic/zic/Makefile | 2 +- 24 files changed, 142 insertions(+), 46 deletions(-) diff --git a/lib/libclang_rt/Makefile.inc b/lib/libclang_rt/Makefile.inc index 53e0f7972768..07b66015acb1 100644 --- a/lib/libclang_rt/Makefile.inc +++ b/lib/libclang_rt/Makefile.inc @@ -32,7 +32,7 @@ CFLAGS+= ${PICFLAG} CFLAGS+= -fno-builtin CFLAGS+= -fno-exceptions CXXFLAGS+= -fno-rtti -.if ${COMPILER_TYPE} == clang +.if ${COMPILER_TYPE} == clang && ${COMPILER_VERSION} >= 30700 CFLAGS+= -fno-sanitize=safe-stack .endif CFLAGS+= -fno-stack-protector diff --git a/lib/libthr/Makefile b/lib/libthr/Makefile index c77b6b565a87..5f3d52661c99 100644 --- a/lib/libthr/Makefile +++ b/lib/libthr/Makefile @@ -29,7 +29,10 @@ CFLAGS+=-Winline CFLAGS.thr_stack.c+= -Wno-cast-align CFLAGS.rtld_malloc.c+= -Wno-cast-align +.include +.if !(${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} < 40300) CFLAGS.thr_symbols.c+= -Wno-missing-variable-declarations +.endif .ifndef NO_THREAD_UNWIND_STACK CFLAGS+=-fexceptions diff --git a/lib/msun/Makefile b/lib/msun/Makefile index 0a486bb5a086..d56b33deabea 100644 --- a/lib/msun/Makefile +++ b/lib/msun/Makefile @@ -119,12 +119,12 @@ COMMON_SRCS+= catrigl.c \ s_nextafterl.c s_nexttoward.c s_remquol.c s_rintl.c s_roundl.c \ s_scalbnl.c s_sinl.c s_sincosl.c \ s_tanhl.c s_tanl.c s_truncl.c w_cabsl.c -# Work around this warning from gcc: +# Work around this warning from gcc 6: # lib/msun/ld80/e_powl.c:275:1: error: floating constant exceeds range of # 'long double' [-Werror=overflow] # if( y >= LDBL_MAX ) # See also: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=130067 -.if ${COMPILER_TYPE} == "gcc" +.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 60000 CFLAGS.e_powl.c+= -Wno-error=overflow .endif .endif diff --git a/libexec/rtld-elf/Makefile b/libexec/rtld-elf/Makefile index be18f1759cc6..a51acf68068a 100644 --- a/libexec/rtld-elf/Makefile +++ b/libexec/rtld-elf/Makefile @@ -111,4 +111,8 @@ ${PROG_FULL}: ${VERSION_MAP} # GCC warns about redeclarations even though they have __exported # and are therefore not identical to the ones from the system headers. CFLAGS+= -Wno-redundant-decls +.if ${COMPILER_VERSION} < 40300 +# Silence -Wshadow false positives in ancient GCC +CFLAGS+= -Wno-shadow +.endif .endif diff --git a/libexec/tftpd/tests/Makefile b/libexec/tftpd/tests/Makefile index 390921e31de7..9aa420cec1a5 100644 --- a/libexec/tftpd/tests/Makefile +++ b/libexec/tftpd/tests/Makefile @@ -2,8 +2,11 @@ .include +# Skip on GCC 4.2, because it lacks __COUNTER__ +.if ${COMPILER_TYPE} != "gcc" || ${COMPILER_VERSION} >= 40300 ATF_TESTS_C= functional TEST_METADATA.functional+= timeout=15 +.endif LIBADD= util WARNS?= 6 diff --git a/share/mk/bsd.compiler.mk b/share/mk/bsd.compiler.mk index 4da0578d1b4e..cd87740730e9 100644 --- a/share/mk/bsd.compiler.mk +++ b/share/mk/bsd.compiler.mk @@ -182,12 +182,20 @@ ${X_}COMPILER_FREEBSD_VERSION= unknown .endif .endif -${X_}COMPILER_FEATURES= c++11 c++14 -.if ${${X_}COMPILER_TYPE} == "clang" || \ +${X_}COMPILER_FEATURES= +.if (${${X_}COMPILER_TYPE} == "clang" && ${${X_}COMPILER_VERSION} >= 30300) || \ + (${${X_}COMPILER_TYPE} == "gcc" && ${${X_}COMPILER_VERSION} >= 40800) +${X_}COMPILER_FEATURES+= c++11 +.endif +.if (${${X_}COMPILER_TYPE} == "clang" && ${${X_}COMPILER_VERSION} >= 30400) || \ + (${${X_}COMPILER_TYPE} == "gcc" && ${${X_}COMPILER_VERSION} >= 50000) +${X_}COMPILER_FEATURES+= c++14 +.endif +.if (${${X_}COMPILER_TYPE} == "clang" && ${${X_}COMPILER_VERSION} >= 50000) || \ (${${X_}COMPILER_TYPE} == "gcc" && ${${X_}COMPILER_VERSION} >= 70000) ${X_}COMPILER_FEATURES+= c++17 .endif -.if ${${X_}COMPILER_TYPE} == "clang" +.if ${${X_}COMPILER_TYPE} == "clang" && ${${X_}COMPILER_VERSION} >= 60000 ${X_}COMPILER_FEATURES+= retpoline .endif diff --git a/share/mk/bsd.sys.mk b/share/mk/bsd.sys.mk index 5ab65b48f3c5..26f5c59063ae 100644 --- a/share/mk/bsd.sys.mk +++ b/share/mk/bsd.sys.mk @@ -6,7 +6,8 @@ # Enable various levels of compiler warning checks. These may be # overridden (e.g. if using a non-gcc compiler) by defining MK_WARNS=no. -# for GCC: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html +# for 4.2.1 GCC: http://gcc.gnu.org/onlinedocs/gcc-4.2.1/gcc/Warning-Options.html +# for current GCC: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html # for clang: https://clang.llvm.org/docs/DiagnosticsReference.html .include @@ -28,6 +29,15 @@ CFLAGS+= -std=${CSTD} CXXFLAGS+= -std=${CXXSTD} .endif +# +# Turn off -Werror for gcc 4.2.1. The compiler is on the glide path out of the +# system, and any warnings specific to it are no longer relevant as there are +# too many false positives. +# +.if ${COMPILER_VERSION} < 50000 +NO_WERROR.gcc= yes +.endif + # -pedantic is problematic because it also imposes namespace restrictions #CFLAGS+= -pedantic .if defined(WARNS) @@ -71,13 +81,19 @@ CWARNFLAGS+= -Wno-pointer-sign # is set to low values, these have to be disabled explicitly. .if ${WARNS} <= 6 CWARNFLAGS.clang+= -Wno-empty-body -Wno-string-plus-int +.if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 30400 CWARNFLAGS.clang+= -Wno-unused-const-variable +.endif .endif # WARNS <= 6 .if ${WARNS} <= 3 CWARNFLAGS.clang+= -Wno-tautological-compare -Wno-unused-value\ -Wno-parentheses-equality -Wno-unused-function -Wno-enum-conversion +.if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 30600 CWARNFLAGS.clang+= -Wno-unused-local-typedef +.endif +.if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 40000 CWARNFLAGS.clang+= -Wno-address-of-packed-member +.endif .if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 90100 CWARNFLAGS.gcc+= -Wno-address-of-packed-member .endif @@ -97,7 +113,7 @@ CWARNFLAGS.clang+= -Wno-array-bounds .endif # NO_WARRAY_BOUNDS .if defined(NO_WMISLEADING_INDENTATION) && \ ((${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 100000) || \ - ${COMPILER_TYPE} == "gcc") + (${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 60100)) CWARNFLAGS+= -Wno-misleading-indentation .endif # NO_WMISLEADING_INDENTATION .endif # WARNS @@ -121,15 +137,8 @@ CWARNFLAGS+= -Werror CWARNFLAGS+= -Wno-format .endif # NO_WFORMAT || NO_WFORMAT.${COMPILER_TYPE} -# GCC -# We should clean up warnings produced with these flags. -# They were originally added as a quick hack to enable gcc5/6. -# The base system requires at least GCC 6.4, but some ports -# use this file with older compilers. Request an exprun -# before changing these. -.if ${COMPILER_TYPE} == "gcc" # GCC 5.2.0 -.if ${COMPILER_VERSION} >= 50200 +.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 50200 CWARNFLAGS+= -Wno-error=address \ -Wno-error=array-bounds \ -Wno-error=attributes \ @@ -149,18 +158,7 @@ CWARNFLAGS+= -Wno-error=address \ .endif # GCC 6.1.0 -.if ${COMPILER_VERSION} >= 60100 -CWARNFLAGS+= -Wno-error=empty-body \ - -Wno-error=maybe-uninitialized \ - -Wno-error=nonnull-compare \ - -Wno-error=redundant-decls \ - -Wno-error=shift-negative-value \ - -Wno-error=tautological-compare \ - -Wno-error=unused-const-variable -.endif - -# GCC 6.1.0 -.if ${COMPILER_VERSION} >= 60100 +.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 60100 CWARNFLAGS+= -Wno-error=empty-body \ -Wno-error=nonnull-compare \ -Wno-error=shift-negative-value \ @@ -169,7 +167,7 @@ CWARNFLAGS+= -Wno-error=empty-body \ .endif # GCC 7.1.0 -.if ${COMPILER_VERSION} >= 70100 +.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 70100 CWARNFLAGS+= -Wno-error=bool-operation \ -Wno-error=deprecated \ -Wno-error=expansion-to-defined \ @@ -185,7 +183,7 @@ CWARNFLAGS+= -Wno-error=bool-operation \ .endif # GCC 8.1.0 -.if ${COMPILER_VERSION} >= 80100 +.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 80100 CWARNFLAGS+= -Wno-error=aggressive-loop-optimizations \ -Wno-error=cast-function-type \ -Wno-error=catch-value \ @@ -194,10 +192,9 @@ CWARNFLAGS+= -Wno-error=aggressive-loop-optimizations \ -Wno-error=sizeof-pointer-memaccess \ -Wno-error=stringop-truncation .endif -.endif # gcc # How to handle FreeBSD custom printf format specifiers. -.if ${COMPILER_TYPE} == "clang" +.if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 30600 FORMAT_EXTENSIONS= -D__printf__=__freebsd_kprintf__ .else FORMAT_EXTENSIONS= -fformat-extensions @@ -214,7 +211,11 @@ CLANG_OPT_SMALL= -mstack-alignment=8 -mllvm -inline-threshold=3 .if ${COMPILER_VERSION} < 130000 CLANG_OPT_SMALL+= -mllvm -simplifycfg-dup-ret .endif +.if ${COMPILER_VERSION} >= 30500 && ${COMPILER_VERSION} < 30700 +CLANG_OPT_SMALL+= -mllvm -enable-gvn=false +.else CLANG_OPT_SMALL+= -mllvm -enable-load-pre=false +.endif CFLAGS.clang+= -Qunused-arguments .if ${MACHINE_CPUARCH} == "sparc64" # Don't emit .cfi directives, since we must use GNU as on sparc64, for now. @@ -229,8 +230,14 @@ CXXFLAGS.clang+= -Wno-c++11-extensions .if ${MK_SSP} != "no" && \ ${MACHINE_CPUARCH} != "arm" && ${MACHINE_CPUARCH} != "mips" +.if (${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 30500) || \ + (${COMPILER_TYPE} == "gcc" && \ + (${COMPILER_VERSION} == 40201 || ${COMPILER_VERSION} >= 40900)) # Don't use -Wstack-protector as it breaks world with -Werror. SSP_CFLAGS?= -fstack-protector-strong +.else +SSP_CFLAGS?= -fstack-protector +.endif CFLAGS+= ${SSP_CFLAGS} .endif # SSP && !ARM && !MIPS diff --git a/stand/arm/uboot/Makefile b/stand/arm/uboot/Makefile index f99282aa6e5a..0c906c99ee6f 100644 --- a/stand/arm/uboot/Makefile +++ b/stand/arm/uboot/Makefile @@ -24,7 +24,7 @@ UBLDR_LOADADDR?= 0x1000000 # Architecture-specific loader code SRCS= start.S conf.c self_reloc.c vers.c -.if ${COMPILER_TYPE} == "gcc" +.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} > 40201 CWARNFLAGS.self_reloc.c+= -Wno-error=maybe-uninitialized .endif diff --git a/stand/defs.mk b/stand/defs.mk index 45d48ccdab8a..c81be884f3ae 100644 --- a/stand/defs.mk +++ b/stand/defs.mk @@ -149,7 +149,11 @@ CFLAGS+= -fPIC -mno-red-zone # Do not generate movt/movw, because the relocation fixup for them does not # translate to the -Bsymbolic -pie format required by self_reloc() in loader(8). # Also, the fpu is not available in a standalone environment. +.if ${COMPILER_VERSION} < 30800 +CFLAGS.clang+= -mllvm -arm-use-movt=0 +.else CFLAGS.clang+= -mno-movt +.endif CFLAGS.clang+= -mfpu=none CFLAGS+= -fPIC .endif diff --git a/stand/efi/Makefile b/stand/efi/Makefile index 94cb5bba5638..9ab6aa4291fb 100644 --- a/stand/efi/Makefile +++ b/stand/efi/Makefile @@ -4,6 +4,10 @@ NO_OBJ=t .include +# In-tree GCC does not support __attribute__((ms_abi)), but gcc newer +# than 4.5 supports it. +.if ${COMPILER_TYPE} != "gcc" || ${COMPILER_VERSION} >= 40500 + SUBDIR.yes+= libefi SUBDIR.${MK_FDT}+= fdt SUBDIR.yes+= .WAIT @@ -14,4 +18,6 @@ SUBDIR.${MK_FORTH}+= loader_4th SUBDIR.${MK_LOADER_LUA}+= loader_lua SUBDIR.yes+= loader_simp +.endif # ${COMPILER_TYPE} != "gcc" || ${COMPILER_VERSION} >= 40500 + .include diff --git a/stand/efi/boot1/Makefile b/stand/efi/boot1/Makefile index 899b00d97341..d4ac55598bb7 100644 --- a/stand/efi/boot1/Makefile +++ b/stand/efi/boot1/Makefile @@ -42,6 +42,10 @@ CFLAGS.zfs_module.c+= -I${SYSDIR}/cddl/contrib/opensolaris/common/lz4 CFLAGS+= -DEFI_ZFS_BOOT .endif +.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} > 40201 +CWARNFLAGS.self_reloc.c+= -Wno-error=maybe-uninitialized +.endif + CFLAGS+= -I${EFIINC} CFLAGS+= -I${EFIINCMD} CFLAGS+= -I${SYSDIR}/contrib/dev/acpica/include diff --git a/stand/efi/loader/Makefile b/stand/efi/loader/Makefile index cda242924be0..d290cae5d4c8 100644 --- a/stand/efi/loader/Makefile +++ b/stand/efi/loader/Makefile @@ -32,6 +32,10 @@ CFLAGS+= -DEFI_ZFS_BOOT HAVE_ZFS= yes .endif +.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} > 40201 +CWARNFLAGS.self_reloc.c+= -Wno-error=maybe-uninitialized +.endif + # We implement a slightly non-standard %S in that it always takes a # CHAR16 that's common in UEFI-land instead of a wchar_t. This only # seems to matter on arm64 where wchar_t defaults to an int instead diff --git a/stand/i386/boot2/Makefile b/stand/i386/boot2/Makefile index 713929efc2b5..3830199b2c4b 100644 --- a/stand/i386/boot2/Makefile +++ b/stand/i386/boot2/Makefile @@ -37,6 +37,9 @@ CFLAGS+=-fomit-frame-pointer \ CFLAGS.gcc+= -Os \ -fno-asynchronous-unwind-tables \ --param max-inline-insns-single=100 +.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} <= 40201 +CFLAGS.gcc+= -mno-align-long-strings +.endif CFLAGS.clang+= -Oz ${CLANG_OPT_SMALL} diff --git a/stand/i386/isoboot/Makefile b/stand/i386/isoboot/Makefile index 59033dfcd4c9..597958065090 100644 --- a/stand/i386/isoboot/Makefile +++ b/stand/i386/isoboot/Makefile @@ -32,6 +32,9 @@ CFLAGS+=-DBOOTPROG=\"isoboot\" \ -Winline -Wno-pointer-sign CFLAGS.gcc+= --param max-inline-insns-single=100 +.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} <= 40201 +CFLAGS.gcc+= -Wno-uninitialized +.endif CFLAGS.clang+= -Oz ${CLANG_OPT_SMALL} LD_FLAGS+=${LD_FLAGS_BIN} diff --git a/stand/libsa/Makefile b/stand/libsa/Makefile index 44db171b141f..0ca994386f47 100644 --- a/stand/libsa/Makefile +++ b/stand/libsa/Makefile @@ -46,7 +46,11 @@ SRCS+= subr_boot.c # Do not generate movt/movw, because the relocation fixup for them does not # translate to the -Bsymbolic -pie format required by self_reloc() in loader(8). # Also, the fpu is not available in a standalone environment. +.if ${COMPILER_VERSION} < 30800 +CFLAGS.clang+= -mllvm -arm-use-movt=0 +.else CFLAGS.clang+= -mno-movt +.endif CFLAGS.clang+= -mfpu=none .PATH: ${SRCTOP}/contrib/llvm-project/compiler-rt/lib/builtins/arm/ diff --git a/sys/conf/Makefile.arm b/sys/conf/Makefile.arm index ba918c27cbc5..8c9069bad311 100644 --- a/sys/conf/Makefile.arm +++ b/sys/conf/Makefile.arm @@ -47,6 +47,10 @@ CFLAGS.clang += -mfpu=none .if !empty(DDB_ENABLED) CFLAGS += -funwind-tables +.if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} < 30500 +# clang < 3.5.0 requires us to tell it to emit assembly with unwind information +CFLAGS += -mllvm -arm-enable-ehabi +.endif .endif # "makeoptions KERNVIRTADDR=" is now optional, supply the default value. diff --git a/sys/conf/kern.mk b/sys/conf/kern.mk index 34ffc8cb15ca..c93be4b1b24c 100644 --- a/sys/conf/kern.mk +++ b/sys/conf/kern.mk @@ -34,14 +34,19 @@ NO_WMISLEADING_INDENTATION= -Wno-misleading-indentation CWARNEXTRA?= -Wno-error=tautological-compare -Wno-error=empty-body \ -Wno-error=parentheses-equality -Wno-error=unused-function \ -Wno-error=pointer-sign +.if ${COMPILER_VERSION} >= 30700 CWARNEXTRA+= -Wno-error=shift-negative-value +.endif +.if ${COMPILER_VERSION} >= 40000 CWARNEXTRA+= -Wno-address-of-packed-member +.endif .if ${COMPILER_VERSION} >= 130000 CWARNFLAGS+= -Wno-error=unused-but-set-variable .endif .endif # clang .if ${COMPILER_TYPE} == "gcc" +.if ${COMPILER_VERSION} >= 40800 # Catch-all for all the things that are in our tree, but for which we're # not yet ready for this compiler. NO_WUNUSED_BUT_SET_VARIABLE = -Wno-unused-but-set-variable @@ -53,15 +58,14 @@ CWARNEXTRA?= -Wno-error=address \ -Wno-error=enum-compare \ -Wno-error=inline \ -Wno-error=maybe-uninitialized \ - -Wno-error=misleading-indentation \ - -Wno-error=nonnull-compare \ -Wno-error=overflow \ -Wno-error=sequence-point \ + -Wno-error=unused-but-set-variable +.if ${COMPILER_VERSION} >= 60100 +CWARNEXTRA+= -Wno-error=misleading-indentation \ + -Wno-error=nonnull-compare \ -Wno-error=shift-overflow \ - -Wno-error=tautological-compare \ - -Wno-unused-but-set-variable -.if ${COMPILER_VERSION} >= 70100 -CWARNEXTRA+= -Wno-error=stringop-overflow + -Wno-error=tautological-compare .endif .if ${COMPILER_VERSION} >= 70200 CWARNEXTRA+= -Wno-error=memset-elt-size @@ -69,10 +73,14 @@ CWARNEXTRA+= -Wno-error=memset-elt-size .if ${COMPILER_VERSION} >= 80000 CWARNEXTRA+= -Wno-error=packed-not-aligned .endif -.if ${COMPILER_VERSION} >= 90100 -CWARNEXTRA+= -Wno-address-of-packed-member +.else +# For gcc 4.2, eliminate the too-often-wrong warnings about uninitialized vars. +CWARNEXTRA?= -Wno-uninitialized +# GCC 4.2 doesn't have -Wno-error=cast-qual, so just disable the warning for +# the few files that are already known to generate cast-qual warnings. +NO_WCAST_QUAL= -Wno-cast-qual +.endif .endif -.endif # gcc # This warning is utter nonsense CWARNFLAGS+= -Wno-format-zero-length @@ -81,7 +89,7 @@ CWARNFLAGS+= -Wno-format-zero-length # to be disabled. WARNING: format checking is disabled in this case. .if ${MK_FORMAT_EXTENSIONS} == "no" FORMAT_EXTENSIONS= -Wno-format -.elif ${COMPILER_TYPE} == "clang" +.elif ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 30600 FORMAT_EXTENSIONS= -D__printf__=__freebsd_kprintf__ .else FORMAT_EXTENSIONS= -fformat-extensions @@ -196,7 +204,12 @@ CFLAGS.gcc+= -mno-spe # DDB happy. ELFv2, if available, has some other efficiency benefits. # .if ${MACHINE_ARCH} == "powerpc64" -CFLAGS+= -mabi=elfv2 +.if ${COMPILER_VERSION} >= 40900 +CFLAGS.gcc+= -mabi=elfv2 +.else +CFLAGS.gcc+= -mcall-aixdesc +.endif +CFLAGS.clang+= -mabi=elfv2 .endif # diff --git a/sys/conf/kern.post.mk b/sys/conf/kern.post.mk index b24909642dfe..cce9fcfd1c6d 100644 --- a/sys/conf/kern.post.mk +++ b/sys/conf/kern.post.mk @@ -311,7 +311,10 @@ ${__obj}: ${OBJS_DEPEND_GUESS.${__obj}} .depend: .PRECIOUS ${SRCS} +.if ${COMPILER_TYPE} == "clang" || \ + (${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 60000) _MAP_DEBUG_PREFIX= yes +.endif _ILINKS= machine .if ${MACHINE} != ${MACHINE_CPUARCH} && ${MACHINE} != "arm64" diff --git a/sys/conf/kern.pre.mk b/sys/conf/kern.pre.mk index 04f34b6e0c5c..7f0099344d18 100644 --- a/sys/conf/kern.pre.mk +++ b/sys/conf/kern.pre.mk @@ -93,7 +93,11 @@ CFLAGS.gcc+= -fms-extensions .if defined(CFLAGS_ARCH_PARAMS) CFLAGS.gcc+=${CFLAGS_ARCH_PARAMS} .endif +.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} < 50000 +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. diff --git a/sys/conf/kmod.mk b/sys/conf/kmod.mk index 3c63deb6ddd1..610484ba7e36 100644 --- a/sys/conf/kmod.mk +++ b/sys/conf/kmod.mk @@ -102,7 +102,11 @@ __KLD_SHARED=no .if !empty(CFLAGS:M-O[23s]) && empty(CFLAGS:M-fno-strict-aliasing) CFLAGS+= -fno-strict-aliasing .endif +.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} < 50000 +WERROR?= -Wno-error +.else WERROR?= -Werror +.endif LINUXKPI_GENSRCS+= \ bus_if.h \ @@ -167,7 +171,11 @@ CFLAGS+= -fPIC # Temporary workaround for PR 196407, which contains the fascinating details. # Don't allow clang to use fpu instructions or registers in kernel modules. .if ${MACHINE_CPUARCH} == arm +.if ${COMPILER_VERSION} < 30800 +CFLAGS.clang+= -mllvm -arm-use-movt=0 +.else CFLAGS.clang+= -mno-movt +.endif CFLAGS.clang+= -mfpu=none CFLAGS+= -funwind-tables .endif @@ -277,7 +285,10 @@ ${FULLPROG}: ${OBJS} ${OBJCOPY} --strip-debug ${.TARGET} .endif +.if ${COMPILER_TYPE} == "clang" || \ + (${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 60000) _MAP_DEBUG_PREFIX= yes +.endif _ILINKS=machine .if ${MACHINE} != ${MACHINE_CPUARCH} && ${MACHINE} != "arm64" diff --git a/sys/modules/Makefile b/sys/modules/Makefile index 61603cf32ab4..f4b7d4f8a5bd 100644 --- a/sys/modules/Makefile +++ b/sys/modules/Makefile @@ -684,8 +684,10 @@ _aac= aac _aacraid= aacraid _acpi= acpi .if ${MK_CRYPT} != "no" || defined(ALL_MODULES) +.if ${COMPILER_TYPE} != "gcc" || ${COMPILER_VERSION} > 40201 _aesni= aesni .endif +.endif _amd_ecc_inject=amd_ecc_inject _amdsbwd= amdsbwd _amdsmn= amdsmn diff --git a/usr.sbin/acpi/acpidb/Makefile b/usr.sbin/acpi/acpidb/Makefile index 5a6fceb2a4cb..566794fa6f4b 100644 --- a/usr.sbin/acpi/acpidb/Makefile +++ b/usr.sbin/acpi/acpidb/Makefile @@ -87,6 +87,6 @@ LIBADD= pthread # integer to pointer, which is a GNU extension. # # Turn off the warning, because this is in contributed code. -.if ${COMPILER_TYPE} == "clang" +.if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 60000 CWARNFLAGS+= -Wno-null-pointer-arithmetic .endif diff --git a/usr.sbin/trpt/Makefile b/usr.sbin/trpt/Makefile index 33a3d1f81a7f..4756cb1a0d03 100644 --- a/usr.sbin/trpt/Makefile +++ b/usr.sbin/trpt/Makefile @@ -8,12 +8,18 @@ MAN= trpt.8 BINGRP= kmem BINMODE= 2555 +.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} < 50000 +WARNS?= 4 +.endif + .if ${MK_INET6_SUPPORT} != "no" CFLAGS+= -DINET6 .endif .include +.if ${COMPILER_TYPE} != "gcc" || ${COMPILER_VERSION} >= 50000 # Several included system headers tickle this warning in ways that are # difficult to work around in this program. CFLAGS+= -Wno-missing-variable-declarations +.endif diff --git a/usr.sbin/zic/zic/Makefile b/usr.sbin/zic/zic/Makefile index 17ffb33a57e7..36cc79009b45 100644 --- a/usr.sbin/zic/zic/Makefile +++ b/usr.sbin/zic/zic/Makefile @@ -15,7 +15,7 @@ CFLAGS+= -I${.CURDIR:H} -I${SRCTOP}/contrib/tzcode/stdtime WARNS?= 2 -.if ${COMPILER_TYPE} == "gcc" +.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 50300 CWARNFLAGS+= -Wno-error=strict-overflow .endif