From 7817b25d7338868fe33267b32fa9b8e11b739a41 Mon Sep 17 00:00:00 2001 From: Nathan Chancellor Date: Tue, 1 Oct 2024 15:11:39 -0700 Subject: [PATCH] patches: mainline: Add patch to avoid timeout with Hexagon See the commit message of the patch itself for further details on why this is needed. Signed-off-by: Nathan Chancellor --- ...ptimization_for_llvm_prior_to_19_1_0.patch | 61 +++++++++++++++++++ patches/mainline/series | 1 + 2 files changed, 62 insertions(+) create mode 100644 patches/mainline/20240819_nathan_hexagon_disable_constant_extender_optimization_for_llvm_prior_to_19_1_0.patch diff --git a/patches/mainline/20240819_nathan_hexagon_disable_constant_extender_optimization_for_llvm_prior_to_19_1_0.patch b/patches/mainline/20240819_nathan_hexagon_disable_constant_extender_optimization_for_llvm_prior_to_19_1_0.patch new file mode 100644 index 00000000..04b2f681 --- /dev/null +++ b/patches/mainline/20240819_nathan_hexagon_disable_constant_extender_optimization_for_llvm_prior_to_19_1_0.patch @@ -0,0 +1,61 @@ +From git@z Thu Jan 1 00:00:00 1970 +Subject: [PATCH] hexagon: Disable constant extender optimization for LLVM + prior to 19.1.0 +From: Nathan Chancellor +Date: Mon, 19 Aug 2024 11:16:10 -0700 +Message-Id: <20240819-hexagon-disable-constant-expander-pass-v1-1-36a734e9527d@kernel.org> +MIME-Version: 1.0 +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 7bit + +The Hexagon-specific constant extender optimization in LLVM may crash on +Linux kernel code [1] (such as with a bcachefs change in -next): + + clang: llvm/lib/Target/Hexagon/HexagonConstExtenders.cpp:745: bool (anonymous namespace)::HexagonConstExtenders::ExtRoot::operator<(const HCE::ExtRoot &) const: Assertion `ThisB->getParent() == OtherB->getParent()' failed. + Stack dump: + 0. Program arguments: clang --target=hexagon-linux-musl ... fs/bcachefs/btree_io.c + 1. parser at end of file + 2. Code generation + 3. Running pass 'Function Pass Manager' on module 'fs/bcachefs/btree_io.c'. + 4. Running pass 'Hexagon constant-extender optimization' on function '@__btree_node_lock_nopath' + +Without assertions enabled, there is just a hang during compilation. + +This has been resolved in LLVM main (20.0.0) [2] and backported to LLVM +19.1.0 but the kernel supports LLVM 13.0.1 and newer, so disable the +constant expander optimization using the '-mllvm' option when using a +toolchain that is not fixed. + +Link: https://github.com/llvm/llvm-project/issues/99714 [1] +Link: https://github.com/llvm/llvm-project/commit/68df06a0b2998765cb0a41353fcf0919bbf57ddb [2] +Link: https://github.com/llvm/llvm-project/commit/2ab8d93061581edad3501561722ebd5632d73892 [3] +Reviewed-by: Brian Cain +Link: https://lore.kernel.org/r/20240819-hexagon-disable-constant-expander-pass-v1-1-36a734e9527d@kernel.org +Signed-off-by: Nathan Chancellor +--- + arch/hexagon/Makefile | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/arch/hexagon/Makefile b/arch/hexagon/Makefile +index 92d005958dfb..ff172cbe5881 100644 +--- a/arch/hexagon/Makefile ++++ b/arch/hexagon/Makefile +@@ -32,3 +32,9 @@ KBUILD_LDFLAGS += $(ldflags-y) + TIR_NAME := r19 + KBUILD_CFLAGS += -ffixed-$(TIR_NAME) -DTHREADINFO_REG=$(TIR_NAME) -D__linux__ + KBUILD_AFLAGS += -DTHREADINFO_REG=$(TIR_NAME) ++ ++# Disable HexagonConstExtenders pass for LLVM versions prior to 19.1.0 ++# https://github.com/llvm/llvm-project/issues/99714 ++ifneq ($(call clang-min-version, 190100),y) ++KBUILD_CFLAGS += -mllvm -hexagon-cext=false ++endif + +--- +base-commit: 47ac09b91befbb6a235ab620c32af719f8208399 +change-id: 20240802-hexagon-disable-constant-expander-pass-8b6b61db6afc + +Best regards, +-- +Nathan Chancellor + diff --git a/patches/mainline/series b/patches/mainline/series index a56ba52a..a3139e6b 100644 --- a/patches/mainline/series +++ b/patches/mainline/series @@ -1 +1,2 @@ +20240819_nathan_hexagon_disable_constant_extender_optimization_for_llvm_prior_to_19_1_0.patch v2_20240916_dan_carpenter_iio_bmi323_fix_copy_and_paste_bugs_in_suspend_resume.patch