[all-commits] [llvm/llvm-project] 4057f8: [libc] Move Linux TLS routines from crt1.o into li...
Jeff Bailey via All-commits
all-commits at lists.llvm.org
Tue Sep 22 22:47:01 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 4057f8e45b7fcadf99b60763c873802f8add8770
https://github.com/llvm/llvm-project/commit/4057f8e45b7fcadf99b60763c873802f8add8770
Author: Jeff Bailey <jbailey at raspberryginger.com>
Date: 2026-09-23 (Wed, 23 Sep 2026)
Changed paths:
M libc/config/linux/app.h
M libc/src/__support/threads/linux/CMakeLists.txt
A libc/src/__support/threads/linux/aarch64/CMakeLists.txt
A libc/src/__support/threads/linux/aarch64/tls.cpp
A libc/src/__support/threads/linux/riscv/CMakeLists.txt
A libc/src/__support/threads/linux/riscv/tls.cpp
A libc/src/__support/threads/linux/x86_64/CMakeLists.txt
A libc/src/__support/threads/linux/x86_64/tls.cpp
M libc/startup/linux/CMakeLists.txt
M libc/startup/linux/aarch64/CMakeLists.txt
R libc/startup/linux/aarch64/tls.cpp
M libc/startup/linux/do_start.cpp
M libc/startup/linux/riscv/CMakeLists.txt
R libc/startup/linux/riscv/tls.cpp
M libc/startup/linux/x86_64/CMakeLists.txt
R libc/startup/linux/x86_64/tls.cpp
Log Message:
-----------
[libc] Move Linux TLS routines from crt1.o into libc.a (#225418)
init_tls, cleanup_tls, and set_thread_ptr are per-thread routines used
by both Thread::run in libc.a and main-thread startup in crt1.o, but
tls.cpp was previously only merged into crt1.o. Linking libc.a without
crt1.o (such as a self-contained shared library statically linking
libc.a, or an executable built with -nostartfiles) failed with undefined
hidden symbols when thread.cpp.o was pulled in.
Move {x86_64,aarch64,riscv}/tls.cpp from libc/startup/linux/ to
libc/src/__support/threads/linux/ alongside tcb.h (matching prior
migrations of auxv and program_invocation_name from startup into src so
dependencies flow from startup -> src). Expose them via a forwarding
ALIAS target libc.src.__support.threads.linux.tls depended on by both
thread and do_start, and remove tls from merge_relocatable_object(crt1).
Mark init_tls with [[gnu::flatten]] and compile tls with
${libc_opt_high_flag}. Once tls.cpp.o is in libc.a rather than first on
the link line inside crt1.o, an earlier object compiled with
-fstack-protector-strong can otherwise win COMDAT selection for
LIBC_INLINE helpers (e.g. linux_syscalls::getrandom) in -O0 builds and
read %fs:0x28 before set_thread_ptr initializes the thread pointer.
Change AppProperties app in libc/config/linux/app.h from extern
[[gnu::weak]] (which resolved to NULL without crt1.o) to
LIBC_INLINE_VAR, providing a COMDAT-deduplicated .bss definition shared
by crt1.o and libc.a, matching auxv::value.
Assisted-by: Automated tooling, human reviewed.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list