boards: native: add support for static linking

Add support for static linking of the final native simulator runner.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
This commit is contained in:
Henrik Brix Andersen
2026-01-05 23:15:59 +00:00
committed by Alberto Escolar
parent c11ae6b6b2
commit 9186d6864a
2 changed files with 11 additions and 0 deletions

View File

@@ -13,6 +13,10 @@ if(SYSROOT_DIR)
target_link_options(native_simulator INTERFACE "--sysroot=${SYSROOT_DIR}")
endif()
if(CONFIG_NATIVE_SIMULATOR_STATIC_LINKING)
target_link_options(native_simulator INTERFACE "-static")
endif()
if("${LINKER}" STREQUAL "lld")
target_link_options(native_simulator INTERFACE "-fuse-ld=lld")
endif()

View File

@@ -48,4 +48,11 @@ config NATIVE_SIMULATOR_AUTOSTART_MCU
If that MCU was, by HW design, going to start at HW boot anyhow, this option does nothing.
This option is meant to facilitate development.
config NATIVE_SIMULATOR_STATIC_LINKING
bool "Attempt to use static linking"
help
Do not link the final native simulator runner with shared libraries.
Static linking depends on all required libraries being available as static libraries.
endif # SOC_POSIX