Skip to content

Commit 3fa77bd

Browse files
committed
rp2: Add temporary workaround for GCC 15.1 build failure.
This is a workaround for this upstream issue: raspberrypi/pico-sdk#2448 Can be removed after the next pico-sdk update. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <[email protected]>
1 parent d01a981 commit 3fa77bd

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

ports/rp2/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ endif()
8484
list(APPEND GIT_SUBMODULES lib/mbedtls)
8585
list(APPEND GIT_SUBMODULES lib/tinyusb)
8686

87+
# Workaround for pico-sdk host toolchain issue, see directory for details
88+
list(APPEND CMAKE_MODULE_PATH "${MICROPY_PORT_DIR}/tools_patch")
89+
8790
# Include component cmake fragments
8891
include(${MICROPY_DIR}/py/py.cmake)
8992
include(${MICROPY_DIR}/extmod/extmod.cmake)
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Finds (or builds) the pioasm executable
2+
#
3+
# This will define the following imported targets
4+
#
5+
# pioasm
6+
#
7+
8+
# This is a temporary patched copy of pico-sdk file Findpioasm.cmake to work around
9+
# a host toolchain issue with GCC 15.1:
10+
# https://github.com/raspberrypi/pico-sdk/issues/2448
11+
12+
if (NOT TARGET pioasm)
13+
# todo we would like to use pckgconfig to look for it first
14+
# see https://pabloariasal.github.io/2018/02/19/its-time-to-do-cmake-right/
15+
16+
include(ExternalProject)
17+
18+
set(PIOASM_SOURCE_DIR ${PICO_SDK_PATH}/tools/pioasm)
19+
set(PIOASM_BINARY_DIR ${CMAKE_BINARY_DIR}/pioasm)
20+
set(PIOASM_INSTALL_DIR ${CMAKE_BINARY_DIR}/pioasm-install CACHE PATH "Directory where pioasm has been installed" FORCE)
21+
22+
set(pioasmBuild_TARGET pioasmBuild)
23+
set(pioasm_TARGET pioasm)
24+
25+
if (NOT TARGET ${pioasmBuild_TARGET})
26+
pico_message_debug("PIOASM will need to be built")
27+
# message("Adding external project ${pioasmBuild_Target} in ${CMAKE_CURRENT_LIST_DIR}}")
28+
ExternalProject_Add(${pioasmBuild_TARGET}
29+
PREFIX pioasm
30+
SOURCE_DIR ${PIOASM_SOURCE_DIR}
31+
BINARY_DIR ${PIOASM_BINARY_DIR}
32+
INSTALL_DIR ${PIOASM_INSTALL_DIR}
33+
CMAKE_ARGS
34+
"--no-warn-unused-cli"
35+
"-DCMAKE_MAKE_PROGRAM:FILEPATH=${CMAKE_MAKE_PROGRAM}"
36+
"-DPIOASM_FLAT_INSTALL=1"
37+
"-DCMAKE_INSTALL_PREFIX=${PIOASM_INSTALL_DIR}"
38+
"-DCMAKE_RULE_MESSAGES=OFF" # quieten the build
39+
"-DCMAKE_INSTALL_MESSAGE=NEVER" # quieten the install
40+
# Toolchain workaround follows
41+
"-DCMAKE_CXX_FLAGS=-include cstdint"
42+
CMAKE_CACHE_ARGS "-DPIOASM_EXTRA_SOURCE_FILES:STRING=${PIOASM_EXTRA_SOURCE_FILES}"
43+
BUILD_ALWAYS 1 # force dependency checking
44+
EXCLUDE_FROM_ALL TRUE
45+
)
46+
endif()
47+
48+
if (CMAKE_HOST_WIN32)
49+
set(pioasm_EXECUTABLE ${PIOASM_INSTALL_DIR}/pioasm/pioasm.exe)
50+
else()
51+
set(pioasm_EXECUTABLE ${PIOASM_INSTALL_DIR}/pioasm/pioasm)
52+
endif()
53+
add_executable(${pioasm_TARGET} IMPORTED GLOBAL)
54+
set_property(TARGET ${pioasm_TARGET} PROPERTY IMPORTED_LOCATION
55+
${pioasm_EXECUTABLE})
56+
57+
add_dependencies(${pioasm_TARGET} ${pioasmBuild_TARGET})
58+
endif()

0 commit comments

Comments
 (0)