From 1b0f5de3b3137509a7c60d372c5e58782144ac57 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Fri, 21 Aug 2015 14:07:05 -0700 Subject: clang/classes: Invert the logic to select toolchain and default to clang So far we have been selecting which packages are compiled using clang this patch changes the logic to use clang by default unless selecting TOOLCHAIN = "gcc" explicitly in the recipe We have not yet enabled clang for native recipes, its only enabled for target recipes needing cross compilation as of now. Get rid of configuration file and move the code to clang.bbclass, simplifies the logic If needed to select gcc to be default system compiler set TOOLCHAIN = "gcc" in local.conf Signed-off-by: Khem Raj --- classes/clang.bbclass | 43 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) (limited to 'classes') diff --git a/classes/clang.bbclass b/classes/clang.bbclass index f6cb648..b560289 100644 --- a/classes/clang.bbclass +++ b/classes/clang.bbclass @@ -1,10 +1,41 @@ - # Add the necessary override -TOOLCHAINOVERRIDES = ":toolchain-${TOOLCHAIN}" -TOOLCHAINOVERRIDES[vardepsexclude] = "TOOLCHAIN" +CC_toolchain-clang = "${TARGET_PREFIX}clang ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}" +CXX_toolchain-clang = "${TARGET_PREFIX}clang++ ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}" +CPP_toolchain-clang = "${TARGET_PREFIX}clang ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} -E" +CCLD_toolchain-clang = "${TARGET_PREFIX}clang ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}" +THUMB_TUNE_CCARGS_remove_toolchain-clang = "-mthumb-interwork" +TUNE_CCARGS_append_toolchain-clang = " -D__extern_always_inline=inline -no-integrated-as" + +TOOLCHAIN_OPTIONS_append_toolchain-clang_class-nativesdk_x86-64 = " -Wl,-dynamic-linker,${base_libdir}/ld-linux-x86-64.so.2" +TOOLCHAIN_OPTIONS_append_toolchain-clang_class-nativesdk_x86 = " -Wl,-dynamic-linker,${base_libdir}/ld-linux.so.2" + +# choose between 'gcc' 'clang' an empty '' can be used as well +TOOLCHAIN ??= "clang" + +TOOLCHAIN_class-native = "gcc" + +OVERRIDES .= "${@['', ':toolchain-${TOOLCHAIN}']['${TOOLCHAIN}' != '']}" +OVERRIDES[vardepsexclude] += "TOOLCHAIN" + +#DEPENDS_append_toolchain-clang_class-target = " clang-cross-${TARGET_ARCH} " +#DEPENDS_remove_toolchain-clang_allarch = "clang-cross-${TARGET_ARCH}" + +def clang_dep_prepend(d): + # + # Ideally this will check a flag so we will operate properly in + # the case where host == build == target, for now we don't work in + # that case though. + # -OVERRIDES .= "${TOOLCHAINOVERRIDES}" -OVERRIDES[vardepsexclude] += "TOOLCHAINOVERRIDES" + deps = "" + # INHIBIT_DEFAULT_DEPS doesn't apply to the patch command. Whether or not + # we need that built is the responsibility of the patch function / class, not + # the application. + if not d.getVar('INHIBIT_DEFAULT_DEPS', False): + if not oe.utils.inherits(d, 'allarch'): + deps += " clang-cross-${TARGET_ARCH} " + return deps -require conf/clang.conf +CLANGDEPENDS = "${@clang_dep_prepend(d)}" +DEPENDS_prepend_toolchain-clang_class-target = "${CLANGDEPENDS} " -- cgit v1.2.3-54-g00ecf