History log of /freebsd-current/sys/conf/kern.mk
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 56b40c28 21-Mar-2024 Richard Scheffenegger <rscheff@FreeBSD.org>

build: add -Wswitch to clang for more consistency with gcc

gcc12 and gcc13 appear to include Wswitch with Wall, while
clang doesn't. For switch() statements on enum, this forces
the use of at least a default: clause, in adherance with style(9).

Reviewed By: emaste
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D44092


# 53fba3b9 11-Feb-2024 Mark Johnston <markj@FreeBSD.org>

build: Default to DWARF4 in the kernel

gcc 12 defaults to emitting DWARF 5, but this is not yet supported by
our libdwarf and thus by ctfconvert.

Reviewed by: emaste, imp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D43837


# ede077bf 14-Nov-2023 John Baldwin <jhb@FreeBSD.org>

sys: Disable -Walloc-size-larger-than for GCC 9+

By default this warns about sizes larger than PTRDIFF_MAX passed to
malloc (rather than SIZE_MAX). This doesn't trigger
deterministically, but it does trigger for kmalloc() of struct_size()
in iwlwifi's iwl_configure_rxq even when struct_size() is changed to
use PTRDIFF_MAX. NB: struct_size() in Linux caps the size at
SIZE_MAX, not PTRDIFF_MAX via size_mul().

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D42587


# d09a64e1 02-Oct-2023 Andrew Turner <andrew@FreeBSD.org>

arm64: Enable kernel branch protection

Add the build flags to enable branch protection on arm64. This enable
the use of PAC and BTI in the kernel.

For PAC we already install the kernel keys when entering the kernel
from userspace so this will start using these to sign the stack.

For BTI we need to mark the kernel page tables with a new guarded page
field. As this will require all code that could be reached through a
function pointer with an appropriate branch target instruction we
are enabling this before setting the field.

As the pointer authentication support shouldn't be reached via a
function pointer it is safe to not enable the use of BTI there.

Reviewed by: markj
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D42079


# e47381c9 29-Sep-2023 Stephen J. Kiernan <stevek@FreeBSD.org>

Allow for CSTD to be set kernel module Makefiles before inclusion

Use ?= when setting the default value for CSTD so it can be set by
Makefiles before inclusion and not be overridden by the .mk file.

Reviewed by: imp, sjg
Obtained from: Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D42019


# 2befa269 01-Sep-2023 Brooks Davis <brooks@FreeBSD.org>

Add INIT_ALL build option

This option replaces WITH_INIT_ALL_PATTERN and WITH_INIT_ALL_ZERO with
INIT_ALL=pattern and INIT_ALL=zero respectively. As these are
relatively rarely used options no backwards compatibility is
implemented.

Reviewed by: emaste
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D41675


# 031beb4e 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

sys: Remove $FreeBSD$: one-line sh pattern

Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/


# ec41a96d 01-Jul-2023 John Baldwin <jhb@FreeBSD.org>

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


# 98d06eea 25-May-2023 John Baldwin <jhb@FreeBSD.org>

sys: Enable -Wunused-but-set-variable for clang 15+.

It was already enabled for older clang versions and GCC.


# 6c08fd3d 25-May-2023 John Baldwin <jhb@FreeBSD.org>

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


# 3741ffdb 23-May-2023 Dimitry Andric <dim@FreeBSD.org>

Fix typo in sys/conf/kern.mk's InitAll warning message

I missed this one in commit 3006f6df025f.

Fixes: 3006f6df025f
MFC after: 3 days


# 3006f6df 23-May-2023 Dimitry Andric <dim@FreeBSD.org>

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


# c32b6c74 25-Apr-2023 Mitchell Horne <mhorne@FreeBSD.org>

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


# 7aab8fc5 25-Apr-2023 John Baldwin <jhb@FreeBSD.org>

clang: Enable -Wdeprecated-non-prototype by default.

PR: 270919 (exp-run)
Reviewed by: dim, emaste
Differential Revision: https://reviews.freebsd.org/D39535


# 42140052 20-Apr-2023 Dimitry Andric <dim@FreeBSD.org>

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


# 1ca12bd9 12-Apr-2023 John Baldwin <jhb@FreeBSD.org>

Remove the riscv64sf architecture.

Reviewed by: jrtc27, arichardson, br, kp, imp, emaste
Differential Revision: https://reviews.freebsd.org/D39496


# cd800d3c 11-Apr-2023 John Baldwin <jhb@FreeBSD.org>

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


# 3b3762c3 10-Apr-2023 John Baldwin <jhb@FreeBSD.org>

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


# 47d1e678 30-Mar-2023 John Baldwin <jhb@FreeBSD.org>

sys: Disable errors for -Wunused-function on GCC.

This matches the handling of this warning on clang.


# 4ffeb3b8 22-Mar-2023 John Baldwin <jhb@FreeBSD.org>

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
(c3179891f897d840f578a5139839fcacb587c96d) triggers this warning on
GCC, but that commit uses nested externs purposefully.

Reviewed by: markj, emaste
Differential Revision: https://reviews.freebsd.org/D39214


# 1a1f7b7d 13-Feb-2023 Warner Losh <imp@FreeBSD.org>

zlib: Add proper NO_WSTRICT_PROTYPES too

Also move NO_WDEPRECATED_NON_PROTOTYPE to a better place...

Sponsored by: Netflix
Noticed by: jhb
Fixes: b9f235ba3178


# b80185c2 13-Feb-2023 Warner Losh <imp@FreeBSD.org>

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: b9f235ba3178
Differential Revision: https://reviews.freebsd.org/D38550


# a4a491e2 10-Sep-2022 Dimitry Andric <dim@FreeBSD.org>

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


# 61cfbce3 13-Aug-2022 Dimitry Andric <dim@FreeBSD.org>

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


# 526f57bf 24-Jul-2022 Dimitry Andric <dim@FreeBSD.org>

Update CWARNFLAGS in bsd.sys.mk and CWARNEXTRA in kern.mk for clang 15.

MFC after: 3 days

# 32661319 21-Dec-2022 John Baldwin <jhb@FreeBSD.org>

Fix spelling of NO_WINFINITE_RECURSION.

Reported by: dim
Fixes: 2e08e4b75ea1 zfs: Fix build with GCC 12.

# 2e08e4b7 21-Dec-2022 John Baldwin <jhb@FreeBSD.org>

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

# 1aa6d44d 21-Dec-2022 John Baldwin <jhb@FreeBSD.org>

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

# 2637ed55 21-Dec-2022 John Baldwin <jhb@FreeBSD.org>

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

# 488c498b 21-Dec-2022 John Baldwin <jhb@FreeBSD.org>

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

# 5115511e 22-Nov-2022 John Baldwin <jhb@FreeBSD.org>

Use __freebsd_kprintf__ with GCC 12+ similar to clang.

# e83ffec3 26-Jul-2022 Dimitry Andric <dim@FreeBSD.org>

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

# 8b83d7e0 18-Apr-2022 John Baldwin <jhb@FreeBSD.org>

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

# 615d289f 18-Apr-2022 John Baldwin <jhb@FreeBSD.org>

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 e8e691983bb75e80153b802f47733f1531615fa2.

Reviewed by: imp, emaste
Differential Revision: https://reviews.freebsd.org/D34948

# e8e69198 05-Apr-2022 Robert Wing <rew@FreeBSD.org>

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

# 2814ba8e 14-Mar-2022 John Baldwin <jhb@FreeBSD.org>

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

# 369216b0 01-Mar-2022 Warner Losh <imp@FreeBSD.org>

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

# 2f6a8424 14-Feb-2022 John Baldwin <jhb@FreeBSD.org>

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

# 5f2aca83 08-Feb-2022 Dimitry Andric <dim@FreeBSD.org>

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

# c227269e 07-Feb-2022 John Baldwin <jhb@FreeBSD.org>

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

# c09981f1 30-Dec-2021 Warner Losh <imp@FreeBSD.org>

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

# e72c7e27 25-Sep-2021 John Baldwin <jhb@FreeBSD.org>

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

# 395d46ca 29-Aug-2021 Dimitry Andric <dim@FreeBSD.org>

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

# 1b8db4b4 04-Aug-2021 Mitchell Horne <mhorne@FreeBSD.org>

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

# c8c62548 22-Mar-2021 Alex Richardson <arichardson@FreeBSD.org>

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

# 15565e0a 10-Mar-2021 Greg V <greg@unrelenting.technology>

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

# 01fe4cac 08-Mar-2021 Alex Richardson <arichardson@FreeBSD.org>

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")

# 172a624f 04-Mar-2021 Alex Richardson <arichardson@FreeBSD.org>

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 17b8b8fb5fc4acc832dabfe7ef11e3e1d399ad0f to kern.mk.

Test Plan: no more warning printed with CROSS_TOOLCHAIN=mips-gcc6
Reviewed By: jhb
Differential Revision: https://reviews.freebsd.org/D29015

# 1e54857b 31-Dec-2020 Ed Maste <emaste@FreeBSD.org>

Stop defaulting to DWRAF2 in kernel compilation

After the removal of obsolete GDB 6.1.1 from the base system in
1c0ea326aa6d 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

# 629c4aea 28-Dec-2020 Ryan Libby <rlibby@FreeBSD.org>

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

# 26676c47 10-Nov-2020 Warner Losh <imp@FreeBSD.org>

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

# d8033dc3 10-Nov-2020 Brooks Davis <brooks@FreeBSD.org>

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

# e268fd0a 10-Nov-2020 Brooks Davis <brooks@FreeBSD.org>

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

# b75abea4 22-Sep-2020 Brandon Bergren <bdragon@FreeBSD.org>

[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

# 2d6bee8f 26-Aug-2020 Alex Richardson <arichardson@FreeBSD.org>

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).

# 2b6ee34c 25-Aug-2020 Alex Richardson <arichardson@FreeBSD.org>

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

# fac6dee9 12-May-2020 Eric van Gyzen <vangyzen@FreeBSD.org>

Remove tests for obsolete compilers in the build system

Assume gcc is at least 6.4, the oldest xtoolchain in the ports tree.
Assume clang is at least 6, which was in 11.2-RELEASE. Drop conditions
for older compilers.

Reviewed by: imp (earlier version), emaste, jhb
MFC after: 2 weeks
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D24802

# 02343a67 27-Apr-2020 John Baldwin <jhb@FreeBSD.org>

Retire the GENERICSF kernel config.

Now that hw.machine_arch handles soft-float vs hard-float there is no
longer a reason for this config.

Submitted by: mhorne (kern.mk hunk)
Reviewed by: imp (earlier version), kp
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D24544

# 6b72948d 27-Feb-2020 Warner Losh <imp@FreeBSD.org>

Better check for floating point type.

Use __riscv_flen instead of __riscv_float_abi_soft. While the latter works for
userland (and one could argue it's more correct), it fails for the kernel. We
compile the kernel with -mabi=lp64 (eg soft float abi) to avoid floating point
instructions in the kernel. We also compile the kernel -march=rv64imafdc for
hard float kernels (eg those with options FPE), but with -march=rv64imac for
softfloat kernels (eg those with FPE). Since we do this, in the kernel (as in
userland) __riscv_flen will be defined for 'riscv64' and not for 'riscv64sf'.

This also removes the -DMACHINE_ARCH hack now that it's no longer needed.

Longer term, we should return the ABI from the sysctl hw.machine_arch like on
amd64 for i386 binaries.

Suggested by: mhorne@
Differential Revision: https://reviews.freebsd.org/D23813

# 990a56e8 24-Feb-2020 Warner Losh <imp@FreeBSD.org>

Add a soft-float riscv kernel config

GENERICSF is just like GENERIC, only creates a soft-float kernel. Omit it from the
universe build for now.

Reviewed by: philip
Differential Revision: https://reviews.freebsd.org/D23812

# bc7d20c4 13-Feb-2020 Dimitry Andric <dim@FreeBSD.org>

Disable new clang 10.0.0 warnings about misleading indentation in ce(4)
and cp(4).

These are false positives, since some of the driver source has been
deliberately obfuscated.

# 58aa35d4 03-Feb-2020 Warner Losh <imp@FreeBSD.org>

Remove sparc64 kernel support

Remove all sparc64 specific files
Remove all sparc64 ifdefs
Removee indireeect sparc64 ifdefs

# f6d5b31f 01-Feb-2020 Dimitry Andric <dim@FreeBSD.org>

Revert r357349, since the clang 10.0.0 warning was actually correct, and
the ! operator should have been a ~ instead:

Merge r357348 from the clang 10.0.0 import branch:

Disable new clang 10.0.0 warnings about converting the result of
shift operations to a boolean in tpm(4):

sys/dev/tpm/tpm_crb.c:301:32: error: converting the result of '<<' to a boolean; did you mean '(1 << (0)) != 0'? [-Werror,-Wint-in-bool-context]
WR4(sc, TPM_CRB_CTRL_CANCEL, !TPM_CRB_CTRL_CANCEL_CMD);
^
sys/dev/tpm/tpm_crb.c:73:34: note: expanded from macro 'TPM_CRB_CTRL_CANCEL_CMD'
#define TPM_CRB_CTRL_CANCEL_CMD BIT(0)
^
sys/dev/tpm/tpm20.h:60:19: note: expanded from macro 'BIT'
#define BIT(x) (1 << (x))
^

Such warnings can be useful in C++ contexts, but not so much in kernel
drivers, where this type of bit twiddling is commonplace. So disable
it for this case.

Noticed by: cem
MFC after: 3 days

# 0a51af91 31-Jan-2020 Dimitry Andric <dim@FreeBSD.org>

Disable new clang 10.0.0 warnings about converting the result of shift
operations to a boolean in tpm(4):

sys/dev/tpm/tpm_crb.c:301:32: error: converting the result of '<<' to a boolean; did you mean '(1 << (0)) != 0'? [-Werror,-Wint-in-bool-context]
WR4(sc, TPM_CRB_CTRL_CANCEL, !TPM_CRB_CTRL_CANCEL_CMD);
^
sys/dev/tpm/tpm_crb.c:73:34: note: expanded from macro 'TPM_CRB_CTRL_CANCEL_CMD'
#define TPM_CRB_CTRL_CANCEL_CMD BIT(0)
^
sys/dev/tpm/tpm20.h:60:19: note: expanded from macro 'BIT'
#define BIT(x) (1 << (x))
^

Such warnings can be useful in C++ contexts, but not so much in kernel
drivers, where this type of bit twiddling is commonplace. So disable it
for this case.

MFC after: 3 days

# 77acc3cf 20-Dec-2019 Ryan Libby <rlibby@FreeBSD.org>

gcc9: quiet Waddress-of-packed-member for kernel build

This is lame, but it's what we already do for the clang build. We take
misaligned pointers into network header structures in many places.

Reviewed by: ian
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D22876

# 0869dceb 05-Dec-2019 John Baldwin <jhb@FreeBSD.org>

Add a new "riscv-relaxations" linker feature.

When the linker doesn't have this feature, add -mno-relax to CFLAGS
on RISC-V.

Define the feature for ld.bfd, but not lld. If lld gains relaxation
support in a newer version, we can enable it for those versions of lld
in bsd.linker.mk.

Reviewed by: mhorne
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D22659

# 88eb44d7 28-Nov-2019 Ryan Libby <rlibby@FreeBSD.org>

kern.mk: -Wno-error=stringop-overflow for gcc due to false positives

Demote gcc's Wstringop-overflow to Wno-error due to false positives.
E.g. the riscv64 build with gcc 8.3.0 has been failing with this warning
since r355062 [1]. A bug has been filed with gcc [2]. The warning was
first introduced in gcc 7.1 [3]. Hopefully we can avoiding suppressing
the warning in future gcc versions.

[1] https://ci.freebsd.org/job/FreeBSD-head-riscv64-build/16691/
[2] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92718
[3] https://gcc.gnu.org/wiki/WarningHistory

Reviewed by: markj
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D22603

# b16a3c9d 22-Sep-2019 Kyle Evans <kevans@FreeBSD.org>

Honor CWARNFLAGS.clang/gcc in the kernel build

Some kernel builds or users may want to disable warnings on a per-compiler
basis, so do this now.

# 45b535fa 08-Sep-2019 Mitchell Horne <mhorne@FreeBSD.org>

RISC-V: fix kernel CFLAGS with clang

Use the -march and -mabi flags for both gcc and clang as they are
compatible. Specify the "medium" code model separately as it goes by the
name "medany" under gcc, although they are equivalent.

Reviewed by: markj
Approved by: markj (mentor)
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D21436

# 6c30aa54 01-Sep-2019 Ed Maste <emaste@FreeBSD.org>

Remove CLANG_NO_IAS definition

CLANG_NO_IAS is not used anywhere in the tree.

Sponsored by: The FreeBSD Foundation

# be3ab187 07-Aug-2019 Conrad Meyer <cem@FreeBSD.org>

Disable useless -Wformat-zero-length

It is part of -Wformat, which is enabled by -Wall. Empty format strings are
well defined and it is perfectly reasonable to expect them in a formatting
interface.

# 82334850 28-Jun-2019 John Baldwin <jhb@FreeBSD.org>

Add an external mbuf buffer type that holds multiple unmapped pages.

Unmapped mbufs allow sendfile to carry multiple pages of data in a
single mbuf, without mapping those pages. It is a requirement for
Netflix's in-kernel TLS, and provides a 5-10% CPU savings on heavy web
serving workloads when used by sendfile, due to effectively
compressing socket buffers by an order of magnitude, and hence
reducing cache misses.

For this new external mbuf buffer type (EXT_PGS), the ext_buf pointer
now points to a struct mbuf_ext_pgs structure instead of a data
buffer. This structure contains an array of physical addresses (this
reduces cache misses compared to an earlier version that stored an
array of vm_page_t pointers). It also stores additional fields needed
for in-kernel TLS such as the TLS header and trailer data that are
currently unused. To more easily detect these mbufs, the M_NOMAP flag
is set in m_flags in addition to M_EXT.

Various functions like m_copydata() have been updated to safely access
packet contents (using uiomove_fromphys()), to make things like BPF
safe.

NIC drivers advertise support for unmapped mbufs on transmit via a new
IFCAP_NOMAP capability. This capability can be toggled via the new
'nomap' and '-nomap' ifconfig(8) commands. For NIC drivers that only
transmit packet contents via DMA and use bus_dma, adding the
capability to if_capabilities and if_capenable should be all that is
required.

If a NIC does not support unmapped mbufs, they are converted to a
chain of mapped mbufs (using sf_bufs to provide the mapping) in
ip_output or ip6_output. If an unmapped mbuf requires software
checksums, it is also converted to a chain of mapped mbufs before
computing the checksum.

Submitted by: gallatin (earlier version)
Reviewed by: gallatin, hselasky, rrs
Discussed with: ae, kp (firewalls)
Relnotes: yes
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D20616

# bd48a010 19-Apr-2019 Conrad Meyer <cem@FreeBSD.org>

kernel build: Disable unhelpful GCC warning (tripped after r346352)

-Wformat-zero-length does not highlight any particularly wrong code and it
is especially meaningless for device_printf(). Turn it off entirely to
remove a source of false positives.

Sponsored by: Dell EMC Isilon

# 5426539c 23-Feb-2019 Matt Macy <mmacy@FreeBSD.org>

gcov support

add gcov support and export results as files in debugfs

Reviewed by: hps@
MFC after: 1 week
Sponsored by: iX Systems
Differential Revision: https://reviews.freebsd.org/D19260

# 0e4a3d93 18-Dec-2018 Mark Johnston <markj@FreeBSD.org>

Remove a use of a negative array index from fxp(4).

This fixes a warning seen when compiling amd64 GENERIC with clang 7.
Also remove the workaround added in r337324. clang 7 and gcc 4.2
generate the same code with or without the code change.

Reviewed by: imp (previous version)
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D18603

# 2a22df74 04-Nov-2018 Dimitry Andric <dim@FreeBSD.org>

Merge ^/head r339813 through r340125.


# ea96b3de 01-Nov-2018 Ed Maste <emaste@FreeBSD.org>

Retire CLANG_NO_IAS34

CLANG_NO_IAS34 was introduced in r276696 to allow then-HEAD kernels to
be built with clang 3.4 in FreeBSD 10. As FreeBSD 11 and later includes
a version of Clang with a sufficiently capable integrated assembler we
do not need the workaround any longer.

Sponsored by: The FreeBSD Foundation

# 3af64f03 11-Sep-2018 Dimitry Andric <dim@FreeBSD.org>

Merge ^/head r338392 through r338594.


# 888c8381 03-Sep-2018 Ruslan Bukin <br@FreeBSD.org>

Enable 'C'-compressed ISA extension.

This was disabled recently due to lack of support in KDB disassembler
and DTrace FBT provider. Support for 'C'-extension to both of these was
added, so we can now enable 'C'-extension.

This reduces size of the kernel important for low-end embedded devices,
and saves cache footprint for high perfomance machines.

Approved by: re (kib)
Sponsored by: DARPA, AFRL

# fc63c661 04-Aug-2018 Dimitry Andric <dim@FreeBSD.org>

Put in a temporary workaround for strange array access in if_fxp.c.

# 8e8fbf19 25-Jul-2018 Ruslan Bukin <br@FreeBSD.org>

Disable 'C'-compressed ISA extension.

It works excellent, but KDB disassembler and DTrace FBT provider for
RISC-V do lack support for it. They currently handle 4-byte instructions
only, while C-compressed ISA extension introduces 2-byte instructions
freely mixing them together.

So disable it for now.

Reviewed by: markj@
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D16436

# ff945277 17-Jul-2018 Warner Losh <imp@FreeBSD.org>

Remove kernel support for armeb

Remove all the big-endian arm architectures (ixp425 and ixp435)
support in the kernel and associated drivers.

Differential Revision: https://reviews.freebsd.org/D16257

# 8cd6c09e 04-Jun-2018 Ruslan Bukin <br@FreeBSD.org>

Fix build: ignore a GCC 7.2.0 warning which says that third argument of
memset(3) should contain the number of elements multiplied by the element
size.

Sponsored by: DARPA, AFRL

# e5ae3af7 18-May-2018 Matt Macy <mmacy@FreeBSD.org>

disable set but not used on code that can't be changed

# cccc969b 18-May-2018 Matt Macy <mmacy@FreeBSD.org>

Silence non-actionable warnings in vendor code

We can't modify vendor code so there's no signal in warnings from it.
Similarly -Waddress-of-packed-member is not useful on networking code
as access to packed structures is fundamental to its operation.

# df66feb8 04-May-2018 Matt Macy <mmacy@FreeBSD.org>

% WITHOUT_FORMAT_EXTENSIONS= XCC=/usr/local/bin/gcc8 make -j96 buildkernel KERNCONF=GENERIC-NODEBUG -s >& log
% grep "inlining failed" log | wc
234 3570 36065
Consensus on those polled is that inlining failure warnings are not useful

Approved by: sbruno

# d39c2658 04-May-2018 Matt Macy <mmacy@FreeBSD.org>

fix gcc8 compile

Approved by: sbruno

# e31b69ec 12-Apr-2018 Ruslan Bukin <br@FreeBSD.org>

Add ld emulation types for hard-float mipses.

Sponsored by: DARPA, AFRL

# 0a646b97 11-Mar-2018 Conrad Meyer <cem@FreeBSD.org>

Implement NO_WCAST_QUAL for gcc4.2 architectures

# e9093b66 28-Feb-2018 Ed Maste <emaste@FreeBSD.org>

Add kernel retpoline option for amd64

Retpoline is a compiler-based mitigation for CVE-2017-5715, also known
as Spectre V2, that protects against speculative execution branch target
injection attacks.

In this commit it is disabled by default, but will be changed in a
followup commit.

Reviewed by: bdrewery (previous version)
MFC after: 3 days
Security: CVE-2017-5715
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D14242

# 5d851700 25-Nov-2017 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Automatically use the ELFv2 ABI on powerpc64 if supported by the compiler.
This has the same effects on DDB working as -mcall=aixdesc, but also is
supported by clang and marginally improves kernel performance.

MFC after: 2 weeks

# 1cbb5888 17-Nov-2017 Warner Losh <imp@FreeBSD.org>

Remove build system support for lint.

Differential Revision: https://reviews.freebsd.org/D13124

# d8371cb1 18-Oct-2017 John Baldwin <jhb@FreeBSD.org>

Remove CPU_HAVEFPU.

Instead, use a runtime decision to handle COP1 traps. If floating point
support is present in the current CPU, enable saving of the floating point
state. If support is not present, fail with SIGILL.

Reviewed by: imp, br
Sponsored by: DARPA / AFRL
Differential Revision: https://reviews.freebsd.org/D12707

# 0b972ac9 05-Oct-2017 Warner Losh <imp@FreeBSD.org>

Support armv7 builds for userland

Make armv7 as a new MACHINE_ARCH.

Copy all the places we do armv6 and add armv7 as basically an
alias. clang appears to generate code for armv7 by default. armv7 hard
float isn't supported by the the in-tree gcc, so it hasn't been
updated to have a new default.

Support armv7 as a new valid MACHINE_ARCH (and by extension
TARGET_ARCH).

Add armv7 to the universe build.

Differential Revision: https://reviews.freebsd.org/D12010

# 4e51f184 13-Sep-2017 Ryan Libby <rlibby@FreeBSD.org>

gcc builds: reenable -Wstrict-overflow for kern.mk

Reviewed by: emaste
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D12284

# af19cc59 10-Aug-2017 Ruslan Bukin <br@FreeBSD.org>

Support for v1.10 (latest) of RISC-V privilege specification.

New version is not compatible on supervisor mode with v1.9.1
(previous version).

Highlights:
o BBL (Berkeley Boot Loader) provides no initial page tables
anymore allowing us to choose VM, to build page tables manually
and enable MMU in S-mode.
o SBI interface changed.
o GENERIC kernel.
FDT is now chosen standard for RISC-V hardware description.
DTB is now provided by Spike (golden model simulator). This
allows us to introduce GENERIC kernel. However, description
for console and timer devices is not provided in DTB, so move
these devices temporary to nexus bus.
o Supervisor can't access userspace by default. Solution is to
set SUM (permit Supervisor User Memory access) bit in sstatus
register.
o Compressed extension is now turned on by default.
o External GCC 7.1 compiler used.
o _gp renamed to __global_pointer$
o Compiler -march= string is now in use allowing us to choose
required extensions (compressed, FPU, atomic, etc).

Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D11800

# fd46810a 05-Apr-2017 John Baldwin <jhb@FreeBSD.org>

Fix the linker emulation setting for riscv.

Reported by: lwhsu
MFC after: 1 week
Sponsored by: DARPA / AFRL

# dc653882 04-Apr-2017 John Baldwin <jhb@FreeBSD.org>

Always pass the linker emulation via -m when linking modules and kernels.

Previously the linker emulation was only passed when building binary
objects for firmware modules. This change always passes the desired
output format for kernel modules and kernels rather than requiring the
toolchain's default output format to match the desired output format.
This in turn permits use of external toolchains whose default output
format does not match the desired output format.

Reviewed by: imp, emaste
Sponsored by: DARPA / AFRL
Differential Revision: https://reviews.freebsd.org/D10085

# dd3c4329 04-Apr-2017 John Baldwin <jhb@FreeBSD.org>

Use correct linker emulation name for armeb.

MFC after: 1 week
Sponsored by: DARPA / AFRL
Differential Revision: https://reviews.freebsd.org/D10085

# 71fe94fd 01-Feb-2017 Dimitry Andric <dim@FreeBSD.org>

Merge ^/head r312968 through r313054.


# d9dbd70b 30-Jan-2017 Justin Hibbits <jhibbits@FreeBSD.org>

Update CFLAGS for clang compatibility

* Clang/llvm does not (yet) support -m(no-)spe, so make it gcc-only
* Clang now supports -msoft-float, and does not appear to recognize
"-disable-ppc-float-in-variadic", which appears to have been a crutch until
soft-float was implemented. It's now implemented for both 32- and 64-bit.
* Clang/llvm use a 'medium' code model by default for powerpc64, supporting up
to 4GB TOC, and does not support the '-mminimal-toc' option. Given both of
these, make -mminimal-toc gcc-only.

MFC after: 2 weeks

# 8177b837 08-Jan-2017 Dimitry Andric <dim@FreeBSD.org>

For kernel builds, make the -Waddress-of-packed-member warning non-fatal.
The warning is informative, but often there is no real alignment problem.

# f369aff3 29-Dec-2016 Alexander Kabaev <kan@FreeBSD.org>

Support mips[*]hf variants in config files

Recognize new MACHINE_ARCH names now as we have added hardfloat support.
Switch JZ4780 to mipselhf and remove all uses of TARGET_ARCH in kernel
.mk files.

Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D8989

# 5bca2215 31-Oct-2016 Ruslan Bukin <br@FreeBSD.org>

Add full softfloat and hardfloat support for MIPS.

This adds new target architectures for hardfloat:
mipselhf mipshf mips64elhf mips64hf.

Tested in QEMU only.

Sponsored by: DARPA, AFRL
Sponsored by: HEIF5
Differential Revision: https://reviews.freebsd.org/D8376

# dc9b124d 21-Oct-2016 Justin Hibbits <jhibbits@FreeBSD.org>

Create a new MACHINE_ARCH for Freescale PowerPC e500v2

Summary:
The Freescale e500v2 PowerPC core does not use a standard FPU.
Instead, it uses a Signal Processing Engine (SPE)--a DSP-style vector processor
unit, which doubles as a FPU. The PowerPC SPE ABI is incompatible with the
stock powerpc ABI, so a new MACHINE_ARCH was created to deal with this.
Additionaly, the SPE opcodes overlap with Altivec, so these are mutually
exclusive. Taking advantage of this fact, a new file, powerpc/booke/spe.c, was
created with the same function set as in powerpc/powerpc/altivec.c, so it
becomes effectively a drop-in replacement. setjmp/longjmp were modified to save
the upper 32-bits of the now-64-bit GPRs (upper 32-bits are only accessible by
the SPE).

Note: This does _not_ support the SPE in the e500v1, as the e500v1 SPE does not
support double-precision floating point.

Also, without a new MACHINE_ARCH it would be impossible to provide binary
packages which utilize the SPE.

Additionally, no work has been done to support ports, work is needed for this.
This also means no newer gcc can yet be used. However, gcc's powerpc support
has been refactored which would make adding a powerpcspe-freebsd target very
easy.

Test Plan:
This was lightly tested on a RouterBoard RB800 and an AmigaOne A1222
(P1022-based) board, compiled against the new ABI. Base system utilities
(/bin/sh, /bin/ls, etc) still function appropriately, the system is able to boot
multiuser.

Reviewed By: bdrewery, imp
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D5683

# cbc6e751 09-Oct-2016 Andrew Turner <andrew@FreeBSD.org>

Set INLINE_LIMIT in the aarch64 case for gcc.

Submitted by: andreast
MFC after: 1 week

# 1dd50172 20-Sep-2016 Ed Maste <emaste@FreeBSD.org>

Always pass -m to ld for converting binary files to kernel ELF objects

This is in preparation for linking with LLVM's lld, which does not have
a compiled-in default output emulation. lld requires that it is
specified via the -m option, or obtained from the object file(s) being
linked.

This will also allow all build targets to share a common linker binary.

Reviewed by: imp
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D7837

# 1c7c2b26 04-Sep-2016 Dimitry Andric <dim@FreeBSD.org>

For kernel builds, instead of suppressing certain clang warnings, make
them non-fatal, so there is some incentive to fix them eventually.

# 9346408d 28-Jul-2016 Ruslan Bukin <br@FreeBSD.org>

Normalise the CWARNFLAGS inter-word spacing: remove all leading
and trailing space, and convert multiple consecutive spaces to
single space.

This helps to keep build output looking good.

# 96c072fc 28-Jul-2016 Ruslan Bukin <br@FreeBSD.org>

o Add warn flags required to build modules with GCC 6.1;
o Sort GCC 4.8 warn flags.

Sponsored by: DARPA, AFRL
Sponsored by: HEIF5

# 8500b15f 24-Jul-2016 Ruslan Bukin <br@FreeBSD.org>

Fix style.

# c4dc5cdb 22-Jul-2016 Ruslan Bukin <br@FreeBSD.org>

Add GCC 6.1 warn flags for kernel as well.

Sponsored by: DARPA, AFRL

# 88f05751 08-Jul-2016 Enji Cooper <ngie@FreeBSD.org>

Revert r302403

lang/gcc{48,49,5} lacks -fformat-extensions support (causing build errors, which
is what prompted r302403 to be committed). devel/amd64-gcc on the other hand
(which is used by Jenkins), has the support.

This fixes the Jenkins failure emails due to excessive warnings being produced
with "make buildkernel".

Discussed with: lwhsu
Reported by: Jenkins (FreeBSD_HEAD_amd64_gcc job)
Sponsored by: EMC / Isilon Storage Division

# d6b483b2 07-Jul-2016 Enji Cooper <ngie@FreeBSD.org>

Do not use -fformat-extensions with non-base versions of gcc

Ports versions of gcc do not have -fformat-extensions support.

This unbreaks compiling the kernel/modules with non-base gcc (4.8,
5.0, etc) if MK_FORMAT_EXTENSIONS=yes (the default).

Approved by: re (gjb)
Differential Revision: https://reviews.freebsd.org/D7150
Reviewed by: bdrewery
Sponsored by: EMC / Isilon Storage Division

# 12701462 13-Mar-2016 Bryan Drewery <bdrewery@FreeBSD.org>

We only support GCC 4.8 for these flags.

- 4.7 introduced maybe-uninitialized
- 4.8 introduced aggressive-loop-optimizations

Sponsored by: EMC / Isilon Storage Division

# 4e47b95c 26-Feb-2016 Bryan Drewery <bdrewery@FreeBSD.org>

Remove more references to targets we've never had.

Sponsored by: EMC / Isilon Storage Division

# 2a9aa1a6 18-Feb-2016 Ruslan Bukin <br@FreeBSD.org>

Use medany (Medium/Anywhere) GCC code model for RISC-V.
This will allow us to use bigger relocations and all
the 64-bit VA space.

# 28029b68 29-Jan-2016 Ruslan Bukin <br@FreeBSD.org>

Welcome the RISC-V 64-bit kernel.

This is the final step required allowing to compile and to run RISC-V
kernel and userland from HEAD.

RISC-V is a completely open ISA that is freely available to academia
and industry.

Thanks to all the people involved! Special thanks to Andrew Turner,
David Chisnall, Ed Maste, Konstantin Belousov, John Baldwin and
Arun Thomas for their help.
Thanks to Robert Watson for organizing this project.

This project sponsored by UK Higher Education Innovation Fund (HEIF5) and
DARPA CTSRD project at the University of Cambridge Computer Laboratory.

FreeBSD/RISC-V project home: https://wiki.freebsd.org/riscv

Reviewed by: andrew, emaste, kib
Relnotes: Yes
Sponsored by: DARPA, AFRL
Sponsored by: HEIF5
Differential Revision: https://reviews.freebsd.org/D4982

# 23df2d67 21-Dec-2015 Warner Losh <imp@FreeBSD.org>

Revert this change. It broke the trampoline build. Until I'm sure
nothing else is broken, I'm reverting.

# 01c61698 19-Dec-2015 Warner Losh <imp@FreeBSD.org>

Move some MIPS specific flags to be more congruent with other
architectures.

# 8598392c 08-Oct-2015 Konstantin Belousov <kib@FreeBSD.org>

Build changes that allow the modules on arm64.
- Move the required kernel compiler flags from Makefile.arm64 to kern.mk.
- Build arm64 modules as PIC; non-PIC relocations in .o for shared object
output cannot be handled.
- Do not try to install aarch64 symlink.
- A hack for arm64 to avoid ld -r stage. See the comment for the explanation.
Some functionality is lost, like ctf handling, but hopefully will be
restored after newer linker is available.

Reviewed by: andrew, emaste
Tested by: andrew (on real hardware)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D3796

# 45587483 17-Aug-2015 Dimitry Andric <dim@FreeBSD.org>

For kernel builds, make the -Wshift-negative-value non-fatal for now.

# 2e8457e7 28-Apr-2015 Warner Losh <imp@FreeBSD.org>

Only include CWARNFLAGS once to reduce command line size from ~1400
characters to "only" ~900 for kernel builds.

# ca65be80 04-Mar-2015 Dimitry Andric <dim@FreeBSD.org>

Merge ^/head r279313 through r279595.


# e52a2dc8 27-Feb-2015 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Use appropriate alternative to -msoft-float for clang-built PowerPC kernels.

# 714e3c81 17-Feb-2015 Dimitry Andric <dim@FreeBSD.org>

Merge ^/head r278756 through r278915.


# cc4a90c4 17-Feb-2015 Gleb Smirnoff <glebius@FreeBSD.org>

Globally enable -fms-extensions when building kernel with gcc, and remove
this option from all modules that enable it theirselves.
In C mode -fms-extensions option enables anonymous structs and unions,
allowing us to use this C11 feature in kernel. Of course, clang supports
it without any extra options.

Reviewed by: dim

# bd9cc051 05-Feb-2015 Dimitry Andric <dim@FreeBSD.org>

Merging ^/head r278224 through r278297.


# 5d6adf25 04-Feb-2015 Peter Wemm <peter@FreeBSD.org>

Add -fwrapv to CFLAGS for the kernel. This essentially un-reverts r259045.

The C standard undefines behavior when signed integers overflow. The
compiler toolchain has become more adept at detecting this and taking
advantage of faster undefined behavior. At the current time this has the
unfortunate effect of the clock stopping after 24 days of uptime.

clang makes no distinction between -fwrapv and -fno-strict-overflow. gcc
does treat them differently but -fwrapv is mature in gcc and is the
behavior are actually expecting.

Obtained from: kib

# f72f83dc 30-Jan-2015 Dimitry Andric <dim@FreeBSD.org>

Merge ^/head r277902 through r277944.


# c234c2de 30-Jan-2015 Dimitry Andric <dim@FreeBSD.org>

For clang, disable -Wcast-qual warnings for specific aesni files, since
clang 3.6.0 will emit a number of such warnings for those files, and
they are partially contributed code.

# accc510a 28-Jan-2015 Dimitry Andric <dim@FreeBSD.org>

Since clang 3.6.0 now implements the archetype 'freebsd_kprintf' for
__attribute__((format(...))), and the -fformat-extensions flag was
removed, introduce a new macro in bsd.sys.mk to choose the right variant
of compile flag for the used compiler, and use it.

Also add something similar to kern.mk, since including bsd.sys.mk from
that file will anger Warner. :-)

Note that bsd.sys.mk does not support the MK_FORMAT_EXTENSIONS knob used
in kern.mk, since that knob is only available in kern.opts.mk, not in
src.opts.mk. We might want to add it later, to more easily support
external compilers for building world (in particular, sys/boot).

# 74079bda 10-Jan-2015 Warner Losh <imp@FreeBSD.org>

Take out some more no-error warnings, as the build is clean without
them.

# 814e92e9 06-Jan-2015 Warner Losh <imp@FreeBSD.org>

Fix typo from too many cut-n-paste operations. Use IMPSRC:T to just
get the tail part of the path. We can now build kernels the
old-fashioned way on FreeBSD 9.x and 10.x on at least amd64 using
clang 3.3, 3.4 or gcc 4.2.1 (though with the latter you need
WITHOUT_MODULES="aesni vmm cxgbe" due to various issues with
gcc 4.2.1).

# 9aca3e0f 04-Jan-2015 Warner Losh <imp@FreeBSD.org>

Clang's 3.5 integrated assembler now handles these files correctly (it
has support for the .codeXX directives). However, it is desirable, for
a time, to allow kernels to be built with clang 3.4. Historically, it
has been advantageous to allow stable X-1 to build kernels the old
way (so long as the impact of doing so is small), and this restores
that ability.

Also, centralize the addition of ${ASM_CFLAGS.${.IMPSRC}}, place it in
kern.mk rather than kern.pre.mk so that all modules can benefit, and
give the same treatment to CFLAGS in kern.mk as well.

# bbae23a7 04-Jan-2015 Ian Lepore <ian@FreeBSD.org>

Eliminate uninitialized variable warnings in kernel and module builds when
building with gcc 4.2

This has been requested several times over the past few months by several
people (including me), because gcc 4.2 just gets it wrong too often. It's
causing us to litter the code with lots of bogus initializers just to
squelch the warnings. We still have clang and coverity telling us about
uninitialized variables, and they do so more accurately.

# f75ecd9b 03-Jan-2015 Warner Losh <imp@FreeBSD.org>

Always use -Wno-unknown-pragmas, not just for clang.

# 4906cdc8 02-Jan-2015 Warner Losh <imp@FreeBSD.org>

Re-support CWARNFLAGS, lost when bsd.sys.mk was removed. Also, support
CWARNFALGS.$file centrally so we don't have to have it in all the
places. Remove a few warning flags that are no longer needed.
Also, always use -Wno-unknown-pragma to (hopefully temporarily) work
around #pragma ident in debug.h in the opensolaris code. Remove some
stale warning suppression that's no longer necessary.

# faa5d16d 01-Jan-2015 Warner Losh <imp@FreeBSD.org>

Move more of the warnings into kern.mk, as well as centralize that as
the place where the C dialect is selected. Have a fairly long list
of newly requires warning suppression for clang 3.5.0, also
centralized in kern.mk. Survive the fallout of the removal of
bsd.sys.mk from bsd.kmod.mk.

# 7ed11c5e 31-Dec-2014 Warner Losh <imp@FreeBSD.org>

Fix module builds on arm (and maybe others) by turning off a whole
raft of new warnings that appear to be on by default in clang 3.5.0.
Fix RPI-B build issues with new clang not liking the ability to pass
arbitrary flags to as, since some flags are more arbitrary (and thus
verboten) than others.

These warnings should be actually fixed in the code, but this is a
band-aide to get things (almost) building again.

# 575bd6d8 29-Nov-2014 Baptiste Daroussin <bapt@FreeBSD.org>

Ignore more warnings with external gcc

# 6627df30 09-Oct-2014 Warner Losh <imp@FreeBSD.org>

For gcc 4.6 and newer, _Static_assert is a keyword, so don't try to
redefine it. It does what we want, and is always available unlike
other alternatives.

# f5bb5524 09-Oct-2014 Warner Losh <imp@FreeBSD.org>

When building with a newer GCC, suppress some warnings for the
moment. The kernel isn't ready for them without a lot of work.

# 20256b0b 14-Aug-2014 Warner Losh <imp@FreeBSD.org>

Disable all inline warnings on gcc >= 4.3. Not sure exactly where the
cutover is, but we need better tools to cope with inline tuning per
compiler version than we have. This is a quick bandaid until such
tools are around.

# e94a64de 14-Aug-2014 Warner Losh <imp@FreeBSD.org>

Streamline format extensions. Either the compiler supports them, and
we enable them and format wordings. Or it doesn't, and we disable
format warnings because the kernel uses the extensions pervasively.

# cfe17cfc 16-Jul-2014 Dimitry Andric <dim@FreeBSD.org>

After r261991, clang warnings about unused functions in the kernel were
completely silenced. Make sure these warnings appear again, so there is
some incentive to fix them, but do not error out the whole kernel build
for them.

Noticed by: steven@pyro.eu.org
PR: 191867
MFC after: 3 days

# e7d939bd 06-Jul-2014 Marcel Moolenaar <marcel@FreeBSD.org>

Remove ia64.

This includes:
o All directories named *ia64*
o All files named *ia64*
o All ia64-specific code guarded by __ia64__
o All ia64-specific makefile logic
o Mention of ia64 in comments and documentation

This excludes:
o Everything under contrib/
o Everything under crypto/
o sys/xen/interface
o sys/sys/elf_common.h

Discussed at: BSDcan

# 724afafa 10-May-2014 Warner Losh <imp@FreeBSD.org>

bitrotted compat cruft removal:
o KMODDEPS warning is 15 years stale. Remove it.
o MK_CTF will always be defined now, so no need to test to see if it
is defined.
o no need to define MK_FORMAT_EXTENTIONS if undefined anymore.

# 22ba0b2f 10-May-2014 Warner Losh <imp@FreeBSD.org>

Simplify clang ifdefs in the kernel a bit. Introduce
CFLAGS.${COMPILER_TYPE} to mirror userland. Be explicit about which
compiler needs something (not clang isn't necessarily gcc in the
future).

# 647a9d04 01-Apr-2014 Warner Losh <imp@FreeBSD.org>

Remove check for clang and expand the comment. Newer versions of gcc
generate dwarf4 by default as well, so always force dwarf2 when
generating debugging data. It is harmless on older versions of both
clang and gcc, but required on newer ones.

# 993c4ac1 25-Mar-2014 Warner Losh <imp@FreeBSD.org>

Add a '*' to the M modifier string so we match any -gdwarf string (even
though it works w/o it for some reason, contrary to our reading of
make(1)). Also add a comment explaining things a bit better so there's
one less mystery that must be answered with svn blame.

Submitted by: ian@

# 3ad1a091 25-Mar-2014 Warner Losh <imp@FreeBSD.org>

Rather than require a makeoptions DEBUG to get debug correct,
add it in kern.mk, but only if we're using clang. While this
option is supported by both clang and gcc, in the future there
may be changes to clang which change the defaults that require
a tweak to build our kernel such that other tools in our tree
will work. Set a good example by forcing -gdwarf-2 only for
clang builds, and only if the user hasn't specified another
dwarf level already. Update UPDATING to reflect the changed
state of affairs. This also keeps us from having to update
all the ARM kernels to add this, and also keeps us from
in the future having to update all the MIPS kernels and is
one less place the user will have to know to do something
special for clang and one less thing developers will need
to do when moving an architecture to clang.

Reviewed by: ian@
MFC after: 1 week

# 90ce288a 23-Feb-2014 Dimitry Andric <dim@FreeBSD.org>

Similar to r262306 for boot1's Makefile, clang spells -mcmodel=medany as
-mcmodel=large, for now. While here, disable -msoft-float for clang
since it is not supported, and add -fno-dwarf2-cfi-asm to stop it from
emitting .cfi directives, which GNU as does not support.

# f785676f 16-Feb-2014 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copy of llvm/clang to 3.4 release. This version supports
all of the features in the current working draft of the upcoming C++
standard, provisionally named C++1y.

The code generator's performance is greatly increased, and the loop
auto-vectorizer is now enabled at -Os and -O2 in addition to -O3. The
PowerPC backend has made several major improvements to code generation
quality and compile time, and the X86, SPARC, ARM32, Aarch64 and SystemZ
backends have all seen major feature work.

Release notes for llvm and clang can be found here:
<http://llvm.org/releases/3.4/docs/ReleaseNotes.html>
<http://llvm.org/releases/3.4/tools/clang/docs/ReleaseNotes.html>

MFC after: 1 month


# 37583470 03-Feb-2014 Warner Losh <imp@FreeBSD.org>

Add a prior version compat define.

# 337a0242 15-Dec-2013 Konstantin Belousov <kib@FreeBSD.org>

Revert r259045.

It seems that clang miscompiles code related to UDP with -fno-strict-overflow.

# 1efe86bb 06-Dec-2013 Konstantin Belousov <kib@FreeBSD.org>

Disallow optimizations which potentially remove boundary checks
for signed values due to a compiler authors considering integer
overflow as impossible.

The change follows suit of other projects taking the same measure.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week

# 54fc0eca 20-May-2013 Brooks Davis <brooks@FreeBSD.org>

Spell extensions correctly.

Submitted by: dim

# a5b2b29f 15-May-2013 Brooks Davis <brooks@FreeBSD.org>

Add a new option WITHOUT_FORMAT_EXTENSIONS to disable flags related to
checking our kernel printf extensions. This is useful to allow
compilers without these extensions to build kernels.

Sponsored by: DARPA, AFRL

# 9215d178 13-Sep-2012 Brooks Davis <brooks@FreeBSD.org>

Introduce a new make variable COMPILER_TYPE that specifies what
type of compiler is being used (currently clang or gcc). COMPILER_TYPE
is set in the new bsd.compiler.mk file based on the value of the CC
variable or, should it prove informative, by running ${CC} --version
and examining the output.

To avoid negative performance impacts in the default case and correct
value for COMPILER_TYPE type is determined and passed in the environment
of submake instances while building world.

Replace adhoc attempts at determining the compiler type by examining
CC or MK_CLANG_IS_CC with checks of COMPILER_TYPE. This eliminates
bootstrapping complications when first setting WITH_CLANG_IS_CC.

Sponsored by: DARPA, AFRL
Reviewed by: Yamaya Takashi <yamayan@kbh.biglobe.ne.jp>, imp, linimon
(with some modifications post review)
MFC after: 2 weeks

# 7ae0e2c9 20-Aug-2012 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copy of llvm/clang to trunk r162107. With thanks to
Benjamin Kramer and Joerg Sonnenberger for their input and fixes.


# 3b5683fc 23-Mar-2012 Dimitry Andric <dim@FreeBSD.org>

Work around the following clang warning in mps(4):

sys/dev/mps/mps_sas.c:861:1: error: function 'mpssas_discovery_timeout' is not needed and will not be emitted [-Werror,-Wunneeded-internal-declaration]
mpssas_discovery_timeout(void *data)
^

Because the driver is obtained from upstream, we don't want to modify
it; just silence the warning instead, it is harmless.

MFC after: 3 days

# 43917540 13-Mar-2012 Dimitry Andric <dim@FreeBSD.org>

Update comments and CFLAGS in sys/conf/kern.mk, introduced in r221879,
to match reality: clang does _not_ disable SSE automatically when
-mno-mmx is used, you have to specify -mno-sse explicitly.

Note this was the case even before r232894, which only makes a change in
the 'positive' flag case; e.g. when you specify -msse, MMX gets enabled
too.

MFC after: 1 week

# 295b83d1 11-Mar-2012 Juli Mallett <jmallett@FreeBSD.org>

Reenable -Winline on MIPS now that we're not compiling Cavium's error
decoding stuff, which is impossibly-huge.

# 47c022f2 10-Mar-2012 Juli Mallett <jmallett@FreeBSD.org>

Disable -Winline on MIPS in preparation for the import of the latest version
of the Cavium Simple Executive, which violates large function growth rules
in such a way that simply increasing the large function growth parameter is
insufficient.

# 2651e350 03-Mar-2012 Dimitry Andric <dim@FreeBSD.org>

Revert r232473. I have been convinced by Doug Barton and Bjoern Zeeb
that it is better to error out when people attempt to build using the
wrong bsd.*.mk files, than to silently ignore the problem.

This means, that after this commit, if you want to build kernel modules
by hand (or via a port) from a head source tree, you *must* make sure
the files in /usr/share/mk are in sync with that tree. If that isn't
possible, for example when you are running on an older FreeBSD branch,
you can:

- Run "make buildenv" from your head source tree, to have the correct
environment setup. (It's advisable to have run "make buildworld", or
at a minimum "make toolchain" first.)
- Alternatively, set MAKESYSPATH to the share/mk directory under your
head source tree. If your build tools are too old, other problems may
still occur.
- Alternatively, use "make -m" and specify the share/mk directory under
your head source tree. Again, build tools that are too old may still
result in trouble.

MFC after: 2 weeks

# 2677e7fe 03-Mar-2012 Dimitry Andric <dim@FreeBSD.org>

After r232322, it turned out many people (and some ports) are building
kernel modules using their old installed /usr/share/mk/bsd.*.mk files,
instead of the updated ones in their source tree. This leads to errors
like:

"sys/conf/kmod.mk", line 111: Malformed conditional (${MK_CLANG_IS_CC} == "no" && ${CC:T:Mclang} != "clang")

Obviously, these errors will go away after a "make installworld", or
alternatively, by using "make buildenv" before attempting to manually
build modules.

However, since it is apparently an expected use case to build using old
.mk files, change the way we test for clang, so it also works when the
MK_CLANG_IS_CC macro doesn't exist.

Note the conditional expressions are becoming rather unreadable now, but
I will attempt to fix that on a followup commit.

MFC after: 2 weeks

# dfbaea83 29-Feb-2012 Dimitry Andric <dim@FreeBSD.org>

Add a WITH_CLANG_IS_CC option for src.conf(5), disabled by default, that
installs clang as /usr/bin/cc, /usr/bin/c++ and /usr/bin/cpp.

Note this does *not* disable building and installing gcc, which will
still be available as /usr/bin/gcc, /usr/bin/g++ and /usr/bin/gcpp. If
you want to disable gcc completely, you must use WITHOUT_GCC.

MFC after: 2 weeks

# 102a3198 23-Feb-2012 Dimitry Andric <dim@FreeBSD.org>

Revert r231978, so I can apply a more proper fix to silence unneeded
internal declaration warnings in several sys/cam/ctl files.

MFC after: 1 week

# a0dd79db 21-Feb-2012 Dimitry Andric <dim@FreeBSD.org>

When building with clang, disable -Wformat-security for
sys/dev/hpt27xx/osm_bsd.c, since it gets the following warnings:

sys/dev/hpt27xx/osm_bsd.c:1180:25: error: format string is not a string literal (potentially insecure) [-Werror,-Wformat-security]
S_IRUSR | S_IWUSR, driver_name);
^~~~~~~~~~~
@/dev/hpt27xx/hpt27xx_config.h:46:21: note: expanded from:
#define driver_name hpt27xx_driver_name
^~~~~~~~~~~~~~~~~~~

Since 'hpt27xx_driver_name' is a constant string symbol (coming from the
proprietary hpt27xx_lib.o file), there is no security problem.

Because this driver is provided by the vendor, and applying changes
requires re-certification and other bureaucratic exercises, just disable
the warning for now.

MFC after: 1 week

# 8508b798 21-Feb-2012 Dimitry Andric <dim@FreeBSD.org>

When building with clang, disable -Wunneeded-internal-declaration for
several sys/cam/ctl files, since these get the following warnings:

In file included from sys/cam/ctl/ctl_backend.c:60:
sys/cam/ctl/ctl_private.h:300:30: error: variable 'page_index_template' is not needed and will not be emitted [-Werror,-Wunneeded-internal-declaration]
static struct ctl_page_index page_index_template[] = {
^

These warnings are tricky to fix without a lot of overhaul, and they are
harmless, so disable them for now.

MFC after: 1 week

# 97a15669 30-Dec-2011 Dimitry Andric <dim@FreeBSD.org>

Disable several instances instances of clang's -Wself-assign warning.
All of these are harmless, and are in fact used to shut up warnings from
lint.

While here, remove -Wno-missing-prototypes from the xfs module
Makefile, as I could not reproduce those warnings either with gcc or
clang.

MFC after: 1 week

# 874fb554 29-Dec-2011 Dimitry Andric <dim@FreeBSD.org>

For several files in sys/dev/drm, disable -Wunused-value when building
with clang. There are several macros in these files that return values,
and in some cases nothing is done with them, but it is completely
harmless. For some other files, also disable -Wconstant-conversion,
since that triggers a false positive with the DMA_BIT_MASK() macro.

MFC after: 1 week

# 8cd925d9 24-Dec-2011 Dimitry Andric <dim@FreeBSD.org>

Make another clang warning, -Wparentheses-equality, non-fatal during
kernel builds. All the instances of this warning in our tree are
completely harmless, and many people seem to like adding extra
parentheses to make precedence clearer.

MFC after: 1 week

# 7afac0fd 24-Dec-2011 Dimitry Andric <dim@FreeBSD.org>

Make another clang warning, -Wempty-body, non-fatal during kernel
builds. All the instances of this warning in our tree are completely
harmless. (Most of the empty bodies look to be used simply as reminder
for the developer to add something later.)

While here, assign to CWARNEXTRA with ?=, so it can be overridden
easily, if needed.

MFC after: 1 week

# 1496f657 23-Dec-2011 Marius Strobl <marius@FreeBSD.org>

Update a comment to reflect reality and explain why we're using the
medany code model.

# 2cd8464e 23-Dec-2011 Dimitry Andric <dim@FreeBSD.org>

Amend r228822 by not directly adding to CWARNFLAGS, but to an optional
CWARNEXTRA variable, which gets included into the initial CWARNFLAGS
setting. This makes it easier to override CWARNFLAGS with completely
custom settings (including enabling any disabled warnings).

Reminded by: arundel
MFC after: 1 week

# 0ed78d64 22-Dec-2011 Dimitry Andric <dim@FreeBSD.org>

When building the kernel with clang, it produces several warnings which
might be useful in some cases, but which are not severe enough to error
out the whole kernel build. Display them anyway, so there is at least
some incentive to fix them eventually.

Start with -Wtautological-compare warnings. These usually occur when
people check if unsigned quantities are negative, or similar cases. To
clean these up would be painful, and might give problems if the base
type which is compared against changes to signed later on.

MFC after: 1 week

# 6f7651b9 21-Dec-2011 Dimitry Andric <dim@FreeBSD.org>

When building with clang, disable -Wshift-count-negative and
-Wshift-count-overflow for sys/dev/ath/ath_hal/ah_regdomain.c, as it
gets multiple instances of the following warnings:

In file included from sys/dev/ath/ath_hal/ah_regdomain.c:99:
sys/dev/ath/ath_hal/ah_regdomain/ah_rd_domains.h:69:15: warning: shift count is negative [-Wshift-count-negative]
.chan11a = BM4(F1_4950_4980,
^~~~~~~~~~~~~~~~~
sys/dev/ath/ath_hal/ah_regdomain/ah_rd_domains.h:41:4: note: expanded from:
W1(_fa) | W1(_fb) | W1(_fc) | W1(_fd) }
^
sys/dev/ath/ath_hal/ah_regdomain/ah_rd_domains.h:34:45: note: expanded from:
(((_a) > 63 && (_a) < 128 ? (((uint64_t) 1)<<((_a)-64)) : (uint64_t) 0))
^ ~~~~~~~~~

and:

In file included from sys/dev/ath/ath_hal/ah_regdomain.c:99:
sys/dev/ath/ath_hal/ah_regdomain/ah_rd_domains.h:629:15: error: shift count >= width of type [-Werror,-Wshift-count-overflow]
.chan11a = BM4(W2_5260_5320,
^~~~~~~~~~~~~~~~~
sys/dev/ath/ath_hal/ah_regdomain/ah_rd_domains.h:40:34: note: expanded from:
{ W0(_fa) | W0(_fb) | W0(_fc) | W0(_fd), \
^
sys/dev/ath/ath_hal/ah_regdomain/ah_rd_domains.h:32:44: note: expanded from:
(((_a) >= 0 && (_a) < 64 ? (((uint64_t) 1)<<(_a)) : (uint64_t) 0))
^ ~~~~

Both warnings are false positives, caused by LLVM PR 10030. For global
initializations, clang fails to detect that the branch of the ternary
operator causing the warning is dead.

MFC after: 1 week

# fea85869 21-Dec-2011 Dimitry Andric <dim@FreeBSD.org>

When building with clang, disable -Warray-bounds for sys/dev/asr/asr.c,
as it gets the following warning:

sys/dev/asr/asr.c:1836:29: warning: array index of '58' indexes past the end of an array (that contains 1 element) [-Warray-bounds]
while ((len > 0) && (sg < &((PPRIVATE_SCSI_SCB_EXECUTE_MESSAGE)
^
sys/dev/asr/i2omsg.h:934:8: note: array 'Simple' declared here
I2O_SGE_SIMPLE_ELEMENT Simple[1];
^

This is a false positive, since I2O_SG_ELEMENT::Simple is not declared
as a C99 flexible array member, but in the old (but more portable) way.
At run-time, the proper number of array elements will hopefully have
been allocated.

MFC after: 1 week

# a380d07b 21-Dec-2011 Dimitry Andric <dim@FreeBSD.org>

Start selectively disabling a few kernel build warnings for clang, since
there are some places in the kernel where fixing them is too disruptive,
or where there is a false positive.

In this case, disable -Wconstant-conversion for two aic7xxx-related
files, as they get the following warning on i386 (and possibly on other
32-bit arches):

sys/dev/aic7xxx/ahc_pci.c:112:10: warning: implicit conversion from 'long long' to 'bus_addr_t' (aka 'unsigned int') changes value from 549755813887 to 4294967295 [-Wconstant-conversion]
? 0x7FFFFFFFFFLL
~~^~~~~~~~~~~~~~

This is a false positive, since the code only passes the 0x7FFFFFFFFFLL
argument, if sizeof(bus_addr_t) is larger than 4 (e.g. on 64 bit arches,
or when PAE is enabled on i386). The code could be refactored to do
compile-time checks, but that is more disruptive.

MFC after: 1 week

# 78e7e3ec 29-Nov-2011 Max Khon <fjoe@FreeBSD.org>

- fix WITH_CTF when specified in /etc/src.conf [1]
- CTFCONVERT_CMD=... is a hack (should be defined to empty string instead):
make(1) should be taught to ignore empty commands silently in compat mode
(as it does in !compat mode, GNU make also silently ignores empty commands)
and to skip printing empty commands in !compat mode
- config(8) should generate ${NORMAL_CTFCONVERT} invocation without '@':
this will allow to simplify kern.pre.mk even more and lessen the number
of shell invocations during kernel build when CTF is turned off
- WITH_CTF can now be converted to usual MK_CTF=yes/no infrastructure

Pointy hat to: fjoe [1]

# b8843fe7 29-Nov-2011 Max Khon <fjoe@FreeBSD.org>

Fix typo in comments (conversation -> conversion).

# cbb7255e 26-Oct-2011 Robert Millan <rmh@FreeBSD.org>

Revert r226665 untill the issues with this change have been resolved.

Approved by: kib (mentor)

# 30ce7fee 24-Oct-2011 Dimitry Andric <dim@FreeBSD.org>

Put in a temporary band-aid to fix kernel builds when CC=clang, after
r226665.

# f9629bc4 23-Oct-2011 Robert Millan <rmh@FreeBSD.org>

Conditionalize a pair of FreeBSD GCC extensions so that its CFLAGS are only
used with FreeBSD GCC.

Approved by: kib (mentor)

# 12dd58a3 24-May-2011 Rebecca Cran <brucec@FreeBSD.org>

Remove an outdated comment as requested by Bruce Evans in a private email to
Alexander Best (arundel@).

For clang, -fdiagnostics-show-option is enabled by default, but for gcc it
isn't. This option will report which -W* flag was responsible for triggering
a certain warning. This will bring gcc warnings closer to the ones clang emits
and might also help developers track down tinderbox failures a bit quicker.

Submitted by: arundel

# d1b9bdd1 14-May-2011 Rebecca Cran <brucec@FreeBSD.org>

gcc and clang semantics imply certain -mno-* flags when other certain -mno-*
flags are also specified. This change makes use of this behaviour and removes
unneeded -mno-* flags.

Note that clang does not yet enable AVX support for any CPU. However at some
point in the future it will and since we definitely want to disable it for the
kernel, we might as well add the -mno-avx flag now.

Submitted by: arundel

# 5b44317b 02-May-2011 Rebecca Cran <brucec@FreeBSD.org>

Add -Wmissing-include-dirs to CWARNFLAGS, so tinderbox will punish those
developers committing new code with broken include directories.
Fix a few whitespace issues.
Improve a couple of comments.
-W is now deprecated and is referred to as -Wextra (see gcc(1)).

Submitted by: arundel

# 58ff0f42 19-Apr-2011 Dimitry Andric <dim@FreeBSD.org>

Remove support for the Intel C Compiler from the build infrastructure.
This support has not worked for several years, and is not likely to work
again, unless Intel decides to release a native FreeBSD version of their
compiler. ;)

# 79c77d72 18-Feb-2011 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Turn off default generation of userland dot symbols on powerpc64 now that
we have a binutils that supports it. Kernel dot symbols remain on to assist
DDB.

# 3ab20ac1 05-Jan-2011 Dimitry Andric <dim@FreeBSD.org>

On i386 and amd64, consistently use the following options whenever we
want to avoid using any "advanced" CPU features:

-mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 -msoft-float

# 9a17b89c 05-Jan-2011 Dimitry Andric <dim@FreeBSD.org>

Sort -mno-(mmx|3dnow|sse|sse2|sse3) options consistently throughout the
tree.

Submitted by: arundel

# c614f4e2 13-Sep-2010 Warner Losh <imp@FreeBSD.org>

Prefer MACHINE_CPUARCH over MACHINE_ARCH

# 187278ca 17-Aug-2010 Rui Paulo <rpaulo@FreeBSD.org>

For every instance of '.if ${CC} == "foo"' or '.if ${CC} != "foo"' in
Makefiles or *.mk files, use ${CC:T:Mfoo} instead, so only the basename
of the compiler command (excluding any arguments) is considered.

This allows you to use, for example, CC="/nondefault/path/clang -xxx",
and still have the various tests in bsd.*.mk identify your compiler as
clang correctly.

ICC if cases were also changed.

Submitted by: Dimitry Andric <dimitry at andric.com>

# 3cc97e66 22-Jul-2010 Rui Paulo <rpaulo@FreeBSD.org>

Handle a few corner cases for clang like we did with icc. These should
reduce the number of warnings seen while building the kernel.

Submitted by: Dimitry Andric <dimitry at andric.com>

# 915b4b09 13-Jul-2010 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Convert several instances of MACHINE_ARCH to MACHINE_CPUARCH and use the
correct compiler flags on 64-bit PowerPC.

# 21edb039 02-Apr-2010 Alexander Leidinger <netchild@FreeBSD.org>

WITH_CTF can now be specified in src.conf (not recommended, there
are some problems with static executables), make.conf (would also
affect ports which do not use GNU make and do not override the
compile targets) or in the kernel config (via "makeoptions
WITH_CTF=yes").

Additional (related) changes:
- propagate WITH_CTF to module builds
- do not add -g to the linker flags, it's a noop there anyway
(at least according to the man page of ld)
- do not add -g to CFLAGS unconditionally
we need to have a look if it is really needed (IMO not) or if there
is a way to add it only when WITH_CTF is used

Note: ctfconvert / ctfmerge lines will not appear in the build output,
to protect the innocent (those which do not build with WITH_CTF would
see the shell-test and may think WITH_CTF is used).

Reviewed by: imp, jhb, scottl (earlier version)
Discussed on: arch@

# 5beb779d 19-Jan-2010 Ruslan Ermilov <ru@FreeBSD.org>

Removed NO_UNDEF.

Nudged by: trasz

# e73a17cf 18-Jan-2010 Edward Tomasz Napierala <trasz@FreeBSD.org>

Undo r169961, removing WITH_GCC3, added as a temporary workaround three
years ago.

# 9fc13460 09-Jan-2010 Warner Losh <imp@FreeBSD.org>

Merge r201902 and r195669 from projects/mips into head by hand:

r201902 | imp | 2010-01-09 10:16:19 -0700 (Sat, 09 Jan 2010) | 2 lines
Fix comment, which was missed in an earlier commit...

r195669 | gonzo | 2009-07-13 17:03:44 -0600 (Mon, 13 Jul 2009) | 3 lines
- Remove -mno-dsp from CFLAGS. MIPS DSP ASE is off by default
now (as it should be)

# e0a04e74 03-Mar-2009 Warner Losh <imp@FreeBSD.org>

Bump down the inline limit on MIPS.

# 5b4975b1 22-Feb-2009 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Explicitly disable generation of Altivec instructions in the kernel on PowerPC,
and add support to allow users to set their CPUTYPE in make.conf.

# a30c29f9 23-Jul-2008 Warner Losh <imp@FreeBSD.org>

Disable SSP for mips until support is added to the base architecture.

# 7cff8cea 22-Jul-2008 Olivier Houchard <cognet@FreeBSD.org>

Disable SSP for the kernel on arm as well (see rev 180605).
I overlooked this because a SSP kernel booted for me.

Apologises to: ticso

# 042df2e2 25-Jun-2008 Ruslan Ermilov <ru@FreeBSD.org>

Enable GCC stack protection (aka Propolice) for userland:
- It is opt-out for now so as to give it maximum testing, but it may be
turned opt-in for stable branches depending on the consensus. You
can turn it off with WITHOUT_SSP.
- WITHOUT_SSP was previously used to disable the build of GNU libssp.
It is harmless to steal the knob as SSP symbols have been provided
by libc for a long time, GNU libssp should not have been much used.
- SSP is disabled in a few corners such as system bootstrap programs
(sys/boot), process bootstrap code (rtld, csu) and SSP symbols themselves.
- It should be safe to use -fstack-protector-all to build world, however
libc will be automatically downgraded to -fstack-protector because it
breaks rtld otherwise.
- This option is unavailable on ia64.

Enable GCC stack protection (aka Propolice) for kernel:
- It is opt-out for now so as to give it maximum testing.
- Do not compile your kernel with -fstack-protector-all, it won't work.

Submitted by: Jeremie Le Hen <jeremie@le-hen.org>

# 64982acf 10-May-2008 Andrey A. Chernov <ache@FreeBSD.org>

Add -mno-sse3 for amd64 case too

PR: 123518
Submitted by: Marc Olzheim <marcolz@stack.nl>

# 578328c9 29-Apr-2008 Oleksandr Tymoshenko <gonzo@FreeBSD.org>

Define INLINE_LIMIT and additional CFLAGS for mips.

Approved by: cognet (mentor)

# 9eef6e33 24-May-2007 David E. O'Brien <obrien@FreeBSD.org>

Temporarily add 'WITH_GCC3' that removes -Wno-pointer-sign from the
compiler invocation. This is just to help get over the hump of people
tracking down bugs that may cross the GCC 4.2 upgrade.
It is envisioned that this option goes away after a suitable amount
of time.

# 42f17ea9 18-May-2007 Alexander Kabaev <kan@FreeBSD.org>

Add -Wno-pointer-sign to CWARNFLAGS.

Switch ia64 kernels to -fpic. This is likely wrong, but at least gets
ia64 kernels to compile and link with GCC 4.2. The previous -mno-sdata
trick is not working anymore.

# f592bb74 26-Nov-2006 Kip Macy <kmacy@FreeBSD.org>

Fix module loading for sparc on machines with greater than 1GB of RAM

t1# uname -m
sparc64
t1# sysctl hw.physmem
hw.physmem: 17150509056
t1# kldload reiserfs
t1# kldstat
Id Refs Address Size Name
1 3 0xc0000000 58cc38 kernel
2 1 0xcbe70000 234000 xfs.ko
3 1 0xcc0b6000 110000 reiserfs.ko

# 1de763bd 29-Jun-2006 David E. O'Brien <obrien@FreeBSD.org>

Create new dialect knob, as setting the language dialect isn't a warning flag.

# a2f3563e 30-May-2006 Ruslan Ermilov <ru@FreeBSD.org>

Enable -Wundef warnings for kernel/module compiles. From cpp.info:

`-Wundef'
Warn whenever an identifier which is not a macro is encountered in
an `#if' directive, outside of `defined'. Such identifiers are
replaced with zero.

# 67ab9fd7 11-May-2006 John Baldwin <jhb@FreeBSD.org>

First pass at removing Alpha kernel support.

# 64b3210d 15-Jul-2005 Andrey A. Chernov <ache@FreeBSD.org>

Add -mno-sse3 for prescott/nocona

# 8d2046fa 31-Mar-2005 Peter Wemm <peter@FreeBSD.org>

Since the question keeps coming up, explain why the -mno-sse etc switches
are there and that it does not have an effect on user applications.

# 0c3a1acb 15-Mar-2005 David E. O'Brien <obrien@FreeBSD.org>

Remove OBE comment about AMD64 memory model.

# 0ed36875 15-Mar-2005 David E. O'Brien <obrien@FreeBSD.org>

Ensure GCC does not use FP registers in integer code.
I think all we really need is -fno-sse2.
I really don't like cluttering up the compiler invocation,
but this bigger hammer will fix reported problems for now.

# d6301dcd 14-May-2004 Olivier Houchard <cognet@FreeBSD.org>

Define INLINE_LIMIT for arm.

# 06d6e4fc 12-Mar-2004 Tom Rhodes <trhodes@FreeBSD.org>

This are the build infrastructure changes to allow to use the
Intel C/C++ compiler (lang/icc) to build the kernel.

The icc CPUTYPE CFLAGS use icc v7 syntax, icc v8 moans about them, but
doesn't abort. They also produce CPU specific code (new instructions
of the CPU, not only CPU specific scheduling), so if you get coredumps
with signal 4 (SIGILL, illegal instruction) you've used the wrong
CPUTYPE.

Incarnations of this patch survive gcc compiles and my make universe.
I use it on my desktop.

To use it update share/mk, add
/usr/local/intel/compiler70/ia32/bin (icc v7, works)
or
/usr/local/intel_cc_80/bin (icc v8, doesn't work)
to your PATH, make sure you have a new kernel compile directory
(e.g. MYKERNEL_icc) and run
CFLAGS="-O2 -ip" CC=icc make depend
CFLAGS="-O2 -ip" CC=icc make
in it.

Don't compile with -ipo, the build infrastructure uses ld directly to
link the kernel and the modules, but -ipo needs the link step to be
performed with Intel's linker.

Problems with icc v8:
- panic: npx0 cannot be emulated on an SMP system
- UP: first start of /bin/sh results in a FP exception

Parts of this commit contains suggestions or submissions from
Marius Strobl <marius@alchemy.franken.de>.

Reviewed by: silence on -arch
Submitted by: netchild

# 4338438b 03-Mar-2004 David E. O'Brien <obrien@FreeBSD.org>

Lower i386's INLINE_LIMIT to AMD64's level.

# 4e37bb8f 06-Feb-2004 Peter Wemm <peter@FreeBSD.org>

Reduce the inline limit from 20000 to 8000 after the previous changes
to simplify the curthread expansion some months ago.

# 813dd172 07-Dec-2003 David E. O'Brien <obrien@FreeBSD.org>

Add PowerPC CFLAGS.

Submitted by: gallatin

# 5064105e 04-Nov-2003 Peter Wemm <peter@FreeBSD.org>

Move the inline limit default variable to a per-arch place. For example,
the amd64 implementation of the pcpu macros is even more verbose than on
i386 and that causes gcc to way overestimate the complexity of this
2-instruction macro. The other platforms can probably lower their
default values.

# edd1f930 29-May-2003 Peter Wemm <peter@FreeBSD.org>

Update the kernel compile flags inside the .if ${MACHINE_ARCH} == "amd64"
section to stop gcc generating the dwarf2 .eh_frame unwind tables. It
is dead weight for the time being. Maybe it can be used to perform
stack traces and/or get the location of function arguments in ddb, but
that requires a dwarf2 runtime interpreter, which we do not have.

Approved by: re (amd64 "safe" bits)

# 3c9a3c9c 22-May-2003 Peter Wemm <peter@FreeBSD.org>

Major pmap rework to take advantage of the larger address space on amd64
systems. Of note:
- Implement a direct mapped region using 2MB pages. This eliminates the
need for temporary mappings when getting ptes. This supports up to
512GB of physical memory for now. This should be enough for a while.
- Implement a 4-tier page table system. Most of the infrastructure is
there for 128TB of userland virtual address space, but only 512GB is
presently enabled due to a mystery bug somewhere. The design of this
was heavily inspired by the alpha pmap.c.
- The kernel is moved into the negative address space(!).
- The kernel has 2GB of KVM available.
- Provide a uma memory allocator to use the direct map region to take
advantage of the 2MB TLBs.
- Fixed some assumptions in the bus_space macros about the ability
to fit virtual addresses in an 'int'.

Notable missing things:
- pmap_growkernel() should be able to grow to 512GB of KVM by expanding
downwards below kernbase. The kernel must be at the top 2GB of the
negative address space because of gcc code generation strategies.
- need to fix the >512GB user vm code.

Approved by: re (blanket)

# 1d7157c5 03-May-2003 David E. O'Brien <obrien@FreeBSD.org>

Use C99 for the kernel.

# a15febf9 30-Apr-2003 Peter Wemm <peter@FreeBSD.org>

Add AMD64 hooks

# 53faa77b 27-Feb-2003 Jake Burkholder <jake@FreeBSD.org>

Sync with bsd.kern.mk.

Reminded by: bde

# 8f6a0ee9 12-Oct-2002 Marcel Moolenaar <marcel@FreeBSD.org>

ia64 specific CFLAGS change:
Fix the "@gprel relocation against dynamic symbol xxx" linker error.

Variables defined in the link unit and small enough to be put in the
short data section will have a gp-relative access sequence (using the
@gprel relocation). It is invalid to have @gprel relocations in shared
libraries, because they are to be resolved by the static linker and
not the dynamic linker. The -fpic option will cause @ltoff relocations
for @gprel relocations, but the side-effects are untested (if any).
Instead, disable/eliminate the short data section to achieve the same.

# c6a1c7c5 03-Oct-2002 Bruce Evans <bde@FreeBSD.org>

Use the -mno-align-long-strings on i386's to debloat the kernel a little.
This reduces the size of GENERIC's text space by 73999 bytes (about 2%).
The bloat is from approximately 3437 strings longer than 31 characters
being padded to a 32-byte boundary.

# c253d72f 06-Sep-2002 Peter Wemm <peter@FreeBSD.org>

Bump the -mev56 to -mev6. Otherwise, when you compile with gcc using
ev6 or pca56 etc this downgrades the cpu specification passed to gas.
As a result, gas will fail when gcc generates media instructions (in
uipc_usrreq.c). This only affects what gas will accept, not what gcc
generates or what our *.s file contain.

# 64fc62d4 25-Aug-2002 Bruce Evans <bde@FreeBSD.org>

Turned format checking back on. It was left turned off for too long after
the gcc lossage that caused it to be turned off was fixed.

Tested with: i386/{GENERIC,LINT,...}, alpha/GENERIC

# e09d00a8 23-May-2002 Peter Wemm <peter@FreeBSD.org>

For now, make the .ifdef GCC3 case default. We should change -Wno-format
back to -fformat-extensions (or whatever) when we have the functionality.
We are gaining warnings again that should be fixed but the are being hidden
by NO_WERROR and all the -Wformat noise.

# 856f29cf 04-May-2002 David E. O'Brien <obrien@FreeBSD.org>

Use -ffreestanding for kernel bits unconditionally.

# ea8f3ee3 10-Sep-2001 Peter Wemm <peter@FreeBSD.org>

This will have to be revised, but allow putting 'makeoptions GCC3=true'
in a kernel config file. This should minimize the tearing-out-hair process
while updating the kernel for gcc-3 compliance.

# 51bb5852 21-Jul-2001 Assar Westerlund <assar@FreeBSD.org>

revert previous accidental commit

# 57762323 21-Jul-2001 Assar Westerlund <assar@FreeBSD.org>

get rid of some printf and pointer type warnings

# 0d409bfd 16-Oct-2000 Doug Rabson <dfr@FreeBSD.org>

Add section for building ia64 kernels.

# 20b11a60 28-Apr-2000 Doug Rabson <dfr@FreeBSD.org>

Reserve register t7 on alpha to point at per-cpu global variables.

# b453864c 24-Apr-2000 Mike Pritchard <mpp@FreeBSD.org>

Fix the grammar in my previous commit "lose" -> "loss".
I should have done it that way in the first place.

Pointed-out-by: bde

# a9914af5 23-Apr-2000 Mike Pritchard <mpp@FreeBSD.org>

Fix a typo in the comments.

Submitted by: Allen Campbell <allenc@verinet.com>

# 54d477a4 17-Nov-1999 David E. O'Brien <obrien@FreeBSD.org>

Make "-mpreferred-stack-boundary=2" the default on the i386.
This reduces the size of the kernel and modules when compiled with GCC 2.95.

# 7f3dea24 27-Aug-1999 Peter Wemm <peter@FreeBSD.org>

$Id$ -> $FreeBSD$

# 9a6c0bd6 29-Jan-1999 Bruce Evans <bde@FreeBSD.org>

Fixed comment and whitespace lossage in recent commits. The -W flag
is not implied by -Wall as claimed by gcc.1. Adding it causes a
measly 7193 new warnings for LINT, mostly for "unused parameter" and
"comparison between signed and unsigned".

# a91f66d4 28-Jan-1999 Matthew Dillon <dillon@FreeBSD.org>

Cleanup bsd.kern.mk after last commit.

# 0bcef6ef 27-Jan-1999 Matthew Dillon <dillon@FreeBSD.org>

Turn on -Wall and -Wcast-qual

# 65be2aac 17-Dec-1998 Doug Rabson <dfr@FreeBSD.org>

Move some compile flags from the kernel makefile to bsd.kern.mk so that
kernel modules are built with the right flags.

Suggested by: Andrew Gallatin <gallatin@cs.duke.edu>

# 072fd7d9 14-Dec-1998 Archie Cobbs <archie@FreeBSD.org>

Add -Wunused to kernel build flags.
Reviewed by: cvs-committers@freebsd.org

# 405b59bc 09-Sep-1998 Bruce Evans <bde@FreeBSD.org>

Turned on -Wformat -fformat-extensions. -fformat-extensions requires a
-current version of gcc. Without it, -Wformat would complain about all
the nonstandard %[Dbrz] formats in the kernel.

# 89f9e39f 01-May-1998 Bruce Evans <bde@FreeBSD.org>

Added -ansi to CWARNFLAGS so that ANSI errors don't come back.

# 7ffe3d1c 21-Oct-1997 Bruce Evans <bde@FreeBSD.org>

Oops, comment lines can't be indented either.

# 1bfc2826 21-Oct-1997 Bruce Evans <bde@FreeBSD.org>

Oops, comment lines can't be continued.

# 6e47de28 21-Oct-1997 Bruce Evans <bde@FreeBSD.org>

Added -Wuninitialized to CWARNFLAGS. Warnings about uninitialialized
variables were lost when we removed -W, and 23 new ones including at
least one serious one have crept in for LINT.

Restored -Winline to CFLAGS. This gives only 3 old warnings and 1 new
for LINT.

# b97fa2ef 22-Feb-1997 Peter Wemm <peter@FreeBSD.org>

Revert $FreeBSD$ to $Id$

# 1130b656 14-Jan-1997 Jordan K. Hubbard <jkh@FreeBSD.org>

Make the long-awaited change from $Id$ to $FreeBSD$

This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore. This update would have been
insane otherwise.

# a400403a 11-Nov-1996 Bruce Evans <bde@FreeBSD.org>

Turned off -W and -Winline so that the warnings that should be fixed for
2.2 are more obvious. -Winline is unimportant, but -W gives thousands
of warnings for comparisions. Turning off -W also loses warnings for:
- auto variables clobbered by longjmp. Not much of a problem in the kernel.
- functions returning without a value. I don't like losing this.
- an expression statement or the left side of a comma operand contains no
side effects. Turning this off also stops warnings for the low quality
debugging macros in gsc.c and lpt.c.

Should be in 2.2.

# 272937b0 09-Oct-1996 Bruce Evans <bde@FreeBSD.org>

Oops, this wasn't supposed to have -Wcast-qual yet.

Also disabled -Wunused. It caused too many warnings even for me.
The sign mismatch warnings should be fixed first. They are more
important and harder to disable (they are controlled by -W, which
controls too many things).

# 6b30bfd3 08-Oct-1996 Bruce Evans <bde@FreeBSD.org>

Oops, forgot to cvs add bsd.kern.mk.

Centralized the definition of CWARNFLAGS into bsd.kern.mk.

# 526f57bf 24-Jul-2022 Dimitry Andric <dim@FreeBSD.org>

Update CWARNFLAGS in bsd.sys.mk and CWARNEXTRA in kern.mk for clang 15.

MFC after: 3 days


# 32661319 21-Dec-2022 John Baldwin <jhb@FreeBSD.org>

Fix spelling of NO_WINFINITE_RECURSION.

Reported by: dim
Fixes: 2e08e4b75ea1 zfs: Fix build with GCC 12.


# 2e08e4b7 21-Dec-2022 John Baldwin <jhb@FreeBSD.org>

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


# 1aa6d44d 21-Dec-2022 John Baldwin <jhb@FreeBSD.org>

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


# 2637ed55 21-Dec-2022 John Baldwin <jhb@FreeBSD.org>

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


# 488c498b 21-Dec-2022 John Baldwin <jhb@FreeBSD.org>

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


# 5115511e 22-Nov-2022 John Baldwin <jhb@FreeBSD.org>

Use __freebsd_kprintf__ with GCC 12+ similar to clang.


# e83ffec3 26-Jul-2022 Dimitry Andric <dim@FreeBSD.org>

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


# 8b83d7e0 18-Apr-2022 John Baldwin <jhb@FreeBSD.org>

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


# 615d289f 18-Apr-2022 John Baldwin <jhb@FreeBSD.org>

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 e8e691983bb75e80153b802f47733f1531615fa2.

Reviewed by: imp, emaste
Differential Revision: https://reviews.freebsd.org/D34948


# e8e69198 05-Apr-2022 Robert Wing <rew@FreeBSD.org>

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


# 2814ba8e 14-Mar-2022 John Baldwin <jhb@FreeBSD.org>

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


# 369216b0 01-Mar-2022 Warner Losh <imp@FreeBSD.org>

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


# 2f6a8424 14-Feb-2022 John Baldwin <jhb@FreeBSD.org>

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


# 5f2aca83 08-Feb-2022 Dimitry Andric <dim@FreeBSD.org>

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


# c227269e 07-Feb-2022 John Baldwin <jhb@FreeBSD.org>

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


# c09981f1 30-Dec-2021 Warner Losh <imp@FreeBSD.org>

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


# e72c7e27 25-Sep-2021 John Baldwin <jhb@FreeBSD.org>

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


# 395d46ca 29-Aug-2021 Dimitry Andric <dim@FreeBSD.org>

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


# 1b8db4b4 04-Aug-2021 Mitchell Horne <mhorne@FreeBSD.org>

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


# c8c62548 22-Mar-2021 Alex Richardson <arichardson@FreeBSD.org>

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


# 15565e0a 10-Mar-2021 Greg V <greg@unrelenting.technology>

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


# 01fe4cac 08-Mar-2021 Alex Richardson <arichardson@FreeBSD.org>

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")


# 172a624f 04-Mar-2021 Alex Richardson <arichardson@FreeBSD.org>

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 17b8b8fb5fc4acc832dabfe7ef11e3e1d399ad0f to kern.mk.

Test Plan: no more warning printed with CROSS_TOOLCHAIN=mips-gcc6
Reviewed By: jhb
Differential Revision: https://reviews.freebsd.org/D29015


# 1e54857b 31-Dec-2020 Ed Maste <emaste@FreeBSD.org>

Stop defaulting to DWRAF2 in kernel compilation

After the removal of obsolete GDB 6.1.1 from the base system in
1c0ea326aa6d 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


# 629c4aea 28-Dec-2020 Ryan Libby <rlibby@FreeBSD.org>

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


# 26676c47 10-Nov-2020 Warner Losh <imp@FreeBSD.org>

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


# d8033dc3 10-Nov-2020 Brooks Davis <brooks@FreeBSD.org>

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


# e268fd0a 10-Nov-2020 Brooks Davis <brooks@FreeBSD.org>

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


# b75abea4 22-Sep-2020 Brandon Bergren <bdragon@FreeBSD.org>

[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


# 2d6bee8f 26-Aug-2020 Alex Richardson <arichardson@FreeBSD.org>

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).


# 2b6ee34c 25-Aug-2020 Alex Richardson <arichardson@FreeBSD.org>

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


# fac6dee9 12-May-2020 Eric van Gyzen <vangyzen@FreeBSD.org>

Remove tests for obsolete compilers in the build system

Assume gcc is at least 6.4, the oldest xtoolchain in the ports tree.
Assume clang is at least 6, which was in 11.2-RELEASE. Drop conditions
for older compilers.

Reviewed by: imp (earlier version), emaste, jhb
MFC after: 2 weeks
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D24802


# 02343a67 27-Apr-2020 John Baldwin <jhb@FreeBSD.org>

Retire the GENERICSF kernel config.

Now that hw.machine_arch handles soft-float vs hard-float there is no
longer a reason for this config.

Submitted by: mhorne (kern.mk hunk)
Reviewed by: imp (earlier version), kp
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D24544


# 6b72948d 27-Feb-2020 Warner Losh <imp@FreeBSD.org>

Better check for floating point type.

Use __riscv_flen instead of __riscv_float_abi_soft. While the latter works for
userland (and one could argue it's more correct), it fails for the kernel. We
compile the kernel with -mabi=lp64 (eg soft float abi) to avoid floating point
instructions in the kernel. We also compile the kernel -march=rv64imafdc for
hard float kernels (eg those with options FPE), but with -march=rv64imac for
softfloat kernels (eg those with FPE). Since we do this, in the kernel (as in
userland) __riscv_flen will be defined for 'riscv64' and not for 'riscv64sf'.

This also removes the -DMACHINE_ARCH hack now that it's no longer needed.

Longer term, we should return the ABI from the sysctl hw.machine_arch like on
amd64 for i386 binaries.

Suggested by: mhorne@
Differential Revision: https://reviews.freebsd.org/D23813


# 990a56e8 24-Feb-2020 Warner Losh <imp@FreeBSD.org>

Add a soft-float riscv kernel config

GENERICSF is just like GENERIC, only creates a soft-float kernel. Omit it from the
universe build for now.

Reviewed by: philip
Differential Revision: https://reviews.freebsd.org/D23812


# bc7d20c4 13-Feb-2020 Dimitry Andric <dim@FreeBSD.org>

Disable new clang 10.0.0 warnings about misleading indentation in ce(4)
and cp(4).

These are false positives, since some of the driver source has been
deliberately obfuscated.


# 58aa35d4 03-Feb-2020 Warner Losh <imp@FreeBSD.org>

Remove sparc64 kernel support

Remove all sparc64 specific files
Remove all sparc64 ifdefs
Removee indireeect sparc64 ifdefs


# f6d5b31f 01-Feb-2020 Dimitry Andric <dim@FreeBSD.org>

Revert r357349, since the clang 10.0.0 warning was actually correct, and
the ! operator should have been a ~ instead:

Merge r357348 from the clang 10.0.0 import branch:

Disable new clang 10.0.0 warnings about converting the result of
shift operations to a boolean in tpm(4):

sys/dev/tpm/tpm_crb.c:301:32: error: converting the result of '<<' to a boolean; did you mean '(1 << (0)) != 0'? [-Werror,-Wint-in-bool-context]
WR4(sc, TPM_CRB_CTRL_CANCEL, !TPM_CRB_CTRL_CANCEL_CMD);
^
sys/dev/tpm/tpm_crb.c:73:34: note: expanded from macro 'TPM_CRB_CTRL_CANCEL_CMD'
#define TPM_CRB_CTRL_CANCEL_CMD BIT(0)
^
sys/dev/tpm/tpm20.h:60:19: note: expanded from macro 'BIT'
#define BIT(x) (1 << (x))
^

Such warnings can be useful in C++ contexts, but not so much in kernel
drivers, where this type of bit twiddling is commonplace. So disable
it for this case.

Noticed by: cem
MFC after: 3 days


# 0a51af91 31-Jan-2020 Dimitry Andric <dim@FreeBSD.org>

Disable new clang 10.0.0 warnings about converting the result of shift
operations to a boolean in tpm(4):

sys/dev/tpm/tpm_crb.c:301:32: error: converting the result of '<<' to a boolean; did you mean '(1 << (0)) != 0'? [-Werror,-Wint-in-bool-context]
WR4(sc, TPM_CRB_CTRL_CANCEL, !TPM_CRB_CTRL_CANCEL_CMD);
^
sys/dev/tpm/tpm_crb.c:73:34: note: expanded from macro 'TPM_CRB_CTRL_CANCEL_CMD'
#define TPM_CRB_CTRL_CANCEL_CMD BIT(0)
^
sys/dev/tpm/tpm20.h:60:19: note: expanded from macro 'BIT'
#define BIT(x) (1 << (x))
^

Such warnings can be useful in C++ contexts, but not so much in kernel
drivers, where this type of bit twiddling is commonplace. So disable it
for this case.

MFC after: 3 days


# 77acc3cf 20-Dec-2019 Ryan Libby <rlibby@FreeBSD.org>

gcc9: quiet Waddress-of-packed-member for kernel build

This is lame, but it's what we already do for the clang build. We take
misaligned pointers into network header structures in many places.

Reviewed by: ian
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D22876


# 0869dceb 05-Dec-2019 John Baldwin <jhb@FreeBSD.org>

Add a new "riscv-relaxations" linker feature.

When the linker doesn't have this feature, add -mno-relax to CFLAGS
on RISC-V.

Define the feature for ld.bfd, but not lld. If lld gains relaxation
support in a newer version, we can enable it for those versions of lld
in bsd.linker.mk.

Reviewed by: mhorne
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D22659


# 88eb44d7 28-Nov-2019 Ryan Libby <rlibby@FreeBSD.org>

kern.mk: -Wno-error=stringop-overflow for gcc due to false positives

Demote gcc's Wstringop-overflow to Wno-error due to false positives.
E.g. the riscv64 build with gcc 8.3.0 has been failing with this warning
since r355062 [1]. A bug has been filed with gcc [2]. The warning was
first introduced in gcc 7.1 [3]. Hopefully we can avoiding suppressing
the warning in future gcc versions.

[1] https://ci.freebsd.org/job/FreeBSD-head-riscv64-build/16691/
[2] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92718
[3] https://gcc.gnu.org/wiki/WarningHistory

Reviewed by: markj
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D22603


# b16a3c9d 22-Sep-2019 Kyle Evans <kevans@FreeBSD.org>

Honor CWARNFLAGS.clang/gcc in the kernel build

Some kernel builds or users may want to disable warnings on a per-compiler
basis, so do this now.


# 45b535fa 08-Sep-2019 Mitchell Horne <mhorne@FreeBSD.org>

RISC-V: fix kernel CFLAGS with clang

Use the -march and -mabi flags for both gcc and clang as they are
compatible. Specify the "medium" code model separately as it goes by the
name "medany" under gcc, although they are equivalent.

Reviewed by: markj
Approved by: markj (mentor)
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D21436


# 6c30aa54 01-Sep-2019 Ed Maste <emaste@FreeBSD.org>

Remove CLANG_NO_IAS definition

CLANG_NO_IAS is not used anywhere in the tree.

Sponsored by: The FreeBSD Foundation


# be3ab187 07-Aug-2019 Conrad Meyer <cem@FreeBSD.org>

Disable useless -Wformat-zero-length

It is part of -Wformat, which is enabled by -Wall. Empty format strings are
well defined and it is perfectly reasonable to expect them in a formatting
interface.


# 82334850 28-Jun-2019 John Baldwin <jhb@FreeBSD.org>

Add an external mbuf buffer type that holds multiple unmapped pages.

Unmapped mbufs allow sendfile to carry multiple pages of data in a
single mbuf, without mapping those pages. It is a requirement for
Netflix's in-kernel TLS, and provides a 5-10% CPU savings on heavy web
serving workloads when used by sendfile, due to effectively
compressing socket buffers by an order of magnitude, and hence
reducing cache misses.

For this new external mbuf buffer type (EXT_PGS), the ext_buf pointer
now points to a struct mbuf_ext_pgs structure instead of a data
buffer. This structure contains an array of physical addresses (this
reduces cache misses compared to an earlier version that stored an
array of vm_page_t pointers). It also stores additional fields needed
for in-kernel TLS such as the TLS header and trailer data that are
currently unused. To more easily detect these mbufs, the M_NOMAP flag
is set in m_flags in addition to M_EXT.

Various functions like m_copydata() have been updated to safely access
packet contents (using uiomove_fromphys()), to make things like BPF
safe.

NIC drivers advertise support for unmapped mbufs on transmit via a new
IFCAP_NOMAP capability. This capability can be toggled via the new
'nomap' and '-nomap' ifconfig(8) commands. For NIC drivers that only
transmit packet contents via DMA and use bus_dma, adding the
capability to if_capabilities and if_capenable should be all that is
required.

If a NIC does not support unmapped mbufs, they are converted to a
chain of mapped mbufs (using sf_bufs to provide the mapping) in
ip_output or ip6_output. If an unmapped mbuf requires software
checksums, it is also converted to a chain of mapped mbufs before
computing the checksum.

Submitted by: gallatin (earlier version)
Reviewed by: gallatin, hselasky, rrs
Discussed with: ae, kp (firewalls)
Relnotes: yes
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D20616


# bd48a010 19-Apr-2019 Conrad Meyer <cem@FreeBSD.org>

kernel build: Disable unhelpful GCC warning (tripped after r346352)

-Wformat-zero-length does not highlight any particularly wrong code and it
is especially meaningless for device_printf(). Turn it off entirely to
remove a source of false positives.

Sponsored by: Dell EMC Isilon


# 5426539c 23-Feb-2019 Matt Macy <mmacy@FreeBSD.org>

gcov support

add gcov support and export results as files in debugfs

Reviewed by: hps@
MFC after: 1 week
Sponsored by: iX Systems
Differential Revision: https://reviews.freebsd.org/D19260


# 0e4a3d93 18-Dec-2018 Mark Johnston <markj@FreeBSD.org>

Remove a use of a negative array index from fxp(4).

This fixes a warning seen when compiling amd64 GENERIC with clang 7.
Also remove the workaround added in r337324. clang 7 and gcc 4.2
generate the same code with or without the code change.

Reviewed by: imp (previous version)
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D18603


# ea96b3de 01-Nov-2018 Ed Maste <emaste@FreeBSD.org>

Retire CLANG_NO_IAS34

CLANG_NO_IAS34 was introduced in r276696 to allow then-HEAD kernels to
be built with clang 3.4 in FreeBSD 10. As FreeBSD 11 and later includes
a version of Clang with a sufficiently capable integrated assembler we
do not need the workaround any longer.

Sponsored by: The FreeBSD Foundation


# 888c8381 03-Sep-2018 Ruslan Bukin <br@FreeBSD.org>

Enable 'C'-compressed ISA extension.

This was disabled recently due to lack of support in KDB disassembler
and DTrace FBT provider. Support for 'C'-extension to both of these was
added, so we can now enable 'C'-extension.

This reduces size of the kernel important for low-end embedded devices,
and saves cache footprint for high perfomance machines.

Approved by: re (kib)
Sponsored by: DARPA, AFRL


# fc63c661 04-Aug-2018 Dimitry Andric <dim@FreeBSD.org>

Put in a temporary workaround for strange array access in if_fxp.c.


# 8e8fbf19 25-Jul-2018 Ruslan Bukin <br@FreeBSD.org>

Disable 'C'-compressed ISA extension.

It works excellent, but KDB disassembler and DTrace FBT provider for
RISC-V do lack support for it. They currently handle 4-byte instructions
only, while C-compressed ISA extension introduces 2-byte instructions
freely mixing them together.

So disable it for now.

Reviewed by: markj@
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D16436


# ff945277 17-Jul-2018 Warner Losh <imp@FreeBSD.org>

Remove kernel support for armeb

Remove all the big-endian arm architectures (ixp425 and ixp435)
support in the kernel and associated drivers.

Differential Revision: https://reviews.freebsd.org/D16257


# 8cd6c09e 04-Jun-2018 Ruslan Bukin <br@FreeBSD.org>

Fix build: ignore a GCC 7.2.0 warning which says that third argument of
memset(3) should contain the number of elements multiplied by the element
size.

Sponsored by: DARPA, AFRL


# e5ae3af7 18-May-2018 Matt Macy <mmacy@FreeBSD.org>

disable set but not used on code that can't be changed


# cccc969b 18-May-2018 Matt Macy <mmacy@FreeBSD.org>

Silence non-actionable warnings in vendor code

We can't modify vendor code so there's no signal in warnings from it.
Similarly -Waddress-of-packed-member is not useful on networking code
as access to packed structures is fundamental to its operation.


# df66feb8 04-May-2018 Matt Macy <mmacy@FreeBSD.org>

% WITHOUT_FORMAT_EXTENSIONS= XCC=/usr/local/bin/gcc8 make -j96 buildkernel KERNCONF=GENERIC-NODEBUG -s >& log
% grep "inlining failed" log | wc
234 3570 36065
Consensus on those polled is that inlining failure warnings are not useful

Approved by: sbruno


# d39c2658 04-May-2018 Matt Macy <mmacy@FreeBSD.org>

fix gcc8 compile

Approved by: sbruno


# e31b69ec 12-Apr-2018 Ruslan Bukin <br@FreeBSD.org>

Add ld emulation types for hard-float mipses.

Sponsored by: DARPA, AFRL


# 0a646b97 11-Mar-2018 Conrad Meyer <cem@FreeBSD.org>

Implement NO_WCAST_QUAL for gcc4.2 architectures


# e9093b66 28-Feb-2018 Ed Maste <emaste@FreeBSD.org>

Add kernel retpoline option for amd64

Retpoline is a compiler-based mitigation for CVE-2017-5715, also known
as Spectre V2, that protects against speculative execution branch target
injection attacks.

In this commit it is disabled by default, but will be changed in a
followup commit.

Reviewed by: bdrewery (previous version)
MFC after: 3 days
Security: CVE-2017-5715
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D14242


# 5d851700 25-Nov-2017 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Automatically use the ELFv2 ABI on powerpc64 if supported by the compiler.
This has the same effects on DDB working as -mcall=aixdesc, but also is
supported by clang and marginally improves kernel performance.

MFC after: 2 weeks


# 1cbb5888 17-Nov-2017 Warner Losh <imp@FreeBSD.org>

Remove build system support for lint.

Differential Revision: https://reviews.freebsd.org/D13124


# d8371cb1 18-Oct-2017 John Baldwin <jhb@FreeBSD.org>

Remove CPU_HAVEFPU.

Instead, use a runtime decision to handle COP1 traps. If floating point
support is present in the current CPU, enable saving of the floating point
state. If support is not present, fail with SIGILL.

Reviewed by: imp, br
Sponsored by: DARPA / AFRL
Differential Revision: https://reviews.freebsd.org/D12707


# 0b972ac9 05-Oct-2017 Warner Losh <imp@FreeBSD.org>

Support armv7 builds for userland

Make armv7 as a new MACHINE_ARCH.

Copy all the places we do armv6 and add armv7 as basically an
alias. clang appears to generate code for armv7 by default. armv7 hard
float isn't supported by the the in-tree gcc, so it hasn't been
updated to have a new default.

Support armv7 as a new valid MACHINE_ARCH (and by extension
TARGET_ARCH).

Add armv7 to the universe build.

Differential Revision: https://reviews.freebsd.org/D12010


# 4e51f184 13-Sep-2017 Ryan Libby <rlibby@FreeBSD.org>

gcc builds: reenable -Wstrict-overflow for kern.mk

Reviewed by: emaste
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D12284


# af19cc59 10-Aug-2017 Ruslan Bukin <br@FreeBSD.org>

Support for v1.10 (latest) of RISC-V privilege specification.

New version is not compatible on supervisor mode with v1.9.1
(previous version).

Highlights:
o BBL (Berkeley Boot Loader) provides no initial page tables
anymore allowing us to choose VM, to build page tables manually
and enable MMU in S-mode.
o SBI interface changed.
o GENERIC kernel.
FDT is now chosen standard for RISC-V hardware description.
DTB is now provided by Spike (golden model simulator). This
allows us to introduce GENERIC kernel. However, description
for console and timer devices is not provided in DTB, so move
these devices temporary to nexus bus.
o Supervisor can't access userspace by default. Solution is to
set SUM (permit Supervisor User Memory access) bit in sstatus
register.
o Compressed extension is now turned on by default.
o External GCC 7.1 compiler used.
o _gp renamed to __global_pointer$
o Compiler -march= string is now in use allowing us to choose
required extensions (compressed, FPU, atomic, etc).

Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D11800


# fd46810a 05-Apr-2017 John Baldwin <jhb@FreeBSD.org>

Fix the linker emulation setting for riscv.

Reported by: lwhsu
MFC after: 1 week
Sponsored by: DARPA / AFRL


# dc653882 04-Apr-2017 John Baldwin <jhb@FreeBSD.org>

Always pass the linker emulation via -m when linking modules and kernels.

Previously the linker emulation was only passed when building binary
objects for firmware modules. This change always passes the desired
output format for kernel modules and kernels rather than requiring the
toolchain's default output format to match the desired output format.
This in turn permits use of external toolchains whose default output
format does not match the desired output format.

Reviewed by: imp, emaste
Sponsored by: DARPA / AFRL
Differential Revision: https://reviews.freebsd.org/D10085


# dd3c4329 04-Apr-2017 John Baldwin <jhb@FreeBSD.org>

Use correct linker emulation name for armeb.

MFC after: 1 week
Sponsored by: DARPA / AFRL
Differential Revision: https://reviews.freebsd.org/D10085


# d9dbd70b 30-Jan-2017 Justin Hibbits <jhibbits@FreeBSD.org>

Update CFLAGS for clang compatibility

* Clang/llvm does not (yet) support -m(no-)spe, so make it gcc-only
* Clang now supports -msoft-float, and does not appear to recognize
"-disable-ppc-float-in-variadic", which appears to have been a crutch until
soft-float was implemented. It's now implemented for both 32- and 64-bit.
* Clang/llvm use a 'medium' code model by default for powerpc64, supporting up
to 4GB TOC, and does not support the '-mminimal-toc' option. Given both of
these, make -mminimal-toc gcc-only.

MFC after: 2 weeks


# 8177b837 08-Jan-2017 Dimitry Andric <dim@FreeBSD.org>

For kernel builds, make the -Waddress-of-packed-member warning non-fatal.
The warning is informative, but often there is no real alignment problem.


# f369aff3 29-Dec-2016 Alexander Kabaev <kan@FreeBSD.org>

Support mips[*]hf variants in config files

Recognize new MACHINE_ARCH names now as we have added hardfloat support.
Switch JZ4780 to mipselhf and remove all uses of TARGET_ARCH in kernel
.mk files.

Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D8989


# 5bca2215 31-Oct-2016 Ruslan Bukin <br@FreeBSD.org>

Add full softfloat and hardfloat support for MIPS.

This adds new target architectures for hardfloat:
mipselhf mipshf mips64elhf mips64hf.

Tested in QEMU only.

Sponsored by: DARPA, AFRL
Sponsored by: HEIF5
Differential Revision: https://reviews.freebsd.org/D8376


# dc9b124d 21-Oct-2016 Justin Hibbits <jhibbits@FreeBSD.org>

Create a new MACHINE_ARCH for Freescale PowerPC e500v2

Summary:
The Freescale e500v2 PowerPC core does not use a standard FPU.
Instead, it uses a Signal Processing Engine (SPE)--a DSP-style vector processor
unit, which doubles as a FPU. The PowerPC SPE ABI is incompatible with the
stock powerpc ABI, so a new MACHINE_ARCH was created to deal with this.
Additionaly, the SPE opcodes overlap with Altivec, so these are mutually
exclusive. Taking advantage of this fact, a new file, powerpc/booke/spe.c, was
created with the same function set as in powerpc/powerpc/altivec.c, so it
becomes effectively a drop-in replacement. setjmp/longjmp were modified to save
the upper 32-bits of the now-64-bit GPRs (upper 32-bits are only accessible by
the SPE).

Note: This does _not_ support the SPE in the e500v1, as the e500v1 SPE does not
support double-precision floating point.

Also, without a new MACHINE_ARCH it would be impossible to provide binary
packages which utilize the SPE.

Additionally, no work has been done to support ports, work is needed for this.
This also means no newer gcc can yet be used. However, gcc's powerpc support
has been refactored which would make adding a powerpcspe-freebsd target very
easy.

Test Plan:
This was lightly tested on a RouterBoard RB800 and an AmigaOne A1222
(P1022-based) board, compiled against the new ABI. Base system utilities
(/bin/sh, /bin/ls, etc) still function appropriately, the system is able to boot
multiuser.

Reviewed By: bdrewery, imp
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D5683


# cbc6e751 09-Oct-2016 Andrew Turner <andrew@FreeBSD.org>

Set INLINE_LIMIT in the aarch64 case for gcc.

Submitted by: andreast
MFC after: 1 week


# 1dd50172 20-Sep-2016 Ed Maste <emaste@FreeBSD.org>

Always pass -m to ld for converting binary files to kernel ELF objects

This is in preparation for linking with LLVM's lld, which does not have
a compiled-in default output emulation. lld requires that it is
specified via the -m option, or obtained from the object file(s) being
linked.

This will also allow all build targets to share a common linker binary.

Reviewed by: imp
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D7837


# 1c7c2b26 04-Sep-2016 Dimitry Andric <dim@FreeBSD.org>

For kernel builds, instead of suppressing certain clang warnings, make
them non-fatal, so there is some incentive to fix them eventually.


# 9346408d 28-Jul-2016 Ruslan Bukin <br@FreeBSD.org>

Normalise the CWARNFLAGS inter-word spacing: remove all leading
and trailing space, and convert multiple consecutive spaces to
single space.

This helps to keep build output looking good.


# 96c072fc 28-Jul-2016 Ruslan Bukin <br@FreeBSD.org>

o Add warn flags required to build modules with GCC 6.1;
o Sort GCC 4.8 warn flags.

Sponsored by: DARPA, AFRL
Sponsored by: HEIF5


# 8500b15f 24-Jul-2016 Ruslan Bukin <br@FreeBSD.org>

Fix style.


# c4dc5cdb 22-Jul-2016 Ruslan Bukin <br@FreeBSD.org>

Add GCC 6.1 warn flags for kernel as well.

Sponsored by: DARPA, AFRL


# 88f05751 08-Jul-2016 Enji Cooper <ngie@FreeBSD.org>

Revert r302403

lang/gcc{48,49,5} lacks -fformat-extensions support (causing build errors, which
is what prompted r302403 to be committed). devel/amd64-gcc on the other hand
(which is used by Jenkins), has the support.

This fixes the Jenkins failure emails due to excessive warnings being produced
with "make buildkernel".

Discussed with: lwhsu
Reported by: Jenkins (FreeBSD_HEAD_amd64_gcc job)
Sponsored by: EMC / Isilon Storage Division


# d6b483b2 07-Jul-2016 Enji Cooper <ngie@FreeBSD.org>

Do not use -fformat-extensions with non-base versions of gcc

Ports versions of gcc do not have -fformat-extensions support.

This unbreaks compiling the kernel/modules with non-base gcc (4.8,
5.0, etc) if MK_FORMAT_EXTENSIONS=yes (the default).

Approved by: re (gjb)
Differential Revision: https://reviews.freebsd.org/D7150
Reviewed by: bdrewery
Sponsored by: EMC / Isilon Storage Division


# 12701462 13-Mar-2016 Bryan Drewery <bdrewery@FreeBSD.org>

We only support GCC 4.8 for these flags.

- 4.7 introduced maybe-uninitialized
- 4.8 introduced aggressive-loop-optimizations

Sponsored by: EMC / Isilon Storage Division


# 4e47b95c 26-Feb-2016 Bryan Drewery <bdrewery@FreeBSD.org>

Remove more references to targets we've never had.

Sponsored by: EMC / Isilon Storage Division


# 2a9aa1a6 18-Feb-2016 Ruslan Bukin <br@FreeBSD.org>

Use medany (Medium/Anywhere) GCC code model for RISC-V.
This will allow us to use bigger relocations and all
the 64-bit VA space.


# 28029b68 29-Jan-2016 Ruslan Bukin <br@FreeBSD.org>

Welcome the RISC-V 64-bit kernel.

This is the final step required allowing to compile and to run RISC-V
kernel and userland from HEAD.

RISC-V is a completely open ISA that is freely available to academia
and industry.

Thanks to all the people involved! Special thanks to Andrew Turner,
David Chisnall, Ed Maste, Konstantin Belousov, John Baldwin and
Arun Thomas for their help.
Thanks to Robert Watson for organizing this project.

This project sponsored by UK Higher Education Innovation Fund (HEIF5) and
DARPA CTSRD project at the University of Cambridge Computer Laboratory.

FreeBSD/RISC-V project home: https://wiki.freebsd.org/riscv

Reviewed by: andrew, emaste, kib
Relnotes: Yes
Sponsored by: DARPA, AFRL
Sponsored by: HEIF5
Differential Revision: https://reviews.freebsd.org/D4982


# 23df2d67 21-Dec-2015 Warner Losh <imp@FreeBSD.org>

Revert this change. It broke the trampoline build. Until I'm sure
nothing else is broken, I'm reverting.


# 01c61698 19-Dec-2015 Warner Losh <imp@FreeBSD.org>

Move some MIPS specific flags to be more congruent with other
architectures.


# 8598392c 08-Oct-2015 Konstantin Belousov <kib@FreeBSD.org>

Build changes that allow the modules on arm64.
- Move the required kernel compiler flags from Makefile.arm64 to kern.mk.
- Build arm64 modules as PIC; non-PIC relocations in .o for shared object
output cannot be handled.
- Do not try to install aarch64 symlink.
- A hack for arm64 to avoid ld -r stage. See the comment for the explanation.
Some functionality is lost, like ctf handling, but hopefully will be
restored after newer linker is available.

Reviewed by: andrew, emaste
Tested by: andrew (on real hardware)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D3796


# 45587483 17-Aug-2015 Dimitry Andric <dim@FreeBSD.org>

For kernel builds, make the -Wshift-negative-value non-fatal for now.


# 2e8457e7 28-Apr-2015 Warner Losh <imp@FreeBSD.org>

Only include CWARNFLAGS once to reduce command line size from ~1400
characters to "only" ~900 for kernel builds.


# e52a2dc8 27-Feb-2015 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Use appropriate alternative to -msoft-float for clang-built PowerPC kernels.


# cc4a90c4 17-Feb-2015 Gleb Smirnoff <glebius@FreeBSD.org>

Globally enable -fms-extensions when building kernel with gcc, and remove
this option from all modules that enable it theirselves.
In C mode -fms-extensions option enables anonymous structs and unions,
allowing us to use this C11 feature in kernel. Of course, clang supports
it without any extra options.

Reviewed by: dim


# 5d6adf25 04-Feb-2015 Peter Wemm <peter@FreeBSD.org>

Add -fwrapv to CFLAGS for the kernel. This essentially un-reverts r259045.

The C standard undefines behavior when signed integers overflow. The
compiler toolchain has become more adept at detecting this and taking
advantage of faster undefined behavior. At the current time this has the
unfortunate effect of the clock stopping after 24 days of uptime.

clang makes no distinction between -fwrapv and -fno-strict-overflow. gcc
does treat them differently but -fwrapv is mature in gcc and is the
behavior are actually expecting.

Obtained from: kib


# c234c2de 30-Jan-2015 Dimitry Andric <dim@FreeBSD.org>

For clang, disable -Wcast-qual warnings for specific aesni files, since
clang 3.6.0 will emit a number of such warnings for those files, and
they are partially contributed code.


# accc510a 28-Jan-2015 Dimitry Andric <dim@FreeBSD.org>

Since clang 3.6.0 now implements the archetype 'freebsd_kprintf' for
__attribute__((format(...))), and the -fformat-extensions flag was
removed, introduce a new macro in bsd.sys.mk to choose the right variant
of compile flag for the used compiler, and use it.

Also add something similar to kern.mk, since including bsd.sys.mk from
that file will anger Warner. :-)

Note that bsd.sys.mk does not support the MK_FORMAT_EXTENSIONS knob used
in kern.mk, since that knob is only available in kern.opts.mk, not in
src.opts.mk. We might want to add it later, to more easily support
external compilers for building world (in particular, sys/boot).


# 74079bda 10-Jan-2015 Warner Losh <imp@FreeBSD.org>

Take out some more no-error warnings, as the build is clean without
them.


# 814e92e9 06-Jan-2015 Warner Losh <imp@FreeBSD.org>

Fix typo from too many cut-n-paste operations. Use IMPSRC:T to just
get the tail part of the path. We can now build kernels the
old-fashioned way on FreeBSD 9.x and 10.x on at least amd64 using
clang 3.3, 3.4 or gcc 4.2.1 (though with the latter you need
WITHOUT_MODULES="aesni vmm cxgbe" due to various issues with
gcc 4.2.1).


# 9aca3e0f 04-Jan-2015 Warner Losh <imp@FreeBSD.org>

Clang's 3.5 integrated assembler now handles these files correctly (it
has support for the .codeXX directives). However, it is desirable, for
a time, to allow kernels to be built with clang 3.4. Historically, it
has been advantageous to allow stable X-1 to build kernels the old
way (so long as the impact of doing so is small), and this restores
that ability.

Also, centralize the addition of ${ASM_CFLAGS.${.IMPSRC}}, place it in
kern.mk rather than kern.pre.mk so that all modules can benefit, and
give the same treatment to CFLAGS in kern.mk as well.


# bbae23a7 04-Jan-2015 Ian Lepore <ian@FreeBSD.org>

Eliminate uninitialized variable warnings in kernel and module builds when
building with gcc 4.2

This has been requested several times over the past few months by several
people (including me), because gcc 4.2 just gets it wrong too often. It's
causing us to litter the code with lots of bogus initializers just to
squelch the warnings. We still have clang and coverity telling us about
uninitialized variables, and they do so more accurately.


# f75ecd9b 03-Jan-2015 Warner Losh <imp@FreeBSD.org>

Always use -Wno-unknown-pragmas, not just for clang.


# 4906cdc8 02-Jan-2015 Warner Losh <imp@FreeBSD.org>

Re-support CWARNFLAGS, lost when bsd.sys.mk was removed. Also, support
CWARNFALGS.$file centrally so we don't have to have it in all the
places. Remove a few warning flags that are no longer needed.
Also, always use -Wno-unknown-pragma to (hopefully temporarily) work
around #pragma ident in debug.h in the opensolaris code. Remove some
stale warning suppression that's no longer necessary.


# faa5d16d 01-Jan-2015 Warner Losh <imp@FreeBSD.org>

Move more of the warnings into kern.mk, as well as centralize that as
the place where the C dialect is selected. Have a fairly long list
of newly requires warning suppression for clang 3.5.0, also
centralized in kern.mk. Survive the fallout of the removal of
bsd.sys.mk from bsd.kmod.mk.


# 7ed11c5e 31-Dec-2014 Warner Losh <imp@FreeBSD.org>

Fix module builds on arm (and maybe others) by turning off a whole
raft of new warnings that appear to be on by default in clang 3.5.0.
Fix RPI-B build issues with new clang not liking the ability to pass
arbitrary flags to as, since some flags are more arbitrary (and thus
verboten) than others.

These warnings should be actually fixed in the code, but this is a
band-aide to get things (almost) building again.


# 575bd6d8 29-Nov-2014 Baptiste Daroussin <bapt@FreeBSD.org>

Ignore more warnings with external gcc


# 6627df30 09-Oct-2014 Warner Losh <imp@FreeBSD.org>

For gcc 4.6 and newer, _Static_assert is a keyword, so don't try to
redefine it. It does what we want, and is always available unlike
other alternatives.


# f5bb5524 09-Oct-2014 Warner Losh <imp@FreeBSD.org>

When building with a newer GCC, suppress some warnings for the
moment. The kernel isn't ready for them without a lot of work.


# 20256b0b 14-Aug-2014 Warner Losh <imp@FreeBSD.org>

Disable all inline warnings on gcc >= 4.3. Not sure exactly where the
cutover is, but we need better tools to cope with inline tuning per
compiler version than we have. This is a quick bandaid until such
tools are around.


# e94a64de 14-Aug-2014 Warner Losh <imp@FreeBSD.org>

Streamline format extensions. Either the compiler supports them, and
we enable them and format wordings. Or it doesn't, and we disable
format warnings because the kernel uses the extensions pervasively.


# cfe17cfc 16-Jul-2014 Dimitry Andric <dim@FreeBSD.org>

After r261991, clang warnings about unused functions in the kernel were
completely silenced. Make sure these warnings appear again, so there is
some incentive to fix them, but do not error out the whole kernel build
for them.

Noticed by: steven@pyro.eu.org
PR: 191867
MFC after: 3 days


# e7d939bd 06-Jul-2014 Marcel Moolenaar <marcel@FreeBSD.org>

Remove ia64.

This includes:
o All directories named *ia64*
o All files named *ia64*
o All ia64-specific code guarded by __ia64__
o All ia64-specific makefile logic
o Mention of ia64 in comments and documentation

This excludes:
o Everything under contrib/
o Everything under crypto/
o sys/xen/interface
o sys/sys/elf_common.h

Discussed at: BSDcan


# 724afafa 10-May-2014 Warner Losh <imp@FreeBSD.org>

bitrotted compat cruft removal:
o KMODDEPS warning is 15 years stale. Remove it.
o MK_CTF will always be defined now, so no need to test to see if it
is defined.
o no need to define MK_FORMAT_EXTENTIONS if undefined anymore.


# 22ba0b2f 10-May-2014 Warner Losh <imp@FreeBSD.org>

Simplify clang ifdefs in the kernel a bit. Introduce
CFLAGS.${COMPILER_TYPE} to mirror userland. Be explicit about which
compiler needs something (not clang isn't necessarily gcc in the
future).


# 647a9d04 01-Apr-2014 Warner Losh <imp@FreeBSD.org>

Remove check for clang and expand the comment. Newer versions of gcc
generate dwarf4 by default as well, so always force dwarf2 when
generating debugging data. It is harmless on older versions of both
clang and gcc, but required on newer ones.


# 993c4ac1 25-Mar-2014 Warner Losh <imp@FreeBSD.org>

Add a '*' to the M modifier string so we match any -gdwarf string (even
though it works w/o it for some reason, contrary to our reading of
make(1)). Also add a comment explaining things a bit better so there's
one less mystery that must be answered with svn blame.

Submitted by: ian@


# 3ad1a091 25-Mar-2014 Warner Losh <imp@FreeBSD.org>

Rather than require a makeoptions DEBUG to get debug correct,
add it in kern.mk, but only if we're using clang. While this
option is supported by both clang and gcc, in the future there
may be changes to clang which change the defaults that require
a tweak to build our kernel such that other tools in our tree
will work. Set a good example by forcing -gdwarf-2 only for
clang builds, and only if the user hasn't specified another
dwarf level already. Update UPDATING to reflect the changed
state of affairs. This also keeps us from having to update
all the ARM kernels to add this, and also keeps us from
in the future having to update all the MIPS kernels and is
one less place the user will have to know to do something
special for clang and one less thing developers will need
to do when moving an architecture to clang.

Reviewed by: ian@
MFC after: 1 week


# 90ce288a 23-Feb-2014 Dimitry Andric <dim@FreeBSD.org>

Similar to r262306 for boot1's Makefile, clang spells -mcmodel=medany as
-mcmodel=large, for now. While here, disable -msoft-float for clang
since it is not supported, and add -fno-dwarf2-cfi-asm to stop it from
emitting .cfi directives, which GNU as does not support.


# 37583470 03-Feb-2014 Warner Losh <imp@FreeBSD.org>

Add a prior version compat define.


# 337a0242 15-Dec-2013 Konstantin Belousov <kib@FreeBSD.org>

Revert r259045.

It seems that clang miscompiles code related to UDP with -fno-strict-overflow.


# 1efe86bb 06-Dec-2013 Konstantin Belousov <kib@FreeBSD.org>

Disallow optimizations which potentially remove boundary checks
for signed values due to a compiler authors considering integer
overflow as impossible.

The change follows suit of other projects taking the same measure.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week


# 54fc0eca 20-May-2013 Brooks Davis <brooks@FreeBSD.org>

Spell extensions correctly.

Submitted by: dim


# a5b2b29f 15-May-2013 Brooks Davis <brooks@FreeBSD.org>

Add a new option WITHOUT_FORMAT_EXTENSIONS to disable flags related to
checking our kernel printf extensions. This is useful to allow
compilers without these extensions to build kernels.

Sponsored by: DARPA, AFRL


# 9215d178 13-Sep-2012 Brooks Davis <brooks@FreeBSD.org>

Introduce a new make variable COMPILER_TYPE that specifies what
type of compiler is being used (currently clang or gcc). COMPILER_TYPE
is set in the new bsd.compiler.mk file based on the value of the CC
variable or, should it prove informative, by running ${CC} --version
and examining the output.

To avoid negative performance impacts in the default case and correct
value for COMPILER_TYPE type is determined and passed in the environment
of submake instances while building world.

Replace adhoc attempts at determining the compiler type by examining
CC or MK_CLANG_IS_CC with checks of COMPILER_TYPE. This eliminates
bootstrapping complications when first setting WITH_CLANG_IS_CC.

Sponsored by: DARPA, AFRL
Reviewed by: Yamaya Takashi <yamayan@kbh.biglobe.ne.jp>, imp, linimon
(with some modifications post review)
MFC after: 2 weeks


# 3b5683fc 23-Mar-2012 Dimitry Andric <dim@FreeBSD.org>

Work around the following clang warning in mps(4):

sys/dev/mps/mps_sas.c:861:1: error: function 'mpssas_discovery_timeout' is not needed and will not be emitted [-Werror,-Wunneeded-internal-declaration]
mpssas_discovery_timeout(void *data)
^

Because the driver is obtained from upstream, we don't want to modify
it; just silence the warning instead, it is harmless.

MFC after: 3 days


# 43917540 13-Mar-2012 Dimitry Andric <dim@FreeBSD.org>

Update comments and CFLAGS in sys/conf/kern.mk, introduced in r221879,
to match reality: clang does _not_ disable SSE automatically when
-mno-mmx is used, you have to specify -mno-sse explicitly.

Note this was the case even before r232894, which only makes a change in
the 'positive' flag case; e.g. when you specify -msse, MMX gets enabled
too.

MFC after: 1 week


# 295b83d1 11-Mar-2012 Juli Mallett <jmallett@FreeBSD.org>

Reenable -Winline on MIPS now that we're not compiling Cavium's error
decoding stuff, which is impossibly-huge.


# 47c022f2 10-Mar-2012 Juli Mallett <jmallett@FreeBSD.org>

Disable -Winline on MIPS in preparation for the import of the latest version
of the Cavium Simple Executive, which violates large function growth rules
in such a way that simply increasing the large function growth parameter is
insufficient.


# 2651e350 03-Mar-2012 Dimitry Andric <dim@FreeBSD.org>

Revert r232473. I have been convinced by Doug Barton and Bjoern Zeeb
that it is better to error out when people attempt to build using the
wrong bsd.*.mk files, than to silently ignore the problem.

This means, that after this commit, if you want to build kernel modules
by hand (or via a port) from a head source tree, you *must* make sure
the files in /usr/share/mk are in sync with that tree. If that isn't
possible, for example when you are running on an older FreeBSD branch,
you can:

- Run "make buildenv" from your head source tree, to have the correct
environment setup. (It's advisable to have run "make buildworld", or
at a minimum "make toolchain" first.)
- Alternatively, set MAKESYSPATH to the share/mk directory under your
head source tree. If your build tools are too old, other problems may
still occur.
- Alternatively, use "make -m" and specify the share/mk directory under
your head source tree. Again, build tools that are too old may still
result in trouble.

MFC after: 2 weeks


# 2677e7fe 03-Mar-2012 Dimitry Andric <dim@FreeBSD.org>

After r232322, it turned out many people (and some ports) are building
kernel modules using their old installed /usr/share/mk/bsd.*.mk files,
instead of the updated ones in their source tree. This leads to errors
like:

"sys/conf/kmod.mk", line 111: Malformed conditional (${MK_CLANG_IS_CC} == "no" && ${CC:T:Mclang} != "clang")

Obviously, these errors will go away after a "make installworld", or
alternatively, by using "make buildenv" before attempting to manually
build modules.

However, since it is apparently an expected use case to build using old
.mk files, change the way we test for clang, so it also works when the
MK_CLANG_IS_CC macro doesn't exist.

Note the conditional expressions are becoming rather unreadable now, but
I will attempt to fix that on a followup commit.

MFC after: 2 weeks


# dfbaea83 29-Feb-2012 Dimitry Andric <dim@FreeBSD.org>

Add a WITH_CLANG_IS_CC option for src.conf(5), disabled by default, that
installs clang as /usr/bin/cc, /usr/bin/c++ and /usr/bin/cpp.

Note this does *not* disable building and installing gcc, which will
still be available as /usr/bin/gcc, /usr/bin/g++ and /usr/bin/gcpp. If
you want to disable gcc completely, you must use WITHOUT_GCC.

MFC after: 2 weeks


# 102a3198 23-Feb-2012 Dimitry Andric <dim@FreeBSD.org>

Revert r231978, so I can apply a more proper fix to silence unneeded
internal declaration warnings in several sys/cam/ctl files.

MFC after: 1 week


# a0dd79db 21-Feb-2012 Dimitry Andric <dim@FreeBSD.org>

When building with clang, disable -Wformat-security for
sys/dev/hpt27xx/osm_bsd.c, since it gets the following warnings:

sys/dev/hpt27xx/osm_bsd.c:1180:25: error: format string is not a string literal (potentially insecure) [-Werror,-Wformat-security]
S_IRUSR | S_IWUSR, driver_name);
^~~~~~~~~~~
@/dev/hpt27xx/hpt27xx_config.h:46:21: note: expanded from:
#define driver_name hpt27xx_driver_name
^~~~~~~~~~~~~~~~~~~

Since 'hpt27xx_driver_name' is a constant string symbol (coming from the
proprietary hpt27xx_lib.o file), there is no security problem.

Because this driver is provided by the vendor, and applying changes
requires re-certification and other bureaucratic exercises, just disable
the warning for now.

MFC after: 1 week


# 8508b798 21-Feb-2012 Dimitry Andric <dim@FreeBSD.org>

When building with clang, disable -Wunneeded-internal-declaration for
several sys/cam/ctl files, since these get the following warnings:

In file included from sys/cam/ctl/ctl_backend.c:60:
sys/cam/ctl/ctl_private.h:300:30: error: variable 'page_index_template' is not needed and will not be emitted [-Werror,-Wunneeded-internal-declaration]
static struct ctl_page_index page_index_template[] = {
^

These warnings are tricky to fix without a lot of overhaul, and they are
harmless, so disable them for now.

MFC after: 1 week


# 97a15669 30-Dec-2011 Dimitry Andric <dim@FreeBSD.org>

Disable several instances instances of clang's -Wself-assign warning.
All of these are harmless, and are in fact used to shut up warnings from
lint.

While here, remove -Wno-missing-prototypes from the xfs module
Makefile, as I could not reproduce those warnings either with gcc or
clang.

MFC after: 1 week


# 874fb554 29-Dec-2011 Dimitry Andric <dim@FreeBSD.org>

For several files in sys/dev/drm, disable -Wunused-value when building
with clang. There are several macros in these files that return values,
and in some cases nothing is done with them, but it is completely
harmless. For some other files, also disable -Wconstant-conversion,
since that triggers a false positive with the DMA_BIT_MASK() macro.

MFC after: 1 week


# 8cd925d9 24-Dec-2011 Dimitry Andric <dim@FreeBSD.org>

Make another clang warning, -Wparentheses-equality, non-fatal during
kernel builds. All the instances of this warning in our tree are
completely harmless, and many people seem to like adding extra
parentheses to make precedence clearer.

MFC after: 1 week


# 7afac0fd 24-Dec-2011 Dimitry Andric <dim@FreeBSD.org>

Make another clang warning, -Wempty-body, non-fatal during kernel
builds. All the instances of this warning in our tree are completely
harmless. (Most of the empty bodies look to be used simply as reminder
for the developer to add something later.)

While here, assign to CWARNEXTRA with ?=, so it can be overridden
easily, if needed.

MFC after: 1 week


# 1496f657 23-Dec-2011 Marius Strobl <marius@FreeBSD.org>

Update a comment to reflect reality and explain why we're using the
medany code model.


# 2cd8464e 23-Dec-2011 Dimitry Andric <dim@FreeBSD.org>

Amend r228822 by not directly adding to CWARNFLAGS, but to an optional
CWARNEXTRA variable, which gets included into the initial CWARNFLAGS
setting. This makes it easier to override CWARNFLAGS with completely
custom settings (including enabling any disabled warnings).

Reminded by: arundel
MFC after: 1 week


# 0ed78d64 22-Dec-2011 Dimitry Andric <dim@FreeBSD.org>

When building the kernel with clang, it produces several warnings which
might be useful in some cases, but which are not severe enough to error
out the whole kernel build. Display them anyway, so there is at least
some incentive to fix them eventually.

Start with -Wtautological-compare warnings. These usually occur when
people check if unsigned quantities are negative, or similar cases. To
clean these up would be painful, and might give problems if the base
type which is compared against changes to signed later on.

MFC after: 1 week


# 6f7651b9 21-Dec-2011 Dimitry Andric <dim@FreeBSD.org>

When building with clang, disable -Wshift-count-negative and
-Wshift-count-overflow for sys/dev/ath/ath_hal/ah_regdomain.c, as it
gets multiple instances of the following warnings:

In file included from sys/dev/ath/ath_hal/ah_regdomain.c:99:
sys/dev/ath/ath_hal/ah_regdomain/ah_rd_domains.h:69:15: warning: shift count is negative [-Wshift-count-negative]
.chan11a = BM4(F1_4950_4980,
^~~~~~~~~~~~~~~~~
sys/dev/ath/ath_hal/ah_regdomain/ah_rd_domains.h:41:4: note: expanded from:
W1(_fa) | W1(_fb) | W1(_fc) | W1(_fd) }
^
sys/dev/ath/ath_hal/ah_regdomain/ah_rd_domains.h:34:45: note: expanded from:
(((_a) > 63 && (_a) < 128 ? (((uint64_t) 1)<<((_a)-64)) : (uint64_t) 0))
^ ~~~~~~~~~

and:

In file included from sys/dev/ath/ath_hal/ah_regdomain.c:99:
sys/dev/ath/ath_hal/ah_regdomain/ah_rd_domains.h:629:15: error: shift count >= width of type [-Werror,-Wshift-count-overflow]
.chan11a = BM4(W2_5260_5320,
^~~~~~~~~~~~~~~~~
sys/dev/ath/ath_hal/ah_regdomain/ah_rd_domains.h:40:34: note: expanded from:
{ W0(_fa) | W0(_fb) | W0(_fc) | W0(_fd), \
^
sys/dev/ath/ath_hal/ah_regdomain/ah_rd_domains.h:32:44: note: expanded from:
(((_a) >= 0 && (_a) < 64 ? (((uint64_t) 1)<<(_a)) : (uint64_t) 0))
^ ~~~~

Both warnings are false positives, caused by LLVM PR 10030. For global
initializations, clang fails to detect that the branch of the ternary
operator causing the warning is dead.

MFC after: 1 week


# fea85869 21-Dec-2011 Dimitry Andric <dim@FreeBSD.org>

When building with clang, disable -Warray-bounds for sys/dev/asr/asr.c,
as it gets the following warning:

sys/dev/asr/asr.c:1836:29: warning: array index of '58' indexes past the end of an array (that contains 1 element) [-Warray-bounds]
while ((len > 0) && (sg < &((PPRIVATE_SCSI_SCB_EXECUTE_MESSAGE)
^
sys/dev/asr/i2omsg.h:934:8: note: array 'Simple' declared here
I2O_SGE_SIMPLE_ELEMENT Simple[1];
^

This is a false positive, since I2O_SG_ELEMENT::Simple is not declared
as a C99 flexible array member, but in the old (but more portable) way.
At run-time, the proper number of array elements will hopefully have
been allocated.

MFC after: 1 week


# a380d07b 21-Dec-2011 Dimitry Andric <dim@FreeBSD.org>

Start selectively disabling a few kernel build warnings for clang, since
there are some places in the kernel where fixing them is too disruptive,
or where there is a false positive.

In this case, disable -Wconstant-conversion for two aic7xxx-related
files, as they get the following warning on i386 (and possibly on other
32-bit arches):

sys/dev/aic7xxx/ahc_pci.c:112:10: warning: implicit conversion from 'long long' to 'bus_addr_t' (aka 'unsigned int') changes value from 549755813887 to 4294967295 [-Wconstant-conversion]
? 0x7FFFFFFFFFLL
~~^~~~~~~~~~~~~~

This is a false positive, since the code only passes the 0x7FFFFFFFFFLL
argument, if sizeof(bus_addr_t) is larger than 4 (e.g. on 64 bit arches,
or when PAE is enabled on i386). The code could be refactored to do
compile-time checks, but that is more disruptive.

MFC after: 1 week


# 78e7e3ec 29-Nov-2011 Max Khon <fjoe@FreeBSD.org>

- fix WITH_CTF when specified in /etc/src.conf [1]
- CTFCONVERT_CMD=... is a hack (should be defined to empty string instead):
make(1) should be taught to ignore empty commands silently in compat mode
(as it does in !compat mode, GNU make also silently ignores empty commands)
and to skip printing empty commands in !compat mode
- config(8) should generate ${NORMAL_CTFCONVERT} invocation without '@':
this will allow to simplify kern.pre.mk even more and lessen the number
of shell invocations during kernel build when CTF is turned off
- WITH_CTF can now be converted to usual MK_CTF=yes/no infrastructure

Pointy hat to: fjoe [1]


# b8843fe7 29-Nov-2011 Max Khon <fjoe@FreeBSD.org>

Fix typo in comments (conversation -> conversion).


# cbb7255e 26-Oct-2011 Robert Millan <rmh@FreeBSD.org>

Revert r226665 untill the issues with this change have been resolved.

Approved by: kib (mentor)


# 30ce7fee 24-Oct-2011 Dimitry Andric <dim@FreeBSD.org>

Put in a temporary band-aid to fix kernel builds when CC=clang, after
r226665.


# f9629bc4 23-Oct-2011 Robert Millan <rmh@FreeBSD.org>

Conditionalize a pair of FreeBSD GCC extensions so that its CFLAGS are only
used with FreeBSD GCC.

Approved by: kib (mentor)


# 12dd58a3 24-May-2011 Rebecca Cran <brucec@FreeBSD.org>

Remove an outdated comment as requested by Bruce Evans in a private email to
Alexander Best (arundel@).

For clang, -fdiagnostics-show-option is enabled by default, but for gcc it
isn't. This option will report which -W* flag was responsible for triggering
a certain warning. This will bring gcc warnings closer to the ones clang emits
and might also help developers track down tinderbox failures a bit quicker.

Submitted by: arundel


# d1b9bdd1 14-May-2011 Rebecca Cran <brucec@FreeBSD.org>

gcc and clang semantics imply certain -mno-* flags when other certain -mno-*
flags are also specified. This change makes use of this behaviour and removes
unneeded -mno-* flags.

Note that clang does not yet enable AVX support for any CPU. However at some
point in the future it will and since we definitely want to disable it for the
kernel, we might as well add the -mno-avx flag now.

Submitted by: arundel


# 5b44317b 02-May-2011 Rebecca Cran <brucec@FreeBSD.org>

Add -Wmissing-include-dirs to CWARNFLAGS, so tinderbox will punish those
developers committing new code with broken include directories.
Fix a few whitespace issues.
Improve a couple of comments.
-W is now deprecated and is referred to as -Wextra (see gcc(1)).

Submitted by: arundel


# 58ff0f42 19-Apr-2011 Dimitry Andric <dim@FreeBSD.org>

Remove support for the Intel C Compiler from the build infrastructure.
This support has not worked for several years, and is not likely to work
again, unless Intel decides to release a native FreeBSD version of their
compiler. ;)


# 79c77d72 18-Feb-2011 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Turn off default generation of userland dot symbols on powerpc64 now that
we have a binutils that supports it. Kernel dot symbols remain on to assist
DDB.


# 3ab20ac1 05-Jan-2011 Dimitry Andric <dim@FreeBSD.org>

On i386 and amd64, consistently use the following options whenever we
want to avoid using any "advanced" CPU features:

-mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 -msoft-float


# 9a17b89c 05-Jan-2011 Dimitry Andric <dim@FreeBSD.org>

Sort -mno-(mmx|3dnow|sse|sse2|sse3) options consistently throughout the
tree.

Submitted by: arundel


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# c614f4e2 13-Sep-2010 Warner Losh <imp@FreeBSD.org>

Prefer MACHINE_CPUARCH over MACHINE_ARCH


# 187278ca 17-Aug-2010 Rui Paulo <rpaulo@FreeBSD.org>

For every instance of '.if ${CC} == "foo"' or '.if ${CC} != "foo"' in
Makefiles or *.mk files, use ${CC:T:Mfoo} instead, so only the basename
of the compiler command (excluding any arguments) is considered.

This allows you to use, for example, CC="/nondefault/path/clang -xxx",
and still have the various tests in bsd.*.mk identify your compiler as
clang correctly.

ICC if cases were also changed.

Submitted by: Dimitry Andric <dimitry at andric.com>


# 3cc97e66 22-Jul-2010 Rui Paulo <rpaulo@FreeBSD.org>

Handle a few corner cases for clang like we did with icc. These should
reduce the number of warnings seen while building the kernel.

Submitted by: Dimitry Andric <dimitry at andric.com>


# 915b4b09 13-Jul-2010 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Convert several instances of MACHINE_ARCH to MACHINE_CPUARCH and use the
correct compiler flags on 64-bit PowerPC.


# 21edb039 02-Apr-2010 Alexander Leidinger <netchild@FreeBSD.org>

WITH_CTF can now be specified in src.conf (not recommended, there
are some problems with static executables), make.conf (would also
affect ports which do not use GNU make and do not override the
compile targets) or in the kernel config (via "makeoptions
WITH_CTF=yes").

Additional (related) changes:
- propagate WITH_CTF to module builds
- do not add -g to the linker flags, it's a noop there anyway
(at least according to the man page of ld)
- do not add -g to CFLAGS unconditionally
we need to have a look if it is really needed (IMO not) or if there
is a way to add it only when WITH_CTF is used

Note: ctfconvert / ctfmerge lines will not appear in the build output,
to protect the innocent (those which do not build with WITH_CTF would
see the shell-test and may think WITH_CTF is used).

Reviewed by: imp, jhb, scottl (earlier version)
Discussed on: arch@


# 5beb779d 19-Jan-2010 Ruslan Ermilov <ru@FreeBSD.org>

Removed NO_UNDEF.

Nudged by: trasz


# e73a17cf 18-Jan-2010 Edward Tomasz Napierala <trasz@FreeBSD.org>

Undo r169961, removing WITH_GCC3, added as a temporary workaround three
years ago.


# 9fc13460 09-Jan-2010 Warner Losh <imp@FreeBSD.org>

Merge r201902 and r195669 from projects/mips into head by hand:

r201902 | imp | 2010-01-09 10:16:19 -0700 (Sat, 09 Jan 2010) | 2 lines
Fix comment, which was missed in an earlier commit...

r195669 | gonzo | 2009-07-13 17:03:44 -0600 (Mon, 13 Jul 2009) | 3 lines
- Remove -mno-dsp from CFLAGS. MIPS DSP ASE is off by default
now (as it should be)


# 02dd9342 09-Jan-2010 Warner Losh <imp@FreeBSD.org>

Fix comment, which was missed in an earlier commit...


# 23a9b716 13-Jul-2009 Oleksandr Tymoshenko <gonzo@FreeBSD.org>

- Remove -mno-dsp from CFLAGS. MIPS DSP ASE is off by default
now (as it should be)


# e0a04e74 03-Mar-2009 Warner Losh <imp@FreeBSD.org>

Bump down the inline limit on MIPS.


# 5b4975b1 22-Feb-2009 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Explicitly disable generation of Altivec instructions in the kernel on PowerPC,
and add support to allow users to set their CPUTYPE in make.conf.


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# a30c29f9 23-Jul-2008 Warner Losh <imp@FreeBSD.org>

Disable SSP for mips until support is added to the base architecture.


# 7cff8cea 22-Jul-2008 Olivier Houchard <cognet@FreeBSD.org>

Disable SSP for the kernel on arm as well (see rev 180605).
I overlooked this because a SSP kernel booted for me.

Apologises to: ticso


# 042df2e2 25-Jun-2008 Ruslan Ermilov <ru@FreeBSD.org>

Enable GCC stack protection (aka Propolice) for userland:
- It is opt-out for now so as to give it maximum testing, but it may be
turned opt-in for stable branches depending on the consensus. You
can turn it off with WITHOUT_SSP.
- WITHOUT_SSP was previously used to disable the build of GNU libssp.
It is harmless to steal the knob as SSP symbols have been provided
by libc for a long time, GNU libssp should not have been much used.
- SSP is disabled in a few corners such as system bootstrap programs
(sys/boot), process bootstrap code (rtld, csu) and SSP symbols themselves.
- It should be safe to use -fstack-protector-all to build world, however
libc will be automatically downgraded to -fstack-protector because it
breaks rtld otherwise.
- This option is unavailable on ia64.

Enable GCC stack protection (aka Propolice) for kernel:
- It is opt-out for now so as to give it maximum testing.
- Do not compile your kernel with -fstack-protector-all, it won't work.

Submitted by: Jeremie Le Hen <jeremie@le-hen.org>


# 64982acf 10-May-2008 Andrey A. Chernov <ache@FreeBSD.org>

Add -mno-sse3 for amd64 case too

PR: 123518
Submitted by: Marc Olzheim <marcolz@stack.nl>


# 578328c9 29-Apr-2008 Oleksandr Tymoshenko <gonzo@FreeBSD.org>

Define INLINE_LIMIT and additional CFLAGS for mips.

Approved by: cognet (mentor)


# 9eef6e33 24-May-2007 David E. O'Brien <obrien@FreeBSD.org>

Temporarily add 'WITH_GCC3' that removes -Wno-pointer-sign from the
compiler invocation. This is just to help get over the hump of people
tracking down bugs that may cross the GCC 4.2 upgrade.
It is envisioned that this option goes away after a suitable amount
of time.


# 42f17ea9 18-May-2007 Alexander Kabaev <kan@FreeBSD.org>

Add -Wno-pointer-sign to CWARNFLAGS.

Switch ia64 kernels to -fpic. This is likely wrong, but at least gets
ia64 kernels to compile and link with GCC 4.2. The previous -mno-sdata
trick is not working anymore.


# f592bb74 26-Nov-2006 Kip Macy <kmacy@FreeBSD.org>

Fix module loading for sparc on machines with greater than 1GB of RAM

t1# uname -m
sparc64
t1# sysctl hw.physmem
hw.physmem: 17150509056
t1# kldload reiserfs
t1# kldstat
Id Refs Address Size Name
1 3 0xc0000000 58cc38 kernel
2 1 0xcbe70000 234000 xfs.ko
3 1 0xcc0b6000 110000 reiserfs.ko


# 1de763bd 29-Jun-2006 David E. O'Brien <obrien@FreeBSD.org>

Create new dialect knob, as setting the language dialect isn't a warning flag.


# a2f3563e 30-May-2006 Ruslan Ermilov <ru@FreeBSD.org>

Enable -Wundef warnings for kernel/module compiles. From cpp.info:

`-Wundef'
Warn whenever an identifier which is not a macro is encountered in
an `#if' directive, outside of `defined'. Such identifiers are
replaced with zero.


# 67ab9fd7 11-May-2006 John Baldwin <jhb@FreeBSD.org>

First pass at removing Alpha kernel support.


# 64b3210d 15-Jul-2005 Andrey A. Chernov <ache@FreeBSD.org>

Add -mno-sse3 for prescott/nocona


# 8d2046fa 31-Mar-2005 Peter Wemm <peter@FreeBSD.org>

Since the question keeps coming up, explain why the -mno-sse etc switches
are there and that it does not have an effect on user applications.


# 0c3a1acb 15-Mar-2005 David E. O'Brien <obrien@FreeBSD.org>

Remove OBE comment about AMD64 memory model.


# 0ed36875 15-Mar-2005 David E. O'Brien <obrien@FreeBSD.org>

Ensure GCC does not use FP registers in integer code.
I think all we really need is -fno-sse2.
I really don't like cluttering up the compiler invocation,
but this bigger hammer will fix reported problems for now.


# d6301dcd 14-May-2004 Olivier Houchard <cognet@FreeBSD.org>

Define INLINE_LIMIT for arm.


# 06d6e4fc 12-Mar-2004 Tom Rhodes <trhodes@FreeBSD.org>

This are the build infrastructure changes to allow to use the
Intel C/C++ compiler (lang/icc) to build the kernel.

The icc CPUTYPE CFLAGS use icc v7 syntax, icc v8 moans about them, but
doesn't abort. They also produce CPU specific code (new instructions
of the CPU, not only CPU specific scheduling), so if you get coredumps
with signal 4 (SIGILL, illegal instruction) you've used the wrong
CPUTYPE.

Incarnations of this patch survive gcc compiles and my make universe.
I use it on my desktop.

To use it update share/mk, add
/usr/local/intel/compiler70/ia32/bin (icc v7, works)
or
/usr/local/intel_cc_80/bin (icc v8, doesn't work)
to your PATH, make sure you have a new kernel compile directory
(e.g. MYKERNEL_icc) and run
CFLAGS="-O2 -ip" CC=icc make depend
CFLAGS="-O2 -ip" CC=icc make
in it.

Don't compile with -ipo, the build infrastructure uses ld directly to
link the kernel and the modules, but -ipo needs the link step to be
performed with Intel's linker.

Problems with icc v8:
- panic: npx0 cannot be emulated on an SMP system
- UP: first start of /bin/sh results in a FP exception

Parts of this commit contains suggestions or submissions from
Marius Strobl <marius@alchemy.franken.de>.

Reviewed by: silence on -arch
Submitted by: netchild


# 4338438b 03-Mar-2004 David E. O'Brien <obrien@FreeBSD.org>

Lower i386's INLINE_LIMIT to AMD64's level.


# 4e37bb8f 06-Feb-2004 Peter Wemm <peter@FreeBSD.org>

Reduce the inline limit from 20000 to 8000 after the previous changes
to simplify the curthread expansion some months ago.


# 813dd172 07-Dec-2003 David E. O'Brien <obrien@FreeBSD.org>

Add PowerPC CFLAGS.

Submitted by: gallatin


# 5064105e 04-Nov-2003 Peter Wemm <peter@FreeBSD.org>

Move the inline limit default variable to a per-arch place. For example,
the amd64 implementation of the pcpu macros is even more verbose than on
i386 and that causes gcc to way overestimate the complexity of this
2-instruction macro. The other platforms can probably lower their
default values.


# edd1f930 29-May-2003 Peter Wemm <peter@FreeBSD.org>

Update the kernel compile flags inside the .if ${MACHINE_ARCH} == "amd64"
section to stop gcc generating the dwarf2 .eh_frame unwind tables. It
is dead weight for the time being. Maybe it can be used to perform
stack traces and/or get the location of function arguments in ddb, but
that requires a dwarf2 runtime interpreter, which we do not have.

Approved by: re (amd64 "safe" bits)


# 3c9a3c9c 22-May-2003 Peter Wemm <peter@FreeBSD.org>

Major pmap rework to take advantage of the larger address space on amd64
systems. Of note:
- Implement a direct mapped region using 2MB pages. This eliminates the
need for temporary mappings when getting ptes. This supports up to
512GB of physical memory for now. This should be enough for a while.
- Implement a 4-tier page table system. Most of the infrastructure is
there for 128TB of userland virtual address space, but only 512GB is
presently enabled due to a mystery bug somewhere. The design of this
was heavily inspired by the alpha pmap.c.
- The kernel is moved into the negative address space(!).
- The kernel has 2GB of KVM available.
- Provide a uma memory allocator to use the direct map region to take
advantage of the 2MB TLBs.
- Fixed some assumptions in the bus_space macros about the ability
to fit virtual addresses in an 'int'.

Notable missing things:
- pmap_growkernel() should be able to grow to 512GB of KVM by expanding
downwards below kernbase. The kernel must be at the top 2GB of the
negative address space because of gcc code generation strategies.
- need to fix the >512GB user vm code.

Approved by: re (blanket)


# 1d7157c5 03-May-2003 David E. O'Brien <obrien@FreeBSD.org>

Use C99 for the kernel.


# a15febf9 30-Apr-2003 Peter Wemm <peter@FreeBSD.org>

Add AMD64 hooks


# 53faa77b 27-Feb-2003 Jake Burkholder <jake@FreeBSD.org>

Sync with bsd.kern.mk.

Reminded by: bde


# 8f6a0ee9 12-Oct-2002 Marcel Moolenaar <marcel@FreeBSD.org>

ia64 specific CFLAGS change:
Fix the "@gprel relocation against dynamic symbol xxx" linker error.

Variables defined in the link unit and small enough to be put in the
short data section will have a gp-relative access sequence (using the
@gprel relocation). It is invalid to have @gprel relocations in shared
libraries, because they are to be resolved by the static linker and
not the dynamic linker. The -fpic option will cause @ltoff relocations
for @gprel relocations, but the side-effects are untested (if any).
Instead, disable/eliminate the short data section to achieve the same.


# c6a1c7c5 03-Oct-2002 Bruce Evans <bde@FreeBSD.org>

Use the -mno-align-long-strings on i386's to debloat the kernel a little.
This reduces the size of GENERIC's text space by 73999 bytes (about 2%).
The bloat is from approximately 3437 strings longer than 31 characters
being padded to a 32-byte boundary.


# c253d72f 06-Sep-2002 Peter Wemm <peter@FreeBSD.org>

Bump the -mev56 to -mev6. Otherwise, when you compile with gcc using
ev6 or pca56 etc this downgrades the cpu specification passed to gas.
As a result, gas will fail when gcc generates media instructions (in
uipc_usrreq.c). This only affects what gas will accept, not what gcc
generates or what our *.s file contain.


# 64fc62d4 25-Aug-2002 Bruce Evans <bde@FreeBSD.org>

Turned format checking back on. It was left turned off for too long after
the gcc lossage that caused it to be turned off was fixed.

Tested with: i386/{GENERIC,LINT,...}, alpha/GENERIC


# e09d00a8 23-May-2002 Peter Wemm <peter@FreeBSD.org>

For now, make the .ifdef GCC3 case default. We should change -Wno-format
back to -fformat-extensions (or whatever) when we have the functionality.
We are gaining warnings again that should be fixed but the are being hidden
by NO_WERROR and all the -Wformat noise.


# 856f29cf 04-May-2002 David E. O'Brien <obrien@FreeBSD.org>

Use -ffreestanding for kernel bits unconditionally.


# ea8f3ee3 10-Sep-2001 Peter Wemm <peter@FreeBSD.org>

This will have to be revised, but allow putting 'makeoptions GCC3=true'
in a kernel config file. This should minimize the tearing-out-hair process
while updating the kernel for gcc-3 compliance.


# 51bb5852 21-Jul-2001 Assar Westerlund <assar@FreeBSD.org>

revert previous accidental commit


# 57762323 21-Jul-2001 Assar Westerlund <assar@FreeBSD.org>

get rid of some printf and pointer type warnings


# 0d409bfd 16-Oct-2000 Doug Rabson <dfr@FreeBSD.org>

Add section for building ia64 kernels.


# 20b11a60 28-Apr-2000 Doug Rabson <dfr@FreeBSD.org>

Reserve register t7 on alpha to point at per-cpu global variables.


# b453864c 24-Apr-2000 Mike Pritchard <mpp@FreeBSD.org>

Fix the grammar in my previous commit "lose" -> "loss".
I should have done it that way in the first place.

Pointed-out-by: bde


# a9914af5 23-Apr-2000 Mike Pritchard <mpp@FreeBSD.org>

Fix a typo in the comments.

Submitted by: Allen Campbell <allenc@verinet.com>


# 54d477a4 17-Nov-1999 David E. O'Brien <obrien@FreeBSD.org>

Make "-mpreferred-stack-boundary=2" the default on the i386.
This reduces the size of the kernel and modules when compiled with GCC 2.95.


# 7f3dea24 27-Aug-1999 Peter Wemm <peter@FreeBSD.org>

$Id$ -> $FreeBSD$


# 9a6c0bd6 29-Jan-1999 Bruce Evans <bde@FreeBSD.org>

Fixed comment and whitespace lossage in recent commits. The -W flag
is not implied by -Wall as claimed by gcc.1. Adding it causes a
measly 7193 new warnings for LINT, mostly for "unused parameter" and
"comparison between signed and unsigned".


# a91f66d4 28-Jan-1999 Matthew Dillon <dillon@FreeBSD.org>

Cleanup bsd.kern.mk after last commit.


# 0bcef6ef 27-Jan-1999 Matthew Dillon <dillon@FreeBSD.org>

Turn on -Wall and -Wcast-qual


# 65be2aac 17-Dec-1998 Doug Rabson <dfr@FreeBSD.org>

Move some compile flags from the kernel makefile to bsd.kern.mk so that
kernel modules are built with the right flags.

Suggested by: Andrew Gallatin <gallatin@cs.duke.edu>


# 072fd7d9 14-Dec-1998 Archie Cobbs <archie@FreeBSD.org>

Add -Wunused to kernel build flags.
Reviewed by: cvs-committers@freebsd.org


# 405b59bc 09-Sep-1998 Bruce Evans <bde@FreeBSD.org>

Turned on -Wformat -fformat-extensions. -fformat-extensions requires a
-current version of gcc. Without it, -Wformat would complain about all
the nonstandard %[Dbrz] formats in the kernel.


# 89f9e39f 01-May-1998 Bruce Evans <bde@FreeBSD.org>

Added -ansi to CWARNFLAGS so that ANSI errors don't come back.


# 7ffe3d1c 21-Oct-1997 Bruce Evans <bde@FreeBSD.org>

Oops, comment lines can't be indented either.


# 1bfc2826 21-Oct-1997 Bruce Evans <bde@FreeBSD.org>

Oops, comment lines can't be continued.


# 6e47de28 21-Oct-1997 Bruce Evans <bde@FreeBSD.org>

Added -Wuninitialized to CWARNFLAGS. Warnings about uninitialialized
variables were lost when we removed -W, and 23 new ones including at
least one serious one have crept in for LINT.

Restored -Winline to CFLAGS. This gives only 3 old warnings and 1 new
for LINT.


# b97fa2ef 22-Feb-1997 Peter Wemm <peter@FreeBSD.org>

Revert $FreeBSD$ to $Id$


# 1130b656 14-Jan-1997 Jordan K. Hubbard <jkh@FreeBSD.org>

Make the long-awaited change from $Id$ to $FreeBSD$

This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore. This update would have been
insane otherwise.


# a400403a 11-Nov-1996 Bruce Evans <bde@FreeBSD.org>

Turned off -W and -Winline so that the warnings that should be fixed for
2.2 are more obvious. -Winline is unimportant, but -W gives thousands
of warnings for comparisions. Turning off -W also loses warnings for:
- auto variables clobbered by longjmp. Not much of a problem in the kernel.
- functions returning without a value. I don't like losing this.
- an expression statement or the left side of a comma operand contains no
side effects. Turning this off also stops warnings for the low quality
debugging macros in gsc.c and lpt.c.

Should be in 2.2.


# 272937b0 09-Oct-1996 Bruce Evans <bde@FreeBSD.org>

Oops, this wasn't supposed to have -Wcast-qual yet.

Also disabled -Wunused. It caused too many warnings even for me.
The sign mismatch warnings should be fixed first. They are more
important and harder to disable (they are controlled by -W, which
controls too many things).


# 6b30bfd3 08-Oct-1996 Bruce Evans <bde@FreeBSD.org>

Oops, forgot to cvs add bsd.kern.mk.

Centralized the definition of CWARNFLAGS into bsd.kern.mk.