diff options
author | Luke T. Shumaker <lukeshu@lukeshu.com> | 2024-12-16 15:17:16 -0500 |
---|---|---|
committer | Luke T. Shumaker <lukeshu@lukeshu.com> | 2025-01-11 23:34:14 -0700 |
commit | 2f8f8102ac0ea4403243e1bd4a6af750edb8f180 (patch) | |
tree | 8c732ef5e2488ab9b53852633d09337a5b03d02a | |
parent | f263b08d4457e36126f150566219472f3a05c906 (diff) |
gc sections from host builds
-rw-r--r-- | CMakeLists.txt | 6 | ||||
-rw-r--r-- | libcr/coroutine.c | 2 |
2 files changed, 7 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 0c2a9e5..ce1a942 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,6 +16,12 @@ project(sbc_harness) pico_sdk_init() +if ((PICO_PLATFORM STREQUAL "host") AND (NOT PICO_NO_GC_SECTIONS)) + # On non-host builds, this is done by `pico_standard_link`. + add_compile_options(-ffunction-sections -fdata-sections) + add_link_options("LINKER:--gc-sections") +endif() + add_compile_options(-Wall -Wextra -Wswitch-enum -Werror) string(TOUPPER "${CMAKE_BUILD_TYPE}" _upper_cmake_build_type) diff --git a/libcr/coroutine.c b/libcr/coroutine.c index 73460b7..708e2ea 100644 --- a/libcr/coroutine.c +++ b/libcr/coroutine.c @@ -647,7 +647,7 @@ void coroutine_main(void) { coroutine_running = 0; #if CONFIG_COROUTINE_GDB /* Some pointless call to prevent cr_gdb_readjmp() from - * getting pruned out of the firmware image. */ + * getting pruned out by `ld --gc-sections`. */ if (coroutine_table[0].state != CR_NONE) cr_gdb_readjmp(&coroutine_table[0].env); #endif |