From 73074461099d90f930897cb78dfb25556a88beaa Mon Sep 17 00:00:00 2001 From: Thiago Alves Date: Mon, 15 Jun 2026 20:09:57 -0400 Subject: [PATCH 1/2] feat(firmware): weak default for strucpp::iec_runtime_fault MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit strucpp's new runtime (feat/iec-runtime-fault) calls iec_runtime_fault() on MCU targets (compiled -fno-exceptions) instead of throwing. Provide the weak default definition in the Arduino runtime glue: halt (for(;;)). VPP HALs may override it with a strong definition (e.g. P1AM blinks its LED). No -fexceptions change is needed in the editor — it never hardcoded it; the flag only came from VPP cxx_flags (removed separately in openplc-packages). NOTE: depends on the new strucpp runtime being bundled (the editor's resources/strucpp is sourced from an official strucpp release). Land after that release ships, alongside the VPP -fexceptions removals. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../sources/arduino/arduino_runtime_glue.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/resources/sources/arduino/arduino_runtime_glue.cpp b/resources/sources/arduino/arduino_runtime_glue.cpp index c7ea73e6b..6e99fd368 100644 --- a/resources/sources/arduino/arduino_runtime_glue.cpp +++ b/resources/sources/arduino/arduino_runtime_glue.cpp @@ -19,6 +19,21 @@ #include "generated.hpp" #include "debug_dispatch.hpp" +// --------------------------------------------------------------------------- +// Runtime fault hook +// --------------------------------------------------------------------------- +// Weak default for strucpp::iec_runtime_fault (declared in iec_fault.hpp). +// On MCU firmware (compiled -fno-exceptions) the runtime calls this instead +// of throwing on an unrecoverable fault (null deref, array OOB, bad located +// address). Default behaviour: halt. A VPP HAL may provide a STRONG override +// to signal the fault its own way — blink a status LED, sound an alarm, +// reboot, etc. Kept free of so this TU stays macro-clean. +__attribute__((weak)) void strucpp::iec_runtime_fault(strucpp::IecFault /*reason*/, + const char* /*context*/) noexcept { + for (;;) { + } +} + // --------------------------------------------------------------------------- // Storage // --------------------------------------------------------------------------- From 92c2750060594a382cc0e12f82a9f1c421e432a6 Mon Sep 17 00:00:00 2001 From: Thiago Alves Date: Mon, 15 Jun 2026 20:43:03 -0400 Subject: [PATCH 2/2] chore(deps): bump strucpp to v0.5.8 (iec_runtime_fault runtime) --- binary-versions.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/binary-versions.json b/binary-versions.json index 66e803966..3ea61ac0f 100644 --- a/binary-versions.json +++ b/binary-versions.json @@ -4,7 +4,7 @@ "repository": "Autonomy-Logic/xml2st" }, "strucpp": { - "version": "v0.5.7", + "version": "v0.5.8", "repository": "Autonomy-Logic/STruCpp" } }