Skip to content

Commit c8ea5d0

Browse files
committed
avoid exporting __assert_func symbol from system lib
__assert_func and its dependencies are automatically added by libc unless we provide a stub implementation and avoid uisng -Wl,--whole-archive when linking against system lib
1 parent a5c0c0c commit c8ea5d0

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Diff for: cores/arduino/abi.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@
2121
extern "C" void __cxa_pure_virtual(void) __attribute__ ((__noreturn__));
2222
extern "C" void __cxa_deleted_virtual(void) __attribute__ ((__noreturn__));
2323

24+
extern "C" void __assert_func(void) __attribute__ ((__noreturn__));
25+
26+
void __assert_func(void) {
27+
while (1)
28+
;
29+
}
2430

2531
void __cxa_pure_virtual(void) {
2632
// We might want to write some diagnostics to uart in this case

Diff for: platform.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -D
6868
recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}"
6969

7070
## Combine gc-sections, archives, and objects
71-
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" {compiler.c.elf.extra_flags} -o "{build.path}/{build.project_name}.elf" "-L{build.path}" "-L{build.variant.path}" -Wl,--whole-archive "-l{build.variant_system_lib}" -Wl,--no-whole-archive -Wl,--start-group "-l{build.variant_system_lib}" -lnsim -lc -lm -lgcc {object_files} "{build.path}/{archive_file}"
71+
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" {compiler.c.elf.extra_flags} -o "{build.path}/{build.project_name}.elf" "-L{build.path}" "-L{build.variant.path}" -Wl,--no-whole-archive -Wl,--start-group -lnsim -lc -lm -lgcc -l{build.variant_system_lib} {object_files} "{build.path}/{archive_file}"
7272

7373
## Save output with debug symbols (.debug.elf file). Uncomment if you wish to use OpenOCD to debug.
7474
recipe.hooks.objcopy.preobjcopy.1.pattern="{runtime.tools.arduino101load.path}/arduino101load" -c -from="{build.path}/{build.project_name}.elf" -to="{build.path}/../arduino101_sketch.debug.elf"

0 commit comments

Comments
 (0)