Force Clang use the initial-exec TLS model instead of the default
local-exec when building code for Serenity.
This patch should be removed when the SerenityOS program loader
implements proper TLS support.
Depends on D154396
Differential D154397
[Driver] Default to -ftls-model=initial-exec on SerenityOS ADKaster on Jul 3 2023, 6:51 PM. Authored by
Details
Force Clang use the initial-exec TLS model instead of the default This patch should be removed when the SerenityOS program loader Depends on D154396
Diff Detail
Event TimelineComment Actions Fair enough, the original patch had "probably don't upstream this" in the commit description. @BertalanD mentioned to me on discord that he had a WIP patch for proper TLS on x86_64 and aarch64 cooking already . I'll drop this one and by the time the series lands we'll most likely have the TLS support in serenity already (or we can add it to the default clang args we already use for setting --sysroot for Ports). Comment Actions I don't think this belongs to the upstream, either. Note: musl's TLS implementation is very clean and may be a good reference. https://maskray.me/blog/2021-02-14-all-about-thread-local-storage
glibc's model makes it very error-prone, even if dlopen TLS is supported to some extent. Comment Actions Hi MaskRay! Your blog post (alongside the Drepper TLS doc) proved to be a very helpful resource for our implementation of the dynamic TLS interface. I currently have a SerenityOS PR open that implements __tls_get_addr and TLSDESC on top of our current TLS infrastructure which only supports static TLS blocks. (Long story short, our loader passes the initial TLS image to the kernel, which automagically copies it over and sets up the thread pointer whenever a new thread is created. We need to move it to the userspace if we want to have a dynamic thread vector and separately allocated TLS blocks). I'd love it if you'd take a look at the PR. |