From 4851d8c8d52ba8376392dc1ffde5da05af938150 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 25 Aug 2022 09:45:16 -0700 Subject: Makefile: Add option to link with C++ Boards that compile C++ files should link with the C++ compiler so that the C++ standard library is included when linking (-lc++ for clang and -lstdc++ for g++). BRANCH=none BUG=b:234181908 TEST=make buildall Force-Relevant-Builds: all Signed-off-by: Tom Hughes Change-Id: I84d7ea44c7f3b3c9f17ca6308521e7041f7e5e8f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3857942 Reviewed-by: Bobby Casey Reviewed-by: Andrea Grandi --- Makefile.toolchain | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'Makefile.toolchain') 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-"). -- cgit v1.2.1