Skip to content

Commit e0d9510

Browse files
committed
Move nano specs hack into our module cmake files.
We've been maintaining a downstream patch to disable C++ exception handling, which gives us some headroom before our builds get too big and overwrite themselves at runtime. Forgetting to apply this patch is a constant source of debugging frustration. It turns out it can just be added to our USER_C_MODULES cmake files instead, where it will implicitly be included when building against our modules.
1 parent 9771274 commit e0d9510

16 files changed

+47
-35
lines changed

.github/workflows/micropython.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,6 @@ jobs:
9595
source $BUILD_TOOLS
9696
micropython_build_mpy_cross
9797
98-
- name: "HACK: CMakeLists.txt Disable C++ Exceptions Patch"
99-
shell: bash
100-
run: |
101-
source $BUILD_TOOLS
102-
hack_patch_micropython_disable_exceptions
103-
10498
- name: "HACK: Pico SDK Patch"
10599
shell: bash
106100
run: |

ci/micropython.sh

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,6 @@ function micropython_version {
4444
echo "MICROPY_GIT_HASH=$MICROPYTHON_VERSION-$TAG_OR_SHA" >> $GITHUB_ENV
4545
}
4646

47-
function hack_patch_micropython_disable_exceptions {
48-
cd micropython
49-
git apply $PIMORONI_PICO_DIR/micropython/micropython_nano_specs.patch
50-
cd ../
51-
}
52-
5347
function hack_patch_pico_sdk {
5448
# pico-sdk-patch.sh will apply the patch if it exists
5549
cd micropython

micropython/micropython_nano_specs.patch

Lines changed: 0 additions & 21 deletions
This file was deleted.

micropython/modules/micropython-cosmic_unicorn.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,6 @@ include(modules_py/modules_py)
3939

4040
# C++ Magic Memory
4141
include(cppmem/micropython)
42+
43+
# Disable build-busting C++ exceptions
44+
include(micropython-disable-exceptions)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Do not include stack unwinding & exception handling for C++ user modules
2+
target_compile_definitions(usermod INTERFACE PICO_CXX_ENABLE_EXCEPTIONS=0)
3+
target_compile_options(usermod INTERFACE $<$<COMPILE_LANGUAGE:CXX>:
4+
-fno-exceptions
5+
-fno-unwind-tables
6+
-fno-rtti
7+
-fno-use-cxa-atexit
8+
>)
9+
target_link_options(usermod INTERFACE -specs=nano.specs)

micropython/modules/micropython-enviro.cmake

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,7 @@ include(motor/micropython)
4747
include(modules_py/modules_py)
4848

4949
# C++ Magic Memory
50-
include(cppmem/micropython)
50+
include(cppmem/micropython)
51+
52+
# Disable build-busting C++ exceptions
53+
include(micropython-disable-exceptions)

micropython/modules/micropython-galactic_unicorn.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,6 @@ include(modules_py/modules_py)
3939

4040
# C++ Magic Memory
4141
include(cppmem/micropython)
42+
43+
# Disable build-busting C++ exceptions
44+
include(micropython-disable-exceptions)

micropython/modules/micropython-inky_frame.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,6 @@ copy_module(inky_frame.py)
5050

5151
# C++ Magic Memory
5252
include(cppmem/micropython)
53+
54+
# Disable build-busting C++ exceptions
55+
include(micropython-disable-exceptions)

micropython/modules/micropython-pico.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ include(pico_wireless/micropython)
1212

1313
# C++ Magic Memory
1414
include(cppmem/micropython)
15+
16+
# Disable build-busting C++ exceptions
17+
include(micropython-disable-exceptions)

micropython/modules/micropython-pico_usb.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ include(pico_wireless/micropython)
1212

1313
# C++ Magic Memory
1414
include(cppmem/micropython)
15+
16+
# Disable build-busting C++ exceptions
17+
include(micropython-disable-exceptions)

0 commit comments

Comments
 (0)