Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp295255pxb; Tue, 15 Feb 2022 13:34:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJyQ9dylY/OOCcxGSQL4bXDyjbs/ygzLHsVIvJ9v4rBUmAFUEJfLGMOS+ASQwsyX87WSFOgm X-Received: by 2002:a05:6402:2802:: with SMTP id h2mr906481ede.255.1644960861622; Tue, 15 Feb 2022 13:34:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644960861; cv=none; d=google.com; s=arc-20160816; b=j3cEdVuMy6eMTRo5LgIHtRwZnaAosvawtTXJaAK5s6p6p6/Et1NDe0xrCchtW5v1Q7 IJQtYEBxJ/C900EtUR/cAZVU/GMdkZEiMtbEuhWHKXLwAhMpg/3F5UQ2fwAhzKXBqkE4 6z7+nlqdDDCJZk4QHMYzzx7Cl2yPV9ZhedFYsGkWozZ9CJ1f5Edw4F3B+uaVOkGQmcRo 7xmktbNBo7iZx2ciSC4qIHNb0tjyQbWSNLBRStzcLIHslpggu0nVhqL6uPN7SXMdlNc6 K/2sn+VDOy7ra+u46y1NjevYmiKi6ID+JWEYc8y0SID4J2mJe4dKIzZmj8PncPk6cWHN 9sTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:mime-version:message-id:date :dkim-signature; bh=BSIelYmbPm1PuRZo7j2Bm2YpHBp5n2KMNsW2+koRF9o=; b=C3mJTssmwKacoX80vzoDDAHSj+yp2FJA6T6OZ0eE1CWhj/K7o+zAnGvPnB15Hz6W5W COKaf4Bb8N8+VTZVaGazpeRM64whjCF/5b8l+6cwBMzY3eNPH2Cyre0xY5yHttIcI4g7 G5TYgQ6Xxsg1B+3jChu5tvEJK87dknw2sQ8aU2Hy8sX53cHu9jEvmqXWT3JPYAtWipym +4TYL/5+jZ7o0iboO5BVqxO8ZCXqVHB3wMTfhc0JnQ1ePur2B1/dA6w/xmw5oZINfP3m 6DPdp5ppK1wb7Atp9HmkVXy/Sv7YXuR99zzhNCU3Q/DdhCPPLYA8Q2Yuep44MXuOV0UR g8CQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=OmOAzde3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bw8si15647828ejb.412.2022.02.15.13.33.58; Tue, 15 Feb 2022 13:34:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=OmOAzde3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243063AbiBOUuH (ORCPT + 99 others); Tue, 15 Feb 2022 15:50:07 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:37822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236924AbiBOUuD (ORCPT ); Tue, 15 Feb 2022 15:50:03 -0500 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E61B0BC11 for ; Tue, 15 Feb 2022 12:49:51 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id b187-20020a251bc4000000b0061e15c5024fso42976953ybb.4 for ; Tue, 15 Feb 2022 12:49:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=BSIelYmbPm1PuRZo7j2Bm2YpHBp5n2KMNsW2+koRF9o=; b=OmOAzde3hQuPTuUUuGTkKQgKqvdyaE/pxNZKEZAB5iLQVTOdo20BMzFWWZZl5ZbEuO sd1n997b8ys5m/fBIWHZk3R3yVqnEhs3ac+tNR/QL3TbIKDeDc62lEtuIZ+MTihDeNt+ /uMoEIQYhieWPpxjXMGJrySmFhr6E2Pz2jG4b9ZqxnGNp3uMfAKLGZPE310w3JihB6Ib OYleI1I1Od0cR5gz1VdeuTIKI4KRWWERhthYNiBNlzzfeN6M5islxffXtHWTDYPL/OBP oNw/HgJ2MVEPIIkZWMx+JbBuobi/Fc76/A58iX0Jry+a8W5t3vfGgWIhQw5UpJEYFWQ0 sjpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=BSIelYmbPm1PuRZo7j2Bm2YpHBp5n2KMNsW2+koRF9o=; b=hOfGx4JoKF3WVAxSuKBa6qcB9rwkOtJDPIXZBue0B/9ajs5j18Xd/NdMLMqgtfkMON AoeB4C5ySOSG5nVXnrxBxx6TIy79AhFe20sUcfnKgvQykwLwibE46wctmcHU8kcIgWrb 2P2YkSgbPRDBM8cxgclf7sGAft0vzvgqcoKSPK8xxrCZvy1QpPjnGq43c1Glrr1JQTp7 CNBSTy5MZPFmHkN3jrnxqOGVKfjCeP/l9MqfITS0Gw69u3Dl4xQwn28W3dHB7WY47BcV VDsmBLpX0qmX3lj+53sy3N1Y+yFDq/W2gH3+E7gfc6faf4h9STrP25yMzb9SslzDK3GJ 5LOg== X-Gm-Message-State: AOAM5307dEj1DHcK8KotiYnHcSy1ef9Cs/pAK1k9LpVQh28cUaIdeDi0 A4MP6Fb2Id55TYDhjW/fIPKE2dwGqY0XGldEhyM= X-Received: from ndesaulniers1.mtv.corp.google.com ([2620:15c:211:202:dfad:458b:9fb2:b77a]) (user=ndesaulniers job=sendgmr) by 2002:a81:c501:: with SMTP id k1mr756814ywi.116.1644958191153; Tue, 15 Feb 2022 12:49:51 -0800 (PST) Date: Tue, 15 Feb 2022 12:49:47 -0800 Message-Id: <20220215204947.1719516-1-ndesaulniers@google.com> Mime-Version: 1.0 X-Developer-Key: i=ndesaulniers@google.com; a=ed25519; pk=lvO/pmg+aaCb6dPhyGC1GyOCvPueDrrc8Zeso5CaGKE= X-Developer-Signature: v=1; a=ed25519-sha256; t=1644958187; l=6237; s=20211004; h=from:subject; bh=KRPwLsTNNlHCWxCWXknX1SGak/+wjdb7pX5i8pARYhc=; b=MLcVqidAwW+ao1oHaVwGiibzFPdmdQSKX4iTNyUvI6u4uHIfv8BAO/pUH3DozcXFBD7mf8xaLcnQ OQKIrOg2BJTK0EvgDF4JpA04IH8tfxy/EXcxeGbLFrXi3Wg8qg0f X-Mailer: git-send-email 2.35.1.265.g69c8d7142f-goog Subject: [PATCH] Documentation/llvm: refresh docs for LLVM=1 From: Nick Desaulniers To: Masahiro Yamada , Jonathan Corbet , Andrew Morton Cc: Miguel Ojeda , Yujie Liu , Philip Li , julie.du@intel.com, Nick Desaulniers , Nathan Chancellor , Michal Marek , llvm@lists.linux.dev, linux-kbuild@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Refresh the docs for 2022: * add link to Chimera Linux. * add Quick Start section pointing out that LLVM=1 is the simple recommended method. * Re-order the sections on Clang and Cross Compiling to come after the section on LLVM utilities. I think the documentation flows better this way. * Add note about LLVM=1 to Omitting CROSS_COMPILE section. * Change note in Supported Architectures from discussing CC=clang vs. LLVM=1 to discussion LLVM=1 vs. LLVM_IAS=0. * Update make command column of support architecture table; we now support LLVM=1 everywhere; just some more work to get ARCH=s390 assembling with clang. * Word wrap a few columns over 80 lines. Signed-off-by: Nick Desaulniers --- Documentation/kbuild/llvm.rst | 82 +++++++++++++++++++++-------------- 1 file changed, 50 insertions(+), 32 deletions(-) diff --git a/Documentation/kbuild/llvm.rst b/Documentation/kbuild/llvm.rst index d32616891dcf..7f52cde70bc7 100644 --- a/Documentation/kbuild/llvm.rst +++ b/Documentation/kbuild/llvm.rst @@ -15,36 +15,27 @@ such as GCC and binutils. Ongoing work has allowed for `Clang `_ and `LLVM `_ utilities to be used as viable substitutes. Distributions such as `Android `_, `ChromeOS -`_, and `OpenMandriva -`_ use Clang built kernels. `LLVM is a +`_, `OpenMandriva +`_, and `Chimera Linux +`_ use Clang built kernels. `LLVM is a collection of toolchain components implemented in terms of C++ objects `_. Clang is a front-end to LLVM that supports C and the GNU C extensions required by the kernel, and is pronounced "klang," not "see-lang." -Clang ------ +Quick Start +----------- +:: -The compiler used can be swapped out via ``CC=`` command line argument to ``make``. -``CC=`` should be set when selecting a config and during a build. :: + make LLVM=1 - make CC=clang defconfig +for native builds or - make CC=clang +or :: -Cross Compiling ---------------- + ARCH=arm64 make LLVM=1 -A single Clang compiler binary will typically contain all supported backends, -which can help simplify cross compiling. :: - - 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 -example: :: - - clang --target=aarch64-linux-gnu foo.c +for cross compiling. LLVM Utilities -------------- @@ -63,6 +54,32 @@ They can be enabled individually. The full list of the parameters: :: The integrated assembler is enabled by default. You can pass ``LLVM_IAS=0`` to disable it. +Clang +----- + +The compiler used can be swapped out via ``CC=`` command line argument to +``make``. ``CC=`` should be set when selecting a config and during a build. +``CC=clang`` is implied by ``LLVM=1``, but if it's desired to simply use clang +as the compiler for the target, then ``CC=`` is a quick substitute. :: + + make CC=clang defconfig + + make CC=clang + +Cross Compiling +--------------- + +A single Clang compiler binary will typically contain all supported backends, +which can help simplify cross compiling. :: + + 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 example: :: + + clang --target=aarch64-linux-gnu foo.c + Omitting CROSS_COMPILE ---------------------- @@ -71,7 +88,8 @@ As explained above, ``CROSS_COMPILE`` is used to set ``--target=``. If ``CROSS_COMPILE`` is not specified, the ``--target=`` is inferred from ``ARCH``. -That means if you use only LLVM tools, ``CROSS_COMPILE`` becomes unnecessary. +That means if you use only LLVM tools via ``LLVM=1``, ``CROSS_COMPILE`` becomes +unnecessary. For example, to cross-compile the arm64 kernel:: @@ -88,13 +106,13 @@ Supported Architectures LLVM does not target all of the architectures that Linux supports and just because a target is supported in LLVM does not mean that the kernel will build or work without any issues. Below is a general summary of -architectures that currently work with ``CC=clang`` or ``LLVM=1``. Level -of support corresponds to "S" values in the MAINTAINERS files. If an -architecture is not present, it either means that LLVM does not target -it or there are known issues. Using the latest stable version of LLVM or -even the development tree will generally yield the best results. -An architecture's ``defconfig`` is generally expected to work well, -certain configurations may have problems that have not been uncovered +architectures that currently work with ``LLVM=1`` but may need the integrated +assembler disabled via ``LLVM_IAS=0``. Level of support corresponds to "S" +values in the MAINTAINERS files. If an architecture is not present, it either +means that LLVM does not target it or there are known issues. Using the latest +stable version of LLVM or even the development tree will generally yield the +best results. An architecture's ``defconfig`` is generally expected to work +well, certain configurations may have problems that have not been uncovered yet. Bug reports are always welcome at the issue tracker below! .. list-table:: @@ -112,16 +130,16 @@ yet. Bug reports are always welcome at the issue tracker below! - ``LLVM=1`` * - mips - Maintained - - ``CC=clang`` + - ``LLVM=1`` * - powerpc - Maintained - - ``CC=clang`` + - ``LLVM=1`` * - riscv - Maintained - - ``CC=clang`` + - ``LLVM=1`` * - s390 - Maintained - - ``CC=clang`` + - ``LLVM=1 LLVM_IAS=0`` * - x86 - Supported - ``LLVM=1`` base-commit: c5d9ae265b105d9a67575fb67bd4650a6fc08e25 -- 2.35.1.265.g69c8d7142f-goog