Issue created by Sebastian Huber: https://gitlab.rtems.org/rtems/rtos/rtems/-/work_items/5753
The compiler reads the thread pointer with `rdhwr $3, $29` for every access to a thread-local object. The instruction exists since MIPS32r2. The R3900 of `mips/jmr3904` raises a reserved instruction exception instead, so RTEMS emulates the instruction in `mips_emulate_rdhwr_ulr()` of `bsps/mips/shared/irq/vectorexceptions.c`. No compiler option avoids this. `mips-rtems7-gcc` 15.2.0 emits the instruction under every value of `-ftls-model`. It emits it for `-march=r3900` as well, wrapped in `.set push`, `.set mips32r2` and `.set pop`. The MIPS backend has no `-mtp=` option. The ARM port shows the shape of the fix. `-mtp=soft` makes the compiler emit a call of `__aeabi_read_tp()`, and RTEMS supplies that function in `cpukit/score/cpu/arm/__aeabi_read_tp.c`. Give the MIPS backend of GCC the same option. Add the helper to `cpukit/score/cpu/mips/`. It returns the thread pointer of the executing thread, like the ARM and the MicroBlaze helpers do. Put the option in the `ABI_FLAGS` of every MIPS BSP, so an application object carries it too. `_CPU_Use_thread_local_storage()` then has nothing to do. `mips_emulate_rdhwr_ulr()` and the reserved instruction case of `mips_vector_exceptions()` go away. The general dynamic model is the alternative. The compiler emits a call of `__tls_get_addr()` for every access, which is what the MicroBlaze port uses. It costs more. The change touches the TLS relocations, and the linker relaxes a general dynamic sequence to local exec in a static link. That relaxation emits `rdhwr` again. Found in the review of merge request !1401 by Kinsey Moore. This description was created with Claude Code assistance. -- View it on GitLab: https://gitlab.rtems.org/rtems/rtos/rtems/-/work_items/5753 You're receiving this email because of your account on gitlab.rtems.org. Unsubscribe from this thread: https://gitlab.rtems.org/-/sent_notifications/5-8vjt45fk72e4wq1wgore65ynz-1d/unsubscribe | Manage all notifications: https://gitlab.rtems.org/-/profile/notifications | Help: https://gitlab.rtems.org/help
_______________________________________________ bugs mailing list [email protected] http://lists.rtems.org/mailman/listinfo/bugs
