Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp36916pxb; Thu, 21 Jan 2021 00:12:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJyqniTksvax6hlX/YIVp5vCo/Bn+EO9eU1mtDmk/ng9cUsD973RfALRFqnUVRGVS0fDn/FM X-Received: by 2002:a17:907:3fa6:: with SMTP id hr38mr8669368ejc.24.1611216738062; Thu, 21 Jan 2021 00:12:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611216738; cv=none; d=google.com; s=arc-20160816; b=DgXF3gvjlPwMb43oVD2NPq4NpkMRYV8WYLUiuqOvSPjd6vbt1CcZpvtyUUFiJMlgeb mqb7d4STpXW+QSIiDwfrVMN3HEt4F+86aeaWnGVBvygYc35O6zUGy4KV1fTSRIwQ7s5X HF24t+XEQErMTnsy+WV0PzamXSouu6rIbpR8f8G8lBIritqOxmL+NHw0KBOCAD7t2D8h 7IMLCCCh/RkgDLVrnRvwg0Pa8t4Zgs/heESu0Wqs3GbeGmt3prz97L6LF8moW+MB8z3n 4m1q6ZfFJNKEgjJWxqvB+47lZNtUrT+WbC62YT6uJ2TgJQz+gWCqFhLMjJkaHEKd4HW0 HXTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=oobkTWZTECnkORfzKz+9DkXYOma+YaOrTTEwIwnDNH8=; b=YHhNbazLkpBPj6huA+JiC1sj4YcPGsE78gAK1N0dWEdWVpXO4hWcVm/WdVSzzM73z2 0SpGts8PVs778Ux7W+HieGYk3HSnrgtjpSreCe6SyOlZJ69zt6vuiRNLpY2cEJLj56Bj Mi7dVBj0szvDFfW5EDv4u6C1KpYItk+FfRq6hpl5VPphRpos6r5qIC+VzXp/n9mopQWG h7U/Vz36JMIHOkVRNNmfNtm8uN1fUopz8H2BUisD2za+7F4wRPKeXCl93aQHH6AyUK5d wdPfDzFcU/9hfxXiQExOA0ofhAmNw4FVloY/Tj4/Fski6vuNR500ZCCG6BFZelZR8ctg 0t1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=i68+xYFE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z2si1502937eja.539.2021.01.21.00.11.53; Thu, 21 Jan 2021 00:12:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=i68+xYFE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727376AbhAUIJt (ORCPT + 99 others); Thu, 21 Jan 2021 03:09:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726540AbhAUIJX (ORCPT ); Thu, 21 Jan 2021 03:09:23 -0500 Received: from mail-yb1-xb2b.google.com (mail-yb1-xb2b.google.com [IPv6:2607:f8b0:4864:20::b2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE8F3C061575; Thu, 21 Jan 2021 00:08:42 -0800 (PST) Received: by mail-yb1-xb2b.google.com with SMTP id y4so1249026ybn.3; Thu, 21 Jan 2021 00:08:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=oobkTWZTECnkORfzKz+9DkXYOma+YaOrTTEwIwnDNH8=; b=i68+xYFE4asEvnU0olUlCe9tm+PQeJevoOK4wTwadHBtORItM9WdTOu3uY3Bq7VHqv dA7npENVOBzKBYblDVhbIZshaWW517HKXnRNYSo+0qDYCuuzci3PCUNAnNDaUyNXLhGy 900VrPprFcyGvqkf30hguRWP7jzA6p97etS34BxEKlDZihKgvjuTIxMycXpnQAVp7Z0J 8H0kQdakt7vAwP/MVSocmyPzpQe25pTKe6F2vBpJkcasQu9NqoFX9AyTJZFFSesThba1 G84Uf0HoL3ZQE1s13G1OVpBEqrQXNOHpGZnPzu3wy8JukWjWIp3Q3ClcEPZ1BT7EzV5c 8tBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=oobkTWZTECnkORfzKz+9DkXYOma+YaOrTTEwIwnDNH8=; b=PI2tF0luH2xyiElgtPJikueG/slWIqicgT4EOEIggi6QLcEuzP9S3Rwjep3cKq686h lhTAROPxwAfmCz611IptZ3tORL/fOcRv+Jzxi+Q3+5rqlT+JPd7PtbeCVDY9nFaQ5keY UoTWRRCaasA7Xi2REHN5aKhjGlCbIgKyOu9fUyD6AAv+zDQz8RkOb1aT8FKnFr12Kayz djQ5X7eT8Vc4dbTTibAMTppE5689Ub3AfCwX3wNu5EtaXkw+eAvK/S2qjMKB/nchnMY3 sRaAzDTGOIkV9j7beaA6A6iFoADoVP3DXtPlUjw9LQKTAn1uO92m3Df8uLODghC/oyde u8PA== X-Gm-Message-State: AOAM533VWjZBYMAtXFq4Vh90Uqp5ZwEmVj31ILy2xc3IEsone+Cm5j2Y 3aGm4gisbPcItAg0oKx6NMK/MuTVORTQs0o0HZs= X-Received: by 2002:a25:854a:: with SMTP id f10mr17694912ybn.510.1611216522128; Thu, 21 Jan 2021 00:08:42 -0800 (PST) MIME-Version: 1.0 References: <1611206855-22555-1-git-send-email-yangtiezhu@loongson.cn> <20210121053627.GA1680146@ubuntu-m3-large-x86> In-Reply-To: <20210121053627.GA1680146@ubuntu-m3-large-x86> From: Andrii Nakryiko Date: Thu, 21 Jan 2021 00:08:31 -0800 Message-ID: Subject: Re: [PATCH bpf-next v3] samples/bpf: Update build procedure for manually compiling LLVM and Clang To: Nathan Chancellor Cc: Tiezhu Yang , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Nick Desaulniers , Networking , bpf , clang-built-linux , open list , Xuefeng Li , Fangrui Song Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 20, 2021 at 9:36 PM Nathan Chancellor wrote: > > On Thu, Jan 21, 2021 at 01:27:35PM +0800, Tiezhu Yang wrote: > > The current LLVM and Clang build procedure in samples/bpf/README.rst is > > out of date. See below that the links are not accessible any more. > > > > $ git clone http://llvm.org/git/llvm.git > > Cloning into 'llvm'... > > fatal: unable to access 'http://llvm.org/git/llvm.git/': Maximum (20) redirects followed > > $ git clone --depth 1 http://llvm.org/git/clang.git > > Cloning into 'clang'... > > fatal: unable to access 'http://llvm.org/git/clang.git/': Maximum (20) redirects followed > > > > The LLVM community has adopted new ways to build the compiler. There are > > different ways to build LLVM and Clang, the Clang Getting Started page [1] > > has one way. As Yonghong said, it is better to copy the build procedure > > in Documentation/bpf/bpf_devel_QA.rst to keep consistent. > > > > I verified the procedure and it is proved to be feasible, so we should > > update README.rst to reflect the reality. At the same time, update the > > related comment in Makefile. > > > > Additionally, as Fangrui said, the dir llvm-project/llvm/build/install is > > not used, BUILD_SHARED_LIBS=OFF is the default option [2], so also change > > Documentation/bpf/bpf_devel_QA.rst together. > > > > [1] https://clang.llvm.org/get_started.html > > [2] https://www.llvm.org/docs/CMake.html > > > > Signed-off-by: Tiezhu Yang > > Acked-by: Yonghong Song > > Reviewed-by: Nathan Chancellor > > Small comment below. > > > --- > > > > v2: Update the commit message suggested by Yonghong, > > thank you very much. > > > > v3: Remove the default option BUILD_SHARED_LIBS=OFF > > and just mkdir llvm-project/llvm/build suggested > > by Fangrui. > > > > Documentation/bpf/bpf_devel_QA.rst | 3 +-- > > samples/bpf/Makefile | 2 +- > > samples/bpf/README.rst | 16 +++++++++------- > > 3 files changed, 11 insertions(+), 10 deletions(-) > > > > diff --git a/Documentation/bpf/bpf_devel_QA.rst b/Documentation/bpf/bpf_devel_QA.rst > > index 5b613d2..18788bb 100644 > > --- a/Documentation/bpf/bpf_devel_QA.rst > > +++ b/Documentation/bpf/bpf_devel_QA.rst > > @@ -506,11 +506,10 @@ that set up, proceed with building the latest LLVM and clang version > > from the git repositories:: > > > > $ git clone https://github.com/llvm/llvm-project.git > > - $ mkdir -p llvm-project/llvm/build/install > > + $ mkdir -p llvm-project/llvm/build > > $ cd llvm-project/llvm/build > > $ cmake .. -G "Ninja" -DLLVM_TARGETS_TO_BUILD="BPF;X86" \ > > -DLLVM_ENABLE_PROJECTS="clang" \ > > - -DBUILD_SHARED_LIBS=OFF \ > > -DCMAKE_BUILD_TYPE=Release \ > > -DLLVM_BUILD_RUNTIME=OFF > > $ ninja > > diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile > > index 26fc96c..d061446 100644 > > --- a/samples/bpf/Makefile > > +++ b/samples/bpf/Makefile > > @@ -208,7 +208,7 @@ TPROGLDLIBS_xdpsock += -pthread -lcap > > TPROGLDLIBS_xsk_fwd += -pthread > > > > # Allows pointing LLC/CLANG to a LLVM backend with bpf support, redefine on cmdline: > > -# make M=samples/bpf/ LLC=~/git/llvm/build/bin/llc CLANG=~/git/llvm/build/bin/clang > > +# make M=samples/bpf LLC=~/git/llvm-project/llvm/build/bin/llc CLANG=~/git/llvm-project/llvm/build/bin/clang > > LLC ?= llc > > CLANG ?= clang > > OPT ?= opt > > diff --git a/samples/bpf/README.rst b/samples/bpf/README.rst > > index dd34b2d..23006cb 100644 > > --- a/samples/bpf/README.rst > > +++ b/samples/bpf/README.rst > > @@ -65,17 +65,19 @@ To generate a smaller llc binary one can use:: > > Quick sniplet for manually compiling LLVM and clang > > (build dependencies are cmake and gcc-c++):: > > Technically, ninja is now a build dependency as well, it might be worth > mentioning that here (usually the package is ninja or ninja-build). it's possible to generate Makefile by passing `-g "Unix Makefiles"`, which would avoid dependency on ninja, no? > > Regardless of whether that is addressed or not (because it is small), > feel free to carry forward my tag in any future revisions unless they > drastically change. > > > - $ git clone http://llvm.org/git/llvm.git > > - $ cd llvm/tools > > - $ git clone --depth 1 http://llvm.org/git/clang.git > > - $ cd ..; mkdir build; cd build > > - $ cmake .. -DLLVM_TARGETS_TO_BUILD="BPF;X86" > > - $ make -j $(getconf _NPROCESSORS_ONLN) > > + $ git clone https://github.com/llvm/llvm-project.git > > + $ mkdir -p llvm-project/llvm/build > > + $ cd llvm-project/llvm/build > > + $ cmake .. -G "Ninja" -DLLVM_TARGETS_TO_BUILD="BPF;X86" \ > > + -DLLVM_ENABLE_PROJECTS="clang" \ > > + -DCMAKE_BUILD_TYPE=Release \ > > + -DLLVM_BUILD_RUNTIME=OFF > > + $ ninja > > > > It is also possible to point make to the newly compiled 'llc' or > > 'clang' command via redefining LLC or CLANG on the make command line:: > > > > - make M=samples/bpf LLC=~/git/llvm/build/bin/llc CLANG=~/git/llvm/build/bin/clang > > + make M=samples/bpf LLC=~/git/llvm-project/llvm/build/bin/llc CLANG=~/git/llvm-project/llvm/build/bin/clang > > > > Cross compiling samples > > ----------------------- > > -- > > 2.1.0 > >