Skip to content

Commit

Permalink
Revert the changes that removed support for old gcc, as stable/12 still
Browse files Browse the repository at this point in the history
uses gcc 4.2.1 for mips, powerpc and sparc64.

Revert "Revert part of r360964"

This reverts commit 2ebf10e.

Revert "Remove tests for obsolete compilers in the build system"

This reverts commit a606cb3.
  • Loading branch information
DimitryAndric committed Sep 3, 2021
1 parent cc11097 commit edc7b28
Show file tree
Hide file tree
Showing 24 changed files with 142 additions and 46 deletions.
2 changes: 1 addition & 1 deletion lib/libclang_rt/Makefile.inc
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions lib/libthr/Makefile
Expand Up @@ -29,7 +29,10 @@ CFLAGS+=-Winline

CFLAGS.thr_stack.c+= -Wno-cast-align
CFLAGS.rtld_malloc.c+= -Wno-cast-align
.include <bsd.compiler.mk>
.if !(${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} < 40300)
CFLAGS.thr_symbols.c+= -Wno-missing-variable-declarations
.endif

.ifndef NO_THREAD_UNWIND_STACK
CFLAGS+=-fexceptions
Expand Down
4 changes: 2 additions & 2 deletions lib/msun/Makefile
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions libexec/rtld-elf/Makefile
Expand Up @@ -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
3 changes: 3 additions & 0 deletions libexec/tftpd/tests/Makefile
Expand Up @@ -2,8 +2,11 @@

.include <bsd.own.mk>

# 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
Expand Down
14 changes: 11 additions & 3 deletions share/mk/bsd.compiler.mk
Expand Up @@ -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

Expand Down
59 changes: 33 additions & 26 deletions share/mk/bsd.sys.mk
Expand Up @@ -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 <bsd.compiler.mk>
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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 \
Expand All @@ -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 \
Expand All @@ -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 \
Expand All @@ -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 \
Expand All @@ -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
Expand All @@ -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.
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion stand/arm/uboot/Makefile
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions stand/defs.mk
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions stand/efi/Makefile
Expand Up @@ -4,6 +4,10 @@ NO_OBJ=t

.include <bsd.init.mk>

# 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
Expand All @@ -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 <bsd.subdir.mk>
4 changes: 4 additions & 0 deletions stand/efi/boot1/Makefile
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions stand/efi/loader/Makefile
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions stand/i386/boot2/Makefile
Expand Up @@ -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}

Expand Down
3 changes: 3 additions & 0 deletions stand/i386/isoboot/Makefile
Expand Up @@ -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}
Expand Down
4 changes: 4 additions & 0 deletions stand/libsa/Makefile
Expand Up @@ -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/
Expand Down
4 changes: 4 additions & 0 deletions sys/conf/Makefile.arm
Expand Up @@ -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.
Expand Down

0 comments on commit edc7b28

Please sign in to comment.