llvm.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/11] Bump the minimum supported version of LLVM to 13.0.1
@ 2024-01-25 22:55 Nathan Chancellor
  2024-01-25 22:55 ` [PATCH 01/11] kbuild: Raise " Nathan Chancellor
                   ` (12 more replies)
  0 siblings, 13 replies; 19+ messages in thread
From: Nathan Chancellor @ 2024-01-25 22:55 UTC (permalink / raw)
  To: akpm, masahiroy
  Cc: nicolas, linux-kbuild, llvm, patches, linux-kernel,
	Nathan Chancellor, tglx, mingo, bp, dave.hansen, x86, linux, ardb,
	linux-arm-kernel, catalin.marinas, will, mark.rutland, mpe,
	npiggin, aneesh.kumar, naveen.n.rao, linuxppc-dev, paul.walmsley,
	palmer, aou, conor, linux-riscv, keescook, linux-hardening

Hi all,

This series bumps the minimum supported version of LLVM for building the
kernel to 13.0.1. The first patch does the bump and all subsequent
patches clean up all the various workarounds and checks for earlier
versions.

Quoting the first patch's commit message for those that were only on CC
for the clean ups:

  When __builtin_mul_overflow() has arguments that differ in terms of
  signedness and width, LLVM may generate a libcall to __muloti4 because
  it performs the checks in terms of 65-bit multiplication. This issue
  becomes harder to hit (but still possible) after LLVM 12.0.0, which
  includes a special case for matching widths but different signs.

  To gain access to this special case, which the kernel can take advantage
  of when calls to __muloti4 appear, bump the minimum supported version of
  LLVM for building the kernel to 13.0.1. 13.0.1 was chosen because there
  is minimal impact to distribution support while allowing a few more
  workarounds to be dropped in the kernel source than if 12.0.0 were
  chosen. Looking at container images of up to date distribution versions:

    archlinux:latest              clang version 16.0.6
    debian:oldoldstable-slim      clang version 7.0.1-8+deb10u2 (tags/RELEASE_701/final)
    debian:oldstable-slim         Debian clang version 11.0.1-2
    debian:stable-slim            Debian clang version 14.0.6
    debian:testing-slim           Debian clang version 16.0.6 (19)
    debian:unstable-slim          Debian clang version 16.0.6 (19)
    fedora:38                     clang version 16.0.6 (Fedora 16.0.6-3.fc38)
    fedora:latest                 clang version 17.0.6 (Fedora 17.0.6-1.fc39)
    fedora:rawhide                clang version 17.0.6 (Fedora 17.0.6-1.fc40)
    opensuse/leap:latest          clang version 15.0.7
    opensuse/tumbleweed:latest    clang version 17.0.6
    ubuntu:focal                  clang version 10.0.0-4ubuntu1
    ubuntu:latest                 Ubuntu clang version 14.0.0-1ubuntu1.1
    ubuntu:rolling                Ubuntu clang version 16.0.6 (15)
    ubuntu:devel                  Ubuntu clang version 17.0.6 (3)

  The only distribution that gets left behind is Debian Bullseye, as the
  default version is 11.0.1; other distributions either have a newer
  version than 13.0.1 or one older than the current minimum of 11.0.0.
  Debian has easy access to more recent LLVM versions through
  apt.llvm.org, so this is not as much of a concern. There are also the
  kernel.org LLVM toolchains, which should work with distributions with
  glibc 2.28 and newer.

  Another benefit of slimming up the number of supported versions of LLVM
  for building the kernel is reducing the build capacity needed to support
  a matrix that builds with each supported version, which allows a matrix
  to reallocate the freed up build capacity towards something else, such
  as more configuration combinations.

This passes my build matrix with all supported versions.

This is based on Andrew's mm-nonmm-unstable to avoid trivial conflicts
with my series to update the LLVM links across the repository [1] but I
can easily rebase it to linux-kbuild if Masahiro would rather these
patches go through there (and defer the conflict resolution to the merge
window).

[1]: https://lore.kernel.org/20240109-update-llvm-links-v1-0-eb09b59db071@kernel.org/

---
Nathan Chancellor (11):
      kbuild: Raise the minimum supported version of LLVM to 13.0.1
      Makefile: Drop warn-stack-size plugin opt
      x86: Drop stack-alignment plugin opt
      ARM: Remove Thumb2 __builtin_thread_pointer workaround for Clang
      arm64: Kconfig: Clean up tautological LLVM version checks
      powerpc: Kconfig: Remove tautology in CONFIG_COMPAT
      riscv: Remove MCOUNT_NAME workaround
      riscv: Kconfig: Remove version dependency from CONFIG_CLANG_SUPPORTS_DYNAMIC_FTRACE
      fortify: Drop Clang version check for 12.0.1 or newer
      lib/Kconfig.debug: Update Clang version check in CONFIG_KCOV
      compiler-clang.h: Update __diag_clang() macros for minimum version bump

 Documentation/process/changes.rst |  2 +-
 Makefile                          |  8 --------
 arch/arm/include/asm/current.h    |  8 +-------
 arch/arm64/Kconfig                |  5 +----
 arch/powerpc/Kconfig              |  1 -
 arch/riscv/Kconfig                |  2 --
 arch/riscv/include/asm/ftrace.h   | 14 ++------------
 arch/riscv/kernel/mcount.S        | 10 +++++-----
 arch/x86/Makefile                 |  6 ------
 include/linux/compiler-clang.h    |  8 ++------
 lib/Kconfig.debug                 |  2 +-
 scripts/min-tool-version.sh       |  2 +-
 scripts/recordmcount.pl           |  2 +-
 security/Kconfig                  |  2 --
 14 files changed, 15 insertions(+), 57 deletions(-)
---
base-commit: 979741ebd48f75ed6d101c7290e3325340d361ff
change-id: 20240124-bump-min-llvm-ver-to-13-0-1-39f84dd36b19

Best regards,
-- 
Nathan Chancellor <nathan@kernel.org>


^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 01/11] kbuild: Raise the minimum supported version of LLVM to 13.0.1
  2024-01-25 22:55 [PATCH 00/11] Bump the minimum supported version of LLVM to 13.0.1 Nathan Chancellor
@ 2024-01-25 22:55 ` Nathan Chancellor
  2024-01-25 22:55 ` [PATCH 02/11] Makefile: Drop warn-stack-size plugin opt Nathan Chancellor
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: Nathan Chancellor @ 2024-01-25 22:55 UTC (permalink / raw)
  To: akpm, masahiroy
  Cc: nicolas, linux-kbuild, llvm, patches, linux-kernel,
	Nathan Chancellor

When __builtin_mul_overflow() has arguments that differ in terms of
signedness and width, LLVM may generate a libcall to __muloti4 because
it performs the checks in terms of 65-bit multiplication. This issue
becomes harder to hit (but still possible) after LLVM 12.0.0, which
includes a special case for matching widths but different signs.

To gain access to this special case, which the kernel can take advantage
of when calls to __muloti4 appear, bump the minimum supported version of
LLVM for building the kernel to 13.0.1. 13.0.1 was chosen because there
is minimal impact to distribution support while allowing a few more
workarounds to be dropped in the kernel source than if 12.0.0 were
chosen. Looking at container images of up to date distribution versions:

  archlinux:latest              clang version 16.0.6
  debian:oldoldstable-slim      clang version 7.0.1-8+deb10u2 (tags/RELEASE_701/final)
  debian:oldstable-slim         Debian clang version 11.0.1-2
  debian:stable-slim            Debian clang version 14.0.6
  debian:testing-slim           Debian clang version 16.0.6 (19)
  debian:unstable-slim          Debian clang version 16.0.6 (19)
  fedora:38                     clang version 16.0.6 (Fedora 16.0.6-3.fc38)
  fedora:latest                 clang version 17.0.6 (Fedora 17.0.6-1.fc39)
  fedora:rawhide                clang version 17.0.6 (Fedora 17.0.6-1.fc40)
  opensuse/leap:latest          clang version 15.0.7
  opensuse/tumbleweed:latest    clang version 17.0.6
  ubuntu:focal                  clang version 10.0.0-4ubuntu1
  ubuntu:latest                 Ubuntu clang version 14.0.0-1ubuntu1.1
  ubuntu:rolling                Ubuntu clang version 16.0.6 (15)
  ubuntu:devel                  Ubuntu clang version 17.0.6 (3)

The only distribution that gets left behind is Debian Bullseye, as the
default version is 11.0.1; other distributions either have a newer
version than 13.0.1 or one older than the current minimum of 11.0.0.
Debian has easy access to more recent LLVM versions through
apt.llvm.org, so this is not as much of a concern. There are also the
kernel.org LLVM toolchains, which should work with distributions with
glibc 2.28 and newer.

Another benefit of slimming up the number of supported versions of LLVM
for building the kernel is reducing the build capacity needed to support
a matrix that builds with each supported version, which allows a matrix
to reallocate the freed up build capacity towards something else, such
as more configuration combinations.

Closes: https://github.com/ClangBuiltLinux/linux/issues/1975
Link: https://github.com/llvm/llvm-project/issues/38013
Link: https://github.com/llvm/llvm-project/commit/3203143f1356a4e4e3ada231156fc6da6e1a9f9d
Link: https://mirrors.edge.kernel.org/pub/tools/llvm/
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 Documentation/process/changes.rst | 2 +-
 scripts/min-tool-version.sh       | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/process/changes.rst b/Documentation/process/changes.rst
index 50b3d1cb1115..d7306b8cad13 100644
--- a/Documentation/process/changes.rst
+++ b/Documentation/process/changes.rst
@@ -30,7 +30,7 @@ you probably needn't concern yourself with pcmciautils.
         Program        Minimal version       Command to check the version
 ====================== ===============  ========================================
 GNU C                  5.1              gcc --version
-Clang/LLVM (optional)  11.0.0           clang --version
+Clang/LLVM (optional)  13.0.1           clang --version
 Rust (optional)        1.74.1           rustc --version
 bindgen (optional)     0.65.1           bindgen --version
 GNU make               3.82             make --version
diff --git a/scripts/min-tool-version.sh b/scripts/min-tool-version.sh
index 9faa4d3d91e3..5d17022ee1f6 100755
--- a/scripts/min-tool-version.sh
+++ b/scripts/min-tool-version.sh
@@ -29,7 +29,7 @@ llvm)
 	elif [ "$SRCARCH" = loongarch ]; then
 		echo 18.0.0
 	else
-		echo 11.0.0
+		echo 13.0.1
 	fi
 	;;
 rustc)

-- 
2.43.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 02/11] Makefile: Drop warn-stack-size plugin opt
  2024-01-25 22:55 [PATCH 00/11] Bump the minimum supported version of LLVM to 13.0.1 Nathan Chancellor
  2024-01-25 22:55 ` [PATCH 01/11] kbuild: Raise " Nathan Chancellor
@ 2024-01-25 22:55 ` Nathan Chancellor
  2024-01-25 22:55 ` [PATCH 03/11] x86: Drop stack-alignment " Nathan Chancellor
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: Nathan Chancellor @ 2024-01-25 22:55 UTC (permalink / raw)
  To: akpm, masahiroy
  Cc: nicolas, linux-kbuild, llvm, patches, linux-kernel,
	Nathan Chancellor

Now that the minimum supported version of LLVM for building the kernel
has been bumped to 13.0.1, the inner ifeq statement is always false, as
the build will fail during the configuration stage for older LLVM
versions.

This effectively reverts commit 24845dcb170e ("Makefile: LTO: have
linker check -Wframe-larger-than") and its follow up fix,
commit 0236526d76b8 ("Makefile: lto: Pass -warn-stack-size only on LLD <
13.0.0").

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 Makefile | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/Makefile b/Makefile
index 9869f57c3fb3..885b2940e20d 100644
--- a/Makefile
+++ b/Makefile
@@ -951,14 +951,6 @@ CC_FLAGS_LTO	+= -fvisibility=hidden
 
 # Limit inlining across translation units to reduce binary size
 KBUILD_LDFLAGS += -mllvm -import-instr-limit=5
-
-# Check for frame size exceeding threshold during prolog/epilog insertion
-# when using lld < 13.0.0.
-ifneq ($(CONFIG_FRAME_WARN),0)
-ifeq ($(call test-lt, $(CONFIG_LLD_VERSION), 130000),y)
-KBUILD_LDFLAGS	+= -plugin-opt=-warn-stack-size=$(CONFIG_FRAME_WARN)
-endif
-endif
 endif
 
 ifdef CONFIG_LTO

-- 
2.43.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 03/11] x86: Drop stack-alignment plugin opt
  2024-01-25 22:55 [PATCH 00/11] Bump the minimum supported version of LLVM to 13.0.1 Nathan Chancellor
  2024-01-25 22:55 ` [PATCH 01/11] kbuild: Raise " Nathan Chancellor
  2024-01-25 22:55 ` [PATCH 02/11] Makefile: Drop warn-stack-size plugin opt Nathan Chancellor
@ 2024-01-25 22:55 ` Nathan Chancellor
  2024-01-25 22:55 ` [PATCH 04/11] ARM: Remove Thumb2 __builtin_thread_pointer workaround for Clang Nathan Chancellor
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: Nathan Chancellor @ 2024-01-25 22:55 UTC (permalink / raw)
  To: akpm, masahiroy
  Cc: nicolas, linux-kbuild, llvm, patches, linux-kernel,
	Nathan Chancellor, tglx, mingo, bp, dave.hansen, x86

Now that the minimum supported version of LLVM for building the kernel
has been bumped to 13.0.1, the inner ifeq statement is always false, as
the build will fail during the configuration stage for older LLVM
versions.

This effectively reverts part of commit b33fff07e3e3 ("x86, build: allow
LTO to be selected") and its follow up fix, commit 2398ce80152a ("x86,
lto: Pass -stack-alignment only on LLD < 13.0.0").

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
Cc: tglx@linutronix.de
Cc: mingo@redhat.com
Cc: bp@alien8.de
Cc: dave.hansen@linux.intel.com
Cc: x86@kernel.org
---
 arch/x86/Makefile | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 1a068de12a56..de30a8b35c41 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -217,12 +217,6 @@ endif
 
 KBUILD_LDFLAGS += -m elf_$(UTS_MACHINE)
 
-ifdef CONFIG_LTO_CLANG
-ifeq ($(call test-lt, $(CONFIG_LLD_VERSION), 130000),y)
-KBUILD_LDFLAGS	+= -plugin-opt=-stack-alignment=$(if $(CONFIG_X86_32),4,8)
-endif
-endif
-
 ifdef CONFIG_X86_NEED_RELOCS
 LDFLAGS_vmlinux := --emit-relocs --discard-none
 else

-- 
2.43.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 04/11] ARM: Remove Thumb2 __builtin_thread_pointer workaround for Clang
  2024-01-25 22:55 [PATCH 00/11] Bump the minimum supported version of LLVM to 13.0.1 Nathan Chancellor
                   ` (2 preceding siblings ...)
  2024-01-25 22:55 ` [PATCH 03/11] x86: Drop stack-alignment " Nathan Chancellor
@ 2024-01-25 22:55 ` Nathan Chancellor
  2024-01-26  8:44   ` Ard Biesheuvel
  2024-01-25 22:55 ` [PATCH 05/11] arm64: Kconfig: Clean up tautological LLVM version checks Nathan Chancellor
                   ` (8 subsequent siblings)
  12 siblings, 1 reply; 19+ messages in thread
From: Nathan Chancellor @ 2024-01-25 22:55 UTC (permalink / raw)
  To: akpm, masahiroy
  Cc: nicolas, linux-kbuild, llvm, patches, linux-kernel,
	Nathan Chancellor, linux, ardb, linux-arm-kernel

Now that the minimum supported version of LLVM for building the kernel
has been bumped to 13.0.1, the conditional expression added to
get_current() by commit c1e42efacb9b ("ARM: 9151/1: Thumb2: avoid
__builtin_thread_pointer() on Clang") is always true, as the build will
fail during the configuration stage for older LLVM versions. Remove it,
effectively reverting the aforementioned change.

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
Cc: linux@armlinux.org.uk
Cc: ardb@kernel.org
Cc: linux-arm-kernel@lists.infradead.org
---
 arch/arm/include/asm/current.h | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/arch/arm/include/asm/current.h b/arch/arm/include/asm/current.h
index 1e1178bf176d..5225cb1c803b 100644
--- a/arch/arm/include/asm/current.h
+++ b/arch/arm/include/asm/current.h
@@ -18,18 +18,12 @@ static __always_inline __attribute_const__ struct task_struct *get_current(void)
 {
 	struct task_struct *cur;
 
-#if __has_builtin(__builtin_thread_pointer) && \
-    defined(CONFIG_CURRENT_POINTER_IN_TPIDRURO) && \
-    !(defined(CONFIG_THUMB2_KERNEL) && \
-      defined(CONFIG_CC_IS_CLANG) && CONFIG_CLANG_VERSION < 130001)
+#if __has_builtin(__builtin_thread_pointer) && defined(CONFIG_CURRENT_POINTER_IN_TPIDRURO)
 	/*
 	 * Use the __builtin helper when available - this results in better
 	 * code, especially when using GCC in combination with the per-task
 	 * stack protector, as the compiler will recognize that it needs to
 	 * load the TLS register only once in every function.
-	 *
-	 * Clang < 13.0.1 gets this wrong for Thumb2 builds:
-	 * https://github.com/ClangBuiltLinux/linux/issues/1485
 	 */
 	cur = __builtin_thread_pointer();
 #elif defined(CONFIG_CURRENT_POINTER_IN_TPIDRURO) || defined(CONFIG_SMP)

-- 
2.43.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 05/11] arm64: Kconfig: Clean up tautological LLVM version checks
  2024-01-25 22:55 [PATCH 00/11] Bump the minimum supported version of LLVM to 13.0.1 Nathan Chancellor
                   ` (3 preceding siblings ...)
  2024-01-25 22:55 ` [PATCH 04/11] ARM: Remove Thumb2 __builtin_thread_pointer workaround for Clang Nathan Chancellor
@ 2024-01-25 22:55 ` Nathan Chancellor
  2024-01-26 12:59   ` Mark Rutland
  2024-01-25 22:55 ` [PATCH 06/11] powerpc: Kconfig: Remove tautology in CONFIG_COMPAT Nathan Chancellor
                   ` (7 subsequent siblings)
  12 siblings, 1 reply; 19+ messages in thread
From: Nathan Chancellor @ 2024-01-25 22:55 UTC (permalink / raw)
  To: akpm, masahiroy
  Cc: nicolas, linux-kbuild, llvm, patches, linux-kernel,
	Nathan Chancellor, catalin.marinas, will, mark.rutland,
	linux-arm-kernel

Now that the minimum supported version of LLVM for building the kernel
has been bumped to 13.0.1, several conditions become tautologies, as
they will always be true because the build will fail during the
configuration stage for older LLVM versions. Drop them, as they are
unnecessary.

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
Cc: catalin.marinas@arm.com
Cc: will@kernel.org
Cc: mark.rutland@arm.com
Cc: linux-arm-kernel@lists.infradead.org
---
 arch/arm64/Kconfig | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 5a8acca4dbf4..cb34e7d780c0 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -383,7 +383,7 @@ config BUILTIN_RETURN_ADDRESS_STRIPS_PAC
 	bool
 	# Clang's __builtin_return_adddress() strips the PAC since 12.0.0
 	# https://github.com/llvm/llvm-project/commit/2a96f47c5ffca84cd774ad402cacd137f4bf45e2
-	default y if CC_IS_CLANG && (CLANG_VERSION >= 120000)
+	default y if CC_IS_CLANG
 	# GCC's __builtin_return_address() strips the PAC since 11.1.0,
 	# and this was backported to 10.2.0, 9.4.0, 8.5.0, but not earlier
 	# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94891
@@ -1387,7 +1387,6 @@ choice
 
 config CPU_BIG_ENDIAN
 	bool "Build big-endian kernel"
-	depends on !LD_IS_LLD || LLD_VERSION >= 130000
 	# https://github.com/llvm/llvm-project/commit/1379b150991f70a5782e9a143c2ba5308da1161c
 	depends on AS_IS_GNU || AS_VERSION >= 150000
 	help
@@ -2018,8 +2017,6 @@ config ARM64_BTI_KERNEL
 	depends on !CC_IS_GCC || GCC_VERSION >= 100100
 	# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106671
 	depends on !CC_IS_GCC
-	# https://github.com/llvm/llvm-project/commit/a88c722e687e6780dcd6a58718350dc76fcc4cc9
-	depends on !CC_IS_CLANG || CLANG_VERSION >= 120000
 	depends on (!FUNCTION_GRAPH_TRACER || DYNAMIC_FTRACE_WITH_ARGS)
 	help
 	  Build the kernel with Branch Target Identification annotations

-- 
2.43.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 06/11] powerpc: Kconfig: Remove tautology in CONFIG_COMPAT
  2024-01-25 22:55 [PATCH 00/11] Bump the minimum supported version of LLVM to 13.0.1 Nathan Chancellor
                   ` (4 preceding siblings ...)
  2024-01-25 22:55 ` [PATCH 05/11] arm64: Kconfig: Clean up tautological LLVM version checks Nathan Chancellor
@ 2024-01-25 22:55 ` Nathan Chancellor
  2024-01-25 22:55 ` [PATCH 07/11] riscv: Remove MCOUNT_NAME workaround Nathan Chancellor
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: Nathan Chancellor @ 2024-01-25 22:55 UTC (permalink / raw)
  To: akpm, masahiroy
  Cc: nicolas, linux-kbuild, llvm, patches, linux-kernel,
	Nathan Chancellor, mpe, npiggin, aneesh.kumar, naveen.n.rao,
	linuxppc-dev

This reverts commit 6fcb574125e6 ("powerpc: Kconfig: disable
CONFIG_COMPAT for clang < 12").

Now that the minimum supported version of LLVM for building the kernel
has been bumped to 13.0.1, this condition is always true, as the build
will fail during the configuration stage for older LLVM versions. Remove
it.

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
Cc: mpe@ellerman.id.au
Cc: npiggin@gmail.com
Cc: aneesh.kumar@kernel.org
Cc: naveen.n.rao@linux.ibm.com
Cc: linuxppc-dev@lists.ozlabs.org
---
 arch/powerpc/Kconfig | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index b9fc064d38d2..86da0d01365a 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -333,7 +333,6 @@ config PANIC_TIMEOUT
 config COMPAT
 	bool "Enable support for 32bit binaries"
 	depends on PPC64
-	depends on !CC_IS_CLANG || CLANG_VERSION >= 120000
 	default y if !CPU_LITTLE_ENDIAN
 	select ARCH_WANT_OLD_COMPAT_IPC
 	select COMPAT_OLD_SIGACTION

-- 
2.43.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 07/11] riscv: Remove MCOUNT_NAME workaround
  2024-01-25 22:55 [PATCH 00/11] Bump the minimum supported version of LLVM to 13.0.1 Nathan Chancellor
                   ` (5 preceding siblings ...)
  2024-01-25 22:55 ` [PATCH 06/11] powerpc: Kconfig: Remove tautology in CONFIG_COMPAT Nathan Chancellor
@ 2024-01-25 22:55 ` Nathan Chancellor
  2024-01-25 22:55 ` [PATCH 08/11] riscv: Kconfig: Remove version dependency from CONFIG_CLANG_SUPPORTS_DYNAMIC_FTRACE Nathan Chancellor
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: Nathan Chancellor @ 2024-01-25 22:55 UTC (permalink / raw)
  To: akpm, masahiroy
  Cc: nicolas, linux-kbuild, llvm, patches, linux-kernel,
	Nathan Chancellor, paul.walmsley, palmer, aou, conor, linux-riscv

Now that the minimum supported version of LLVM for building the kernel
has been bumped to 13.0.1, the condition for using _mcount as
MCOUNT_NAME is always true, as the build will fail during the
configuration stage for older LLVM versions. Replace MCOUNT_NAME with
_mcount directly.

This effectively reverts commit 7ce047715030 ("riscv: Workaround mcount
name prior to clang-13").

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
Cc: paul.walmsley@sifive.com
Cc: palmer@dabbelt.com
Cc: aou@eecs.berkeley.edu
Cc: conor@kernel.org
Cc: linux-riscv@lists.infradead.org
---
 arch/riscv/include/asm/ftrace.h | 14 ++------------
 arch/riscv/kernel/mcount.S      | 10 +++++-----
 scripts/recordmcount.pl         |  2 +-
 3 files changed, 8 insertions(+), 18 deletions(-)

diff --git a/arch/riscv/include/asm/ftrace.h b/arch/riscv/include/asm/ftrace.h
index 06874fb1311e..cf5b63e789fa 100644
--- a/arch/riscv/include/asm/ftrace.h
+++ b/arch/riscv/include/asm/ftrace.h
@@ -13,19 +13,9 @@
 #endif
 #define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR
 
-/*
- * Clang prior to 13 had "mcount" instead of "_mcount":
- * https://github.com/llvm/llvm-project/commit/ef58ae86ba778ed7d01cd3f6bd6d08f943abab44
- */
-#if defined(CONFIG_CC_IS_GCC) || CONFIG_CLANG_VERSION >= 130000
-#define MCOUNT_NAME _mcount
-#else
-#define MCOUNT_NAME mcount
-#endif
-
 #define ARCH_SUPPORTS_FTRACE_OPS 1
 #ifndef __ASSEMBLY__
-void MCOUNT_NAME(void);
+void _mcount(void);
 static inline unsigned long ftrace_call_adjust(unsigned long addr)
 {
 	return addr;
@@ -75,7 +65,7 @@ struct dyn_arch_ftrace {
  * both auipc and jalr at the same time.
  */
 
-#define MCOUNT_ADDR		((unsigned long)MCOUNT_NAME)
+#define MCOUNT_ADDR		((unsigned long)_mcount)
 #define JALR_SIGN_MASK		(0x00000800)
 #define JALR_OFFSET_MASK	(0x00000fff)
 #define AUIPC_OFFSET_MASK	(0xfffff000)
diff --git a/arch/riscv/kernel/mcount.S b/arch/riscv/kernel/mcount.S
index d7ec69ac6910..3a42f6287909 100644
--- a/arch/riscv/kernel/mcount.S
+++ b/arch/riscv/kernel/mcount.S
@@ -50,8 +50,8 @@
 
 SYM_TYPED_FUNC_START(ftrace_stub)
 #ifdef CONFIG_DYNAMIC_FTRACE
-       .global MCOUNT_NAME
-       .set    MCOUNT_NAME, ftrace_stub
+       .global _mcount
+       .set    _mcount, ftrace_stub
 #endif
 	ret
 SYM_FUNC_END(ftrace_stub)
@@ -80,7 +80,7 @@ SYM_FUNC_END(return_to_handler)
 #endif
 
 #ifndef CONFIG_DYNAMIC_FTRACE
-SYM_FUNC_START(MCOUNT_NAME)
+SYM_FUNC_START(_mcount)
 	la	t4, ftrace_stub
 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
 	la	t0, ftrace_graph_return
@@ -126,6 +126,6 @@ SYM_FUNC_START(MCOUNT_NAME)
 	jalr	t5
 	RESTORE_ABI_STATE
 	ret
-SYM_FUNC_END(MCOUNT_NAME)
+SYM_FUNC_END(_mcount)
 #endif
-EXPORT_SYMBOL(MCOUNT_NAME)
+EXPORT_SYMBOL(_mcount)
diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl
index f84df9e383fd..0871b2e92584 100755
--- a/scripts/recordmcount.pl
+++ b/scripts/recordmcount.pl
@@ -352,7 +352,7 @@ if ($arch eq "x86_64") {
     $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s_mcount\$";
 } elsif ($arch eq "riscv") {
     $function_regex = "^([0-9a-fA-F]+)\\s+<([^.0-9][0-9a-zA-Z_\\.]+)>:";
-    $mcount_regex = "^\\s*([0-9a-fA-F]+):\\sR_RISCV_CALL(_PLT)?\\s_?mcount\$";
+    $mcount_regex = "^\\s*([0-9a-fA-F]+):\\sR_RISCV_CALL(_PLT)?\\s_mcount\$";
     $type = ".quad";
     $alignment = 2;
 } elsif ($arch eq "csky") {

-- 
2.43.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 08/11] riscv: Kconfig: Remove version dependency from CONFIG_CLANG_SUPPORTS_DYNAMIC_FTRACE
  2024-01-25 22:55 [PATCH 00/11] Bump the minimum supported version of LLVM to 13.0.1 Nathan Chancellor
                   ` (6 preceding siblings ...)
  2024-01-25 22:55 ` [PATCH 07/11] riscv: Remove MCOUNT_NAME workaround Nathan Chancellor
@ 2024-01-25 22:55 ` Nathan Chancellor
  2024-01-25 22:55 ` [PATCH 09/11] fortify: Drop Clang version check for 12.0.1 or newer Nathan Chancellor
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: Nathan Chancellor @ 2024-01-25 22:55 UTC (permalink / raw)
  To: akpm, masahiroy
  Cc: nicolas, linux-kbuild, llvm, patches, linux-kernel,
	Nathan Chancellor, paul.walmsley, palmer, aou, conor, linux-riscv

Now that the minimum supported version of LLVM for building the kernel
has been bumped to 13.0.1, this condition is always true, as the build
will fail during the configuration stage for older LLVM versions. Remove
it.

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
Cc: paul.walmsley@sifive.com
Cc: palmer@dabbelt.com
Cc: aou@eecs.berkeley.edu
Cc: conor@kernel.org
Cc: linux-riscv@lists.infradead.org
---
 arch/riscv/Kconfig | 2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 69d24f513922..00edc4ff589c 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -174,8 +174,6 @@ config RISCV
 
 config CLANG_SUPPORTS_DYNAMIC_FTRACE
 	def_bool CC_IS_CLANG
-	# https://github.com/llvm/llvm-project/commit/6ab8927931851bb42b2c93a00801dc499d7d9b1e
-	depends on CLANG_VERSION >= 130000
 	# https://github.com/ClangBuiltLinux/linux/issues/1817
 	depends on AS_IS_GNU || (AS_IS_LLVM && (LD_IS_LLD || LD_VERSION >= 23600))
 

-- 
2.43.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 09/11] fortify: Drop Clang version check for 12.0.1 or newer
  2024-01-25 22:55 [PATCH 00/11] Bump the minimum supported version of LLVM to 13.0.1 Nathan Chancellor
                   ` (7 preceding siblings ...)
  2024-01-25 22:55 ` [PATCH 08/11] riscv: Kconfig: Remove version dependency from CONFIG_CLANG_SUPPORTS_DYNAMIC_FTRACE Nathan Chancellor
@ 2024-01-25 22:55 ` Nathan Chancellor
  2024-01-25 23:09   ` Kees Cook
  2024-01-25 22:55 ` [PATCH 10/11] lib/Kconfig.debug: Update Clang version check in CONFIG_KCOV Nathan Chancellor
                   ` (3 subsequent siblings)
  12 siblings, 1 reply; 19+ messages in thread
From: Nathan Chancellor @ 2024-01-25 22:55 UTC (permalink / raw)
  To: akpm, masahiroy
  Cc: nicolas, linux-kbuild, llvm, patches, linux-kernel,
	Nathan Chancellor, keescook, linux-hardening

Now that the minimum supported version of LLVM for building the kernel
has been bumped to 13.0.1, this condition is always true, as the build
will fail during the configuration stage for older LLVM versions. Remove
it.

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
Cc: keescook@chromium.org
Cc: linux-hardening@vger.kernel.org
---
 security/Kconfig | 2 --
 1 file changed, 2 deletions(-)

diff --git a/security/Kconfig b/security/Kconfig
index 606a87c29a01..412e76f1575d 100644
--- a/security/Kconfig
+++ b/security/Kconfig
@@ -142,8 +142,6 @@ config HARDENED_USERCOPY
 config FORTIFY_SOURCE
 	bool "Harden common str/mem functions against buffer overflows"
 	depends on ARCH_HAS_FORTIFY_SOURCE
-	# https://llvm.org/pr41459
-	depends on !CC_IS_CLANG || CLANG_VERSION >= 120001
 	# https://github.com/llvm/llvm-project/issues/53645
 	depends on !CC_IS_CLANG || !X86_32
 	help

-- 
2.43.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 10/11] lib/Kconfig.debug: Update Clang version check in CONFIG_KCOV
  2024-01-25 22:55 [PATCH 00/11] Bump the minimum supported version of LLVM to 13.0.1 Nathan Chancellor
                   ` (8 preceding siblings ...)
  2024-01-25 22:55 ` [PATCH 09/11] fortify: Drop Clang version check for 12.0.1 or newer Nathan Chancellor
@ 2024-01-25 22:55 ` Nathan Chancellor
  2024-01-25 22:55 ` [PATCH 11/11] compiler-clang.h: Update __diag_clang() macros for minimum version bump Nathan Chancellor
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: Nathan Chancellor @ 2024-01-25 22:55 UTC (permalink / raw)
  To: akpm, masahiroy
  Cc: nicolas, linux-kbuild, llvm, patches, linux-kernel,
	Nathan Chancellor

Now that the minimum supported version of LLVM for building the kernel
has been bumped to 13.0.1, this condition can be changed to just
CONFIG_CC_IS_CLANG, as the build will fail during the configuration
stage for older LLVM versions.

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 lib/Kconfig.debug | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 8f502f15dc7f..1339fb893d71 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -2085,7 +2085,7 @@ config KCOV
 	depends on ARCH_HAS_KCOV
 	depends on CC_HAS_SANCOV_TRACE_PC || GCC_PLUGINS
 	depends on !ARCH_WANTS_NO_INSTR || HAVE_NOINSTR_HACK || \
-		   GCC_VERSION >= 120000 || CLANG_VERSION >= 130000
+		   GCC_VERSION >= 120000 || CC_IS_CLANG
 	select DEBUG_FS
 	select GCC_PLUGIN_SANCOV if !CC_HAS_SANCOV_TRACE_PC
 	select OBJTOOL if HAVE_NOINSTR_HACK

-- 
2.43.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 11/11] compiler-clang.h: Update __diag_clang() macros for minimum version bump
  2024-01-25 22:55 [PATCH 00/11] Bump the minimum supported version of LLVM to 13.0.1 Nathan Chancellor
                   ` (9 preceding siblings ...)
  2024-01-25 22:55 ` [PATCH 10/11] lib/Kconfig.debug: Update Clang version check in CONFIG_KCOV Nathan Chancellor
@ 2024-01-25 22:55 ` Nathan Chancellor
  2024-01-25 23:10 ` [PATCH 00/11] Bump the minimum supported version of LLVM to 13.0.1 Kees Cook
  2024-03-25  4:42 ` patchwork-bot+linux-riscv
  12 siblings, 0 replies; 19+ messages in thread
From: Nathan Chancellor @ 2024-01-25 22:55 UTC (permalink / raw)
  To: akpm, masahiroy
  Cc: nicolas, linux-kbuild, llvm, patches, linux-kernel,
	Nathan Chancellor

The minimum supported version of LLVM for building the kernel
has been bumped to 13.0.1. Update the __diag_clang() macros for this
bump.

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 include/linux/compiler-clang.h | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/include/linux/compiler-clang.h b/include/linux/compiler-clang.h
index f0a47afef125..49feac0162a5 100644
--- a/include/linux/compiler-clang.h
+++ b/include/linux/compiler-clang.h
@@ -114,11 +114,7 @@
 #define __diag_str(s)		__diag_str1(s)
 #define __diag(s)		_Pragma(__diag_str(clang diagnostic s))
 
-#if CONFIG_CLANG_VERSION >= 110000
-#define __diag_clang_11(s)	__diag(s)
-#else
-#define __diag_clang_11(s)
-#endif
+#define __diag_clang_13(s)	__diag(s)
 
 #define __diag_ignore_all(option, comment) \
-	__diag_clang(11, ignore, option)
+	__diag_clang(13, ignore, option)

-- 
2.43.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [PATCH 09/11] fortify: Drop Clang version check for 12.0.1 or newer
  2024-01-25 22:55 ` [PATCH 09/11] fortify: Drop Clang version check for 12.0.1 or newer Nathan Chancellor
@ 2024-01-25 23:09   ` Kees Cook
  0 siblings, 0 replies; 19+ messages in thread
From: Kees Cook @ 2024-01-25 23:09 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: akpm, masahiroy, nicolas, linux-kbuild, llvm, patches,
	linux-kernel, linux-hardening

On Thu, Jan 25, 2024 at 03:55:15PM -0700, Nathan Chancellor wrote:
> Now that the minimum supported version of LLVM for building the kernel
> has been bumped to 13.0.1, this condition is always true, as the build
> will fail during the configuration stage for older LLVM versions. Remove
> it.
> 
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>

Acked-by: Kees Cook <keescook@chromium.org>

-- 
Kees Cook

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 00/11] Bump the minimum supported version of LLVM to 13.0.1
  2024-01-25 22:55 [PATCH 00/11] Bump the minimum supported version of LLVM to 13.0.1 Nathan Chancellor
                   ` (10 preceding siblings ...)
  2024-01-25 22:55 ` [PATCH 11/11] compiler-clang.h: Update __diag_clang() macros for minimum version bump Nathan Chancellor
@ 2024-01-25 23:10 ` Kees Cook
  2024-03-25  4:42 ` patchwork-bot+linux-riscv
  12 siblings, 0 replies; 19+ messages in thread
From: Kees Cook @ 2024-01-25 23:10 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: akpm, masahiroy, nicolas, linux-kbuild, llvm, patches,
	linux-kernel, tglx, mingo, bp, dave.hansen, x86, linux, ardb,
	linux-arm-kernel, catalin.marinas, will, mark.rutland, mpe,
	npiggin, aneesh.kumar, naveen.n.rao, linuxppc-dev, paul.walmsley,
	palmer, aou, conor, linux-riscv, linux-hardening

On Thu, Jan 25, 2024 at 03:55:06PM -0700, Nathan Chancellor wrote:
> Hi all,
> 
> This series bumps the minimum supported version of LLVM for building the
> kernel to 13.0.1. The first patch does the bump and all subsequent
> patches clean up all the various workarounds and checks for earlier
> versions.
> 
> Quoting the first patch's commit message for those that were only on CC
> for the clean ups:
> 
>   When __builtin_mul_overflow() has arguments that differ in terms of
>   signedness and width, LLVM may generate a libcall to __muloti4 because
>   it performs the checks in terms of 65-bit multiplication. This issue
>   becomes harder to hit (but still possible) after LLVM 12.0.0, which
>   includes a special case for matching widths but different signs.
> 
>   To gain access to this special case, which the kernel can take advantage
>   of when calls to __muloti4 appear, bump the minimum supported version of
>   LLVM for building the kernel to 13.0.1. 13.0.1 was chosen because there
>   is minimal impact to distribution support while allowing a few more
>   workarounds to be dropped in the kernel source than if 12.0.0 were
>   chosen. Looking at container images of up to date distribution versions:
> 
>     archlinux:latest              clang version 16.0.6
>     debian:oldoldstable-slim      clang version 7.0.1-8+deb10u2 (tags/RELEASE_701/final)
>     debian:oldstable-slim         Debian clang version 11.0.1-2
>     debian:stable-slim            Debian clang version 14.0.6
>     debian:testing-slim           Debian clang version 16.0.6 (19)
>     debian:unstable-slim          Debian clang version 16.0.6 (19)
>     fedora:38                     clang version 16.0.6 (Fedora 16.0.6-3.fc38)
>     fedora:latest                 clang version 17.0.6 (Fedora 17.0.6-1.fc39)
>     fedora:rawhide                clang version 17.0.6 (Fedora 17.0.6-1.fc40)
>     opensuse/leap:latest          clang version 15.0.7
>     opensuse/tumbleweed:latest    clang version 17.0.6
>     ubuntu:focal                  clang version 10.0.0-4ubuntu1
>     ubuntu:latest                 Ubuntu clang version 14.0.0-1ubuntu1.1
>     ubuntu:rolling                Ubuntu clang version 16.0.6 (15)
>     ubuntu:devel                  Ubuntu clang version 17.0.6 (3)
> 
>   The only distribution that gets left behind is Debian Bullseye, as the
>   default version is 11.0.1; other distributions either have a newer
>   version than 13.0.1 or one older than the current minimum of 11.0.0.
>   Debian has easy access to more recent LLVM versions through
>   apt.llvm.org, so this is not as much of a concern. There are also the
>   kernel.org LLVM toolchains, which should work with distributions with
>   glibc 2.28 and newer.
> 
>   Another benefit of slimming up the number of supported versions of LLVM
>   for building the kernel is reducing the build capacity needed to support
>   a matrix that builds with each supported version, which allows a matrix
>   to reallocate the freed up build capacity towards something else, such
>   as more configuration combinations.
> 
> This passes my build matrix with all supported versions.
> 
> This is based on Andrew's mm-nonmm-unstable to avoid trivial conflicts
> with my series to update the LLVM links across the repository [1] but I
> can easily rebase it to linux-kbuild if Masahiro would rather these
> patches go through there (and defer the conflict resolution to the merge
> window).
> 
> [1]: https://lore.kernel.org/20240109-update-llvm-links-v1-0-eb09b59db071@kernel.org/
> 
> ---
> Nathan Chancellor (11):
>       kbuild: Raise the minimum supported version of LLVM to 13.0.1
>       Makefile: Drop warn-stack-size plugin opt
>       x86: Drop stack-alignment plugin opt
>       ARM: Remove Thumb2 __builtin_thread_pointer workaround for Clang
>       arm64: Kconfig: Clean up tautological LLVM version checks
>       powerpc: Kconfig: Remove tautology in CONFIG_COMPAT
>       riscv: Remove MCOUNT_NAME workaround
>       riscv: Kconfig: Remove version dependency from CONFIG_CLANG_SUPPORTS_DYNAMIC_FTRACE
>       fortify: Drop Clang version check for 12.0.1 or newer
>       lib/Kconfig.debug: Update Clang version check in CONFIG_KCOV
>       compiler-clang.h: Update __diag_clang() macros for minimum version bump
> 
>  Documentation/process/changes.rst |  2 +-
>  Makefile                          |  8 --------
>  arch/arm/include/asm/current.h    |  8 +-------
>  arch/arm64/Kconfig                |  5 +----
>  arch/powerpc/Kconfig              |  1 -
>  arch/riscv/Kconfig                |  2 --
>  arch/riscv/include/asm/ftrace.h   | 14 ++------------
>  arch/riscv/kernel/mcount.S        | 10 +++++-----
>  arch/x86/Makefile                 |  6 ------
>  include/linux/compiler-clang.h    |  8 ++------
>  lib/Kconfig.debug                 |  2 +-
>  scripts/min-tool-version.sh       |  2 +-
>  scripts/recordmcount.pl           |  2 +-
>  security/Kconfig                  |  2 --
>  14 files changed, 15 insertions(+), 57 deletions(-)
> ---
> base-commit: 979741ebd48f75ed6d101c7290e3325340d361ff
> change-id: 20240124-bump-min-llvm-ver-to-13-0-1-39f84dd36b19
> 
> Best regards,
> -- 
> Nathan Chancellor <nathan@kernel.org>
> 

Yes, please. :) This looks reasonable -- I appreciate the review of
default Clang versions across distros!

Reviewed-by: Kees Cook <keescook@chromium.org>

-- 
Kees Cook

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 04/11] ARM: Remove Thumb2 __builtin_thread_pointer workaround for Clang
  2024-01-25 22:55 ` [PATCH 04/11] ARM: Remove Thumb2 __builtin_thread_pointer workaround for Clang Nathan Chancellor
@ 2024-01-26  8:44   ` Ard Biesheuvel
  0 siblings, 0 replies; 19+ messages in thread
From: Ard Biesheuvel @ 2024-01-26  8:44 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: akpm, masahiroy, nicolas, linux-kbuild, llvm, patches,
	linux-kernel, linux, linux-arm-kernel

On Thu, 25 Jan 2024 at 23:56, Nathan Chancellor <nathan@kernel.org> wrote:
>
> Now that the minimum supported version of LLVM for building the kernel
> has been bumped to 13.0.1, the conditional expression added to
> get_current() by commit c1e42efacb9b ("ARM: 9151/1: Thumb2: avoid
> __builtin_thread_pointer() on Clang") is always true, as the build will
> fail during the configuration stage for older LLVM versions. Remove it,
> effectively reverting the aforementioned change.
>
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>

Reviewed-by: Ard Biesheuvel <ardb@kernel.org>

> ---
> Cc: linux@armlinux.org.uk
> Cc: ardb@kernel.org
> Cc: linux-arm-kernel@lists.infradead.org
> ---
>  arch/arm/include/asm/current.h | 8 +-------
>  1 file changed, 1 insertion(+), 7 deletions(-)
>
> diff --git a/arch/arm/include/asm/current.h b/arch/arm/include/asm/current.h
> index 1e1178bf176d..5225cb1c803b 100644
> --- a/arch/arm/include/asm/current.h
> +++ b/arch/arm/include/asm/current.h
> @@ -18,18 +18,12 @@ static __always_inline __attribute_const__ struct task_struct *get_current(void)
>  {
>         struct task_struct *cur;
>
> -#if __has_builtin(__builtin_thread_pointer) && \
> -    defined(CONFIG_CURRENT_POINTER_IN_TPIDRURO) && \
> -    !(defined(CONFIG_THUMB2_KERNEL) && \
> -      defined(CONFIG_CC_IS_CLANG) && CONFIG_CLANG_VERSION < 130001)
> +#if __has_builtin(__builtin_thread_pointer) && defined(CONFIG_CURRENT_POINTER_IN_TPIDRURO)
>         /*
>          * Use the __builtin helper when available - this results in better
>          * code, especially when using GCC in combination with the per-task
>          * stack protector, as the compiler will recognize that it needs to
>          * load the TLS register only once in every function.
> -        *
> -        * Clang < 13.0.1 gets this wrong for Thumb2 builds:
> -        * https://github.com/ClangBuiltLinux/linux/issues/1485
>          */
>         cur = __builtin_thread_pointer();
>  #elif defined(CONFIG_CURRENT_POINTER_IN_TPIDRURO) || defined(CONFIG_SMP)
>
> --
> 2.43.0
>

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 05/11] arm64: Kconfig: Clean up tautological LLVM version checks
  2024-01-25 22:55 ` [PATCH 05/11] arm64: Kconfig: Clean up tautological LLVM version checks Nathan Chancellor
@ 2024-01-26 12:59   ` Mark Rutland
  2024-01-26 16:10     ` Nathan Chancellor
  0 siblings, 1 reply; 19+ messages in thread
From: Mark Rutland @ 2024-01-26 12:59 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: akpm, masahiroy, nicolas, linux-kbuild, llvm, patches,
	linux-kernel, catalin.marinas, will, linux-arm-kernel

On Thu, Jan 25, 2024 at 03:55:11PM -0700, Nathan Chancellor wrote:
> Now that the minimum supported version of LLVM for building the kernel
> has been bumped to 13.0.1, several conditions become tautologies, as
> they will always be true because the build will fail during the
> configuration stage for older LLVM versions. Drop them, as they are
> unnecessary.
> 
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
> Cc: catalin.marinas@arm.com
> Cc: will@kernel.org
> Cc: mark.rutland@arm.com
> Cc: linux-arm-kernel@lists.infradead.org
> ---
>  arch/arm64/Kconfig | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index 5a8acca4dbf4..cb34e7d780c0 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -383,7 +383,7 @@ config BUILTIN_RETURN_ADDRESS_STRIPS_PAC
>  	bool
>  	# Clang's __builtin_return_adddress() strips the PAC since 12.0.0
>  	# https://github.com/llvm/llvm-project/commit/2a96f47c5ffca84cd774ad402cacd137f4bf45e2
> -	default y if CC_IS_CLANG && (CLANG_VERSION >= 120000)
> +	default y if CC_IS_CLANG
>  	# GCC's __builtin_return_address() strips the PAC since 11.1.0,
>  	# and this was backported to 10.2.0, 9.4.0, 8.5.0, but not earlier
>  	# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94891
> @@ -1387,7 +1387,6 @@ choice
>  
>  config CPU_BIG_ENDIAN
>  	bool "Build big-endian kernel"
> -	depends on !LD_IS_LLD || LLD_VERSION >= 130000
>  	# https://github.com/llvm/llvm-project/commit/1379b150991f70a5782e9a143c2ba5308da1161c

We can delete the URL here, since that was just to describe why this depended
upon LLVM 13+; it's weird for it to sit here on its own.

The URL above for __builtin_return_address() can stay or go; it may as well
stay since we have the comment aboout LLvm 12+ above it.

With that:

Acked-by: Mark Rutland <mark.rutland@arm.com>

Mark.

>  	depends on AS_IS_GNU || AS_VERSION >= 150000
>  	help
> @@ -2018,8 +2017,6 @@ config ARM64_BTI_KERNEL
>  	depends on !CC_IS_GCC || GCC_VERSION >= 100100
>  	# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106671
>  	depends on !CC_IS_GCC
> -	# https://github.com/llvm/llvm-project/commit/a88c722e687e6780dcd6a58718350dc76fcc4cc9
> -	depends on !CC_IS_CLANG || CLANG_VERSION >= 120000
>  	depends on (!FUNCTION_GRAPH_TRACER || DYNAMIC_FTRACE_WITH_ARGS)
>  	help
>  	  Build the kernel with Branch Target Identification annotations
> 
> -- 
> 2.43.0
> 

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 05/11] arm64: Kconfig: Clean up tautological LLVM version checks
  2024-01-26 12:59   ` Mark Rutland
@ 2024-01-26 16:10     ` Nathan Chancellor
  2024-01-26 17:00       ` Mark Rutland
  0 siblings, 1 reply; 19+ messages in thread
From: Nathan Chancellor @ 2024-01-26 16:10 UTC (permalink / raw)
  To: Mark Rutland
  Cc: akpm, masahiroy, nicolas, linux-kbuild, llvm, patches,
	linux-kernel, catalin.marinas, will, linux-arm-kernel

On Fri, Jan 26, 2024 at 12:59:55PM +0000, Mark Rutland wrote:
> On Thu, Jan 25, 2024 at 03:55:11PM -0700, Nathan Chancellor wrote:
> > Now that the minimum supported version of LLVM for building the kernel
> > has been bumped to 13.0.1, several conditions become tautologies, as
> > they will always be true because the build will fail during the
> > configuration stage for older LLVM versions. Drop them, as they are
> > unnecessary.
> > 
> > Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> > ---
> > Cc: catalin.marinas@arm.com
> > Cc: will@kernel.org
> > Cc: mark.rutland@arm.com
> > Cc: linux-arm-kernel@lists.infradead.org
> > ---
> >  arch/arm64/Kconfig | 5 +----
> >  1 file changed, 1 insertion(+), 4 deletions(-)
> > 
> > diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> > index 5a8acca4dbf4..cb34e7d780c0 100644
> > --- a/arch/arm64/Kconfig
> > +++ b/arch/arm64/Kconfig
> > @@ -383,7 +383,7 @@ config BUILTIN_RETURN_ADDRESS_STRIPS_PAC
> >  	bool
> >  	# Clang's __builtin_return_adddress() strips the PAC since 12.0.0
> >  	# https://github.com/llvm/llvm-project/commit/2a96f47c5ffca84cd774ad402cacd137f4bf45e2
> > -	default y if CC_IS_CLANG && (CLANG_VERSION >= 120000)
> > +	default y if CC_IS_CLANG
> >  	# GCC's __builtin_return_address() strips the PAC since 11.1.0,
> >  	# and this was backported to 10.2.0, 9.4.0, 8.5.0, but not earlier
> >  	# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94891
> > @@ -1387,7 +1387,6 @@ choice
> >  
> >  config CPU_BIG_ENDIAN
> >  	bool "Build big-endian kernel"
> > -	depends on !LD_IS_LLD || LLD_VERSION >= 130000
> >  	# https://github.com/llvm/llvm-project/commit/1379b150991f70a5782e9a143c2ba5308da1161c
> 
> We can delete the URL here, since that was just to describe why this depended
> upon LLVM 13+; it's weird for it to sit here on its own.

I think this is the URL for the fix for the problem brought up by
commit 146a15b87335 ("arm64: Restrict CPU_BIG_ENDIAN to GNU as or LLVM
IAS 15.x or newer"), so I think it should stay? It does not look like I
ever added a link or context for the LLD line, I definitely should have.

> The URL above for __builtin_return_address() can stay or go; it may as well
> stay since we have the comment aboout LLvm 12+ above it.

That's the conclusion I came to as well.

Thanks a lot for taking a look!

Cheers,
Nathan

> With that:
> 
> Acked-by: Mark Rutland <mark.rutland@arm.com>
> 
> Mark.
> 
> >  	depends on AS_IS_GNU || AS_VERSION >= 150000
> >  	help
> > @@ -2018,8 +2017,6 @@ config ARM64_BTI_KERNEL
> >  	depends on !CC_IS_GCC || GCC_VERSION >= 100100
> >  	# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106671
> >  	depends on !CC_IS_GCC
> > -	# https://github.com/llvm/llvm-project/commit/a88c722e687e6780dcd6a58718350dc76fcc4cc9
> > -	depends on !CC_IS_CLANG || CLANG_VERSION >= 120000
> >  	depends on (!FUNCTION_GRAPH_TRACER || DYNAMIC_FTRACE_WITH_ARGS)
> >  	help
> >  	  Build the kernel with Branch Target Identification annotations
> > 
> > -- 
> > 2.43.0
> > 
> 

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 05/11] arm64: Kconfig: Clean up tautological LLVM version checks
  2024-01-26 16:10     ` Nathan Chancellor
@ 2024-01-26 17:00       ` Mark Rutland
  0 siblings, 0 replies; 19+ messages in thread
From: Mark Rutland @ 2024-01-26 17:00 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: akpm, masahiroy, nicolas, linux-kbuild, llvm, patches,
	linux-kernel, catalin.marinas, will, linux-arm-kernel

On Fri, Jan 26, 2024 at 09:10:25AM -0700, Nathan Chancellor wrote:
> On Fri, Jan 26, 2024 at 12:59:55PM +0000, Mark Rutland wrote:
> > On Thu, Jan 25, 2024 at 03:55:11PM -0700, Nathan Chancellor wrote:
> > >  config CPU_BIG_ENDIAN
> > >  	bool "Build big-endian kernel"
> > > -	depends on !LD_IS_LLD || LLD_VERSION >= 130000
> > >  	# https://github.com/llvm/llvm-project/commit/1379b150991f70a5782e9a143c2ba5308da1161c
> > 
> > We can delete the URL here, since that was just to describe why this depended
> > upon LLVM 13+; it's weird for it to sit here on its own.
> 
> I think this is the URL for the fix for the problem brought up by
> commit 146a15b87335 ("arm64: Restrict CPU_BIG_ENDIAN to GNU as or LLVM
> IAS 15.x or newer"), so I think it should stay? It does not look like I
> ever added a link or context for the LLD line, I definitely should have.

Whoops; I clearly misread that, and yes it should stay.

Sorry about that; for the patch as-is:

Acked-by: Mark Rutland <mark.rutland@arm.com>

Mark.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 00/11] Bump the minimum supported version of LLVM to 13.0.1
  2024-01-25 22:55 [PATCH 00/11] Bump the minimum supported version of LLVM to 13.0.1 Nathan Chancellor
                   ` (11 preceding siblings ...)
  2024-01-25 23:10 ` [PATCH 00/11] Bump the minimum supported version of LLVM to 13.0.1 Kees Cook
@ 2024-03-25  4:42 ` patchwork-bot+linux-riscv
  12 siblings, 0 replies; 19+ messages in thread
From: patchwork-bot+linux-riscv @ 2024-03-25  4:42 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: linux-riscv, akpm, masahiroy, nicolas, linux-kbuild, llvm,
	patches, linux-kernel, tglx, mingo, bp, dave.hansen, x86, linux,
	ardb, linux-arm-kernel, catalin.marinas, will, mark.rutland, mpe,
	npiggin, aneesh.kumar, naveen.n.rao, linuxppc-dev, paul.walmsley,
	palmer, aou, conor, keescook, linux-hardening

Hello:

This series was applied to riscv/linux.git (fixes)
by Andrew Morton <akpm@linux-foundation.org>:

On Thu, 25 Jan 2024 15:55:06 -0700 you wrote:
> Hi all,
> 
> This series bumps the minimum supported version of LLVM for building the
> kernel to 13.0.1. The first patch does the bump and all subsequent
> patches clean up all the various workarounds and checks for earlier
> versions.
> 
> [...]

Here is the summary with links:
  - [07/11] riscv: Remove MCOUNT_NAME workaround
    https://git.kernel.org/riscv/c/de5f3984664e
  - [08/11] riscv: Kconfig: Remove version dependency from CONFIG_CLANG_SUPPORTS_DYNAMIC_FTRACE
    https://git.kernel.org/riscv/c/a38d97181271

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2024-03-25  4:42 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-25 22:55 [PATCH 00/11] Bump the minimum supported version of LLVM to 13.0.1 Nathan Chancellor
2024-01-25 22:55 ` [PATCH 01/11] kbuild: Raise " Nathan Chancellor
2024-01-25 22:55 ` [PATCH 02/11] Makefile: Drop warn-stack-size plugin opt Nathan Chancellor
2024-01-25 22:55 ` [PATCH 03/11] x86: Drop stack-alignment " Nathan Chancellor
2024-01-25 22:55 ` [PATCH 04/11] ARM: Remove Thumb2 __builtin_thread_pointer workaround for Clang Nathan Chancellor
2024-01-26  8:44   ` Ard Biesheuvel
2024-01-25 22:55 ` [PATCH 05/11] arm64: Kconfig: Clean up tautological LLVM version checks Nathan Chancellor
2024-01-26 12:59   ` Mark Rutland
2024-01-26 16:10     ` Nathan Chancellor
2024-01-26 17:00       ` Mark Rutland
2024-01-25 22:55 ` [PATCH 06/11] powerpc: Kconfig: Remove tautology in CONFIG_COMPAT Nathan Chancellor
2024-01-25 22:55 ` [PATCH 07/11] riscv: Remove MCOUNT_NAME workaround Nathan Chancellor
2024-01-25 22:55 ` [PATCH 08/11] riscv: Kconfig: Remove version dependency from CONFIG_CLANG_SUPPORTS_DYNAMIC_FTRACE Nathan Chancellor
2024-01-25 22:55 ` [PATCH 09/11] fortify: Drop Clang version check for 12.0.1 or newer Nathan Chancellor
2024-01-25 23:09   ` Kees Cook
2024-01-25 22:55 ` [PATCH 10/11] lib/Kconfig.debug: Update Clang version check in CONFIG_KCOV Nathan Chancellor
2024-01-25 22:55 ` [PATCH 11/11] compiler-clang.h: Update __diag_clang() macros for minimum version bump Nathan Chancellor
2024-01-25 23:10 ` [PATCH 00/11] Bump the minimum supported version of LLVM to 13.0.1 Kees Cook
2024-03-25  4:42 ` patchwork-bot+linux-riscv

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).