diff --git a/firmware/Makefile b/firmware/Makefile index 2ba4791de5..ca84bac724 100644 --- a/firmware/Makefile +++ b/firmware/Makefile @@ -129,6 +129,12 @@ ifeq ($(USE_LTO),) USE_OPT += -flto=auto endif +ifeq ($(OS),Windows_NT) + USE_OPT += -DIS_WINDOWS_COMPILER=1 +else + USE_OPT += -DIS_WINDOWS_COMPILER=0 +endif + # If enabled, this option allows to compile the application in THUMB mode. ifeq ($(USE_THUMB),) USE_THUMB = yes diff --git a/firmware/controllers/algo/engine_configuration.h b/firmware/controllers/algo/engine_configuration.h index dfe889d678..75a42e89c9 100644 --- a/firmware/controllers/algo/engine_configuration.h +++ b/firmware/controllers/algo/engine_configuration.h @@ -21,8 +21,9 @@ #define MOCK_UNDEFINED -1 -// why is Windows compiler not happy around simulator?! feature or defect?! -#if !defined(EFI_SIM_IS_WINDOWS) || !EFI_SIM_IS_WINDOWS +// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90826 Weak symbol does not work reliably on windows +// https://sourceware.org/bugzilla/show_bug.cgi?id=9687 Weak symbols not working on mingw32 +#if !defined(IS_WINDOWS_COMPILER) || !IS_WINDOWS_COMPILER #define PUBLIC_API_WEAK_SOMETHING_WEIRD __attribute__((weak)) #else #define PUBLIC_API_WEAK_SOMETHING_WEIRD diff --git a/simulator/Makefile b/simulator/Makefile index 9fce8cb178..9b061f7bff 100644 --- a/simulator/Makefile +++ b/simulator/Makefile @@ -54,9 +54,9 @@ ifeq ($(USE_OPT),) USE_OPT += -D US_TO_NT_MULTIPLIER=$(US_TO_NT_MULTIPLIER) ifeq ($(OS),Windows_NT) - USE_OPT += -DEFI_SIM_IS_WINDOWS=1 + USE_OPT += -DEFI_SIM_IS_WINDOWS=1 -DIS_WINDOWS_COMPILER=1 else - USE_OPT += -m32 -DEFI_SIM_IS_WINDOWS=0 + USE_OPT += -m32 -DEFI_SIM_IS_WINDOWS=0 -DIS_WINDOWS_COMPILER=0 endif endif diff --git a/unit_tests/global_mocks.cpp b/unit_tests/global_mocks.cpp index 74e3c7f79c..201b1f19d2 100644 --- a/unit_tests/global_mocks.cpp +++ b/unit_tests/global_mocks.cpp @@ -15,9 +15,6 @@ efitimems_t getTimeNowMs() { void initLogging(LoggingWithStorage *logging, const char *name) { } -void setBoardConfigOverrides() { -} - void onCliCaseError(const char *token) { } diff --git a/unit_tests/unit_test_rules.mk b/unit_tests/unit_test_rules.mk index ae54260ee9..04a407bab4 100644 --- a/unit_tests/unit_test_rules.mk +++ b/unit_tests/unit_test_rules.mk @@ -147,6 +147,13 @@ CPPWARN = -Wall -Wextra -Wno-unused-parameter -Wno-unused-function -Wno-unused-v USE_OPT += -Werror=switch +ifeq ($(OS),Windows_NT) + USE_OPT += -DIS_WINDOWS_COMPILER=1 +else + USE_OPT += -DIS_WINDOWS_COMPILER=0 +endif + + # # Compiler settings ##############################################################################