brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.1 KiB · 39f0c47 Raw
54 lines · plain
1.. _libc_uefi_building:2 3======================4Building libc for UEFI5======================6 7.. contents:: Table of Contents8  :depth: 49  :local:10 11Building LLVM libc for UEFI12===========================13 14This document will present recipes to build the LLVM C library for UEFI.15UEFI builds use the same :ref:`cross build<full_cross_build>` support as16the other targets. However, the UEFI target has the restriction that it *must*17be built with an up-to-date ``clang`` compiler. This is because UEFI support18in ``clang`` is still an experimental feature.19 20Currently, it is only possible to build LLVM libc for UEFI for ``x86_64``21CPUs. This is due to the target not being enabled for ``aarch64`` and22``riscv64``.23 24Once you have finished building, refer to :ref:`libc_uefi_usage` to get started25with the newly built C library.26 27Standard runtimes build28-----------------------29 30The simplest way to build for UEFI is to use the existing LLVM runtimes31support. This will automatically handle bootstrapping an up-to-date ``clang``32compiler and use it to build the C library. The following CMake invocation33will instruct it to build the ``libc`` runtime targeting ``x86_64`` CPUs.34 35.. code-block:: sh36 37   $> cd llvm-project  # The llvm-project checkout38   $> mkdir build39   $> cd build40   $> cmake ../llvm -G Ninja                                                 \41      -DLLVM_ENABLE_PROJECTS="clang;lld"                                     \42      -DCMAKE_BUILD_TYPE=<Debug|Release>  \ # Select build type43      -DCMAKE_INSTALL_PREFIX=<PATH>       \ # Where the libraries will live44      -DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-unknown-uefi-llvm                  \45      -DLLVM_RUNTIME_TARGETS=x86_64-unknown-uefi-llvm                        \46      -DRUNTIMES_x86_64-unknown-uefi-llvm_LLVM_ENABLE_RUNTIMES=libc          \47      -DRUNTIMES_x86_64-unknown-uefi-llvm_LLVM_LIBC_FULL_BUILD=true          \48   $> ninja install49 50We need ``clang`` to build the UEFI C library and ``lld`` to link UEFI PE51executables, so we enable them in ``LLVM_ENABLE_PROJECTS``. We then set52``RUNTIMES_<triple>_LLVM_ENABLE_RUNTIMES`` to enable ``libc`` for the UEFI53targets.54