Skip to content

Commit 7951ef9

Browse files
committed
CI: Hack: Patch MicroPython to remove exception handling.
Force "-specs=nano.specs" on MicroPython builds and disable various stack unwinding and exception handling features for C++ modules.
1 parent b30d9ca commit 7951ef9

File tree

2 files changed

+32
-6
lines changed

2 files changed

+32
-6
lines changed

.github/workflows/micropython.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ jobs:
1919
uses: actions/cache@v3
2020
with:
2121
path: ${{runner.workspace}}
22-
key: workspace-micropython-${{env.MICROPYTHON_VERSION}}-pico
22+
key: workspace-micropython-${{env.MICROPYTHON_VERSION}}-nano-specs
2323
restore-keys: |
24-
workspace-micropython-${{env.MICROPYTHON_VERSION}}-pico
24+
workspace-micropython-${{env.MICROPYTHON_VERSION}}-nano-specs
2525
2626
# Check out MicroPython
2727
- name: Checkout MicroPython
@@ -129,18 +129,24 @@ jobs:
129129
echo "MICROPY_GIT_TAG=$MICROPYTHON_VERSION, ${{matrix.name}} ${{github.event.release.tag_name || github.sha}}" >> $GITHUB_ENV
130130
echo "MICROPY_GIT_HASH=$MICROPYTHON_VERSION-${{github.event.release.tag_name || github.sha}}" >> $GITHUB_ENV
131131
132-
- name: "HACK: Clean ports/rp2/modules" # We should move to using manifest.py to include our custom modules
132+
- name: "HACK: Clean ports/rp2/modules and ports/rp2/CMakeLists.txt"
133133
shell: bash
134134
working-directory: micropython/ports/rp2
135135
run: |
136136
rm -rf modules
137137
git checkout modules
138138
139-
- name: "HACK: Revert Pico SDK Patch" # Avoid an already-patched MicroPython tree breaking our build
139+
- name: "HACK: Revert Patches" # Avoid an already-patched MicroPython tree breaking our build
140140
shell: bash
141-
working-directory: micropython/lib/pico-sdk
141+
working-directory: micropython
142142
run: |
143-
git checkout .
143+
git checkout lib/pico-sdk
144+
git checkout ports/rp2/CMakeLists.txt
145+
146+
- name: "HACK: CMakeLists.txt Disable C++ Exceptions Patch"
147+
shell: bash
148+
working-directory: micropython
149+
run: git apply $GITHUB_WORKSPACE/pimoroni-pico-${{ github.sha }}/micropython/micropython_nano_specs.patch
144150

145151
- name: "HACK: Pico SDK Patch"
146152
if: matrix.patch == true
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
diff --git a/ports/rp2/CMakeLists.txt b/ports/rp2/CMakeLists.txt
2+
index 094031c6852a..5f268414c08f 100644
3+
--- a/ports/rp2/CMakeLists.txt
4+
+++ b/ports/rp2/CMakeLists.txt
5+
@@ -374,6 +374,15 @@ target_compile_options(${MICROPY_TARGET} PRIVATE
6+
target_link_options(${MICROPY_TARGET} PRIVATE
7+
-Wl,--defsym=__micropy_c_heap_size__=${MICROPY_C_HEAP_SIZE}
8+
)
9+
+# Do not include stack unwinding & exception handling for C++ user modules
10+
+target_compile_definitions(usermod INTERFACE PICO_CXX_ENABLE_EXCEPTIONS=0)
11+
+target_compile_options(usermod INTERFACE $<$<COMPILE_LANGUAGE:CXX>:
12+
+ -fno-exceptions
13+
+ -fno-unwind-tables
14+
+ -fno-rtti
15+
+ -fno-use-cxa-atexit
16+
+>)
17+
+target_link_options(usermod INTERFACE -specs=nano.specs)
18+
19+
set_source_files_properties(
20+
${PICO_SDK_PATH}/src/rp2_common/pico_double/double_math.c

0 commit comments

Comments
 (0)