summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Bertalan <dani@danielbertalan.dev>2021-10-06 22:47:39 +0200
committerLinus Groh <mail@linusgroh.de>2021-10-17 17:09:58 +0100
commitc524f5829050c94d5bc286e8a7994b7be0ce2de9 (patch)
tree98fdf55a97d82674b859472e01e38088f78e3390
parent95c32fdf19adbc94223c8a288f72e9c3d71aaba5 (diff)
downloadserenity-c524f5829050c94d5bc286e8a7994b7be0ce2de9.zip
Toolchain: Introduce stubs for core system libraries
This allows the linker to link against these dynamic libraries when compiling libc++/libunwind, without having to do a separate bootstrapping LibC build. Without this change, libc++ would fail to pick up the need to link to `LibPthread` if no prior builds of it existed. Because of this, we'd immediately have an assertion failure in SystemServer, as mutexes are used for the safe construction of function-local static variables.
-rw-r--r--Toolchain/Stubs/README.md21
-rw-r--r--Toolchain/Stubs/i686clang/libc.sobin0 -> 67712 bytes
-rw-r--r--Toolchain/Stubs/i686clang/libdl.sobin0 -> 996 bytes
-rw-r--r--Toolchain/Stubs/i686clang/libm.sobin0 -> 4852 bytes
-rw-r--r--Toolchain/Stubs/i686clang/libpthread.sobin0 -> 4952 bytes
-rw-r--r--Toolchain/Stubs/x86_64clang/libc.sobin0 -> 80216 bytes
-rw-r--r--Toolchain/Stubs/x86_64clang/libdl.sobin0 -> 1384 bytes
-rw-r--r--Toolchain/Stubs/x86_64clang/libm.sobin0 -> 6520 bytes
-rw-r--r--Toolchain/Stubs/x86_64clang/libpthread.sobin0 -> 6160 bytes
9 files changed, 21 insertions, 0 deletions
diff --git a/Toolchain/Stubs/README.md b/Toolchain/Stubs/README.md
new file mode 100644
index 0000000000..c5bfe89a57
--- /dev/null
+++ b/Toolchain/Stubs/README.md
@@ -0,0 +1,21 @@
+# Library stubs
+
+This directory contains stubs for SerenityOS libraries (LibC, LibM, LibDl, LibPthread)
+that are referenced from the LLVM runtime libraries. These are needed by the linker
+in order to add the required `DT_NEEDED` entries.
+
+## Do these need to be updated?
+
+Generally, no. LLVM does not use the header files to decide which functionality it can
+use. After adding a new function to a header, you don't have to worry about LLVM
+toolchain builds failing because the symbol is not present in the stubs.
+
+## How to generate these?
+
+First, you need to have a working SerenityOS installation that's been built by the
+Clang toolchain. Then, using the `llvm-ifs` tool, these libraries need to be converted
+into a stripped-down stub form. To do that, run the following command:
+
+```sh
+Toolchain/Local/clang/bin/llvm-ifs --output-format=ELF --output=<path-to-stub> <path-to-original>
+```
diff --git a/Toolchain/Stubs/i686clang/libc.so b/Toolchain/Stubs/i686clang/libc.so
new file mode 100644
index 0000000000..99d7659f48
--- /dev/null
+++ b/Toolchain/Stubs/i686clang/libc.so
Binary files differ
diff --git a/Toolchain/Stubs/i686clang/libdl.so b/Toolchain/Stubs/i686clang/libdl.so
new file mode 100644
index 0000000000..ab3b2af601
--- /dev/null
+++ b/Toolchain/Stubs/i686clang/libdl.so
Binary files differ
diff --git a/Toolchain/Stubs/i686clang/libm.so b/Toolchain/Stubs/i686clang/libm.so
new file mode 100644
index 0000000000..fe2a0a6d56
--- /dev/null
+++ b/Toolchain/Stubs/i686clang/libm.so
Binary files differ
diff --git a/Toolchain/Stubs/i686clang/libpthread.so b/Toolchain/Stubs/i686clang/libpthread.so
new file mode 100644
index 0000000000..557e7200dc
--- /dev/null
+++ b/Toolchain/Stubs/i686clang/libpthread.so
Binary files differ
diff --git a/Toolchain/Stubs/x86_64clang/libc.so b/Toolchain/Stubs/x86_64clang/libc.so
new file mode 100644
index 0000000000..373cbddcec
--- /dev/null
+++ b/Toolchain/Stubs/x86_64clang/libc.so
Binary files differ
diff --git a/Toolchain/Stubs/x86_64clang/libdl.so b/Toolchain/Stubs/x86_64clang/libdl.so
new file mode 100644
index 0000000000..18638c1063
--- /dev/null
+++ b/Toolchain/Stubs/x86_64clang/libdl.so
Binary files differ
diff --git a/Toolchain/Stubs/x86_64clang/libm.so b/Toolchain/Stubs/x86_64clang/libm.so
new file mode 100644
index 0000000000..16cc84faef
--- /dev/null
+++ b/Toolchain/Stubs/x86_64clang/libm.so
Binary files differ
diff --git a/Toolchain/Stubs/x86_64clang/libpthread.so b/Toolchain/Stubs/x86_64clang/libpthread.so
new file mode 100644
index 0000000000..cf839e8d80
--- /dev/null
+++ b/Toolchain/Stubs/x86_64clang/libpthread.so
Binary files differ