From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C28A4271447 for ; Wed, 25 Jun 2025 08:49:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750841369; cv=none; b=QPjiR/J80wzQUL6+9ebUwximx7n/KLeP8ApKoPonyYPivIY+q/LfNI7n9Lf9hziil/ql124Hq7VWY+jt9OSd8X8+z1WhgQsanhCBm58tVMEVbfb8Xxr84JXqhMDKnJfV+Eh4cqM02jYQ7UN03M67lJ+9c4tS+3w4pV5odtn//8M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750841369; c=relaxed/simple; bh=P0aj9BdXHxQiJ81TgLpZFEHx3If+tEUymmcUS9IdlUo=; h=Subject:To:Cc:From:Date:Message-ID:MIME-Version:Content-Type; b=czyRjyrT4UN93ygg4y8Q2T5LL0a5w0XA7/AunqUhZCFPZ4SqNantv96HsOaDnHfXH6mJ9UUCKhVBZ8dMQaR9dQ4fFWEbbsGiT0nRdbzftX3WE0JGZ6spYiwycTMDfrpB3VnmQrzO7sF2RUWpchsfFujdNkDjG/mOPtnUyXjHu6w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=HC6bIxwM; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="HC6bIxwM" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1759AC4CEEA; Wed, 25 Jun 2025 08:49:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1750841369; bh=P0aj9BdXHxQiJ81TgLpZFEHx3If+tEUymmcUS9IdlUo=; h=Subject:To:Cc:From:Date:From; b=HC6bIxwMwBT/EaaXUD7vHFvMH1HKzzPmvWkrlBfsHdwcglp2eJ8Er7/Tmp5CwskFE S6I5JY8WoKtekGg/ghYCD/vRUM4zY7WU3S/eIQgwoPe3PaKgppHpLSJS6qvAZqVd3O SAbk99k4SuG0fkq9RJOr3rrEuOvTUnu6yQQqDqiM= Subject: FAILED: patch "[PATCH] kbuild: add $(CLANG_FLAGS) to KBUILD_CPPFLAGS" failed to apply to 5.4-stable tree To: masahiroy@kernel.org,nathan@kernel.org,trini@konsulko.com Cc: From: Date: Wed, 25 Jun 2025 09:49:27 +0100 Message-ID: <2025062527-parkway-hardening-abe3@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 5.4-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.4.y git checkout FETCH_HEAD git cherry-pick -x feb843a469fb0ab00d2d23cfb9bcc379791011bb # git commit -s git send-email --to '' --in-reply-to '2025062527-parkway-hardening-abe3@gregkh' --subject-prefix 'PATCH 5.4.y' HEAD^.. Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From feb843a469fb0ab00d2d23cfb9bcc379791011bb Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sun, 9 Apr 2023 23:53:57 +0900 Subject: [PATCH] kbuild: add $(CLANG_FLAGS) to KBUILD_CPPFLAGS When preprocessing arch/*/kernel/vmlinux.lds.S, the target triple is not passed to $(CPP) because we add it only to KBUILD_{C,A}FLAGS. As a result, the linker script is preprocessed with predefined macros for the build host instead of the target. Assuming you use an x86 build machine, compare the following: $ clang -dM -E -x c /dev/null $ clang -dM -E -x c /dev/null -target aarch64-linux-gnu There is no actual problem presumably because our linker scripts do not rely on such predefined macros, but it is better to define correct ones. Move $(CLANG_FLAGS) to KBUILD_CPPFLAGS, so that all *.c, *.S, *.lds.S will be processed with the proper target triple. [Note] After the patch submission, we got an actual problem that needs this commit. (CBL issue 1859) Link: https://github.com/ClangBuiltLinux/linux/issues/1859 Reported-by: Tom Rini Signed-off-by: Masahiro Yamada Reviewed-by: Nathan Chancellor Tested-by: Nathan Chancellor diff --git a/scripts/Makefile.clang b/scripts/Makefile.clang index 9076cc939e87..058a4c0f864e 100644 --- a/scripts/Makefile.clang +++ b/scripts/Makefile.clang @@ -34,6 +34,5 @@ CLANG_FLAGS += -Werror=unknown-warning-option CLANG_FLAGS += -Werror=ignored-optimization-argument CLANG_FLAGS += -Werror=option-ignored CLANG_FLAGS += -Werror=unused-command-line-argument -KBUILD_CFLAGS += $(CLANG_FLAGS) -KBUILD_AFLAGS += $(CLANG_FLAGS) +KBUILD_CPPFLAGS += $(CLANG_FLAGS) export CLANG_FLAGS