From patchwork Mon Aug 2 18:39:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Desaulniers X-Patchwork-Id: 12414539 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=-31.2 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT,USER_IN_DEF_DKIM_WL 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 6BF9CC4338F for ; Mon, 2 Aug 2021 18:39:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 501C460EBD for ; Mon, 2 Aug 2021 18:39:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230323AbhHBSja (ORCPT ); Mon, 2 Aug 2021 14:39:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229903AbhHBSj3 (ORCPT ); Mon, 2 Aug 2021 14:39:29 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29B8FC06175F for ; Mon, 2 Aug 2021 11:39:20 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id t101-20020a25aaee0000b0290578c0c455b2so19878918ybi.13 for ; Mon, 02 Aug 2021 11:39:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=gB4C2V/JRguj4rIBL7q84P8CEYcrLKzVf1rrlRWL8ws=; b=ibOF2huEqj8zm7B5cvTjuBhfuojGGoi5tyhfAmlRya+6n1AKH2xsdr32hT93l0oM2F oJ/xeRaqKS0JtzQ3Zrl0fw6lJhRf1CneqRAdyrm1cwO0jMNuPMGeJh5WnZj/1uN0rnih 1157OL1ZTTXVJ7HXH+xo6hQDGsXwt6VqCYIEfRruduII6ZqWSNjdSwND2rcaq0j+10Pc S2JR8/KG06oHR/3oivBq2sYIba7r1V3syN7AlmYKivGvn1n9aoVEciM281hJD3qRw/KZ 6dAGOpKr2rXfm39y2MvRvnug12KNDYvGTQJwvtMFYHkraE8bhfAkYHf8tYpxOi5VBlgg d87w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=gB4C2V/JRguj4rIBL7q84P8CEYcrLKzVf1rrlRWL8ws=; b=gDUOswEcz25tgmkKU2FmReb2s3AJS8uMVs6IYX2u2gx2nwNzFUUWsPDEVCExJrnRwb 2ltUcFoeckZtR8Btg73KGuJYKy8zZE5IPRbkTeGqBzB8YDlt521upgyscoRg5SzR+7hO X28g4nJEMcT2cDiKgM2p4cI8vl7c1BqTaiimSudm/dXNsq7vF/tZmUVvuJCV9axUMiS9 B5juYg7k+2pS848rqpqdKQQTTusZqMDTjRZYbySqCaZ7PIDOpesqAtZyrDrfALer+MV1 XNvWZlQwpbaiGQ/JmX1kwVGm2Fx9gT6lqOBetgQfr1B3dZfM2QZ0o4/1Ek3Y+mP6CVvM uo2w== X-Gm-Message-State: AOAM532jJCQIJIn12FBqgc0dr4xV4In+R6Xp3sTmwhGm+gYFgYNNwp+G E9YrEtXygjPc9gi6E8AVazl3Ww3tpEezeOO/h/o= X-Google-Smtp-Source: ABdhPJxEHNPJZkwXVTm+0ZWk4gLLYQ//MtT+jGwZS2AH42Aj8E3EBqO4/9+9QJzQcvn4lsFUcImip8y6QRcc6ZOKkkE= X-Received: from ndesaulniers1.mtv.corp.google.com ([2620:15c:211:202:3db0:42c:8665:a4ae]) (user=ndesaulniers job=sendgmr) by 2002:a25:be09:: with SMTP id h9mr24786099ybk.239.1627929559410; Mon, 02 Aug 2021 11:39:19 -0700 (PDT) Date: Mon, 2 Aug 2021 11:39:08 -0700 In-Reply-To: <20210802183910.1802120-1-ndesaulniers@google.com> Message-Id: <20210802183910.1802120-2-ndesaulniers@google.com> Mime-Version: 1.0 References: <20210802183910.1802120-1-ndesaulniers@google.com> X-Mailer: git-send-email 2.32.0.554.ge1b32706d8-goog Subject: [PATCH v6 1/3] Makefile: move initial clang flag handling into scripts/Makefile.clang From: Nick Desaulniers To: Masahiro Yamada Cc: Miguel Ojeda , Fangrui Song , Michal Marek , Arnd Bergmann , linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, clang-built-linux@googlegroups.com, Geert Uytterhoeven , Christoph Hellwig , Linus Torvalds , Nick Desaulniers , Nathan Chancellor Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org With some of the changes we'd like to make to CROSS_COMPILE, the initial block of clang flag handling which controls things like the target triple, whether or not to use the integrated assembler and how to find GAS, and erroring on unknown warnings is becoming unwieldy. Move it into its own file under scripts/. Reviewed-by: Nathan Chancellor Signed-off-by: Nick Desaulniers --- MAINTAINERS | 1 + Makefile | 15 +-------------- scripts/Makefile.clang | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 14 deletions(-) create mode 100644 scripts/Makefile.clang diff --git a/MAINTAINERS b/MAINTAINERS index 19135a9d778e..3af8d39f43ef 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -4501,6 +4501,7 @@ B: https://github.com/ClangBuiltLinux/linux/issues C: irc://chat.freenode.net/clangbuiltlinux F: Documentation/kbuild/llvm.rst F: include/linux/compiler-clang.h +F: scripts/Makefile.clang F: scripts/clang-tools/ K: \b(?i:clang|llvm)\b diff --git a/Makefile b/Makefile index 6b555f64df06..444558e62cbc 100644 --- a/Makefile +++ b/Makefile @@ -586,20 +586,7 @@ endif CC_VERSION_TEXT = $(subst $(pound),,$(shell $(CC) --version 2>/dev/null | head -n 1)) ifneq ($(findstring clang,$(CC_VERSION_TEXT)),) -ifneq ($(CROSS_COMPILE),) -CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%)) -endif -ifeq ($(LLVM_IAS),1) -CLANG_FLAGS += -integrated-as -else -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) -KBUILD_AFLAGS += $(CLANG_FLAGS) -export CLANG_FLAGS +include $(srctree)/scripts/Makefile.clang endif # Include this also for config targets because some architectures need diff --git a/scripts/Makefile.clang b/scripts/Makefile.clang new file mode 100644 index 000000000000..297932e973d4 --- /dev/null +++ b/scripts/Makefile.clang @@ -0,0 +1,14 @@ +ifneq ($(CROSS_COMPILE),) +CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%)) +endif +ifeq ($(LLVM_IAS),1) +CLANG_FLAGS += -integrated-as +else +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) +KBUILD_AFLAGS += $(CLANG_FLAGS) +export CLANG_FLAGS From patchwork Mon Aug 2 18:39:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Desaulniers X-Patchwork-Id: 12414541 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=-31.2 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT,USER_IN_DEF_DKIM_WL 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 A5841C4338F for ; Mon, 2 Aug 2021 18:39:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8EF1B610FC for ; Mon, 2 Aug 2021 18:39:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230459AbhHBSje (ORCPT ); Mon, 2 Aug 2021 14:39:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230409AbhHBSjc (ORCPT ); Mon, 2 Aug 2021 14:39:32 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FC0BC061760 for ; Mon, 2 Aug 2021 11:39:22 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id n192-20020a25dac90000b029054c59edf217so19957206ybf.3 for ; Mon, 02 Aug 2021 11:39:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=4dz3SiE+uajglxOG7tZCdstmLAOcBmHBPB4xfwqxLic=; b=FX1LwuZZPbRbk1DMzYK7B8cWdA3VPi3/o+qSc6Irmgjg0miBtcXtlgER5JxNsybBdQ +enZTkX5KmqA/d/EUeaqZP9xEjJ0XVVXpV3Sx/d7AY98dNgBbKxtgO8Mmojs96l/ysqO esGFPVs9cP1EOrOHavZb1ZqqfaM3CoUlIJzUYLAv3zvAABfDszQzCYjhLXuPby/7uFS+ PytaCzDJTHz09ng4rM5CyVDfK+UdbKlBCI1DAARjBsPx1RK+DwJrmlCmpSDCNXqQPOLu el9r3jFBQ7/7JKmkXSavaJWneWF9Yq6boWl/Km7G4IpZId2+U50vcEhCup7v7A1foqT3 9xIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=4dz3SiE+uajglxOG7tZCdstmLAOcBmHBPB4xfwqxLic=; b=EaZjyR0/wVQEUPfvj6wDkthdg4tUzaDOMdGtRfHKoiGax2Wq2YQEsU4h5wstFZQ9N0 xaW8tBbCMaGzDYMrmNUTKPodKRgX+ayJZgzDI3wctJXZ4IIkF9BmLDH6vjEGlHTp9VBA cHqOu4nSmHlj1ZPavCUbFcyNLr1b5NLHg7r60v5lxpplKbQwaWBrRYn0e0P5NaQNWX00 qPern6MfWkiqceDbK9UI/x6LWktQLK3GqKm3kWP9/TkhgFl7JNPnQxzGnQUxuYwi6pE2 L7++JHV1zNa0SaH0Ydpvib5c5gr0kru7vVHiOUTjY7e0NcCui8fA7DbKXABe2a1oesBZ PGQA== X-Gm-Message-State: AOAM533MLD2D1EKnH6OoTWjwkPgX8XuoXOyhB0VSiYbGYHRYBYqAoIG6 zy5aDgHlQO5AZ0BJYqgPIAYj6qs3Fqy5VIXrqPk= X-Google-Smtp-Source: ABdhPJwLijclpfvgqa2ibRACKCRjdetSzF0+dGX6mfkpN/yjZFBUsDXL4j4VoCcV0YE/IrAhd8BK2xeCvPrPj3+W+8o= X-Received: from ndesaulniers1.mtv.corp.google.com ([2620:15c:211:202:3db0:42c:8665:a4ae]) (user=ndesaulniers job=sendgmr) by 2002:a25:8445:: with SMTP id r5mr24083636ybm.20.1627929561736; Mon, 02 Aug 2021 11:39:21 -0700 (PDT) Date: Mon, 2 Aug 2021 11:39:09 -0700 In-Reply-To: <20210802183910.1802120-1-ndesaulniers@google.com> Message-Id: <20210802183910.1802120-3-ndesaulniers@google.com> Mime-Version: 1.0 References: <20210802183910.1802120-1-ndesaulniers@google.com> X-Mailer: git-send-email 2.32.0.554.ge1b32706d8-goog Subject: [PATCH v6 2/3] Makefile: infer --target from ARCH for CC=clang From: Nick Desaulniers To: Masahiro Yamada Cc: Miguel Ojeda , Fangrui Song , Michal Marek , Arnd Bergmann , linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, clang-built-linux@googlegroups.com, Geert Uytterhoeven , Christoph Hellwig , Linus Torvalds , Nick Desaulniers , Nathan Chancellor Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org We get constant feedback that the command line invocation of make is too long when compiling with LLVM. CROSS_COMPILE is helpful when a toolchain has a prefix of the target triple, or is an absolute path outside of $PATH. Since a Clang binary is generally multi-targeted, we can infer a given target from SRCARCH/ARCH. If CROSS_COMPILE is not set, simply set --target= for CLANG_FLAGS, KBUILD_CFLAGS, and KBUILD_AFLAGS based on $SRCARCH. Previously, we'd cross compile via: $ ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make LLVM=1 LLVM_IAS=1 Now: $ ARCH=arm64 make LLVM=1 LLVM_IAS=1 For native builds (not involving cross compilation) we now explicitly specify a target triple rather than rely on the implicit host triple. Link: https://github.com/ClangBuiltLinux/linux/issues/1399 Suggested-by: Arnd Bergmann Suggested-by: Linus Torvalds Suggested-by: Masahiro Yamada Suggested-by: Nathan Chancellor Acked-by: Arnd Bergmann Reviewed-by: Nathan Chancellor Signed-off-by: Nick Desaulniers Acked-by: Miguel Ojeda --- Changes v5 -> v6: * Use indirection as per Linus. We now have CLANG_TARGET_FLAGS and a few variables suffixed with $SRCARCH. * Add Linus' SB tag. * Change hexagon target triple from -gnu to -musl. Changes v3 -> v4: * Reword commit message and oneline, as per Nathan. * Drop documentation change (it's the next patch, could be squashed in, I guess). * Drop LLVM_IAS=1 requirement, as per Masahiro. * Carry Arnd's and Nathan's AB/RB/TB tags, confirmed OK on IRC+Discord. Changes v2 -> v3: * Drop check/requirement for LLVM=1, as per Masahiro. * Change oneliner from LLVM=1 LLVM_IAS=1 to CC=clang LLVM_IAS=1. * Don't carry forward Nathan's RB/TB tags. :( Sorry Nathan, but thank you for testing+reviewing v2. * Update wording of docs slightly. Changes v1 -> v2: * Fix typos in commit message as per Geert and Masahiro. * Use SRCARCH instead of ARCH, simplifying x86 handling, as per Masahiro. Add his sugguested by tag. * change commit oneline from 'drop' to 'infer.' * Add detail about explicit host --target and relationship of ARCH to SRCARCH, as per Masahiro. Changes RFC -> v1: * Rebase onto linux-kbuild/for-next * Keep full target triples since missing the gnueabi suffix messes up 32b ARM. Drop Fangrui's sugguested by tag. Update commit message to drop references to arm64. * Flush out TODOS. * Add note about -EL/-EB, -m32/-m64. * Add note to Documentation/. scripts/Makefile.clang | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/scripts/Makefile.clang b/scripts/Makefile.clang index 297932e973d4..1f4e3eb70f88 100644 --- a/scripts/Makefile.clang +++ b/scripts/Makefile.clang @@ -1,6 +1,27 @@ -ifneq ($(CROSS_COMPILE),) +# Individual arch/{arch}/Makefiles should use -EL/-EB to set intended +# endianness and -m32/-m64 to set word size based on Kconfigs instead of +# relying on the target triple. +CLANG_TARGET_FLAGS_arm := arm-linux-gnueabi +CLANG_TARGET_FLAGS_arm64 := aarch64-linux-gnu +CLANG_TARGET_FLAGS_hexagon := hexagon-linux-musl +CLANG_TARGET_FLAGS_m68k := m68k-linux-gnu +CLANG_TARGET_FLAGS_mips := mipsel-linux-gnu +CLANG_TARGET_FLAGS_powerpc := powerpc64le-linux-gnu +CLANG_TARGET_FLAGS_riscv := riscv64-linux-gnu +CLANG_TARGET_FLAGS_s390 := s390x-linux-gnu +CLANG_TARGET_FLAGS_x86 := x86_64-linux-gnu +CLANG_TARGET_FLAGS := $(CLANG_TARGET_FLAGS_$(SRCARCH)) + +ifeq ($(CROSS_COMPILE),) +ifeq ($(CLANG_TARGET_FLAGS),) +$(error Specify CROSS_COMPILE or add '--target=' option to scripts/Makefile.clang) +else +CLANG_FLAGS += --target=$(CLANG_TARGET_FLAGS) +endif # CLANG_TARGET_FLAGS +else CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%)) -endif +endif # CROSS_COMPILE + ifeq ($(LLVM_IAS),1) CLANG_FLAGS += -integrated-as else From patchwork Mon Aug 2 18:39:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Desaulniers X-Patchwork-Id: 12414543 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=-26.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL 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 D10DBC4320A for ; Mon, 2 Aug 2021 18:39:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B6E7A60EBD for ; Mon, 2 Aug 2021 18:39:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230437AbhHBSjg (ORCPT ); Mon, 2 Aug 2021 14:39:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230476AbhHBSje (ORCPT ); Mon, 2 Aug 2021 14:39:34 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDF00C061796 for ; Mon, 2 Aug 2021 11:39:24 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id c63-20020a25e5420000b0290580b26e708aso19958009ybh.12 for ; Mon, 02 Aug 2021 11:39:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=kxeZ499IZ34ScBxCoMfNAW68U3dStYlxpnDRACL6igo=; b=UDtO0O6rkVrtHHJ0SY0aJGfDOIrgTELa5pL49JkakQig4VEH4F1RYPBtFkzclcT1AW 3PYpRFCoePQetkTDZL+0BrzS8/HVZxoo3wrAfaXiYGNEjJjkjR+Lre0Z/trVZs8EOrvE xPjy1vqLoQfm3SdKS6zR92Rcz8ZeeCJi1mnhoMXiR5Kefvq5XTnqWPAF538d0TmdybiM WAxHashTaJSGdc3V0M7MnMsaLgYpLGV8PnWc95a3yhi4twIkoMJyHTee6JOPjOxtnWms ZDgytj6HYE24k3Hd02+cJBlh6WcUtHK35hdESUs3xtAkQDy8TTjgHRXBAxVi4MdOArRh BPCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=kxeZ499IZ34ScBxCoMfNAW68U3dStYlxpnDRACL6igo=; b=Rw0rnvQIlYHJsmUmk8MYgXwmfSmIlY+YV+Ui5ooIjnl/KGdvhGbpyqLu7Vb2rRzxN5 kBCiV5baBOd+QHM44FRgwUTEO1wtUPQ9L5z90kEW9c95xVbEMIgqjeHBVYWVHbVCANrg aZwhtKt46dsMBkVu549egunpVJWzsvHiKBunhpicLBhM9aFqfIFr2GCNicBGR02We082 6bd7rMatkOfgCsG4yBkYEG7HXeKK6feF1JmGLgUBTHIFj2Mg42ZAy4n3e1FgLgpTeZnk k6C7IhxMg4rfzqwc/uQyEVaFVnshM1w5rrQFRBALu45AYt21xmGrjixhRLL+C2zD6Ek/ tNDg== X-Gm-Message-State: AOAM533J0ahrBQFXlRdkm8Cu2Jzy7BUqL0zaNVqfC+MgAevHf35dL7JG llwDmsN0bODtu8f+QSn8h0ktTHUuKi5qinWHAlg= X-Google-Smtp-Source: ABdhPJyBc75e6umajU61NkjBzyfbdudAXcaX8RkqZXnlzjHPPA2xyUOOdVxKt0zDI5XsREBsXdW2CnvdVowH+Cip42Y= X-Received: from ndesaulniers1.mtv.corp.google.com ([2620:15c:211:202:3db0:42c:8665:a4ae]) (user=ndesaulniers job=sendgmr) by 2002:a25:320f:: with SMTP id y15mr22007134yby.515.1627929564059; Mon, 02 Aug 2021 11:39:24 -0700 (PDT) Date: Mon, 2 Aug 2021 11:39:10 -0700 In-Reply-To: <20210802183910.1802120-1-ndesaulniers@google.com> Message-Id: <20210802183910.1802120-4-ndesaulniers@google.com> Mime-Version: 1.0 References: <20210802183910.1802120-1-ndesaulniers@google.com> X-Mailer: git-send-email 2.32.0.554.ge1b32706d8-goog Subject: [PATCH v6 3/3] Documentation/llvm: update CROSS_COMPILE inferencing From: Nick Desaulniers To: Masahiro Yamada Cc: Miguel Ojeda , Fangrui Song , Michal Marek , Arnd Bergmann , linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, clang-built-linux@googlegroups.com, Geert Uytterhoeven , Christoph Hellwig , Linus Torvalds , Nick Desaulniers Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org As noted by Masahiro, document how we can generally infer CROSS_COMPILE (and the more specific details about --target and --prefix) based on ARCH. Change use of env vars to command line parameters. Suggested-by: Masahiro Yamada Reviewed-by: Fangrui Song Signed-off-by: Nick Desaulniers Reviewed-by: Nathan Chancellor --- Changes v5 -> v6: * Pick up Fangrui's RB tag. * Change use of env vars to command line parameters for consistency. Documentation/kbuild/llvm.rst | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Documentation/kbuild/llvm.rst b/Documentation/kbuild/llvm.rst index b18401d2ba82..f8a360958f4c 100644 --- a/Documentation/kbuild/llvm.rst +++ b/Documentation/kbuild/llvm.rst @@ -38,7 +38,7 @@ Cross Compiling A single Clang compiler binary will typically contain all supported backends, which can help simplify cross compiling. :: - ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make CC=clang + make ARCH=arm64 CC=clang CROSS_COMPILE=aarch64-linux-gnu- ``CROSS_COMPILE`` is not used to prefix the Clang compiler binary, instead ``CROSS_COMPILE`` is used to set a command line flag: ``--target=``. For @@ -63,6 +63,23 @@ They can be enabled individually. The full list of the parameters: :: Currently, the integrated assembler is disabled by default. You can pass ``LLVM_IAS=1`` to enable it. +Omitting CROSS_COMPILE +---------------------- + +As explained above, ``CROSS_COMPILE`` is used to set ``--target=``. + +Unless ``LLVM_IAS=1`` is specified, ``CROSS_COMPILE`` is also used to derive +``--prefix=`` to search for the GNU assembler and linker. + +If ``CROSS_COMPILE`` is not specified, the ``--target=`` is inferred +from ``ARCH``. + +That means if you use only LLVM tools, ``CROSS_COMPILE`` becomes unnecessary. + +For example, to cross-compile the arm64 kernel:: + + make ARCH=arm64 LLVM=1 LLVM_IAS=1 + Supported Architectures -----------------------