From f44a84b40c78863d8d42f7f4c8d29c645780d4cd Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Sun, 25 Jul 2021 18:23:23 -0700 Subject: [PATCH] set up precompiled header (#2971) * ignore * set up precompiled header * makefile * fixes * cleanup * only depend cpp on pch * efifeatures in pch * f7 efifeatures * consolidate * simulator * proteus build * error handling is a good one * bootloader pch * don't auto include pch * dirs * delete on clean * bootloader cleans * clean.sh deletes pch * disable in bl for now * there was a typo so maybe it'll work now * remove todo * don't need that any more * don't need these parts * don't need this part * undo changes * use a different cpp as example * s * Revert "cleanup" This reverts commit 8de8698490f5d09c2df753f00a89751aa898be9a. * also unnecessary now * buh * comment Co-authored-by: Matthew Kennedy --- firmware/.gitignore | 4 ++++ firmware/Makefile | 13 ++++++++++-- firmware/bootloader/compile_bootloader.sh | 0 firmware/bootloader/src/Makefile | 8 ++++++- firmware/clean.sh | 1 + firmware/config/boards/proteus/board.mk | 2 +- firmware/controllers/algo/engine.cpp | 13 ++---------- firmware/pch/pch.h | 26 +++++++++++++++++++++++ firmware/rusefi_pch.mk | 24 +++++++++++++++++++++ simulator/Makefile | 10 ++++++++- unit_tests/Makefile | 4 +++- unit_tests/rules.mk | 4 +++- unit_tests/unit_test_rules.mk | 7 ++++-- 13 files changed, 96 insertions(+), 20 deletions(-) mode change 100644 => 100755 firmware/bootloader/compile_bootloader.sh create mode 100644 firmware/pch/pch.h create mode 100644 firmware/rusefi_pch.mk diff --git a/firmware/.gitignore b/firmware/.gitignore index 4ee74c32c7..aeed331c0a 100644 --- a/firmware/.gitignore +++ b/firmware/.gitignore @@ -4,3 +4,7 @@ gen_*.log deliver/ rusefi_tool.log build* + +# precompiled headers +*.h.gch +*.h.gcno diff --git a/firmware/Makefile b/firmware/Makefile index 7e626dd61d..4f6873e357 100644 --- a/firmware/Makefile +++ b/firmware/Makefile @@ -13,6 +13,10 @@ include rusefi_rules.mk PROJECT = rusefi PROJECT_DIR = . +# Configure precompiled header +PCH_DIR = $(PROJECT_DIR)/pch +PCHSRC = $(PCH_DIR)/pch.h + # Imported source files and paths CHIBIOS_CONTRIB = ChibiOS-Contrib @@ -55,7 +59,7 @@ endif # C++ specific options here (added to USE_OPT). ifeq ($(USE_CPPOPT),) - USE_CPPOPT = -std=c++17 -Wno-register -fno-rtti -fno-threadsafe-statics -fno-exceptions -fno-use-cxa-atexit + USE_CPPOPT = -std=c++17 -Wno-register -fno-rtti -fno-threadsafe-statics -fno-exceptions -fno-use-cxa-atexit -Winvalid-pch endif # Hellen is one of the boards which cares @@ -270,7 +274,9 @@ TCPPSRC = ASMXSRC = $(ALLXASMSRC) \ $(RUSEFIASM) -INCDIR = $(ALLINC) \ +INCDIR = \ + $(PCH_DIR) \ + $(ALLINC) \ $(TESTINC) \ $(BOOTLOADERINC) \ $(CHIBIOS)/os/various \ @@ -372,3 +378,6 @@ ULIBS = -lm --specs=nano.specs ############################################################################## include $(RULESFILE) + +# Enable precompiled header +include rusefi_pch.mk diff --git a/firmware/bootloader/compile_bootloader.sh b/firmware/bootloader/compile_bootloader.sh old mode 100644 new mode 100755 diff --git a/firmware/bootloader/src/Makefile b/firmware/bootloader/src/Makefile index 9b6c29c4bd..e7453b2179 100644 --- a/firmware/bootloader/src/Makefile +++ b/firmware/bootloader/src/Makefile @@ -39,7 +39,7 @@ endif # C++ specific options here (added to USE_OPT). ifeq ($(USE_CPPOPT),) # constexpr float expf_taylor_impl probably needs just c++14 but why not go with 17? - USE_CPPOPT = -std=c++17 -Wno-register -fno-rtti -fno-exceptions -fno-use-cxa-atexit -Werror=write-strings -Werror=type-limits + USE_CPPOPT = -std=c++17 -Wno-register -fno-rtti -fno-exceptions -fno-use-cxa-atexit -Werror=write-strings -Werror=type-limits -Winvalid-pch endif # Enable this if you want the linker to remove unused code and data @@ -117,6 +117,10 @@ endif PROJECT = bootloader PROJECT_DIR = .. +# Configure precompiled header +PCH_DIR = $(PROJECT_DIR)/pch +PCHSRC = $(PCH_DIR)/pch.h + # Imported source files and paths CHIBIOS = $(PROJECT_DIR)/ChibiOS # todo: looks like 'CHIBIOS_CONTRIB' path is universal shall we defined it only once? @@ -209,6 +213,7 @@ TCPPSRC = ASMXSRC = $(STARTUPASM) $(PORTASM) $(OSALASM) INCDIR = $(ALLINC) \ + $(PCH_DIR) \ .. \ $(CHIBIOS)/os/various \ $(CHIBIOS)/os/ex/ST \ @@ -317,3 +322,4 @@ ULIBS = -lm --specs=nano.specs ############################################################################## include $(RULESFILE) +include $(PROJECT_DIR)/rusefi_pch.mk diff --git a/firmware/clean.sh b/firmware/clean.sh index b4d10a862c..bc1d5e8c7b 100755 --- a/firmware/clean.sh +++ b/firmware/clean.sh @@ -3,3 +3,4 @@ echo "Entering firmware/clean.sh" rm -rf .dep rm -rf build +rm -f pch/pch.h.gch diff --git a/firmware/config/boards/proteus/board.mk b/firmware/config/boards/proteus/board.mk index 54bedbdbaa..a07170d7dd 100644 --- a/firmware/config/boards/proteus/board.mk +++ b/firmware/config/boards/proteus/board.mk @@ -30,7 +30,7 @@ endif # disable hardware serial ports on H7 ifeq ($(PROJECT_CPU),ARCH_STM32H7) - DDEFS += -DTS_NO_PRIMARY -DTS_NO_SECONDARY + DDEFS += -DTS_NO_PRIMARY -DTS_NO_SECONDARY else # Hardware serial port on UART 2 -> PD5/PD6 DDEFS += -DSTM32_UART_USE_USART2=TRUE diff --git a/firmware/controllers/algo/engine.cpp b/firmware/controllers/algo/engine.cpp index 2c74a97b11..0c7cb5cd4f 100644 --- a/firmware/controllers/algo/engine.cpp +++ b/firmware/controllers/algo/engine.cpp @@ -9,19 +9,15 @@ * @author Andrey Belomutskiy, (c) 2012-2020 */ -#include "engine.h" -#include "allsensors.h" -#include "efi_gpio.h" -#include "pin_repository.h" +#include "pch.h" + #include "trigger_central.h" #include "fuel_math.h" -#include "engine_math.h" #include "advance_map.h" #include "speed_density.h" #include "advance_map.h" #include "os_util.h" #include "os_access.h" -#include "settings.h" #include "aux_valves.h" #include "map_averaging.h" #include "fsio_impl.h" @@ -29,7 +25,6 @@ #include "backup_ram.h" #include "idle_thread.h" #include "idle_hardware.h" -#include "sensor.h" #include "gppwm.h" #include "tachometer.h" #include "dynoview.h" @@ -40,10 +35,6 @@ #include "mc33816.h" #endif // EFI_MC33816 -#if EFI_TUNER_STUDIO -#include "tunerstudio_outputs.h" -#endif /* EFI_TUNER_STUDIO */ - #if EFI_PROD_CODE #include "trigger_emulator_algo.h" #include "bench_test.h" diff --git a/firmware/pch/pch.h b/firmware/pch/pch.h new file mode 100644 index 0000000000..7456ae87c1 --- /dev/null +++ b/firmware/pch/pch.h @@ -0,0 +1,26 @@ +/** + * @file pch.h + * + * This file is rusEFI's precompiled header. Most cpp files should include + * this file in lieu of any of the files below. + * + * This helps compilation performance by parsing/analyzing these files only + * once, then re-loading that precompiled data for every file that includes + * this file. + */ + +#include "efifeatures.h" +#include "engine_ptr.h" +#include "global.h" +#include "efi_gpio.h" +#include "engine.h" +#include "engine_configuration.h" +#include "engine_controller.h" +#include "tunerstudio_outputs.h" +#include "engine_math.h" +#include "pwm_generator_logic.h" +#include "allsensors.h" +#include "sensor.h" +#include "error_handling.h" +#include "settings.h" + diff --git a/firmware/rusefi_pch.mk b/firmware/rusefi_pch.mk new file mode 100644 index 0000000000..ee56296f59 --- /dev/null +++ b/firmware/rusefi_pch.mk @@ -0,0 +1,24 @@ + + +# Add the PCH dir to source path +SRCPATHS += $(PCH_DIR) + +PCHOBJ = $(addprefix $(PCH_DIR)/, $(notdir $(PCHSRC:.h=.h.gch))) + +# Compile precompiled header file(s) as a cpp file, but output to .h.gch file +$(PCHOBJ) : $(PCH_DIR)/%.h.gch : %.h Makefile +ifeq ($(USE_VERBOSE_COMPILE),yes) + @echo + $(CPPC) -c $(CPPFLAGS) $(AOPT) -I. $(IINCDIR) $< -o $@ +else + @echo Compiling $(