From b0feb9c7ee54cdf87d69a205fd804d76e65f9bb4 Mon Sep 17 00:00:00 2001 From: Dryw Wade Date: Fri, 17 Oct 2025 15:44:37 -0600 Subject: [PATCH] mimxrt/Makefile: Add CXXFLAGS, and libstdc++ to LDFLAGS. This allows user C modules to be built into the mimxrt port. The change is copied from `samd/Makefile`. Fixes issue #18292. Signed-off-by: Dryw Wade --- ports/mimxrt/Makefile | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ports/mimxrt/Makefile b/ports/mimxrt/Makefile index 576f6e64a..2c1b41fcd 100644 --- a/ports/mimxrt/Makefile +++ b/ports/mimxrt/Makefile @@ -437,6 +437,15 @@ CFLAGS += \ -Wfloat-conversion \ -Wno-error=unused-parameter +# Flags for optional C++ source code +CXXFLAGS += $(filter-out -std=c99,$(CFLAGS)) + +# TODO make this common -- shouldn't be using these "private" vars from py.mk +ifneq ($(SRC_CXX)$(SRC_USERMOD_CXX)$(SRC_USERMOD_LIB_CXX),) +LIBSTDCPP_FILE_NAME = "$(shell $(CXX) $(CXXFLAGS) -print-file-name=libstdc++.a)" +LDFLAGS += -L"$(shell dirname $(LIBSTDCPP_FILE_NAME))" +endif + # Configure respective board flash type # Add hal/flexspi_nor_flash.h or hal/flexspi_hyper_flash.h respectively CFLAGS += -DBOARD_FLASH_OPS_HEADER_H=\"hal/flexspi_$(subst qspi_,,$(FLEXSPI_FLASH_TYPE)).h\"