From 4e6adefc2b90589aea8ac2c51e0160a2c4d52ed8 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 22 Dec 2020 10:50:12 +0900 Subject: [PATCH] sim: Use c++14 for LIBCXX The compiler default varies among the environment. Especially, the default std version for xcode clang doesn't work for libcxx. This commit just ensures to use the consistent std version among compilers. we can come up with a more sophisticated way to control the version later if desiable. clang/macOS (from xcode): spacetanuki% c++ -dM -E -x c++ /dev/null | grep __cplusplus #define __cplusplus 199711L spacetanuki% c++ --version Apple clang version 11.0.0 (clang-1100.0.33.17) Target: x86_64-apple-darwin18.7.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin spacetanuki% clang/macOS (from homebrew): spacetanuki% /usr/local/Cellar/llvm/11.0.0/bin/clang++ -dM -E -x c++ /dev/null | grep __cplusplus #define __cplusplus 201402L spacetanuki% /usr/local/Cellar/llvm/11.0.0/bin/clang++ --version clang version 11.0.0 Target: x86_64-apple-darwin18.7.0 Thread model: posix InstalledDir: /usr/local/Cellar/llvm/11.0.0/bin spacetanuki% gcc/ubuntu: root@477d94753e9b:/# c++ -dM -E -x c++ /dev/null | grep __cplusplus #define __cplusplus 201402L root@477d94753e9b:/# c++ --version c++ (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0 Copyright (C) 2019 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. root@477d94753e9b:/# --- boards/sim/sim/sim/scripts/Make.defs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/boards/sim/sim/sim/scripts/Make.defs b/boards/sim/sim/sim/scripts/Make.defs index 22c4835d681..e64b3b5098e 100644 --- a/boards/sim/sim/sim/scripts/Make.defs +++ b/boards/sim/sim/sim/scripts/Make.defs @@ -106,6 +106,15 @@ CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) \ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ ifeq ($(CONFIG_LIBCXX),y) + # Why c++14? + # * libcxx seems to require c++11. + # * The compiler defaults varies: + # clang/macOS (from xcode): 199711L + # gcc/ubuntu: 201402L + # * There is a precedent to use c++14. + # (boards/arm/stm32l4/nucleo-l476rg/scripts/Make.defs) + CXXFLAGS += -std=c++14 + ifeq ($(CONFIG_HOST_MACOS),y) # macOS uses libc++abi CXXFLAGS += -DLIBCXX_BUILDING_LIBCXXABI