Commit Graph

253 Commits

Author SHA1 Message Date
Warner Losh
031beb4e23 sys: Remove $FreeBSD$: one-line sh pattern
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
2023-08-16 11:54:58 -06:00
John Baldwin
ec41a96daa sys: Switch the kernel's C standard from C99 to GNU99.
This matches the default used in userland, and the kernel already
depends on various GNU extensions to standard C that are supported by
both clang and GCC.

This should be a no-op for clang, but for GCC it enables some GNU
extensions that aren't otherwise enabled.  It also enables GCC for
i386 to avoid the need for a floatundidf intrinsic in libkern.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D40646
2023-07-01 12:21:13 -07:00
John Baldwin
98d06eea14 sys: Enable -Wunused-but-set-variable for clang 15+.
It was already enabled for older clang versions and GCC.
2023-05-25 10:44:53 -07:00
John Baldwin
6c08fd3dc8 Enable -Wstrict-prototypes by default in the kernel for clang 15+.
PR:		271072 (exp-run)
Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D39734
2023-05-25 07:11:38 -07:00
Dimitry Andric
3741ffdb14 Fix typo in sys/conf/kern.mk's InitAll warning message
I missed this one in commit 3006f6df02.

Fixes:		3006f6df02
MFC after:	3 days
2023-05-23 19:56:46 +02:00
Dimitry Andric
3006f6df02 Update -ftrivial-auto-var-init flags for clang >= 16
As of clang 16, the -ftrivial-auto-var-init=zero option no longer needs
-enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
to enable the option. Only add it for older clang versions.

PR:		271047
Reviewed by:	emaste
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D40208
2023-05-23 19:44:45 +02:00
Mitchell Horne
c32b6c742f riscv: retire the FPE kernel option
We always build the kernel floating point support. Now that the
riscv64sf userspace variant has been removed the option is required for
correct operation.

Reviewed by:	jhb
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D39851
2023-05-02 15:01:31 -03:00
John Baldwin
7aab8fc5c5 clang: Enable -Wdeprecated-non-prototype by default.
PR:		270919 (exp-run)
Reviewed by:	dim, emaste
Differential Revision:	https://reviews.freebsd.org/D39535
2023-04-25 14:09:21 -07:00
Dimitry Andric
4214005276 kern.mk: clang >= 16 already infers ELFv2 for powerpc64
There is no need to pass -mabi=elfv2 explicitly anymore, and with clang
16 in fact results in a "unused argument" warning.

MFC after:	3 days
2023-04-20 21:27:27 +02:00
John Baldwin
1ca12bd927 Remove the riscv64sf architecture.
Reviewed by:	jrtc27, arichardson, br, kp, imp, emaste
Differential Revision:	https://reviews.freebsd.org/D39496
2023-04-12 11:09:27 -07:00
John Baldwin
cd800d3c96 Enable -Warray-parameter for clang.
I fixed many of these previously for GCC 12 and make tinderbox passes
with this enabled.

Differential Revision:	https://reviews.freebsd.org/D39378
2023-04-11 13:47:59 -07:00
John Baldwin
3b3762c34e sys: Enable -Wunused-but-set-variable for GCC.
It has been enabled for clang for a while now.

Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D39358
2023-04-10 10:36:33 -07:00
John Baldwin
47d1e67874 sys: Disable errors for -Wunused-function on GCC.
This matches the handling of this warning on clang.
2023-03-30 15:43:48 -07:00
John Baldwin
4ffeb3b88e sys: Stop enabling -Wnested-externs.
clang doesn't implement this warning, so violations are only caught by
GCC.  It is also no longer a common practice to use this as it was in
the original BSD code, so the need for the warning is not as important
as when it was used to do cleanups 20 years ago.  A recent commit
(c3179891f8) triggers this warning on
GCC, but that commit uses nested externs purposefully.

Reviewed by:	markj, emaste
Differential Revision:	https://reviews.freebsd.org/D39214
2023-03-22 12:35:09 -07:00
Warner Losh
1a1f7b7df7 zlib: Add proper NO_WSTRICT_PROTYPES too
Also move NO_WDEPRECATED_NON_PROTOTYPE to a better place...

Sponsored by:	Netflix
Noticed by:	jhb
Fixes:		b9f235ba31
2023-02-13 12:50:56 -07:00
Warner Losh
b80185c267 zlib: Use NO_WDEPRECATED_NON_PROTOTYPE
Also add it to kern.mk so it's available for module builds.

Sponsored by:		Netflix
Noticed by:		mjg
Fixes:			b9f235ba31
Differential Revision:	https://reviews.freebsd.org/D38550
2023-02-13 09:59:51 -07:00
Dimitry Andric
a4a491e223 Merge llvm-project release/15.x llvmorg-15.0.0-9-g1c73596d3454
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-15.0.0-9-g1c73596d3454.

PR:		265425
MFC after:	2 weeks
2023-02-08 20:05:02 +01:00
Dimitry Andric
61cfbce334 Merge llvm-project release/15.x llvmorg-15.0.0-rc2-40-gfbd2950d8d0d
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-15.0.0-rc2-40-gfbd2950d8d0d.

PR:		265425
MFC after:	2 weeks
2023-02-08 20:04:56 +01:00
Dimitry Andric
526f57bf85 Update CWARNFLAGS in bsd.sys.mk and CWARNEXTRA in kern.mk for clang 15.
MFC after:	3 days
2022-12-25 12:58:22 +01:00
John Baldwin
3266131908 Fix spelling of NO_WINFINITE_RECURSION.
Reported by:	dim
Fixes:		2e08e4b75e zfs: Fix build with GCC 12.
2022-12-21 14:45:29 -08:00
John Baldwin
2e08e4b75e zfs: Fix build with GCC 12.
Silence -Winfinite-recursion for ldo.c in lua and -Wstringop-overread
for nvpair.c.

Reviewed by:	mm
Differential Revision:	https://reviews.freebsd.org/D37631
2022-12-21 10:49:23 -08:00
John Baldwin
1aa6d44dec Disable -Wzero-length-bounds for the kernel for GCC 12.
The mlx5 driver and some other OFED bits use a somewhat dubious
pattern of:

  struct foo {
      uint64_t arg[0];
      /* Real members of a struct */
  };

The code then treats 'arg' as if it were really a kind of union
such that foo.arg[N] functions similarly to (uint64_t *)foo[N].
This uses of foo.arg[N] then trigger this warning.

No real bugs were found by this warning though, so just turn it off
globally.

Reviewed by:	hselasky, kib
Differential Revision:	https://reviews.freebsd.org/D37630
2022-12-21 10:48:15 -08:00
John Baldwin
2637ed558b Disable -Wdangling-pointer for the kernel for GCC 12.
Some of the warnings raised in the kernel seem to be outright bugs in
the compiler (e.g. the cases in ata_xpt.c and scsi_xpt.c).  Other
cases are not fatal and it didn't seem to find any legitimate bugs in
the kernel.

Differential Revision:	https://reviews.freebsd.org/D37629
2022-12-21 10:46:26 -08:00
John Baldwin
488c498b09 Disable errors for -Wnonnull for the kernel for GCC 12.
The USB code and some other places raise false positives when a NULL
pointer is passed to an inlined function along with a separate length
and the compiler can't determine that the separate length of 0
prevents the use of the NULL pointer.

Differential Revision:	https://reviews.freebsd.org/D37627
2022-12-21 10:46:06 -08:00
John Baldwin
5115511ed4 Use __freebsd_kprintf__ with GCC 12+ similar to clang. 2022-11-22 08:36:12 -08:00
Dimitry Andric
e83ffec3af Suppress -Wstrict-prototypes for several zlib files
Clang 15 is more strict about function definitions not matching
declarations, and zlib has a lot of these, but since it is contributed
code (and in K&R style to boot), suppress those warnings instead.

MFC after:	3 days
2022-07-26 21:25:08 +02:00
John Baldwin
8b83d7e0ee Make -Wunused-but-set-variable a fatal error for clang 13+ for kernel builds.
Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D34949
2022-04-18 16:06:27 -07:00
John Baldwin
615d289ffe Re-enable set but not used warnings for kernel builds.
make tinderbox now passes with this warning enabled as a fatal error,
so revert the change to hide it in preparation for making it fatal.

This reverts commit e8e691983b.

Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D34948
2022-04-18 16:06:14 -07:00
Robert Wing
e8e691983b suppress set but not used warnings for kernel builds
Use -Wno-unused-but-set-variable for kernel builds with clang13.

To turn this warning back on, set the following in src.conf:
    WITH_SET_BUT_NOTUSED_KERNEL_WARNINGS=

Reviewed by:	mjg, imp
Differential Revision:	https://reviews.freebsd.org/D34784
2022-04-05 13:34:34 -08:00
John Baldwin
2814ba8ef1 Move NO_WUNUSED_BUT_SET_VARIABLE clang helper to the right place.
Reviewed by:	imp, dim, emaste
Sponsored by:	University of Cambridge, Google, Inc.
Differential Revision:	https://reviews.freebsd.org/D34537
2022-03-14 14:05:25 -07:00
Warner Losh
369216b039 ath: fix older clang build.
Define NO_WUNUSED_BUT_SET_VARIABLE for newer clang, and use it in ATH_C
to account for different clang versions. Use it in Makefiles as well.

Sponsored by:		Netflix
Reviewed by:		kevans, jhb
Differential Revision:	https://reviews.freebsd.org/D34408
2022-03-01 22:55:34 -07:00
John Baldwin
2f6a842484 Disable -Wreturn-type on GCC.
GCC is more pedantic than clang about warning when a function doesn't
handle undefined enum values (see GCC bug 87950).  Clang's warning
gives a more pragmatic coverage and should find any real bugs, so
disable the warning for GCC rather than adding __unreachable
annotations to appease GCC.

Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D34147
2022-02-14 11:48:47 -08:00
Dimitry Andric
5f2aca8394 Disable clang 14 warning about bitwise operators in zstd
Parts of zstd, used in openzfs and other places, trigger a new clang 14
-Werror warning:

```
sys/contrib/zstd/lib/decompress/huf_decompress.c:889:25: error: use of bitwise '&' with boolean operands [-Werror,-Wbitwise-instead-of-logical]
                        (BIT_reloadDStreamFast(&bitD1) == BIT_DStream_unfinished)
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

While the warning is benign, it should ideally be fixed upstream and
then vendor-imported, but for now silence it selectively.

MFC after:	3 days
2022-02-08 21:46:08 +01:00
John Baldwin
c227269e2f Stop adding -Wredundant-decls to CWARNFLAGS.
clang doesn't implement it, and Linux doesn't enforce it.  As a
result, new instances keep cropping up both in FreeBSD's code and in
upstream sources from vendors.

Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D34144
2022-02-07 12:47:51 -08:00
Warner Losh
c09981f142 mips: Remove sys/mips
Remove sys/mips as the next step of decomissioning mips from the tree.
Remove mips special cases from the kernel make files. Remove the mips
specific linker scripts.

Sponsored by:		Netflix
2021-12-30 20:57:24 -07:00
John Baldwin
e72c7e2738 kernel: Disable errors for -Walloca-larger-than for GCC.
GCC complains about the use of alloca() with variable sizes (for XSAVE
state len) in sendsig() for i386.  Modern XSAVE state is probably
getting a bit large for the i386 kstack, but downgrade the error to a
warning.

Reviewed by:	kib, emaste
Differential Revision:	https://reviews.freebsd.org/D31934
2021-09-25 11:24:35 -07:00
Dimitry Andric
395d46caae Don't error out on unused but set variables with clang 13
Clang 13.0.0 now has a -Wunused-but-set-variable warning similar to the
one gcc has had for quite a while. Since this triggers *very* often for
our kernel builds, don't make it a hard error, but leave the warning
visible so is some incentive to fix the instances.

MFC after:	3 days
2021-08-29 15:53:40 +02:00
Mitchell Horne
1b8db4b4e3 arm: enable stack-smashing protection
With current generation clang/llvm it can pass all of our tests in
libc/ssp.

While here, remove the extra MACHINE_CPUARCH check for mips. SSP is
included in BROKEN_OPTIONS for this architecture in src.opts.mk, which
is enough to ensure normal builds won't set SSP_CFLAGS.

Reviewed by:	kevans, imp, emaste
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D31400
2021-08-04 15:23:22 -03:00
Alex Richardson
c8c62548bf Don't add -Winline for WARNS=6
This warning is very rarely useful (inline is a hint and not mandatory).
This flag results in many warnings being printed when compiling C++
code that uses the standard library with GCC.

This flag was originally added in back in r94332 but the flag is a no-op
in Clang ("This diagnostic flag exists for GCC compatibility, and has no
effect in Clang"). Removing it should make the GCC build output slightly
more readable.

Reviewed By:	jrtc27, imp
Differential Revision: https://reviews.freebsd.org/D29235
2021-03-22 11:55:45 +00:00
Greg V
15565e0a21 kern.mk: fix -Wno-error style to fix build with Clang 12
Clang 12 no longer supports -Wno-error-..., only the -Wno-error=...
style (which is already used everywhere else in the tree).

Differential Revision:	https://reviews.freebsd.org/D29157
2021-03-10 17:34:35 -05:00
Alex Richardson
01fe4cac28 kern.mk: Fix wrong variable being used for linker path after 172a624f0
When I synchronized kern.mk with bsd.sys.mk, I accidentally changed
CCLDFLAGS to LDFLAGS which is not used by the kernel builds. This commit
should unbreak the GitHub actions cross-build CI. I didn't notice it
locally because cheribuild already passes -fuse-ld in the linker flags as
it predates this being done in the makefiles.

Reported By:	Jose Luis Duran
Fixes:		172a624f0 ("Silence annoying and incorrect non-default linker warning with GCC")
2021-03-08 09:37:46 +00:00
Alex Richardson
172a624f0c Silence annoying and incorrect non-default linker warning with GCC
The CROSS_TOOLCHAIN GCC .mk files include -B${CROSS_BINUTILS_PREFIX}, so
GCC will select the right linker and we don't need to warn.
While here also apply 17b8b8fb5f to kern.mk.

Test Plan:	no more warning printed with CROSS_TOOLCHAIN=mips-gcc6
Reviewed By:	jhb
Differential Revision: https://reviews.freebsd.org/D29015
2021-03-04 18:27:39 +00:00
Ed Maste
1e54857bd9 Stop defaulting to DWRAF2 in kernel compilation
After the removal of obsolete GDB 6.1.1 from the base system in
1c0ea326aa we no longer need to downgrade to DWARF2 debug info.

We will need to ensure that our tools (e.g. ctfconvert) handle DWARF5
prior to it becoming the default in the Clang and GCC versions we use.

Reported by:	jhb
Relnotes:	Yes
Sponsored by:	The FreeBSD Foundation
2020-12-31 15:56:18 -05:00
Ryan Libby
629c4aeace kern.mk: drop flag only patched in-tree gcc understood
-mno-align-long-strings was a flag maintained by FreeBSD for the
now-deleted in-tree gcc.  Upstream gcc has no such flag, so just drop
it.

The flag was originally submitted by bde and committed in 2002 (svn
r97911 & r104455).  However, upstream gcc did address this same issue in
2004 (gcc svn r76694 / git 4137ba7ab7a), reducing long string alignment
in general, and to 1 with -Os.

Reviewed by:	kib
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D27768
2020-12-28 14:03:36 -08:00
Warner Losh
26676c47dc Add INIT_ALL_ZERO and INIT_ALL_PATTERN to kern.opts.mk
These options need to be in the kern.opts.mk file to be alive for kernel
and module builds. This also reverts r367579 since that's not needed with
this fix: the host's bsd.opts.mk is irrelevant.

Reviewed by: brooks@
Differential Revision:  https://reviews.freebsd.org/D27170
2020-11-10 23:25:16 +00:00
Brooks Davis
d8033dc3d3 Be more tolerant of share/mk and kern.mk mismatch
When building out-of-tree modules, it appears that the system share/mk
is used, but sys/conf/kern.mk is used.  That results in MK_INIT_ALL_ZERO
being undefined.  In the interest of maximum compatability, check
that MK_INIT_ALL_* and COMPILER_FEATURES are defined before comparing
their values.

Reported by:	mmacy
Sponsored by:	DARPA
2020-11-10 21:12:32 +00:00
Brooks Davis
e268fd0a02 Support initializing stack variables on function entry
There are two options:
 - WITH_INIT_ALL_ZERO: Zero all variables on the stack.
 - WITH_INIT_ALL_PATTERN: Initialize variables with well-defined patterns.

The exact pattern are a compiler implementation detail and vary by type.
They are somewhat documented in the LLVM commit message:
https://reviews.llvm.org/rL349442
I've used WITH_INIT_ALL_* to match Microsoft's InitAll feature rather
than naming them after the LLVM specific compiler flags.

In a range of consumer products, options like these are used in
both debug and production builds with debugs builds using patterns
(intended to provoke crashes on use of uninitialized values) and
production using zeros (deemed more likely to lead to harmless
misbehavior or NULL-pointer dereferences).

Reviewed by:	emaste
Obtained from:	CheriBSD
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D27131
2020-11-10 19:15:13 +00:00
Brandon Bergren
b75abea4d0 [PowerPC64LE] Set up powerpc.powerpc64le architecture
This is the initial set up for PowerPC64LE.

The current plan is for this arch to remain experimental for FreeBSD 13.

This started as a weekend learning project for me and kinda snowballed from
there.

(More to follow momentarily.)

Reviewed by:	imp (earlier version), emaste
Sponsored by:	Tag1 Consulting, Inc.
Differential Revision:	https://reviews.freebsd.org/D26399
2020-09-22 23:49:30 +00:00
Alex Richardson
2d6bee8f00 Fix builds that set LD=ld.lld after r364761
When using relative paths for the linker we have to transform the name
since clang does not like -fuse-ld=ld.lld and instead requires -fuse-ld=lld
(the same also applies for ld.bfd).
2020-08-26 09:19:44 +00:00
Alex Richardson
2b6ee34cf6 Pass -fuse-ld=/path/to/ld if ${LD} != "ld"
This is needed so that setting LD/XLD is not ignored when linking with $CC
instead of directly using $LD. Currently only clang accepts an absolute
path for -fuse-ld= (Clang 12+ will add a new --ld-path flag), so we now
warn when building with GCC and $LD != "ld" since that might result in the
wrong linker being used.

We have been setting XLD=/path/to/cheri/ld.lld in CheriBSD for a long time and
used a similar version of this patch to avoid linking with /usr/bin/ld.
This change is also required when building FreeBSD on an Ubuntu with Clang:
In that case we set XCC=/usr/lib/llvm-10/bin/clang and since
/usr/lib/llvm-10/bin/ does not contain a "ld" binary the build fails with
`clang: error: unable to execute command: Executable "ld" doesn't exist!`
unless we pass -fuse-ld=/usr/lib/llvm-10/bin/ld.lld.

This change passes -fuse-ld instead of copying ${XLD} to WOLRDTMP/bin/ld
since then we would have to ensure that this file does not exist while
building the bootstrap tools. The cross-linker might not be compatible with
the host linker (e.g. when building on macos: host-linker= Mach-O /usr/bin/ld,
cross-linker=LLVM ld.lld).

Reviewed By:	brooks, emaste
Differential Revision: https://reviews.freebsd.org/D26055
2020-08-25 13:30:03 +00:00