From nobody Wed Feb 8 19:07:41 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4PBqJJ1j7dz3nnhT; Wed, 8 Feb 2023 19:07:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PBqJJ0jXKz44GZ; Wed, 8 Feb 2023 19:07:44 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675883264; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=2S088XzPpS12/ctfG4/Eb6wfS0sm+lD2NENNLhpMF+4=; b=qlLy2ctsRP4jUrkzEJ3sBncKYDA0QDvxGvfu0JbF0zDqKP5xlVqTBFO7mItL6qLwwnkesn 2OqgMLUE1t7vld4KgTbp52XlJhE1fzwL6yEx+X0JXv3+FjgqY4mKktIb2xbDbp/DKoZuw0 FmQ3RVqD7nfNaxAdQ2kFZ1vOWNm92gm5B335G4Aez3oTV2SF/1buHcuU7usga7vMe/y625 ohRjDzX394NpH9CKQmpgWvdxz8r9ybU155pruYn/rlEOIsM4l7902lj9bACdWfLskGM34z jLPtsJ6dZ1PRFI5EcQvtvOr7g89ajnNftuPXqZHnYHQc+3FPyevQiOybacf5iA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675883264; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=2S088XzPpS12/ctfG4/Eb6wfS0sm+lD2NENNLhpMF+4=; b=FL7zZKYMVNpjdeLisTVpPrU9Cem8DsQUQjCILiCrg9gFPJrPMSlxxFTaLCSvC3yvQXzIHI UgymAKknr80UG58jKx1TdpVK9y8CAsp8S/flCzCcQTGeVtjAKfk31h1C7w1kjgwYDtYKxp SIXivOyxGj6/Z+dr+4c6DpEbP2ABk9+AIeaxB2AkdSIzYS2DW1+DfiypvBF4ZepreiyUSC ip5Bbsoe+NI6IhRcV7DGc2Msr03ABzCtro2zXdAA0G2nUtYXJ+AtVJl2Mu9iHIP0SmjWmH sOyzH+h+J/SCwq6OUmRV43q2E+WgNZGiP1c59S49yLfmYO0DAlPZ0QS+qVrAKQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1675883264; a=rsa-sha256; cv=none; b=gJ0EKfv3g6VqwjVBxu43XhwYdrJEe7Bsi33G5WuMQuoC0dMUA72v1WWgulzy3tirau2/Tt dCrZ62hodwLqeE/lnOEqnErClsVQSa1CFsoxl0ccXbOzDaboBmdDWc0MvWBp4MhrQygVFK 3oYNhjr/XHwB1pPu0cPC5dElJjIioyhrQolKX3pLkSsFtMEHWinQFTO71t00IaMeK+EcVN Sf/1hXPlzGl2tz2geUHGZLorrMi7kQpjIHqAa33QwKcwnwfBr31A/mK7ywo6EGUj/q9EC2 iR5CAVw4QYhNu8x88kMJ8WOrAqhFCri2cWjXVgiqzZKMCenZmMOf50BKp/KftQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4PBqJH6HXKz17bB; Wed, 8 Feb 2023 19:07:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 318J7hvZ095750; Wed, 8 Feb 2023 19:07:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 318J7fsg095747; Wed, 8 Feb 2023 19:07:41 GMT (envelope-from git) Date: Wed, 8 Feb 2023 19:07:41 GMT Message-Id: <202302081907.318J7fsg095747@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dimitry Andric Subject: git: a4a491e2238b - main - Merge llvm-project release/15.x llvmorg-15.0.0-9-g1c73596d3454 List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a4a491e2238b12ccd64d3faf9e6401487f6f1f1b Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=a4a491e2238b12ccd64d3faf9e6401487f6f1f1b commit a4a491e2238b12ccd64d3faf9e6401487f6f1f1b Merge: 61cfbce3347e 5bf671d65857 Author: Dimitry Andric AuthorDate: 2022-09-10 18:56:18 +0000 Commit: Dimitry Andric CommitDate: 2023-02-08 19:05:02 +0000 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 .../clang/include/clang/Lex/Preprocessor.h | 7 + .../clang/lib/AST/RecordLayoutBuilder.cpp | 7 +- .../clang/lib/Basic/Targets/AArch64.cpp | 5 +- .../clang/lib/CodeGen/CGStmtOpenMP.cpp | 13 +- .../clang/lib/CodeGen/CodeGenFunction.h | 7 +- .../llvm-project/clang/lib/CodeGen/TargetInfo.cpp | 15 +- .../clang/lib/Driver/ToolChains/Cuda.cpp | 4 +- .../clang/lib/Format/TokenAnnotator.cpp | 19 -- contrib/llvm-project/clang/lib/Headers/cpuid.h | 1 + .../clang/lib/Lex/PPMacroExpansion.cpp | 55 ++++ contrib/llvm-project/clang/lib/Sema/SemaExpr.cpp | 7 + .../llvm-project/clang/lib/Sema/SemaExprCXX.cpp | 2 + contrib/llvm-project/clang/lib/Sema/SemaOpenMP.cpp | 3 + .../clang/utils/TableGen/SveEmitter.cpp | 2 + contrib/llvm-project/libcxx/include/regex | 2 +- contrib/llvm-project/libcxx/include/span | 7 +- contrib/llvm-project/lld/COFF/Driver.cpp | 15 +- contrib/llvm-project/lld/docs/ReleaseNotes.rst | 11 +- .../include/llvm/Analysis/LoopAccessAnalysis.h | 2 + .../llvm/DebugInfo/Symbolize/MarkupFilter.h | 30 +- .../llvm-project/llvm/include/llvm/MC/MCContext.h | 6 +- .../llvm-project/llvm/include/llvm/MC/MCDwarf.h | 6 + .../llvm/lib/Analysis/LoopAccessAnalysis.cpp | 3 +- .../llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 56 ++-- .../CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp | 5 +- .../llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp | 10 +- .../llvm/lib/DebugInfo/Symbolize/MarkupFilter.cpp | 302 +++++++++++++++++++-- contrib/llvm-project/llvm/lib/MC/MCContext.cpp | 39 +-- contrib/llvm-project/llvm/lib/MC/MCDwarf.cpp | 14 +- .../llvm/lib/MC/MCParser/ELFAsmParser.cpp | 3 +- contrib/llvm-project/llvm/lib/Support/Host.cpp | 1 + .../llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp | 11 +- .../llvm/lib/Target/RISCV/RISCVCodeGenPrepare.cpp | 4 +- .../Target/RISCV/TargetInfo/RISCVTargetInfo.cpp | 8 +- .../Target/Sparc/MCTargetDesc/SparcMCAsmInfo.cpp | 1 - .../llvm/lib/Target/X86/X86ISelLowering.cpp | 49 +++- .../Transforms/InstCombine/InstCombineCompares.cpp | 4 +- .../llvm/lib/Transforms/Utils/LoopUtils.cpp | 5 +- .../llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp | 12 +- .../lib/Transforms/Vectorize/SLPVectorizer.cpp | 18 +- .../llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp | 28 +- lib/clang/include/VCSVersion.inc | 6 +- lib/clang/include/lld/Common/Version.inc | 2 +- lib/clang/include/llvm/Support/VCSRevision.h | 2 +- sys/conf/kern.mk | 2 +- 45 files changed, 617 insertions(+), 194 deletions(-) diff --cc lib/clang/include/VCSVersion.inc index 4756d002a956,000000000000..4441e4d4aafa mode 100644,000000..100644 --- a/lib/clang/include/VCSVersion.inc +++ b/lib/clang/include/VCSVersion.inc @@@ -1,10 -1,0 +1,10 @@@ +// $FreeBSD$ + - #define LLVM_REVISION "llvmorg-15.0.0-rc2-40-gfbd2950d8d0d" ++#define LLVM_REVISION "llvmorg-15.0.0-9-g1c73596d3454" +#define LLVM_REPOSITORY "https://github.com/llvm/llvm-project.git" + - #define CLANG_REVISION "llvmorg-15.0.0-rc2-40-gfbd2950d8d0d" ++#define CLANG_REVISION "llvmorg-15.0.0-9-g1c73596d3454" +#define CLANG_REPOSITORY "https://github.com/llvm/llvm-project.git" + - #define LLDB_REVISION "llvmorg-15.0.0-rc2-40-gfbd2950d8d0d" ++#define LLDB_REVISION "llvmorg-15.0.0-9-g1c73596d3454" +#define LLDB_REPOSITORY "https://github.com/llvm/llvm-project.git" diff --cc lib/clang/include/lld/Common/Version.inc index eaf7ae8ff492,000000000000..7325d25e08a6 mode 100644,000000..100644 --- a/lib/clang/include/lld/Common/Version.inc +++ b/lib/clang/include/lld/Common/Version.inc @@@ -1,4 -1,0 +1,4 @@@ +// Local identifier in __FreeBSD_version style +#define LLD_FREEBSD_VERSION 1400005 + - #define LLD_VERSION_STRING "15.0.0 (FreeBSD llvmorg-15.0.0-rc2-40-gfbd2950d8d0d-" __XSTRING(LLD_FREEBSD_VERSION) ")" ++#define LLD_VERSION_STRING "15.0.0 (FreeBSD llvmorg-15.0.0-9-g1c73596d3454-" __XSTRING(LLD_FREEBSD_VERSION) ")" diff --cc lib/clang/include/llvm/Support/VCSRevision.h index 8fd2403121b2,000000000000..a655458a3666 mode 100644,000000..100644 --- a/lib/clang/include/llvm/Support/VCSRevision.h +++ b/lib/clang/include/llvm/Support/VCSRevision.h @@@ -1,3 -1,0 +1,3 @@@ +/* $FreeBSD$ */ - #define LLVM_REVISION "llvmorg-15.0.0-rc2-40-gfbd2950d8d0d" ++#define LLVM_REVISION "llvmorg-15.0.0-9-g1c73596d3454" +#define LLVM_REPOSITORY "https://github.com/llvm/llvm-project.git" diff --cc sys/conf/kern.mk index 2b84b0be94b8,000000000000..bdceeba3a5b3 mode 100644,000000..100644 --- a/sys/conf/kern.mk +++ b/sys/conf/kern.mk @@@ -1,335 -1,0 +1,335 @@@ +# $FreeBSD$ + +# +# Warning flags for compiling the kernel and components of the kernel: +# +CWARNFLAGS?= -Wall -Wnested-externs -Wstrict-prototypes \ + -Wmissing-prototypes -Wpointer-arith -Wcast-qual \ + -Wundef -Wno-pointer-sign ${FORMAT_EXTENSIONS} \ + -Wmissing-include-dirs -fdiagnostics-show-option \ + -Wno-unknown-pragmas \ + ${CWARNEXTRA} +# +# The following flags are next up for working on: +# -Wextra + +# Disable a few warnings for clang, since there are several places in the +# kernel where fixing them is more trouble than it is worth, or where there is +# a false positive. +.if ${COMPILER_TYPE} == "clang" +NO_WCONSTANT_CONVERSION= -Wno-error=constant-conversion +NO_WSHIFT_COUNT_NEGATIVE= -Wno-shift-count-negative +NO_WSHIFT_COUNT_OVERFLOW= -Wno-shift-count-overflow +NO_WSELF_ASSIGN= -Wno-self-assign +NO_WUNNEEDED_INTERNAL_DECL= -Wno-error=unneeded-internal-declaration +NO_WSOMETIMES_UNINITIALIZED= -Wno-error=sometimes-uninitialized +NO_WCAST_QUAL= -Wno-error=cast-qual +NO_WTAUTOLOGICAL_POINTER_COMPARE= -Wno-tautological-pointer-compare +.if ${COMPILER_VERSION} >= 100000 +NO_WMISLEADING_INDENTATION= -Wno-misleading-indentation +.endif +.if ${COMPILER_VERSION} >= 130000 +NO_WUNUSED_BUT_SET_VARIABLE= -Wno-unused-but-set-variable +.endif +.if ${COMPILER_VERSION} >= 140000 +NO_WBITWISE_INSTEAD_OF_LOGICAL= -Wno-bitwise-instead-of-logical +.endif +.if ${COMPILER_VERSION} >= 150000 +NO_WSTRICT_PROTOTYPES= -Wno-strict-prototypes +.endif +# Several other warnings which might be useful in some cases, but not severe +# enough to error out the whole kernel build. Display them anyway, so there is +# some incentive to fix them eventually. +CWARNEXTRA?= -Wno-error=tautological-compare -Wno-error=empty-body \ + -Wno-error=parentheses-equality -Wno-error=unused-function \ + -Wno-error=pointer-sign +CWARNEXTRA+= -Wno-error=shift-negative-value +CWARNEXTRA+= -Wno-address-of-packed-member +.if ${COMPILER_VERSION} >= 150000 +# Clang 15 has much more aggressive diagnostics about inconsistently declared +# array parameters, K&R prototypes, mismatched prototypes, and unused-but-set +# variables. Make these non-fatal for the time being. +CWARNEXTRA+= -Wno-error=array-parameter +CWARNEXTRA+= -Wno-error=deprecated-non-prototype - CWARNEXTRA+= -Wno-error=strict-protoypes ++CWARNEXTRA+= -Wno-error=strict-prototypes +CWARNEXTRA+= -Wno-error=unused-but-set-variable +.endif +.endif # clang + +.if ${COMPILER_TYPE} == "gcc" +# Catch-all for all the things that are in our tree, but for which we're +# not yet ready for this compiler. +NO_WUNUSED_BUT_SET_VARIABLE=-Wno-unused-but-set-variable +CWARNEXTRA?= -Wno-error=address \ + -Wno-error=aggressive-loop-optimizations \ + -Wno-error=array-bounds \ + -Wno-error=attributes \ + -Wno-error=cast-qual \ + -Wno-error=enum-compare \ + -Wno-error=maybe-uninitialized \ + -Wno-error=misleading-indentation \ + -Wno-error=nonnull-compare \ + -Wno-error=overflow \ + -Wno-error=sequence-point \ + -Wno-error=shift-overflow \ + -Wno-error=tautological-compare \ + -Wno-unused-but-set-variable +.if ${COMPILER_VERSION} >= 70100 +CWARNEXTRA+= -Wno-error=stringop-overflow +.endif +.if ${COMPILER_VERSION} >= 70200 +CWARNEXTRA+= -Wno-error=memset-elt-size +.endif +.if ${COMPILER_VERSION} >= 80000 +CWARNEXTRA+= -Wno-error=packed-not-aligned +.endif +.if ${COMPILER_VERSION} >= 90100 +CWARNEXTRA+= -Wno-address-of-packed-member \ + -Wno-error=alloca-larger-than= +.if ${COMPILER_VERSION} >= 120100 +CWARNEXTRA+= -Wno-error=nonnull \ + -Wno-dangling-pointer \ + -Wno-zero-length-bounds +NO_WINFINITE_RECURSION= -Wno-infinite-recursion +NO_WSTRINGOP_OVERREAD= -Wno-stringop-overread +.endif +.endif + +# GCC produces false positives for functions that switch on an +# enum (GCC bug 87950) +CWARNFLAGS+= -Wno-return-type +.endif # gcc + +# This warning is utter nonsense +CWARNFLAGS+= -Wno-format-zero-length + +# External compilers may not support our format extensions. Allow them +# to be disabled. WARNING: format checking is disabled in this case. +.if ${MK_FORMAT_EXTENSIONS} == "no" +FORMAT_EXTENSIONS= -Wno-format +.elif ${COMPILER_TYPE} == "clang" || \ + (${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 120100) +FORMAT_EXTENSIONS= -D__printf__=__freebsd_kprintf__ +.else +FORMAT_EXTENSIONS= -fformat-extensions +.endif + +# +# On i386, do not align the stack to 16-byte boundaries. Otherwise GCC 2.95 +# and above adds code to the entry and exit point of every function to align the +# stack to 16-byte boundaries -- thus wasting approximately 12 bytes of stack +# per function call. While the 16-byte alignment may benefit micro benchmarks, +# it is probably an overall loss as it makes the code bigger (less efficient +# use of code cache tag lines) and uses more stack (less efficient use of data +# cache tag lines). Explicitly prohibit the use of FPU, SSE and other SIMD +# operations inside the kernel itself. These operations are exclusively +# reserved for user applications. +# +# gcc: +# Setting -mno-mmx implies -mno-3dnow +# Setting -mno-sse implies -mno-sse2, -mno-sse3 and -mno-ssse3 +# +# clang: +# Setting -mno-mmx implies -mno-3dnow and -mno-3dnowa +# Setting -mno-sse implies -mno-sse2, -mno-sse3, -mno-ssse3, -mno-sse41 and -mno-sse42 +# +.if ${MACHINE_CPUARCH} == "i386" +CFLAGS.gcc+= -mpreferred-stack-boundary=2 +CFLAGS.clang+= -mno-aes -mno-avx +CFLAGS+= -mno-mmx -mno-sse -msoft-float +INLINE_LIMIT?= 8000 +.endif + +.if ${MACHINE_CPUARCH} == "arm" +INLINE_LIMIT?= 8000 +.endif + +.if ${MACHINE_CPUARCH} == "aarch64" +# We generally don't want fpu instructions in the kernel. +CFLAGS += -mgeneral-regs-only +# Reserve x18 for pcpu data +CFLAGS += -ffixed-x18 +INLINE_LIMIT?= 8000 +.endif + +# +# For RISC-V we specify the soft-float ABI (lp64) to avoid the use of floating +# point registers within the kernel. However, for kernels supporting hardware +# float (FPE), we have to include that in the march so we can have limited +# floating point support in context switching needed for that. This is different +# than userland where we use a hard-float ABI (lp64d). +# +# We also specify the "medium" code model, which generates code suitable for a +# 2GiB addressing range located at any offset, allowing modules to be located +# anywhere in the 64-bit address space. Note that clang and GCC refer to this +# code model as "medium" and "medany" respectively. +# +.if ${MACHINE_CPUARCH} == "riscv" +CFLAGS+= -march=rv64imafdc +CFLAGS+= -mabi=lp64 +CFLAGS.clang+= -mcmodel=medium +CFLAGS.gcc+= -mcmodel=medany +INLINE_LIMIT?= 8000 + +.if ${LINKER_FEATURES:Mriscv-relaxations} == "" +CFLAGS+= -mno-relax +.endif +.endif + +# +# For AMD64, we explicitly prohibit the use of FPU, SSE and other SIMD +# operations inside the kernel itself. These operations are exclusively +# reserved for user applications. +# +# gcc: +# Setting -mno-mmx implies -mno-3dnow +# Setting -mno-sse implies -mno-sse2, -mno-sse3, -mno-ssse3 and -mfpmath=387 +# +# clang: +# Setting -mno-mmx implies -mno-3dnow and -mno-3dnowa +# Setting -mno-sse implies -mno-sse2, -mno-sse3, -mno-ssse3, -mno-sse41 and -mno-sse42 +# (-mfpmath= is not supported) +# +.if ${MACHINE_CPUARCH} == "amd64" +CFLAGS.clang+= -mno-aes -mno-avx +CFLAGS+= -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float \ + -fno-asynchronous-unwind-tables +INLINE_LIMIT?= 8000 +.endif + +# +# For PowerPC we tell gcc to use floating point emulation. This avoids using +# floating point registers for integer operations which it has a tendency to do. +# Also explicitly disable Altivec instructions inside the kernel. +# +.if ${MACHINE_CPUARCH} == "powerpc" +CFLAGS+= -mno-altivec -msoft-float +INLINE_LIMIT?= 15000 +.endif + +.if ${MACHINE_ARCH} == "powerpcspe" +CFLAGS.gcc+= -mno-spe +.endif + +# +# Use dot symbols (or, better, the V2 ELF ABI) on powerpc64 to make +# DDB happy. ELFv2, if available, has some other efficiency benefits. +# +.if ${MACHINE_ARCH:Mpowerpc64*} != "" +CFLAGS+= -mabi=elfv2 +.endif + +# +# GCC 3.0 and above like to do certain optimizations based on the +# assumption that the program is linked against libc. Stop this. +# +CFLAGS+= -ffreestanding + +# +# The C standard leaves signed integer overflow behavior undefined. +# gcc and clang opimizers take advantage of this. The kernel makes +# use of signed integer wraparound mechanics so we need the compiler +# to treat it as a wraparound and not take shortcuts. +# +CFLAGS+= -fwrapv + +# +# GCC SSP support +# +.if ${MK_SSP} != "no" +CFLAGS+= -fstack-protector +.endif + +# +# Retpoline speculative execution vulnerability mitigation (CVE-2017-5715) +# +.if defined(COMPILER_FEATURES) && ${COMPILER_FEATURES:Mretpoline} != "" && \ + ${MK_KERNEL_RETPOLINE} != "no" +CFLAGS+= -mretpoline +.endif + +# +# Initialize stack variables on function entry +# +.if ${MK_INIT_ALL_ZERO} == "yes" +.if ${COMPILER_FEATURES:Minit-all} +CFLAGS+= -ftrivial-auto-var-init=zero \ + -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang +.else +.warning InitAll (zeros) requested but not support by compiler +.endif +.elif ${MK_INIT_ALL_PATTERN} == "yes" +.if ${COMPILER_FEATURES:Minit-all} +CFLAGS+= -ftrivial-auto-var-init=pattern +.else +.warning InitAll (pattern) requested but not support by compiler +.endif +.endif + +CFLAGS+= ${CWARNFLAGS:M*} ${CWARNFLAGS.${.IMPSRC:T}} +CFLAGS+= ${CWARNFLAGS.${COMPILER_TYPE}} +CFLAGS+= ${CFLAGS.${COMPILER_TYPE}} ${CFLAGS.${.IMPSRC:T}} + +# Tell bmake not to mistake standard targets for things to be searched for +# or expect to ever be up-to-date. +PHONY_NOTMAIN = afterdepend afterinstall all beforedepend beforeinstall \ + beforelinking build build-tools buildfiles buildincludes \ + checkdpadd clean cleandepend cleandir cleanobj configure \ + depend distclean distribute exe \ + html includes install installfiles installincludes \ + obj objlink objs objwarn \ + realinstall regress \ + tags whereobj + +.PHONY: ${PHONY_NOTMAIN} +.NOTMAIN: ${PHONY_NOTMAIN} + +CSTD= c99 + +.if ${CSTD} == "k&r" +CFLAGS+= -traditional +.elif ${CSTD} == "c89" || ${CSTD} == "c90" +CFLAGS+= -std=iso9899:1990 +.elif ${CSTD} == "c94" || ${CSTD} == "c95" +CFLAGS+= -std=iso9899:199409 +.elif ${CSTD} == "c99" +CFLAGS+= -std=iso9899:1999 +.else # CSTD +CFLAGS+= -std=${CSTD} +.endif # CSTD + +# Please keep this if in sync with bsd.sys.mk +.if ${LD} != "ld" && (${CC:[1]:H} != ${LD:[1]:H} || ${LD:[1]:T} != "ld") +# Add -fuse-ld=${LD} if $LD is in a different directory or not called "ld". +.if ${COMPILER_TYPE} == "clang" +# Note: Clang does not like relative paths for ld so we map ld.lld -> lld. +.if ${COMPILER_VERSION} >= 120000 +CCLDFLAGS+= --ld-path=${LD:[1]:S/^ld.//1W} +.else +CCLDFLAGS+= -fuse-ld=${LD:[1]:S/^ld.//1W} +.endif +.else +# GCC does not support an absolute path for -fuse-ld so we just print this +# warning instead and let the user add the required symlinks. +# However, we can avoid this warning if -B is set appropriately (e.g. for +# CROSS_TOOLCHAIN=...-gcc). +.if !(${LD:[1]:T} == "ld" && ${CC:tw:M-B${LD:[1]:H}/}) +.warning LD (${LD}) is not the default linker for ${CC} but -fuse-ld= is not supported +.endif +.endif +.endif + +# Set target-specific linker emulation name. +LD_EMULATION_aarch64=aarch64elf +LD_EMULATION_amd64=elf_x86_64_fbsd +LD_EMULATION_arm=armelf_fbsd +LD_EMULATION_armv6=armelf_fbsd +LD_EMULATION_armv7=armelf_fbsd +LD_EMULATION_i386=elf_i386_fbsd +LD_EMULATION_powerpc= elf32ppc_fbsd +LD_EMULATION_powerpcspe= elf32ppc_fbsd +LD_EMULATION_powerpc64= elf64ppc_fbsd +LD_EMULATION_powerpc64le= elf64lppc_fbsd +LD_EMULATION_riscv64= elf64lriscv +LD_EMULATION_riscv64sf= elf64lriscv +LD_EMULATION=${LD_EMULATION_${MACHINE_ARCH}}