Skip to content

Commit 465dff2

Browse files
committed
use the same runtime_init() as for newlib -> picolibc now working for clang19.1.5/21.1.1
1 parent f7255e7 commit 465dff2

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/rp2_common/pico_clib_interface/picolibc_interface.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,19 @@ void runtime_init(void) {
124124
runtime_init_per_core_install_stack_guard(&__StackBottom);
125125
#endif
126126

127-
// piolibc __libc_init_array does __preint_array and __init_array
128-
extern void __libc_init_array(void);
129-
__libc_init_array();
127+
// todo maybe we want to do this in the future, but it does stuff like register_tm_clones
128+
// which we didn't do in previous SDKs
129+
//extern void __libc_init_array(void);
130+
//__libc_init_array();
131+
132+
// ... so instead just do the __preinit_array
133+
runtime_run_initializers();
134+
// ... and the __init_array
135+
extern void (*__init_array_start)(void);
136+
extern void (*__init_array_end)(void);
137+
for (void (**p)(void) = &__init_array_start; p < &__init_array_end; ++p) {
138+
(*p)();
139+
}
130140
}
131141

132142
#if !PICO_RUNTIME_NO_INIT_PER_CORE_TLS_SETUP
@@ -151,4 +161,4 @@ PICO_RUNTIME_INIT_FUNC_PER_CORE(runtime_init_pre_core_tls_setup, PICO_RUNTIME_IN
151161
// "ldr r0, =__tls_base\n"
152162
// "bx lr\n"
153163
// );
154-
//}
164+
//}

0 commit comments

Comments
 (0)