thread local storage related issues
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
SBCL |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
Upon further digging, this issue is not unique to Android.
gcc 14 complains on linux/arm64:
/root/sbcl/
: unsupported relocation
collect2: error: ld returned 1 exit status
And there is a report about monitor.c 's compilation error:
https:/
----
make-android.sh fails with higher (official recommended) version of NDK.
error message since 562a1a329ae9d23
ld.lld: error: relocation R_AARCH64_
>>> defined in thread.pic.o
>>> referenced by arm64-assem.S:153
>>> arm64-assem.
clang-17: error: linker command failed with exit code 1 (use -v to see invocation)
This is probably due to GNU binutils is deprecated (GNU ld being replaced by clang's ld) since NDK version 22. (however, I suspect that the old relocation
would not work properly in PIC mode).
error message since f082b007bb342ae
monitor.c:324:20: error: incompatible pointer to integer conversion assigning to 'pthread_key_t' (aka 'int') from 'struct thread *' [-Wint-conversion]
current_thread = all_threads;
This is probably due to not considering without-gcc-tls flag.
I have attached a patch to fix said issue.
summary: |
- make-android.sh failing with newer version of NDK + thread local storage related issues |
description: | updated |
Changed in sbcl: | |
status: | New → Fix Released |
Updated version of the patch.
The main difference is removed the c preprocessor flag entirely.
The relocation works in non-PIC mode nonetheless; the original idea was to separate them to allow non-PIC mode having more efficient code.
But on the second thought, the performance gain is probably too small to justify the confusion of code.
---
The patch reused the c macro ASSIGN_ CURRENT_ THREAD (and its family) for monitor.c to fix its problem.
The relocation fix is pretty standard relocation: using adrp+ldr to load the address of current_thread in the global object table (GOT), which is a table for address of global variables, so use another ldr to dereference it.
The relocation fix is addressing to bugs that only observed on arm64 and PIC mode (compiling to shared memory).