Skip to content

Commit 86e8958

Browse files
committed
platform: Make sure picolibc.c is included in every build when needed
Add picolibc.c to many source lists when CONFIG_PICOLIBC is defined to ensure the constructor is defined. If this file is missing, linking with picolibc will fail because this file also defines some symbols needed by picolibc's crt0.o Signed-off-by: Keith Packard <[email protected]>
1 parent 97b9a27 commit 86e8958

File tree

12 files changed

+19
-1
lines changed

12 files changed

+19
-1
lines changed

bl1/bl1_1/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ target_link_options(bl1_1
4040
target_sources(bl1_1
4141
PRIVATE
4242
main.c
43+
$<$<BOOL:${CONFIG_PICOLIBC}>:${CMAKE_SOURCE_DIR}/platform/ext/common/picolibc.c>
4344
$<$<BOOL:${CONFIG_GNU_SYSCALL_STUB_ENABLED}>:${CMAKE_SOURCE_DIR}/platform/ext/common/syscalls_stub.c>
4445
)
4546

bl1/bl1_2/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ target_link_options(bl1_2
4242
target_sources(bl1_2
4343
PRIVATE
4444
main.c
45+
$<$<BOOL:${CONFIG_PICOLIBC}>:${CMAKE_SOURCE_DIR}/platform/ext/common/picolibc.c>
4546
$<$<BOOL:${CONFIG_GNU_SYSCALL_STUB_ENABLED}>:${CMAKE_SOURCE_DIR}/platform/ext/common/syscalls_stub.c>
4647
)
4748

bl2/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ add_executable(bl2
128128
$<$<BOOL:${DEFAULT_MCUBOOT_FLASH_MAP}>:src/default_flash_map.c>
129129
$<$<BOOL:${MCUBOOT_DATA_SHARING}>:src/shared_data.c>
130130
$<$<BOOL:${PLATFORM_DEFAULT_PROVISIONING}>:src/provisioning.c>
131+
$<$<BOOL:${CONFIG_PICOLIBC}>:${CMAKE_SOURCE_DIR}/platform/ext/common/picolibc.c>
131132
$<$<BOOL:${CONFIG_GNU_SYSCALL_STUB_ENABLED}>:${CMAKE_SOURCE_DIR}/platform/ext/common/syscalls_stub.c>
132133
)
133134

cmake/install.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,11 @@ install(DIRECTORY $<BUILD_INTERFACE:${CMSIS_PATH}/CMSIS/Core/Include>
254254
$<BUILD_INTERFACE:${CMSIS_PATH}/CMSIS/Driver/Include>
255255
DESTINATION ${INSTALL_PLATFORM_NS_DIR}/ext/cmsis)
256256

257+
if(CONFIG_PICOLIBC)
258+
install(FILES ${PLATFORM_DIR}/ext/common/picolibc.c
259+
DESTINATION ${INSTALL_PLATFORM_NS_DIR}/ext/common)
260+
endif()
261+
257262
if(PLATFORM_DEFAULT_UART_STDOUT)
258263
install(FILES ${PLATFORM_DIR}/ext/common/uart_stdout.c
259264
${PLATFORM_DIR}/ext/common/uart_stdout.h

cmake/spe-CMakeLists.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ add_subdirectory(platform)
104104

105105
target_sources(platform_ns
106106
PRIVATE
107+
$<$<BOOL:${CONFIG_PICOLIBC}>:${CMAKE_CURRENT_SOURCE_DIR}/platform/ext/common/picolibc.c>
107108
$<$<BOOL:${PLATFORM_DEFAULT_UART_STDOUT}>:${CMAKE_CURRENT_SOURCE_DIR}/platform/ext/common/uart_stdout.c>
108109
)
109110

platform/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ target_sources(platform_s
8181
$<$<BOOL:${PLATFORM_DEFAULT_PROVISIONING}>:ext/common/provisioning.c>
8282
$<$<OR:$<BOOL:${TEST_S_FPU}>,$<BOOL:${TEST_NS_FPU}>>:${CMAKE_SOURCE_DIR}/platform/ext/common/test_interrupt.c>
8383
$<$<BOOL:${TFM_SANITIZE}>:ext/common/tfm_sanitize_handlers.c>
84+
$<$<BOOL:${CONFIG_PICOLIBC}>:ext/common/picolibc.c>
8485
./ext/common/tfm_fatal_error.c
8586
)
8687

@@ -90,7 +91,6 @@ target_sources(platform_s
9091
target_sources(tfm_s
9192
PRIVATE
9293
ext/common/faults.c
93-
ext/common/picolibc.c
9494
)
9595

9696
target_link_libraries(platform_s
@@ -204,6 +204,7 @@ if(BL2)
204204
$<$<OR:$<BOOL:${PLATFORM_DEFAULT_NV_COUNTERS}>,$<BOOL:${PLATFORM_DEFAULT_OTP}>>:ext/common/template/flash_otp_nv_counters_backend.c>
205205
$<$<BOOL:${PLATFORM_DEFAULT_OTP}>:ext/common/template/otp_flash.c>
206206
$<$<BOOL:${BL2_SANITIZE}>:ext/common/tfm_sanitize_handlers.c>
207+
$<$<BOOL:${CONFIG_PICOLIBC}>:ext/common/picolibc.c>
207208
./ext/common/tfm_fatal_error.c
208209
)
209210

@@ -305,6 +306,7 @@ if(BL1 AND PLATFORM_DEFAULT_BL1)
305306
$<$<BOOL:${PLATFORM_DEFAULT_OTP}>:ext/common/template/flash_otp_nv_counters_backend.c>
306307
$<$<BOOL:${PLATFORM_DEFAULT_OTP}>:ext/common/template/otp_flash.c>
307308
$<$<OR:$<BOOL:${BL1_1_SANITIZE}>,$<BOOL:${TFM_BL1_2_SANITIZE}>>:ext/common/tfm_sanitize_handlers.c>
309+
$<$<BOOL:${CONFIG_PICOLIBC}>:ext/common/picolibc.c>
308310
./ext/common/tfm_fatal_error.c
309311
)
310312

@@ -360,6 +362,7 @@ if(BL1 AND PLATFORM_DEFAULT_BL1)
360362
$<$<BOOL:${PLATFORM_DEFAULT_NV_COUNTERS}>:ext/common/template/nv_counters.c>
361363
$<$<OR:$<BOOL:${PLATFORM_DEFAULT_NV_COUNTERS}>,$<BOOL:${PLATFORM_DEFAULT_OTP}>>:ext/common/template/flash_otp_nv_counters_backend.c>
362364
$<$<BOOL:${PLATFORM_DEFAULT_OTP}>:ext/common/template/otp_flash.c>
365+
$<$<BOOL:${CONFIG_PICOLIBC}>:ext/common/picolibc.c>
363366
)
364367

365368
target_link_libraries(platform_bl1_2

platform/ext/common/provisioning_bundle/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ target_sources(provisioning_bundle
5454
PRIVATE
5555
./provisioning_code.c
5656
./provisioning_data.c
57+
$<$<BOOL:${CONFIG_PICOLIBC}>:${CMAKE_SOURCE_DIR}/platform/ext/common/picolibc.c>
5758
$<$<BOOL:${CONFIG_GNU_SYSCALL_STUB_ENABLED}>:${CMAKE_SOURCE_DIR}/platform/ext/common/syscalls_stub.c>
5859
)
5960

platform/ext/target/arm/mps4/common/provisioning/bundle_cm/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ target_sources(cm_provisioning_bundle
6262
PRIVATE
6363
cm_provisioning_code.c
6464
cm_provisioning_data.c
65+
$<$<BOOL:${CONFIG_PICOLIBC}>:${CMAKE_SOURCE_DIR}/platform/ext/common/picolibc.c>
6566
$<$<BOOL:${CONFIG_GNU_SYSCALL_STUB_ENABLED}>:${CMAKE_SOURCE_DIR}/platform/ext/common/syscalls_stub.c>
6667
)
6768

platform/ext/target/arm/mps4/common/provisioning/bundle_dm/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ target_sources(dm_provisioning_bundle
6565
PRIVATE
6666
dm_provisioning_code.c
6767
dm_provisioning_data.c
68+
$<$<BOOL:${CONFIG_PICOLIBC}>:${CMAKE_SOURCE_DIR}/platform/ext/common/picolibc.c>
6869
$<$<BOOL:${CONFIG_GNU_SYSCALL_STUB_ENABLED}>:${CMAKE_SOURCE_DIR}/platform/ext/common/syscalls_stub.c>
6970
)
7071

platform/ext/target/arm/rse/common/provisioning/bundle/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ macro(create_provisioning_code_target target)
6767

6868
target_sources(${target}_provisioning_code
6969
PRIVATE
70+
$<$<BOOL:${CONFIG_PICOLIBC}>:${CMAKE_SOURCE_DIR}/platform/ext/common/picolibc.c>
7071
$<$<BOOL:${CONFIG_GNU_SYSCALL_STUB_ENABLED}>:${CMAKE_SOURCE_DIR}/platform/ext/common/syscalls_stub.c>
7172
)
7273

0 commit comments

Comments
 (0)