From 32305699e5de8ca806db0ba08dbf75bdbf85fe97 Mon Sep 17 00:00:00 2001 From: Robin Lee Date: Sat, 3 Mar 2018 16:27:36 +0800 Subject: libcxx: Add settings to build with libcxx as default C++ standard library Signed-off-by: Robin Lee --- README.md | 24 +++++++++++++++++++++++- recipes-devtools/clang/compiler-rt_git.bb | 1 + recipes-devtools/clang/libcxx_git.bb | 1 + 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d63060d..986f77c 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,22 @@ you can select clang per package too by writing bbappends for them containing TOOLCHAIN = "clang" ``` +# Default C++ Standard Library Switch + +Note that by default libstdc++ will remain the default C++ standard library, however if you wish +libc++ to be the default one then set + +```python +TARGET_CXXFLAGS_append_toolchain-clang ?= " -stdlib=libc++ " +``` + +in local.conf. +You can select libc++ per package too by writing bbappends for them containing + +```python +TARGET_CXXFLAGS_append_toolchain-clang = " -stdlib=libc++ " +``` + # Building Below we build for qemuarm machine as an example @@ -61,7 +77,13 @@ simply add it to conf/nonclangable.inc e.g. TOOLCHAIN_pn- = "gcc" ``` -and OE will start using gcc to cross compile that recipe, +and OE will start using gcc to cross compile that recipe. + +And if a component does not build with libc++, you can add it to conf/nonclangable.inc e.g. + +```shell +TARGET_CXXFLAGS_remove_pn-_toolchain-clang = " -stdlib=libc++ " +``` # Dependencies diff --git a/recipes-devtools/clang/compiler-rt_git.bb b/recipes-devtools/clang/compiler-rt_git.bb index 834d2d6..ae21806 100644 --- a/recipes-devtools/clang/compiler-rt_git.bb +++ b/recipes-devtools/clang/compiler-rt_git.bb @@ -27,6 +27,7 @@ SRCREV_FORMAT = "compiler-rt" BASEDEPENDS_remove_toolchain-clang_class-target = "compiler-rt" BASEDEPENDS_remove_toolchain-clang_class-target = "libcxx" +TARGET_CXXFLAGS_remove_toolchain-clang = " -stdlib=libc++ " DEPENDS += "ninja-native" diff --git a/recipes-devtools/clang/libcxx_git.bb b/recipes-devtools/clang/libcxx_git.bb index 0f3b2a8..57f0654 100644 --- a/recipes-devtools/clang/libcxx_git.bb +++ b/recipes-devtools/clang/libcxx_git.bb @@ -14,6 +14,7 @@ PV .= "+git${SRCPV}" DEPENDS += "ninja-native" BASEDEPENDS_remove_toolchain-clang_class-target = "libcxx" +TARGET_CXXFLAGS_remove_toolchain-clang = " -stdlib=libc++ " PROVIDES = "libunwind" PROVIDES_remove_mipsarch = "libunwind" -- cgit v1.2.3-54-g00ecf