Skip to content

[ATfE] Provide nohost init and exit in llvmlibc startup code#683

Merged
voltur01 merged 2 commits intoarm:arm-softwarefrom
voltur01:add_unhosted_exit
Jan 19, 2026
Merged

[ATfE] Provide nohost init and exit in llvmlibc startup code#683
voltur01 merged 2 commits intoarm:arm-softwarefrom
voltur01:add_unhosted_exit

Conversation

@voltur01
Copy link
Contributor

Provide init and exit handlers for not hosted environments in llvm libc crt0.

Update the documentation accordingly.

Update the UART sample to make use of the symbols provided in crt0 and refine the comments for the remaining symbols related to IO retargeting.

Provide init and exit handlers for not hosted environments in llvm libc crt0.

Update the documentation accordingly.

Update the UART sample to make use of the symbols provided in crt0 and refine the comments for the remaining symbols related to IO retargeting.
@voltur01 voltur01 requested a review from a team as a code owner January 19, 2026 15:06
Copy link
Contributor

@smithp35 smithp35 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I think disabling interrupts and going into low-power mode is sensible for a lot of applications. It won't be universally applicable. For example what if there's a timer on an interrupt that resets the system? Or if the program is running without the privilege.

For a universal default I think we'd better off following picolibc's lead and doing an infinite loop.

#error "Unsupported architecture"
#endif

static inline void idle_once(void) { __asm__ volatile("wfi" ::: "memory"); }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an intrinsic in the ACLE for this https://arm-software.github.io/acle/main/acle.html#hints

I think wfi is also not supported in v4t, I think it needs 5te.

// Go into low power infinite loop on exit
[[gnu::weak, noreturn]] void __llvm_libc_exit(int status) {
(void)status;
mask_irqs();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will need a privileged instruction and we may (likely) be running at user-mode or EL0 so this will generate an abort.

Copy link
Contributor

@smithp35 smithp35 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for the update.

@voltur01 voltur01 merged commit ab657ec into arm:arm-software Jan 19, 2026
2 checks passed
voltur01 added a commit to voltur01/arm-toolchain that referenced this pull request Jan 21, 2026
Provide init and exit handlers for not hosted environments in llvm libc
crt0.

Update the documentation accordingly.

Update the UART sample to make use of the symbols provided in crt0 and
refine the comments for the remaining symbols related to IO retargeting.

(cherry picked from commit ab657ec)
voltur01 added a commit that referenced this pull request Jan 22, 2026
This applies the following changes to 22.x release branch:

#667
[ATfE] Use semihosting SYS_READC for stdin with llvm libc

#676
[ATfE] Remove __LLVM_LIBC__ define workaround for libcxx

#678
[ATfE] Replace call to abort with __llvm_libc_exit in libc startup code

#679
[ATfE] Update comment about handling cleanup for exit()

#683
[ATfE] Provide nohost init and exit in llvmlibc startup code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants