From nobody Mon Feb 9 16:21:23 2026 Received: from zg8tmja5ljk3lje4ms43mwaa.icoremail.net (zg8tmja5ljk3lje4ms43mwaa.icoremail.net [209.97.181.73]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 148FD1758E; Wed, 31 Jul 2024 03:41:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.97.181.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722397300; cv=none; b=KCiKvhy+qWafv7tNUKHlYjyXwV6mlEesv78YekpRlEqNbUP4Wb/ryJx5/GJx+AtRdUoPkdtl1tw/OCgwGkTgw60aTl3g2LHHae8ZfR129cO1UC9xxejZMW4A8Y93iqKigGJTxxOana+rFfrJFq5BPypWIqVcwpT9+RxBesQFpbs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722397300; c=relaxed/simple; bh=lzjZl/VOtHSlkY6zSysCMvp6XITg7Ealf7nsFzpcTJA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=svds+SmspTcw7UhdHAtr0kEG5lPIIyo6Kf8Ik+lKoB+7+Lww4Na2vGFy2NdqSMPQzHcnAN7oSXpZI2gzZFSiSXWsUtii8uy3eoJDBNWd3KhSSZutvqlm2cabBYtn+6jAEhWqhcJO2hxiUNj7nNwFGxIY5MK7cJMucnGcB7zjMH4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=whu.edu.cn; spf=pass smtp.mailfrom=whu.edu.cn; dkim=fail (0-bit key) header.d=whu.edu.cn header.i=@whu.edu.cn header.b=rElqWGJ6 reason="key not found in DNS"; arc=none smtp.client-ip=209.97.181.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=whu.edu.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=whu.edu.cn Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=whu.edu.cn header.i=@whu.edu.cn header.b="rElqWGJ6" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=whu.edu.cn; s=dkim; h=Received:Received:From:To:Cc:Subject: Date:Message-ID:MIME-Version:Content-Transfer-Encoding; bh=SGe0w 04NrXG0POhBZ8e5VOKgXrrmS/WG4AesW9zLv6Y=; b=rElqWGJ6oq+T2wCXIeCCf hQXQJePwhAE6rBQ6DdlXDYBPFGtCmj/QJYmpvRmOHA6hxF+XE9Xrf9uNxcdnztN/ jydEVZrNb7reAJjFdMYwZyQJWrQEWkqCdYVZv8EMO4qwMQ1m1Nl22t/QZEgVqIzY 3fkjNoPPRcQOGd8qfa7v6I= Received: from whu.edu.cn (unknown [10.1.14.8]) by app2 (Coremail) with SMTP id Bw4BCgB3bhRlsqlmFs8SAA--.53786S2; Wed, 31 Jul 2024 11:41:25 +0800 (CST) Received: from zehuixu-vmwarevirtualplatform.localdomain (unknown [82.130.46.207]) by mtasvr (Coremail) with SMTP id _____wAn1MNbsqlm6GcLAA--.3583S2; Wed, 31 Jul 2024 11:41:20 +0800 (CST) From: Zehui Xu To: ojeda@kernel.org, alex.gaynor@gmail.com, wedsonaf@gmail.com Cc: boqun.feng@gmail.com, gary@garyguo.net, bjorn3_gh@protonmail.com, benno.lossin@proton.me, a.hindborg@samsung.com, aliceryhl@google.com, rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, zehuixu@whu.edu.cn Subject: [PATCH v2] rust: Kbuild: Skip -fmin-function-alignment in bindgen flags Date: Wed, 31 Jul 2024 06:41:12 +0300 Message-ID: <20240731034112.6060-1-zehuixu@whu.edu.cn> X-Mailer: git-send-email 2.45.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: Bw4BCgB3bhRlsqlmFs8SAA--.53786S2 Authentication-Results: app2; spf=neutral smtp.m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UUUU= X-CM-SenderInfo: qsqrmjqqqqijqqxyq4lkxovvfxof0/1tbiAQcPA2apDkwYeAABsm Content-Type: text/plain; charset="utf-8" GCC 14 recently added the -fmin-function-alignment option and the root Makefile uses it to replace -falign-functions when available. However, this flag can cause issues when passed to the Rust Makefile and affect the bindgen process. Bindgen relies on libclang to parse C code, and currently does not support the -fmin-function-alignment flag, leading to compilation failures when GCC 14 is used. This patch addresses the issue by adding -fmin-function-alignment to the bindgen_skip_c_flags in rust/Makefile. This prevents the flag from causing compilation issues and maintains compatibility. In addition, since -falign-functions is not used when -fmin-function-alignment is available but skipped and libclang supports -falign-functions, this patch adds it back to the bindgen_extra_c_flags to ensure the intended function alignment is maintained. Link: https://lore.kernel.org/linux-kbuild/20240222133500.16991-1-petr.pavl= u@suse.com/ Signed-off-by: Zehui Xu --- Hello again! This is the second version of my patch. I discovered some issues right after sending the email. Since this is my first kernel patch, I was too excited. I will be more careful and calm during my checks next time. Compared to the first patch, this version includes not only changes to the format of the commit message (thanks to Miguel Ojeda for the patient guidance) but also some code changes. While preparing the second version of the patch, I realized that the root Makefile replaces -falign-functions with -fmin-function-alignment, and if we simply skip we'll lose this config. To ensure consistency, I added it back = in bindgen_extra_c_flags. Though I am uncertain if this is a good approach. Looking for suggestions and thank you all for your time! v1: * https://lore.kernel.org/all/20240730222053.37066-1-zehuixu@whu.edu.cn/ v2: * Added -falign-functions to bindgen_extra_c_flags when skipping=20 -fmin-function-alignment to maintain function alignment settings in GCC 14 * Used reasonable length to wrap commit messages * Moved email content out of the commit message * Used the "Link" tag instead of "Reference:" and removed empty lines betwe= en tags * Specified the base commit rust/Makefile | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/rust/Makefile b/rust/Makefile index 1f10f92737f2..bb21e74abd87 100644 --- a/rust/Makefile +++ b/rust/Makefile @@ -227,7 +227,7 @@ bindgen_skip_c_flags :=3D -mno-fp-ret-in-387 -mpreferre= d-stack-boundary=3D% \ -fno-reorder-blocks -fno-allow-store-data-races -fasan-shadow-offset=3D% \ -fzero-call-used-regs=3D% -fno-stack-clash-protection \ -fno-inline-functions-called-once -fsanitize=3Dbounds-strict \ - -fstrict-flex-arrays=3D% \ + -fstrict-flex-arrays=3D% -fmin-function-alignment=3D% \ --param=3D% --param asan-% =20 # Derived from `scripts/Makefile.clang`. @@ -254,6 +254,16 @@ bindgen_extra_c_flags +=3D -enable-trivial-auto-var-in= it-zero-knowing-it-will-be-r endif endif =20 +# Starting from GCC 14, the root Makefile uses -fmin-function-alignment to= replace +# -falign-functions, which libclang doesn't support. We skipped +# -fmin-function-alignment in bindgen_skip_c_flags, resulting in missing +# compilation flags. Therefore we add -falign-functions in bindgen_extra_c= _flags +# to fall back and complete the alignment settings. +# https://lore.kernel.org/linux-kbuild/20240222133500.16991-1-petr.pavlu@s= use.com/ +ifdef CONFIG_CC_HAS_MIN_FUNCTION_ALIGNMENT +bindgen_extra_c_flags +=3D -falign-functions=3D$(CONFIG_FUNCTION_ALIGNMENT) +endif + bindgen_c_flags =3D $(filter-out $(bindgen_skip_c_flags), $(c_flags)) \ $(bindgen_extra_c_flags) endif base-commit: 8400291e289ee6b2bf9779ff1c83a291501f017b --=20 2.45.2