Skip to content

Commit e17c15c

Browse files
committed
pico-sdk: Switch to picolibc
This selects picolibc by using --specs=picolibc.specs for compiling and linking. The linker scripts are adjusted to add KEEP to ensure that --gc-sections doesn't remove the contents of the files. Signed-off-by: Keith Packard <[email protected]>
1 parent 7b57b24 commit e17c15c

File tree

6 files changed

+13
-11
lines changed

6 files changed

+13
-11
lines changed

src/rp2040/boot_stage2/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,16 @@ function(pico_define_boot_stage2 NAME SOURCES)
4343
if (PICO_C_COMPILER_IS_CLANG)
4444
target_link_options(${NAME} PRIVATE "-nostdlib")
4545
elseif (PICO_C_COMPILER_IS_GNU)
46-
target_link_options(${NAME} PRIVATE "--specs=nosys.specs")
46+
target_compile_options(${NAME} PRIVATE "--specs=picolibc.specs")
47+
target_link_options(${NAME} PRIVATE "--specs=picolibc.specs")
4748
target_link_options(${NAME} PRIVATE "-nostartfiles")
4849
endif ()
4950

5051
# boot2_helpers include dir
5152
target_include_directories(${NAME} PRIVATE ${PICO_BOOT_STAGE2_DIR}/asminclude)
5253

5354
target_link_libraries(${NAME} hardware_regs boot_stage2_headers)
54-
target_link_options(${NAME} PRIVATE "LINKER:--script=${PICO_BOOT_STAGE2_DIR}/boot_stage2.ld")
55+
target_link_options(${NAME} PRIVATE "-T${PICO_BOOT_STAGE2_DIR}/boot_stage2.ld")
5556
set_target_properties(${NAME} PROPERTIES LINK_DEPENDS ${PICO_BOOT_STAGE2_DIR}/boot_stage2.ld)
5657

5758
pico_add_dis_output(${NAME})

src/rp2040/boot_stage2/boot_stage2.ld

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ SECTIONS {
88
. = ORIGIN(SRAM);
99
.text : {
1010
_start = .; /* make LLVM happy */
11-
*(.entry)
12-
*(.text)
11+
KEEP(*(.entry))
12+
KEEP(*(.text .text.*))
1313
} >SRAM
1414
}

src/rp2350/boot_stage2/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ function(pico_define_boot_stage2 NAME SOURCES)
4343
if (PICO_C_COMPILER_IS_CLANG)
4444
target_link_options(${NAME} PRIVATE "-nostdlib")
4545
elseif (PICO_C_COMPILER_IS_GNU)
46-
target_link_options(${NAME} PRIVATE "--specs=nosys.specs")
46+
target_link_options(${NAME} PRIVATE "--specs=picolibc.specs")
4747
target_link_options(${NAME} PRIVATE "-nostartfiles")
4848
endif ()
4949

5050
# boot2_helpers include dir
5151
target_include_directories(${NAME} PRIVATE ${PICO_BOOT_STAGE2_DIR}/asminclude)
5252

5353
target_link_libraries(${NAME} hardware_regs boot_stage2_headers)
54-
target_link_options(${NAME} PRIVATE "LINKER:--script=${PICO_BOOT_STAGE2_DIR}/boot_stage2.ld")
54+
target_link_options(${NAME} PRIVATE "-T${PICO_BOOT_STAGE2_DIR}/boot_stage2.ld")
5555
set_target_properties(${NAME} PROPERTIES LINK_DEPENDS ${PICO_BOOT_STAGE2_DIR}/boot_stage2.ld)
5656

5757
pico_add_dis_output(${NAME})

src/rp2350/boot_stage2/boot_stage2.ld

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ SECTIONS {
88
. = ORIGIN(SRAM);
99
.text : {
1010
_start = .; /* make LLVM happy */
11-
*(.entry)
12-
*(.text)
11+
KEEP(*(.entry .entry.*))
12+
KEEP(*(.text .text.*))
1313
} >SRAM
1414
}

src/rp2_common/pico_runtime/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ endforeach()
4646

4747
# todo is this correct/needed?
4848
if (PICO_C_COMPILER_IS_GNU)
49-
target_link_options(pico_runtime INTERFACE "--specs=nosys.specs")
49+
target_compile_options(pico_runtime INTERFACE "--specs=picolibc.specs")
50+
target_link_options(pico_runtime INTERFACE "--specs=picolibc.specs")
5051
elseif (PICO_C_COMPILER_IS_CLANG)
5152
# target_link_options(pico_runtime INTERFACE "-nostdlib")
5253
endif()
@@ -144,4 +145,4 @@ function(pico_minimize_runtime TARGET)
144145
if (NOT RUNTIME_INCLUDE_FPGA_CHECK)
145146
target_compile_definitions(${TARGET} PRIVATE PICO_NO_FPGA_CHECK=1)
146147
endif()
147-
endfunction()
148+
endfunction()

src/rp2_common/pico_standard_link/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ if (NOT TARGET pico_standard_link)
6565
# if PICO_TARGET_BINARY_TYPE is set to foo on the target, otherwise ${CMAKE_CURRENT_LIST_DIR}/memmap_${PICO_DEFAULT_BINARY_TYPE).ld
6666
set(_LINKER_SCRIPT_EXPRESSION "$<IF:$<BOOL:$<TARGET_PROPERTY:PICO_TARGET_LINKER_SCRIPT>>,$<TARGET_PROPERTY:PICO_TARGET_LINKER_SCRIPT>,${PICO_LINKER_SCRIPT_PATH}/memmap_$<IF:$<STREQUAL:$<TARGET_PROPERTY:PICO_TARGET_BINARY_TYPE>,>,${PICO_DEFAULT_BINARY_TYPE},$<TARGET_PROPERTY:PICO_TARGET_BINARY_TYPE>>.ld>")
6767
target_link_options(pico_standard_link INTERFACE
68-
"LINKER:--script=${_LINKER_SCRIPT_EXPRESSION}"
68+
"-T${_LINKER_SCRIPT_EXPRESSION}"
6969
)
7070
pico_add_link_depend(pico_standard_link ${_LINKER_SCRIPT_EXPRESSION})
7171
unset(_LINKER_SCRIPT_EXPRESSION)

0 commit comments

Comments
 (0)