I'll make this post more polished.
Patch musl per Re: Draft riscv64 TLSDESC implementation
1 |
|
1 | (mkdir -p out/rv64 && cd out/rv64 && ../../configure --target=riscv64-linux-gnu && make -j 50) |
Adjust ~/musl/out/rv64/lib/musl-gcc.specs
and update
~/musl/out/rv64/obj/musl-gcc
1 | cat > ~/musl/out/rv64/obj/musl-gcc <<eof |
Prepare a runtime test mentioned at the end of https://maskray.me/blog/2021-02-14-all-about-thread-local-storage
1 | cat > ./a.c <<eof |
Compile b.c
to bb.s
. Replace
general-dynamic code sequences (e.g.
la.tls.gd a0,tls0; call __tls_get_addr@plt
) with TLSDESC,
e.g.
1 | .Ltlsdesc_hi0: |
Apply LLVM CodeGen/assembly and lld patch (https://github.com/llvm/llvm-project/pull/79099) to
llvm-project. Build clang and lld. Create an alias
bin/ld.lld
to be used with
-Bbin -fuse-ld=lld
.
bmake run
=> succeeded!
1 | % bmake run |