From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796382461; b=yyW3nm/Vr8MlNsqaHl6r6B3+XHbPYkWHSaxoBtGnEhvEL0w+q5AKAiKgAxNuMILNsj8A OswOGPx0f3wBS6kuw70tDbpdYIPLgxECP7oLKvTmQ3sWQRT+Sr1pBbT1UzKouW300wYWU jS1FWXfAkAi2LY4M7j3SErrxo22pYvjWmiZOPjNu1fHuyfyhPZec3iuzhnfV5xTMyOIbe 4BqYlmmGxM3JQ7NhQGCvhYvIVoVr5sIni/pnyZ7CYlIFnBc8X0KqpIXtxo4812oCcFLNT SBuR/yS0nafP/307t2TvH9qhVAINuxEG/sCa/zEoKnrxqjG489oWIjuGH9pflO3RaDw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796382461; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=OIZgPaFi7/ZDonrkVuBLKXCjMpEiQ1sQ2UuAMAuNdGY=; b=GilGN3/GfP8smeYtavAXb61vmyOk/juG7cCLRnck1LvRA6ZknMCQb71sMpy86G024BBK BK4ZOxdlTio9DbN7/zgFRtmk0slUItCKF2FN1MGl1zXLx1kUbI90r2HzLauiGF1xxUJok wzXfgzTDHX7OO4lcoRcymIWZJXP9/rgbqGSzXF8P1avsEdtySml7PD3qc7zhKfmFrGKH/ RV4SSC9vF5Rpr3qdy7++faupsr/TOYjmN/9g25ojNB16jQ44fqsqjZ6hZLna3LATSBBUV JTgT4p1jtcHIFl1a/Ss/OC+KW/vMyjOlpUXLzKWoeg12rlobgeQ8wCN0UTuCeKh9A+w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=iQD5mVdc; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 660F9606A335; Fri, 4 Dec 2026 11:07:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=iQD5mVdc Received: by smtp.kernel.org (Postfix) with ESMTPSA id D92361F000CE; Fri, 4 Dec 2026 11:07:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796382461; bh=OIZgPaFi7/ZDonrkVuBLKXCjMpEiQ1sQ2UuAMAuNdGY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=iQD5mVdcjl53iMDLskMdH0ReANUGdihvP2U/2mseMj2R68bTx+xc4WIa17mPhrCLO eUW05M2xn12CfN75H/TD9oXOMJ7Mr/ZwYs5wA9HhQwDa0gig26uNJ8Nyq76trVoLmW I9Izg+jxxNmHJcEsto+k+dnJIvFL1Nn2+c36xwi0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Alice Ryhl , Gary Guo , Sami Tolvanen , Miguel Ojeda Subject: [PATCH 6.18 465/703] kbuild: rust: disable function merging unconditionally Date: Fri, 4 Dec 2026 19:06:04 +0900 Message-ID: <20261204100640.151516930@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Alice Ryhl commit 73bdf8773de4af2c2b7f49370191ae6d5aeddea5 upstream. Function merging causes various different issues: * For CONFIG_CFI there's an LLVM bug causing functions with different CFI hashes to get merged. This can lead to crashes at runtime. * For gendwarfksyms it causes functions with different CRCs to get merged. This leads to broken MODVERSIONS information if the function changes in the future so that it can no longer be merged. * Wrong backtraces when a crash occurs in a merged function. * Possibly also issues with pahole/BTF as the merged function's debug info is lost. These issues are new to Rust because in clang, function merging is off by default, so these things have never come up before. Because of this, turn this option off for all configurations. [ The LLVM bug is tracked at [1]. Nick asked what function merging refers to here, and Alice writes [2]: No, this isn't linker ICF. rustc doesn't pass --icf, and in any case kbuild invokes rustc with --emit=obj and does the final link itself, so rustc's linker arguments never come into play. What I'm referring to is LLVM's MergeFunctions IR pass (llvm/lib/Transforms/IPO/MergeFunctions.cpp). It runs as part of the optimization pipeline, within a single codegen unit, before any object file is emitted. Clang only enables it with the cc1-only flag -fmerge-functions, which the kernel never passes, so C code in the kernel never sees it. rustc, however, enables it by default whenever optimizing for speed or size (opt-level 2, 3, s or z), which covers both kernel configurations. It uses the "aliases" mode: when two functions have identical bodies, one is deleted and its symbol becomes a GlobalAlias to the other. You can turn it off with -Zmerge-functions=disabled. - Miguel ] Link: https://lore.kernel.org/all/avy_9SPRaPSKD8b4@google.com/ Fixes: ac61506bf2d1 ("rust: Use gendwarfksyms + extended modversions for CONFIG_MODVERSIONS") Signed-off-by: Alice Ryhl Cc: stable@vger.kernel.org Reviewed-by: Gary Guo Reviewed-by: Sami Tolvanen Link: https://github.com/llvm/llvm-project/issues/217629 [1] Link: https://lore.kernel.org/rust-for-linux/CAH5fLgidhnPbP=xXQ3162w6q0U6rWHPZ9Mu6-E5va4_CXyanOg@mail.gmail.com/ [2] Link: https://patch.msgid.link/20261118-rust-merge-functions-v1-1-fe86126522b9@google.com Signed-off-by: Miguel Ojeda Signed-off-by: Greg Kroah-Hartman --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/Makefile +++ b/Makefile @@ -607,6 +607,7 @@ KBUILD_RUSTFLAGS := $(rust_common_flags) -Csymbol-mangling-version=v0 \ -Crelocation-model=static \ -Zfunction-sections=n \ + -Zmerge-functions=disabled \ -Wclippy::float_arithmetic KBUILD_RUSTFLAGS_OPTION_CHKS := @@ -1037,8 +1038,7 @@ endif ifdef CONFIG_RUST # Always pass -Zsanitizer-cfi-normalize-integers as CONFIG_RUST selects # CONFIG_CFI_ICALL_NORMALIZE_INTEGERS. - # Disable function merging as LLVM incorrectly merges functions with different KCFI types. - RUSTC_FLAGS_CFI := -Zsanitizer=kcfi -Zsanitizer-cfi-normalize-integers -Zmerge-functions=disabled + RUSTC_FLAGS_CFI := -Zsanitizer=kcfi -Zsanitizer-cfi-normalize-integers KBUILD_RUSTFLAGS += $(RUSTC_FLAGS_CFI) export RUSTC_FLAGS_CFI endif