From patchwork Sun Apr 9 14:53:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13206002 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D6A01C77B70 for ; Sun, 9 Apr 2023 14:54:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229478AbjDIOyH (ORCPT ); Sun, 9 Apr 2023 10:54:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229462AbjDIOyG (ORCPT ); Sun, 9 Apr 2023 10:54:06 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 136973A87; Sun, 9 Apr 2023 07:54:06 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A0F9E60B9F; Sun, 9 Apr 2023 14:54:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 601D6C433EF; Sun, 9 Apr 2023 14:54:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681052045; bh=sR52KGMqxK6Vt6XY9CUVOsj3Fqld4NSi7ibY6IQOrls=; h=From:To:Cc:Subject:Date:From; b=c7+bCLim2D3xhHj9JAL0ZLjWdWnrvkOKClHaZBXuRTJFRMzoD8+7yJCMn65AyhspJ r/A8d6GIy75OYca0Ddu2CRsJQzfb6/ttOugEx92E3i+u0hQF7CJlv+1l3c9fZPqdEt 7kehPv01N4jrHKBwDghBZA5gWap3UGFm7P19NLQqAQ8yPSo9/PdcSqmei6+punbR02 CoFynNaG9cf9QaRFNCKr+yGod6Ajoewn/kCBzpR0egG9Qggebl5e+fCbE/rXiCX3Fj ZnH3QCzmboEVdeLxLQf1TQ0lx3TKAr4NuZVb4F7OwoSB27ubtdDp1gvW2MJytgEgAm vH/w1ohaBirdw== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada , Tom Rini , Nathan Chancellor , Nick Desaulniers , Nicolas Schier , Tom Rix , llvm@lists.linux.dev Subject: [PATCH] kbuild: add $(CLANG_CFLAGS) to KBUILD_CPPFLAGS Date: Sun, 9 Apr 2023 23:53:57 +0900 Message-Id: <20230409145358.2538266-1-masahiroy@kernel.org> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org 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 $(CFLAGS_CFLAGS) to KBUILD_CPPFLAGS, so that all *.c, *.S, *.lds.S will be processed with the proper target triple. Reported-by: Tom Rini Signed-off-by: Masahiro Yamada Reviewed-by: Nathan Chancellor Tested-by: Nathan Chancellor --- scripts/Makefile.clang | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/Makefile.clang b/scripts/Makefile.clang index 70b354fa1cb4..93ca059cc3b8 100644 --- a/scripts/Makefile.clang +++ b/scripts/Makefile.clang @@ -38,6 +38,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