Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CONFIG_THREAD_LOCAL_STORAGE=y build fails with ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb #29541

Closed
pfalcon opened this issue Oct 26, 2020 · 11 comments · Fixed by #29542 or #29591
Closed

CONFIG_THREAD_LOCAL_STORAGE=y build fails with ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb #29541

pfalcon opened this issue Oct 26, 2020 · 11 comments · Fixed by #29542 or #29591
Assignees
Labels
area: Minimal libc Minimal C Standard Library area: Portability Standard compliant code, toolchain abstraction area: Toolchains Toolchains bug The issue is a bug, or the PR is fixing a bug priority: medium Medium impact/importance bug

Comments

@pfalcon
Copy link
Contributor

pfalcon commented Oct 26, 2020

ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb is one of the supported toolchains to build Zephyr (for ARM architecture). After #28982 was merged, and with CONFIG_THREAD_LOCAL_STORAGE enabled (which it is, for one sanitycheck configuration of tests/kernel/common), the build fails with:

[ 87%] Linking C executable app_smem_unaligned_prebuilt.elf
/home/buildslave/srv/toolchain/gcc-arm-none-eabi-9-2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: /home/buildslave/srv/toolchain/gcc-arm-none-eabi-9-2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/thumb/v7e-m/nofp/libgcc.a(emutls.o): in function `emutls_alloc':
emutls.c:(.text+0x5a): undefined reference to `abort'
/home/buildslave/srv/toolchain/gcc-arm-none-eabi-9-2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: /home/buildslave/srv/toolchain/gcc-arm-none-eabi-9-2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/thumb/v7e-m/nofp/libgcc.a(emutls.o): in function `__emutls_get_address':
emutls.c:(.text+0x7a): undefined reference to `abort'
collect2: error: ld returned 1 exit status
make[2]: *** [zephyr/app_smem_unaligned_prebuilt.elf] Error 1
make[1]: *** [zephyr/CMakeFiles/app_smem_unaligned_prebuilt.dir/all] Error 2
make: *** [all] Error 2

INFO    - /home/buildslave/srv/zephyr/master/gnuarmemb/frdm_k64f/frdm_k64f/tests/kernel/common/kernel.common.tls/build.log

Full build log: https://ci.linaro.org/job/zephyr-upstream/PLATFORM=frdm_k64f,ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb,label=docker-xenial-amd64-13/5680/console

@pfalcon pfalcon added the bug The issue is a bug, or the PR is fixing a bug label Oct 26, 2020
@pfalcon
Copy link
Contributor Author

pfalcon commented Oct 26, 2020

@galak: FYI

@pfalcon pfalcon added area: Minimal libc Minimal C Standard Library area: Portability Standard compliant code, toolchain abstraction area: Toolchains Toolchains labels Oct 26, 2020
@pfalcon pfalcon self-assigned this Oct 26, 2020
@pfalcon
Copy link
Contributor Author

pfalcon commented Oct 26, 2020

This error doesn't happen if built with CONFIG_NEWLIB_LIBC=y, which leads us to the patch #29542.

Note that I didn't try to investigate why emutls.c "the emulation of thread local storage using malloc()" https://github.com/gcc-mirror/gcc/blob/master/libgcc/emutls.c is being used. @galak, let me know if you think that should be investigated.

@nashif nashif added the priority: medium Medium impact/importance bug label Oct 27, 2020
@galak
Copy link
Collaborator

galak commented Oct 27, 2020

@dcpleung fyi

@galak
Copy link
Collaborator

galak commented Oct 27, 2020

since this is the case w/minlibc that fails, its odd to me that this works ok w/Zephyr SDK & fails w/gnuarmemb.

@pfalcon
Copy link
Contributor Author

pfalcon commented Oct 27, 2020

Apparently, some implicitly linked libs included with Zephyr SDK provide abort().

@galak
Copy link
Collaborator

galak commented Oct 27, 2020

Apparently, some implicitly linked libs included with Zephyr SDK provide abort().

looking at the error message in more detail, I see this is in libgcc, so that partially explains it.

@galak
Copy link
Collaborator

galak commented Oct 27, 2020

Based on https://github.com/ARM-software/toolchain-gnu-bare-metal/blob/365499ead3c18e9c1a70880c34d8efe08549df3c/build-toolchain.sh#L423 we should probably change things so TLS is only supported w/Zephyr toolchain.

@dcpleung
Copy link
Member

Submitted #29591 to limit the kconfig option to Zephyr SDK only. Hopefully that fixes the issue.

@pfalcon
Copy link
Contributor Author

pfalcon commented Oct 27, 2020

we should probably change things so TLS is only supported w/Zephyr toolchain.

Right. But that's orthogonal to the missing abort() in minlibc, PR #29542.

dcpleung added a commit to dcpleung/zephyr that referenced this issue Oct 27, 2020
Toolchains other than Zephyr SDK may not support generating
code with thread local storage. So limit TLS to Zephyr SDK
for now, and only enable TLS on other toolchains as needed.

Fixes zephyrproject-rtos#29541

Signed-off-by: Daniel Leung <[email protected]>
@andrewboie
Copy link
Contributor

It's not clear to me the root cause here. Does this toolchain really not support TLS at all? Or is this just some reference to abort() from libgcc that is simply fixed by #29542

@dcpleung
Copy link
Member

According to the link from @galak, it looks like the toolchain is built without TLS support (as configured with --disable-tls).

pfalcon added a commit to pfalcon/zephyr that referenced this issue Oct 28, 2020
abort() is an important runtime function, oftentimes used to signal
abnormal execution conditions in generic applications. Worse, they
may be used under such circumstances in e.g. compiler support
libraries, in which case lack of implementation of this function
will lead to link error.

Fixes: zephyrproject-rtos#29541

Signed-off-by: Paul Sokolovsky <[email protected]>
carlescufi pushed a commit that referenced this issue Oct 28, 2020
abort() is an important runtime function, oftentimes used to signal
abnormal execution conditions in generic applications. Worse, they
may be used under such circumstances in e.g. compiler support
libraries, in which case lack of implementation of this function
will lead to link error.

Fixes: #29541

Signed-off-by: Paul Sokolovsky <[email protected]>
carlescufi pushed a commit that referenced this issue Oct 30, 2020
Toolchains other than Zephyr SDK may not support generating
code with thread local storage. So limit TLS to Zephyr SDK
for now, and only enable TLS on other toolchains as needed.

Fixes #29541

Signed-off-by: Daniel Leung <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Minimal libc Minimal C Standard Library area: Portability Standard compliant code, toolchain abstraction area: Toolchains Toolchains bug The issue is a bug, or the PR is fixing a bug priority: medium Medium impact/importance bug
Projects
None yet
5 participants