arch: riscv + xtensa + x86: workaround needed for LLVM linker #99273
+27 −0
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.



Due to slight differences in the way that LLVM and GNU linkers work, the call to
z_stack_space_get()is not dead-stripped when linking with LLVMlldbut it is dead-stripped when linking with GNUld.The
z_stack_space_get()function is only available whenCONFIG_INIT_STACKSandCONFIG_THREAD_STACK_INFOare defined. So add a workaround toarch_thread_priv_stack_space_get()for riscv, x86, and xtensa, to return an error earlier if those Kconfig options are not enabled. This triggers LLVM to strip the call toz_stack_space_get()as dead code.The issue is reproducible (although requires building LLVM and setting up some environment variables) and goes away with the proposed workaround.
Fixes #98491