Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build-llvm.py: Utilize LLVM_DISTRIBUTION_COMPONENTS to build fewer targets #243

Merged
merged 2 commits into from
Sep 23, 2023

Conversation

MaskRay
Copy link
Member

@MaskRay MaskRay commented Sep 22, 2023

build/llvm/bootstrap/bin/ contains a lot of LLVM and Clang tools that are not needed to build the kernel or later stages of Clang. Utilize LLVM_DISTRIBUTION_COMPONENTS to build fewer targets for 'bootstrap' and 'instrumented'. The final directory still contains everything.

When BOLT is disabled, we now just build the following executables:

% ls build/llvm/bootstrap/bin/
clang@     clang-cpp@     llvm-ar*          llvm-objcopy*   llvm-readelf@  wasm-ld@
clang++@   clang-tblgen*  llvm-lit*         llvm-objdump*   llvm-readobj*  ld64.lld@
clang-18*  lld*           llvm-min-tblgen*  llvm-profdata*  llvm-strip@    ld.lld@
clang-cl@  lld-link@      llvm-nm*          llvm-ranlib@    llvm-tblgen*

Tested:
./build-llvm.py --install-folder $PWD/install --projects clang lld --show-build-commands --targets X86 --pgo kernel-defconfig

…rgets

`build/llvm/bootstrap/bin/` contains a lot of LLVM and Clang tools that
are not needed to build the kernel or later stages of Clang. Utilize
LLVM_DISTRIBUTION_COMPONENTS to build fewer targets for 'bootstrap' and
'instrumented'. The `final` directory still contains everything.

When BOLT is disabled, we now just build the following executables:
```
% ls build/llvm/bootstrap/bin/
clang@     clang-cpp@     llvm-ar*          llvm-objcopy*   llvm-readelf@  wasm-ld@
clang++@   clang-tblgen*  llvm-lit*         llvm-objdump*   llvm-readobj*  ld64.lld@
clang-18*  lld*           llvm-min-tblgen*  llvm-profdata*  llvm-strip@    ld.lld@
clang-cl@  lld-link@      llvm-nm*          llvm-ranlib@    llvm-tblgen*
```

Tested:
  ./build-llvm.py --install-folder $PWD/install --projects clang lld --show-build-commands --targets X86 --pgo kernel-defconfig
  ./build-llvm.py --install-folder $PWD/install --projects clang lld --show-build-commands --targets X86 --pgo kernel-defconfig --bolt
Copy link
Member

@nathanchance nathanchance left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot, I am excited to get some better build times from this. One comment below, feel free to address if you want.

tc_build/llvm.py Outdated Show resolved Hide resolved
…lvm-objcopy;llvm-objdump;llvm-readelf;llvm-strip to a list
@MaskRay MaskRay merged commit 796736c into ClangBuiltLinux:main Sep 23, 2023
6 checks passed
@MaskRay MaskRay deleted the slim-bootstrap branch September 23, 2023 05:09
nathanchance added a commit to nathanchance/tc-build that referenced this pull request Oct 2, 2023
… building runtimes

In the instrumented stage of the LLVM build when performing PGO, we set
LLVM_BUILD_RUNTIME to OFF, as recommended by the LLVM documentation:

https://llvm.org/docs/HowToBuildWithPGO.html#building-clang-with-pgo

This breaks adding 'profile' to the distribution components, which was
done in ClangBuiltLinux#243, as shown by the following cmake error:

  $ build-llvm.py \
        --llvm-folder . \
        --pgo kernel-defconfig \
        --projects clang compiler-rt lld \
        --targets X86
  ...
  CMake Error at cmake/modules/LLVMDistributionSupport.cmake:276 (message):
    Specified distribution component 'profile' doesn't have an install target
  Call Stack (most recent call first):
    CMakeLists.txt:1340 (llvm_distribution_add_targets)

  CMake Error at cmake/modules/LLVMDistributionSupport.cmake:284 (message):
    Specified distribution component 'profile' doesn't have an install-stripped
    target.  Its installation target creation should be changed to use
    add_llvm_install_targets, or you should manually create the
    'install-profile-stripped' target.
  Call Stack (most recent call first):
    CMakeLists.txt:1340 (llvm_distribution_add_targets)

compiler-rt is only included when LLVM_BUILD_RUNTIME is ON, so don't
include the 'llvm-profdata' and 'profile' targets when
LLVM_BUILD_RUNTIME is OFF.

Signed-off-by: Nathan Chancellor <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants