From patchwork Tue Feb 15 20:49:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Desaulniers X-Patchwork-Id: 12747613 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 504DDC433EF for ; Tue, 15 Feb 2022 20:49:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241337AbiBOUuF (ORCPT ); Tue, 15 Feb 2022 15:50:05 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:37824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231775AbiBOUuD (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 E6205BC14 for ; Tue, 15 Feb 2022 12:49:51 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id h6-20020a253a06000000b0061de83305f2so43179032yba.19 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=mdlM9suhNxJ5FlrZEeiXjC6hzuoKJJW/epLUuq+SGzd+J0NJRwO2fhv0nU/SdCwE9r I4NRaZbyJ1KgkoV34+EPS2dDI/13yW2eQaiVC8uK2Ly4I02YpuRrZ8qKeb93EisxuBOx xq9Gc2dEC+0a/GCX4kZppwJOYnrrTd2aU+oJH3q2iDOV20jKt1Oox64zbrm/qnUUnLu8 5cttgkt1+7SMoRGwFESttiSVwBSgV9AQNHAoRk4lIQ1jxKE7phn8y9bLwxMle5ryWj6A 9rtpBeEZXy+wwtZE3RyENaDd4Y0VxnZCI3rPxGszyry+iyrOHigcYn8R1inodXJaJtJy woyQ== X-Gm-Message-State: AOAM532D2Osmkz50CLMyGSoyn/JZ64YGJyhtan6Bb9AV3ltA/+NIC4oS gJyyWRpi55gdR0IBYhoo6bwUmE3dLpMAfO6TZ/Y= X-Google-Smtp-Source: ABdhPJzP9ryL032NQtZ90yOl34xGEV9EIKEu/dsnCdcGdVufhTNhFh8paAmrE7BnYvSQ/nYsBzO5GcuJqvTablHmSFk= 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 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@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(-) base-commit: c5d9ae265b105d9a67575fb67bd4650a6fc08e25 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``