Skip to content

Commit f31e364

Browse files
fix(simulator): stub host serial WASM imports for native builds
The host_drv bridge added in the previous commit calls four WASM imports (simuAuxSerialStart/Stop/SetBaudrate/SendBuffer). On WASM targets WASM_IMPORT resolves them via import_name attributes, but on native builds (gtests-radio, SDL simu) the macro is a no-op, leaving the declarations as plain externs with no definitions and breaking link of every target with AUX_SERIAL enabled. Provide no-op stubs for the four functions in simulib.cpp, guarded by !__wasm__, so native builds link cleanly. The WASM simulator path is untouched and Companion continues to resolve the symbols through WAMR. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent ab03354 commit f31e364

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

radio/src/targets/simu/simulib.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,19 @@ const etx_serial_port_t UsbSerialPort = { "USB-VCP", nullptr, nullptr };
403403
#endif
404404

405405
#if defined(AUX_SERIAL) || defined(AUX2_SERIAL)
406+
#if !defined(__wasm__)
407+
// Native builds (unit-tests, SDL simulator) don't have a WASM host to
408+
// forward aux-serial traffic to: WASM_IMPORT is a no-op macro off-target,
409+
// so the declarations in simulib.h become plain externs with no
410+
// definitions. Provide no-op stubs so host_drv_* can link — the host
411+
// bridge is only meaningfully exercised in the WASM simulator, where
412+
// these symbols are resolved as WAMR imports by Companion.
413+
void simuAuxSerialStart(uint8_t, uint32_t, uint8_t) {}
414+
void simuAuxSerialStop(uint8_t) {}
415+
void simuAuxSerialSetBaudrate(uint8_t, uint32_t) {}
416+
void simuAuxSerialSendBuffer(uint8_t, const uint8_t*, uint32_t) {}
417+
#endif
418+
406419
// Per-port bridge state. TX is forwarded to the host via WASM imports;
407420
// RX bytes pushed in via simuAuxSerialReceive() are buffered in rxQueue
408421
// and consumed by the firmware through host_drv_get_byte().

0 commit comments

Comments
 (0)