diff --git a/libc/startup/linux/riscv/start.cpp b/libc/startup/linux/riscv/start.cpp --- a/libc/startup/linux/riscv/start.cpp +++ b/libc/startup/linux/riscv/start.cpp @@ -80,7 +80,11 @@ } static void set_thread_ptr(uintptr_t val) { +#ifdef LIBC_TARGET_ARCH_IS_RISCV32 + LIBC_INLINE_ASM("lw tp, %0\n\t" : : "m"(val)); +#else // LIBC_TARGET_ARCH_IS_RISCV64 LIBC_INLINE_ASM("ld tp, %0\n\t" : : "m"(val)); +#endif } using InitCallback = void(int, char **, char **);