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.
pull/968/head
Phil Howard 2024-07-03 16:18:44 +01:00
rodzic 9771274e90
commit e0d9510769
16 zmienionych plików z 47 dodań i 35 usunięć

Wyświetl plik

@ -95,12 +95,6 @@ jobs:
source $BUILD_TOOLS
micropython_build_mpy_cross
- name: "HACK: CMakeLists.txt Disable C++ Exceptions Patch"
shell: bash
run: |
source $BUILD_TOOLS
hack_patch_micropython_disable_exceptions
- name: "HACK: Pico SDK Patch"
shell: bash
run: |

Wyświetl plik

@ -44,12 +44,6 @@ function micropython_version {
echo "MICROPY_GIT_HASH=$MICROPYTHON_VERSION-$TAG_OR_SHA" >> $GITHUB_ENV
}
function hack_patch_micropython_disable_exceptions {
cd micropython
git apply $PIMORONI_PICO_DIR/micropython/micropython_nano_specs.patch
cd ../
}
function hack_patch_pico_sdk {
# pico-sdk-patch.sh will apply the patch if it exists
cd micropython

Wyświetl plik

@ -1,21 +0,0 @@
diff --git a/ports/rp2/CMakeLists.txt b/ports/rp2/CMakeLists.txt
index fcc435b7b..efabcb3a3 100644
--- a/ports/rp2/CMakeLists.txt
+++ b/ports/rp2/CMakeLists.txt
@@ -464,6 +464,16 @@ set_source_files_properties(
COMPILE_OPTIONS "-O2"
)
+# Do not include stack unwinding & exception handling for C++ user modules
+target_compile_definitions(usermod INTERFACE PICO_CXX_ENABLE_EXCEPTIONS=0)
+target_compile_options(usermod INTERFACE $<$<COMPILE_LANGUAGE:CXX>:
+ -fno-exceptions
+ -fno-unwind-tables
+ -fno-rtti
+ -fno-use-cxa-atexit
+>)
+target_link_options(usermod INTERFACE -specs=nano.specs)
+
set_source_files_properties(
${PICO_SDK_PATH}/src/rp2_common/pico_double/double_math.c
${PICO_SDK_PATH}/src/rp2_common/pico_float/float_math.c

Wyświetl plik

@ -39,3 +39,6 @@ include(modules_py/modules_py)
# C++ Magic Memory
include(cppmem/micropython)
# Disable build-busting C++ exceptions
include(micropython-disable-exceptions)

Wyświetl plik

@ -0,0 +1,9 @@
# Do not include stack unwinding & exception handling for C++ user modules
target_compile_definitions(usermod INTERFACE PICO_CXX_ENABLE_EXCEPTIONS=0)
target_compile_options(usermod INTERFACE $<$<COMPILE_LANGUAGE:CXX>:
-fno-exceptions
-fno-unwind-tables
-fno-rtti
-fno-use-cxa-atexit
>)
target_link_options(usermod INTERFACE -specs=nano.specs)

Wyświetl plik

@ -47,4 +47,7 @@ include(motor/micropython)
include(modules_py/modules_py)
# C++ Magic Memory
include(cppmem/micropython)
include(cppmem/micropython)
# Disable build-busting C++ exceptions
include(micropython-disable-exceptions)

Wyświetl plik

@ -39,3 +39,6 @@ include(modules_py/modules_py)
# C++ Magic Memory
include(cppmem/micropython)
# Disable build-busting C++ exceptions
include(micropython-disable-exceptions)

Wyświetl plik

@ -50,3 +50,6 @@ copy_module(inky_frame.py)
# C++ Magic Memory
include(cppmem/micropython)
# Disable build-busting C++ exceptions
include(micropython-disable-exceptions)

Wyświetl plik

@ -12,3 +12,6 @@ include(pico_wireless/micropython)
# C++ Magic Memory
include(cppmem/micropython)
# Disable build-busting C++ exceptions
include(micropython-disable-exceptions)

Wyświetl plik

@ -12,3 +12,6 @@ include(pico_wireless/micropython)
# C++ Magic Memory
include(cppmem/micropython)
# Disable build-busting C++ exceptions
include(micropython-disable-exceptions)

Wyświetl plik

@ -14,3 +14,6 @@ enable_ulab()
# C++ Magic Memory
include(cppmem/micropython)
# Disable build-busting C++ exceptions
include(micropython-disable-exceptions)

Wyświetl plik

@ -14,3 +14,6 @@ enable_ulab()
# C++ Magic Memory
include(cppmem/micropython)
# Disable build-busting C++ exceptions
include(micropython-disable-exceptions)

Wyświetl plik

@ -11,3 +11,6 @@ include(micropython-common)
# C++ Magic Memory
include(cppmem/micropython)
# Disable build-busting C++ exceptions
include(micropython-disable-exceptions)

Wyświetl plik

@ -39,3 +39,6 @@ include(modules_py/modules_py)
# C++ Magic Memory
include(cppmem/micropython)
# Disable build-busting C++ exceptions
include(micropython-disable-exceptions)

Wyświetl plik

@ -11,3 +11,6 @@ include(micropython-common)
# C++ Magic Memory
include(cppmem/micropython)
# Disable build-busting C++ exceptions
include(micropython-disable-exceptions)

Wyświetl plik

@ -44,4 +44,7 @@ enable_ulab()
include(modules_py/modules_py)
# C++ Magic Memory
include(cppmem/micropython)
include(cppmem/micropython)
# Disable build-busting C++ exceptions
include(micropython-disable-exceptions)