diff options
-rw-r--r-- | Makefile.rules | 6 | ||||
-rw-r--r-- | Makefile.toolchain | 11 |
2 files changed, 14 insertions, 3 deletions
diff --git a/Makefile.rules b/Makefile.rules index 87d21b6b03..7173cc8aae 100644 --- a/Makefile.rules +++ b/Makefile.rules @@ -86,7 +86,7 @@ cmd_elf_to_hex = $(OBJCOPY) -O ihex $< $@ cmd_bin_to_hex = $(OBJCOPY) -I binary -O ihex \ --change-addresses $(_program_memory_base) $^ $@ cmd_smap = $(NM) $< | sort > $@ -cmd_elf = $(CC) $(objs) $(libsharedobjs_elf-y) $(LDFLAGS) \ +cmd_elf = $(COMPILER) $(objs) $(libsharedobjs_elf-y) $(LDFLAGS) \ -o $@ -Wl,-T,$< -Wl,-Map,$(patsubst %.elf,%.map,$@) ifeq ($(cc-name),gcc) cmd_elf+= -flto-partition=one @@ -98,7 +98,7 @@ endif cmd_fuzz_exe = $(CXX) $^ $(HOST_TEST_LDFLAGS) $(LDFLAGS_EXTRA) -o $@ cmd_run_fuzz = build/host/$*/$*.exe -seed=1 -runs=1 $(silent) \ $(silent_err) || (echo "Test $* failed!" && false) -cmd_exe = $(CC) $(ro-objs) $(HOST_TEST_LDFLAGS) $(LDFLAGS_EXTRA) -o $@ +cmd_exe = $(COMPILER) $(ro-objs) $(HOST_TEST_LDFLAGS) $(LDFLAGS_EXTRA) -o $@ cmd_c_to_o = $(CC) -std=gnu11 $(C_WARN) $(CFLAGS) -MMD -MP -MF $@.d -c $< \ -MT $(@D)/$(@F) -o $(@D)/$(@F) cmd_cxx_to_o = $(CXX) -std=gnu++17 $(CFLAGS) $(CXXFLAGS) -MMD -MP -MF $@.d -c $< \ @@ -131,7 +131,7 @@ cmd_mv_from_tmp = mv $(out)/$*.bin.tmp $(out)/$*.bin cmd_extractrw-y = dd if=$(out)/$(PROJECT).bin.tmp of=$(out)/$(PROJECT).RW.bin \ bs=1 count=$(_rw_size) skip=$(_rw_off) $(silent_err) cmd_copyrw-y = cd $(out) && cp RW/$(PROJECT).RW.flat RW/$(PROJECT).RW.bin -cmd_sharedlib_elf = $(CC) $(libsharedobjs_deps) \ +cmd_sharedlib_elf = $(COMPILER) $(libsharedobjs_deps) \ -Wl,-T,common/ec.$(SHOBJLIB).ld $(LDFLAGS) \ -o $(out)/$(SHOBJLIB)/$(SHOBJLIB).elf \ -Wl,-Map,$(out)/$(SHOBJLIB)/$(SHOBJLIB).map diff --git a/Makefile.toolchain b/Makefile.toolchain index a37e7cc100..fe7bfd7a83 100644 --- a/Makefile.toolchain +++ b/Makefile.toolchain @@ -29,6 +29,10 @@ endif # library. USE_BUILTIN_STDLIB:=1 +# When set to 1, link with the C++ compiler. +# When set to 0, link with the C compiler. +USE_CXX_COMPILER:=0 + # Boards that compile with clang by default. # We can't use a config for this since the config generation uses the compiler. CLANG_BOARDS:= \ @@ -42,6 +46,13 @@ CLANG_BOARDS:= \ ifeq ($(filter $(BOARD), $(CLANG_BOARDS)), $(BOARD)) CC=clang USE_BUILTIN_STDLIB:=0 +USE_CXX_COMPILER:=1 +endif + +ifeq ($(USE_CXX_COMPILER), 1) +COMPILER=$(CXX) +else +COMPILER=$(CC) endif # Set the prefix for the compiler if specified (e.g., "x86_64-pc-linux-gnu-"). |