ladybird/Toolchain/Stubs
Dan Klishch fa1eef8bbe Toolchain: Update LLVM to 18.1.3
Apart from bumping the toolchain Clang's and port's version, this commit
completely overhauls the way LLVM toolchain is built.

First, it gets rid of a complicated two-stage process of first compiling
clang and compiler-rt builtins and then building libunwind, libc++abi,
and libc++ -- it is possible to create a complete cross-compilation
toolchain in a single CMake invocation with a modern LLVM. Moreover, the
old method was inherently unsupported and subtly broken.

Next, it utilizes full potential of the Stubs "framework". Now we are
even able to compile Clang with -Wl,-z,defs which makes one of the
patches obsolete and the whole installation less error-prone. Note that
it comes at a cost of complicating the bootstrap process on a completely
novel architecture but this hopefully won't happen often.

Lastly, it fixes handling of the -no*lib* family of flags in the
Serenity LLVM driver and correctly uses -nostartfiles in conjunction
with stubs to make necessary CMake configure-time checks succeed.
2024-04-18 13:14:33 -06:00
..
aarch64 Toolchain: Update LLVM to 18.1.3 2024-04-18 13:14:33 -06:00
riscv64 Toolchain: Update LLVM to 18.1.3 2024-04-18 13:14:33 -06:00
x86_64 Toolchain: Update LLVM to 18.1.3 2024-04-18 13:14:33 -06:00
README.md Toolchain: Update LLVM to 18.1.3 2024-04-18 13:14:33 -06:00

Library stubs

This directory contains stubs for SerenityOS's LibC that are referenced from the LLVM runtime libraries. These are needed by the linker in order to add the required DT_NEEDED entries and to not emit errors regarding undefiend libc symbols. Additionally, it provides fake empty libunwind.so and libc++.so for CMake configuration checks to succeed when bootstrapping the OS.

Do these need to be updated?

Most likely no but it depends. Either way, if you are reading this, you are probably qualified enough to figure out if a failing LLVM toolchain configuration or build is caused by an out-of-date LibC stub.

How to generate LibC stub?

First, you need to compile the LLVM toolchain and the SerenityOS's LibC. This will be a bit awkward (see discussion at https://github.com/SerenityOS/serenity/pull/23960) until (unless) we solve the dependency cycle between LibC and libunwind. Then, using the llvm-ifs tool, Userland/Libraries/LibC/libc.so can be converted into a stripped-down stub form. To do that, run the following command:

Toolchain/Local/clang/bin/llvm-ifs --output-elf=<path-to-stub> <path-to-original>

How to generate empty.so?

Simple, my friend:

touch empty.cpp
Toolchain/Local/clang/bin/clang++ --target={arch}-pc-serenity -nostdlib -shared empty.cpp -o empty.so
# And optionally,
Toolchain/Local/clang/bin/llvm-strip empty.so