From patchwork Tue Mar 9 20:59:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 12126539 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1F33BC4332D for ; Tue, 9 Mar 2021 21:00:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DA7F36523B for ; Tue, 9 Mar 2021 21:00:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232056AbhCIVAM (ORCPT ); Tue, 9 Mar 2021 16:00:12 -0500 Received: from mail.kernel.org ([198.145.29.99]:47250 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231872AbhCIU7v (ORCPT ); Tue, 9 Mar 2021 15:59:51 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 23BB165243; Tue, 9 Mar 2021 20:59:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1615323590; bh=xKnQy4lOzj4k8Ph2fNHWK9GUggtn0blvGQT07e7lvIA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nXv9MXb029siXwQLMe2V12871C4suockJUAGv/eXhEAWMj+msKfHzogm0ULDD5g8a P99tPVhQWnBHA3PtXSTGaHSmJtFKvp/h97ugEaWAIenX/VqKFlwAS9vXdiEDoc4fik kMwaycxfpgYa0ZxuBgBmuDeHzh8s2pY/3w0f4ZPuDiYADwXo4F4hFfHfpoZ3QVd9n4 uDvOIP6YqpEm4djUbLfO/ZG7TYzNgT77zNaoqbxfxx3/2AK1CfKWXqSwMYE5VvmKz5 lEkUO7crbbFBlfs93JyhzuccR9epGVWm81IICgloXg8KxD0M0ltKCmFWuaO0XaydyQ 6+df88xFd/d/w== From: Nathan Chancellor To: Masahiro Yamada , Michal Marek , Nick Desaulniers Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Sedat Dilek , Fangrui Song , Nathan Chancellor Subject: [PATCH v2 1/2] Makefile: Remove '--gcc-toolchain' flag Date: Tue, 9 Mar 2021 13:59:14 -0700 Message-Id: <20210309205915.2340265-1-nathan@kernel.org> X-Mailer: git-send-email 2.31.0.rc1 In-Reply-To: <20210302210646.3044738-1-nathan@kernel.org> References: <20210302210646.3044738-1-nathan@kernel.org> MIME-Version: 1.0 X-Patchwork-Bot: notify Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org This flag was originally added to allow clang to find the GNU cross tools in commit 785f11aa595b ("kbuild: Add better clang cross build support"). This flag was not enough to find the tools at times so '--prefix' was added to the list in commit ef8c4ed9db80 ("kbuild: allow to use GCC toolchain not in Clang search path") and improved upon in commit ca9b31f6bb9c ("Makefile: Fix GCC_TOOLCHAIN_DIR prefix for Clang cross compilation"). Now that '--prefix' specifies a full path and prefix, '--gcc-toolchain' serves no purpose because the kernel builds with '-nostdinc' and '-nostdlib'. This has been verified with self compiled LLVM 10.0.1 and LLVM 13.0.0 as well as a distribution version of LLVM 11.1.0 without binutils in the LLVM toolchain locations. Link: https://reviews.llvm.org/D97902 Signed-off-by: Nathan Chancellor Reviewed-by: Fangrui Song Tested-by: Sedat Dilek # LLVM/Clang v13-git --- v1 -> v2: * Improve commit message (add history behind flag and link to Fangrui's documentation improvement). I did not carry tags forward so that people could re-review and test. Makefile | 4 ---- 1 file changed, 4 deletions(-) base-commit: a38fd8748464831584a19438cbb3082b5a2dab15 diff --git a/Makefile b/Makefile index 31dcdb3d61fa..182e93d91198 100644 --- a/Makefile +++ b/Makefile @@ -568,10 +568,6 @@ ifneq ($(CROSS_COMPILE),) CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%)) GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit)) CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE)) -GCC_TOOLCHAIN := $(realpath $(GCC_TOOLCHAIN_DIR)/..) -endif -ifneq ($(GCC_TOOLCHAIN),) -CLANG_FLAGS += --gcc-toolchain=$(GCC_TOOLCHAIN) endif ifneq ($(LLVM_IAS),1) CLANG_FLAGS += -no-integrated-as From patchwork Tue Mar 9 20:59:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 12126537 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BF2CBC433E9 for ; Tue, 9 Mar 2021 21:00:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8EF1E6523B for ; Tue, 9 Mar 2021 21:00:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232062AbhCIVAN (ORCPT ); Tue, 9 Mar 2021 16:00:13 -0500 Received: from mail.kernel.org ([198.145.29.99]:47274 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231906AbhCIU74 (ORCPT ); Tue, 9 Mar 2021 15:59:56 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id A643365244; Tue, 9 Mar 2021 20:59:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1615323596; bh=TYc2sxF9jlelu+yoQjVMheyf4gRhjMbLomqGl2trdgk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Lkve6UV0CSpybHVH2mF9r3f2goFOa59edwGzdalytdMeMwEt0HzOX601f4/jI/7nj b1U+puVzO9Bv8VT3u3oJgFmuVyL2Xsi6JvATd4cacUhLFVlhoS+uxQsZMRV/uRUQke gDBe8dEdUks5VEtVsW7RXowmas2i4SjFrfBLjC40BZ/BAk/F7O37iI73yiQK6gx1sL MySbqwPpbzxu3bahYUI79VSr4/YC+BGUKYnWeSwP26QK7T8n3uf/uwoZ2gPZ16G9b6 Bi2OveewphjKRofUY6cmMG6+HisneW7GftmP0FML1Crp7EkoeOHnwGgj/61jZ+1KGV oUkcSwUTDOxLw== From: Nathan Chancellor To: Masahiro Yamada , Michal Marek , Nick Desaulniers Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Sedat Dilek , Fangrui Song , Nathan Chancellor Subject: [PATCH v2 2/2] Makefile: Only specify '--prefix=' when building with clang + GNU as Date: Tue, 9 Mar 2021 13:59:15 -0700 Message-Id: <20210309205915.2340265-2-nathan@kernel.org> X-Mailer: git-send-email 2.31.0.rc1 In-Reply-To: <20210309205915.2340265-1-nathan@kernel.org> References: <20210302210646.3044738-1-nathan@kernel.org> <20210309205915.2340265-1-nathan@kernel.org> MIME-Version: 1.0 X-Patchwork-Bot: notify Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org When building with LLVM_IAS=1, there is no point to specifying '--prefix=' because that flag is only used to find GNU cross tools, which will not be used indirectly when using the integrated assembler. All of the tools are invoked directly from PATH or a full path specified via the command line, which does not depend on the value of '--prefix='. Sharing commands to reproduce issues becomes a little bit easier without a '--prefix=' value because that '--prefix=' value is specific to a user's machine due to it being an absolute path. Some further notes from Fangrui Song: clang can spawn GNU as (if -f?no-integrated-as is specified) and GNU objcopy (-f?no-integrated-as and -gsplit-dwarf and -g[123]). objcopy is only used for GNU as assembled object files. With integrated assembler, the object file streamer creates .o and .dwo simultaneously. With GNU as, two objcopy commands are needed to extract .debug*.dwo to .dwo files && another command to remove .debug*.dwo sections. A small consequence of this change (to keep things simple) is that '--prefix=' will always be specified now, even with a native build, when it was not before. This should not be an issue due to the way that the Makefile searches for the prefix (based on elfedit's location). This ends up improving the experience for host builds because PATH is better respected and matches GCC's behavior more closely. See the below thread for more details: https://lore.kernel.org/r/20210205213651.GA16907@Ryzen-5-4500U.localdomain/ Signed-off-by: Nathan Chancellor --- v1 -> v2: * Fix position of -no-integrated-as flag to fix native build (thanks to Masahiro for catching it and sorry for the breakage). * Add Fangrui's comments about what GNU binaries clang can spawn at Masahiro's request. * Reword commit message. I did not carry tags forward so that people could re-review and test. Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 182e93d91198..15292a6d63f5 100644 --- a/Makefile +++ b/Makefile @@ -566,11 +566,11 @@ CC_VERSION_TEXT = $(shell $(CC) --version 2>/dev/null | head -n 1 | sed 's/\#//g ifneq ($(findstring clang,$(CC_VERSION_TEXT)),) ifneq ($(CROSS_COMPILE),) CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%)) -GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit)) -CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE)) endif ifneq ($(LLVM_IAS),1) CLANG_FLAGS += -no-integrated-as +GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit)) +CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE)) endif CLANG_FLAGS += -Werror=unknown-warning-option KBUILD_CFLAGS += $(CLANG_FLAGS)