From 41b7f5296d1176160712d79730d3b5ce0c58d1da Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Mon, 23 Oct 2023 17:20:24 -0700 Subject: meta-clang: Replace RUNTIME with TC_CXX_RUNTIME TC_CXX_RUNTIME is now defined in OE-core Signed-off-by: Khem Raj --- README.md | 10 +++++----- classes/clang.bbclass | 18 +++++++++--------- conf/layer.conf | 2 +- recipes-devtools/clang/clang_git.bb | 6 +++--- recipes-devtools/clang/compiler-rt-sanitizers_git.bb | 2 +- recipes-devtools/clang/libcxx_git.bb | 6 +++--- recipes-extended/ghostscript/ghostscript_%.bbappend | 2 +- 7 files changed, 23 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 3ec2313..0bc7cfb 100644 --- a/README.md +++ b/README.md @@ -67,17 +67,17 @@ PROVIDES:pn-nativesdk-clang = "nativesdk-llvm" ``` # Default Compiler Runtime -Default is to use GNU runtime `RUNTIME = "gnu"` which consists of libgcc, libstdc++ to provide C/C++ +Default is to use GNU runtime `TC_CXX_RUNTIME = "gnu"` which consists of libgcc, libstdc++ to provide C/C++ runtime support. However it's possible to use LLVM runtime to replace it where compile-rt, llvm libunwind, and libc++ are used to provide C/C++ runtime, while GNU runtime works with both GCC and Clang, LLVM runtime is only tested with Clang compiler, switching to use LLVM runtime is done via a config metadata knob ```shell -RUNTIME = "llvm" +TC_CXX_RUNTIME = "llvm" ``` -RUNTIME variable influences individual runtime elements and can be set explicitly as well +TC_CXX_RUNTIME variable influences individual runtime elements and can be set explicitly as well e.g. `LIBCPLUSPLUS` `COMPILER_RT` and `UNWINDLIB`. Please note that this will still use crt files from GNU compiler always, while llvm now @@ -85,8 +85,8 @@ do provide crt files, they have not been yet integrated into the toolchain. # Default C++ Standard Library Switch -Using RUNTIME variable will select which C++ runtime is used, however it can be overridden -if needed to by modifying `LIBCPLUSPLUS` variable, usually defaults used by `RUNTIME` are +Using TC_CXX_RUNTIME variable will select which C++ runtime is used, however it can be overridden +if needed to by modifying `LIBCPLUSPLUS` variable, usually defaults used by `TC_CXX_RUNTIME` are best fit. e.g. below we select LLVM C++ as default C++ runtime. ```shell diff --git a/classes/clang.bbclass b/classes/clang.bbclass index 605bfd5..f0330b3 100644 --- a/classes/clang.bbclass +++ b/classes/clang.bbclass @@ -75,11 +75,11 @@ DEBUG_PREFIX_MAP:remove:toolchain-clang = "-fcanon-prefix-map" # choose between 'gcc' 'clang' an empty '' can be used as well TOOLCHAIN ??= "gcc" # choose between 'gnu' 'llvm' -RUNTIME ??= "gnu" +TC_CXX_RUNTIME ??= "gnu" # Using gcc or llvm runtime is only available when using clang for compiler -#RUNTIME:toolchain-gcc = "gnu" -RUNTIME:armeb = "gnu" -RUNTIME:armv5 = "gnu" +#TC_CXX_RUNTIME:toolchain-gcc = "gnu" +TC_CXX_RUNTIME:armeb = "gnu" +TC_CXX_RUNTIME:armv5 = "gnu" TOOLCHAIN:class-native = "gcc" TOOLCHAIN:class-nativesdk = "gcc" @@ -88,8 +88,8 @@ TOOLCHAIN:class-crosssdk = "gcc" TOOLCHAIN:class-cross = "gcc" OVERRIDES =. "${@['', 'toolchain-${TOOLCHAIN}:']['${TOOLCHAIN}' != '']}" -OVERRIDES =. "${@['', 'runtime-${RUNTIME}:']['${RUNTIME}' != '']}" -OVERRIDES[vardepsexclude] += "TOOLCHAIN RUNTIME" +OVERRIDES =. "${@['', 'runtime-${TC_CXX_RUNTIME}:']['${TC_CXX_RUNTIME}' != '']}" +OVERRIDES[vardepsexclude] += "TOOLCHAIN TC_CXX_RUNTIME" YOCTO_ALTERNATE_EXE_PATH:toolchain-clang:class-target = "${STAGING_BINDIR}/llvm-config" YOCTO_ALTERNATE_LIBDIR:toolchain-clang:class-target = "/${BASELIB}" @@ -104,16 +104,16 @@ def clang_base_deps(d): if not d.getVar('INHIBIT_DEFAULT_DEPS', False): if not oe.utils.inherits(d, 'allarch') : ret = " ${MLPREFIX}clang-cross-${TARGET_ARCH} virtual/libc " - if (d.getVar('RUNTIME').find('android') != -1): + if (d.getVar('TC_CXX_RUNTIME').find('android') != -1): ret += " libcxx" return ret - if (d.getVar('RUNTIME').find('llvm') != -1): + if (d.getVar('TC_CXX_RUNTIME').find('llvm') != -1): ret += " compiler-rt" elif (d.getVar('COMPILER_RT').find('-rtlib=compiler-rt') != -1): ret += " compiler-rt " else: ret += " libgcc " - if (d.getVar('RUNTIME').find('llvm') != -1): + if (d.getVar('TC_CXX_RUNTIME').find('llvm') != -1): ret += " libcxx" elif (d.getVar('COMPILER_RT').find('--unwindlib=libunwind') != -1): ret += " libcxx " diff --git a/conf/layer.conf b/conf/layer.conf index 67baca0..3f1fee1 100644 --- a/conf/layer.conf +++ b/conf/layer.conf @@ -27,7 +27,7 @@ BBFILES_DYNAMIC += " \ PREFERRED_PROVIDER_libgcc-initial = "libgcc-initial" #PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}compilerlibs_forcevariable = "libcxx" -PREFERRED_PROVIDER_libunwind = "${@bb.utils.contains_any("RUNTIME", "llvm android", "libcxx", "libunwind", d)}" +PREFERRED_PROVIDER_libunwind = "${@bb.utils.contains_any("TC_CXX_RUNTIME", "llvm android", "libcxx", "libunwind", d)}" INHERIT += "clang" # Do not include clang in SDK unless user wants to diff --git a/recipes-devtools/clang/clang_git.bb b/recipes-devtools/clang/clang_git.bb index f735090..1d9ff2e 100644 --- a/recipes-devtools/clang/clang_git.bb +++ b/recipes-devtools/clang/clang_git.bb @@ -57,11 +57,11 @@ def get_clang_experimental_target_arch(bb, d): PACKAGECONFIG ??= "compiler-rt libcplusplus shared-libs lldb-wchar \ ${@bb.utils.filter('DISTRO_FEATURES', 'thin-lto lto', d)} \ - ${@bb.utils.contains('RUNTIME', 'llvm', 'compiler-rt libcplusplus unwindlib libomp', '', d)} \ + ${@bb.utils.contains('TC_CXX_RUNTIME', 'llvm', 'compiler-rt libcplusplus unwindlib libomp', '', d)} \ rtti eh libedit terminfo \ " -PACKAGECONFIG:class-native = "rtti eh libedit shared-libs ${@bb.utils.contains('RUNTIME', 'llvm', 'compiler-rt libcplusplus unwindlib libomp', '', d)}" -PACKAGECONFIG:class-nativesdk = "rtti eh libedit shared-libs ${@bb.utils.filter('DISTRO_FEATURES', 'thin-lto lto', d)} ${@bb.utils.contains('RUNTIME', 'llvm', 'compiler-rt libcplusplus unwindlib libomp', '', d)}" +PACKAGECONFIG:class-native = "rtti eh libedit shared-libs ${@bb.utils.contains('TC_CXX_RUNTIME', 'llvm', 'compiler-rt libcplusplus unwindlib libomp', '', d)}" +PACKAGECONFIG:class-nativesdk = "rtti eh libedit shared-libs ${@bb.utils.filter('DISTRO_FEATURES', 'thin-lto lto', d)} ${@bb.utils.contains('TC_CXX_RUNTIME', 'llvm', 'compiler-rt libcplusplus unwindlib libomp', '', d)}" PACKAGECONFIG[compiler-rt] = "-DCLANG_DEFAULT_RTLIB=compiler-rt,," PACKAGECONFIG[libcplusplus] = "-DCLANG_DEFAULT_CXX_STDLIB=libc++,," diff --git a/recipes-devtools/clang/compiler-rt-sanitizers_git.bb b/recipes-devtools/clang/compiler-rt-sanitizers_git.bb index 6c413b2..bc72861 100644 --- a/recipes-devtools/clang/compiler-rt-sanitizers_git.bb +++ b/recipes-devtools/clang/compiler-rt-sanitizers_git.bb @@ -40,7 +40,7 @@ EXTRA_OECMAKE += "-DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DCMAKE_C_COMPILER_TARGET=${HOST_ARCH}${HOST_VENDOR}-${HOST_OS}${HF} \ -DCOMPILER_RT_BUILD_BUILTINS=OFF \ -DCOMPILER_RT_INCLUDE_TESTS=OFF \ - -DSANITIZER_CXX_ABI_LIBNAME=${@bb.utils.contains("RUNTIME", "llvm", "libc++", "libstdc++", d)} \ + -DSANITIZER_CXX_ABI_LIBNAME=${@bb.utils.contains("TC_CXX_RUNTIME", "llvm", "libc++", "libstdc++", d)} \ -DCOMPILER_RT_BUILD_XRAY=ON \ -DCOMPILER_RT_BUILD_SANITIZERS=ON \ -DCOMPILER_RT_BUILD_LIBFUZZER=ON \ diff --git a/recipes-devtools/clang/libcxx_git.bb b/recipes-devtools/clang/libcxx_git.bb index 13136fc..3d5ce54 100644 --- a/recipes-devtools/clang/libcxx_git.bb +++ b/recipes-devtools/clang/libcxx_git.bb @@ -10,7 +10,7 @@ require common-source.inc inherit cmake cmake-native python3native -PACKAGECONFIG ??= "compiler-rt exceptions ${@bb.utils.contains("RUNTIME", "llvm", "unwind unwind-shared", "", d)}" +PACKAGECONFIG ??= "compiler-rt exceptions ${@bb.utils.contains("TC_CXX_RUNTIME", "llvm", "unwind unwind-shared", "", d)}" PACKAGECONFIG:append:armv5 = " no-atomics" PACKAGECONFIG:remove:class-native = "compiler-rt" PACKAGECONFIG[unwind] = "-DLIBCXXABI_USE_LLVM_UNWINDER=ON -DLIBCXXABI_ENABLE_STATIC_UNWINDER=ON,-DLIBCXXABI_USE_LLVM_UNWINDER=OFF,," @@ -50,7 +50,7 @@ LIC_FILES_CHKSUM = "file://libcxx/LICENSE.TXT;md5=55d89dd7eec8d3b4204b680e27da39 " OECMAKE_TARGET_COMPILE = "cxxabi cxx" -OECMAKE_TARGET_INSTALL = "install-cxx install-cxxabi ${@bb.utils.contains("RUNTIME", "llvm", "install-unwind", "", d)}" +OECMAKE_TARGET_INSTALL = "install-cxx install-cxxabi ${@bb.utils.contains("TC_CXX_RUNTIME", "llvm", "install-unwind", "", d)}" OECMAKE_SOURCEPATH = "${S}/llvm" EXTRA_OECMAKE += "\ @@ -97,7 +97,7 @@ ALLOW_EMPTY:${PN} = "1" PROVIDES:append:runtime-llvm = " libunwind" do_install:append() { - if ${@bb.utils.contains("RUNTIME", "llvm", "true", "false", d)} + if ${@bb.utils.contains("TC_CXX_RUNTIME", "llvm", "true", "false", d)} then for f in libunwind.h __libunwind_config.h unwind.h unwind_itanium.h unwind_arm_ehabi.h do diff --git a/recipes-extended/ghostscript/ghostscript_%.bbappend b/recipes-extended/ghostscript/ghostscript_%.bbappend index c1496d0..49cf24e 100644 --- a/recipes-extended/ghostscript/ghostscript_%.bbappend +++ b/recipes-extended/ghostscript/ghostscript_%.bbappend @@ -1,7 +1,7 @@ FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" do_configure:prepend:toolchain-clang () { - if ${@bb.utils.contains('RUNTIME', 'llvm', 'true', 'false', d)}; then + if ${@bb.utils.contains('TC_CXX_RUNTIME', 'llvm', 'true', 'false', d)}; then sed -i -e "s|-stdlib=libstdc++|-stdlib=libc++|g" ${S}/configure.ac fi } -- cgit v1.2.3-54-g00ecf