summaryrefslogtreecommitdiff
path: root/Makefile.toolchain
diff options
context:
space:
mode:
authorTom Hughes <tomhughes@chromium.org>2022-08-25 09:45:16 -0700
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-09-29 02:19:23 +0000
commit4851d8c8d52ba8376392dc1ffde5da05af938150 (patch)
tree989dd20dfa5e7511d29dddded22c527038b4c144 /Makefile.toolchain
parent52cd0dcce80561ea74413e3e0a1796b3dcb5e671 (diff)
downloadchrome-ec-4851d8c8d52ba8376392dc1ffde5da05af938150.tar.gz
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 <tomhughes@chromium.org> Change-Id: I84d7ea44c7f3b3c9f17ca6308521e7041f7e5e8f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3857942 Reviewed-by: Bobby Casey <bobbycasey@google.com> Reviewed-by: Andrea Grandi <agrandi@google.com>
Diffstat (limited to 'Makefile.toolchain')
-rw-r--r--Makefile.toolchain11
1 files changed, 11 insertions, 0 deletions
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-").