using external TLS variables with ATfE-22.1.0-Linux-x86_64 compiler fails with a link error #3112
Labels
No labels
bazel
bluetooth
board settings
boot_stage2
bug
build
c++
can't reproduce
clang
clib-interface
cmsis
code cleanliness
code size
compiler version issues
cyw43_driver
debug
discussion
documentation
duplicate
dynamic_clock
elf2uf2
enhancement
errata
filesystem
flash layout
floating point
FreeRTOS
hardware_adc
hardware_claim
hardware_clocks
hardware_dma
hardware_exception
hardware_flash
hardware_gpio
hardware_i2c
hardware_irq
hardware_pio
hardware_pwm
hardware_rcp
hardware_rtc
hardware_spi
hardware_sync
hardware_uart
hardware_vreg
hardware_watchdog
hardware_xosc
help wanted
host
IAR
installation
invalid
linker scripts
lto
lwip
mbedtls
missing API
needs reporter detail
networking
newlib
newlib-multicore
non-c
non-cmake
non-gcc
openocd
orphan PR
OS integration
pico_async_context
pico_base
pico_binary_info
pico_flash
picolibc
pico_lwip
pico_malloc
pico_multicore
pico_printf
pico_runtime
pico_stdio
pico_stdio_usb
pico_sync
pico_time
pico_util
pioasm
port
question
review
review2
rtos interop
runtime init
static library
svd
test
tinyusb
vscode
wifi integration
wontfix
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-raspberrypi/pico-sdk#3112
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I got the compiler ATfE-22.1.0-Linux-x86_64 from here https://github.com/arm/arm-toolchain/releases (also tried ATfE-21.1.1-Linux-x86_64)
It is based on llvm and uses picoclib.
I have a very simple program that uses errno and when I build it I get a link error.
It seems related to the .tbss_space section. The spacer's arithmetic assumes nothing is allocated between bss_start and the spacer itself, and an unplaced .got breaks that assumption on lld. (Thank claude for that)
Anyway - the fix suggested is to add the following into pico_arm_clang_common.cmake - it's what picolibc.specs does evidently.
Claude seems to think this is related to the following issue - but it's a bit over my head: https://github.com/raspberrypi/pico-sdk/issues/3064
I've pushed the test to a branch. The above fix is currently commented out but it does seem to resolve the problem.
Was able to reproduce this using your SDK branch and:
and yes, seems like the location counter has been bumped by four bytes already, so this line tries to move it backward:
I find the location counter semantics slightly mysterious here, but this is fixed by placing the GOT section, as per #3065:
I had to look up that flag you mentioned: https://support.arm.com/documentation/107976/21-1-1/Clang-reference/clang-command-line-options/-ftls-model
It sounds like maybe we should be using
local-execanyway, but here it would be a symptomatic fix.note whilst #3064 fixes this issue (likely) we should be adding local-exec anyway so leaving this open
It does, I checked. But yeah we should be using tp-relative access for all thread-local storage. I can't think of a reason why not.
-ftls-model=local-exec now added too