From 0ce41d411f9fd8213584e2b9fdc1cbb99910c330 Mon Sep 17 00:00:00 2001 From: Ming Liu Date: Wed, 23 Aug 2017 09:26:13 +0200 Subject: clang: fix nativesdk build I could not manage to build nativesdk-clang, I encountered errors as follows: (trimmed for purpose) | ../gcc/x86_64-pokysdk-linux/6.3.0/ld:: | cannot find crt1.o: No such file or directory | cannot find crtbegin.o: No such file or directory | cannot find -lgcc | cannot find -lgcc_s After some investigation, I found it's caused by the llvm native tools could not compile with crosssdk toolchains. (special linking flags are needed) So we introduce a cmake-native class with a task to generate a native toolchain file, it will be used to build llvm native tools by passed with CROSS_TOOLCHAIN_FLAGS_NATIVE. Signed-off-by: Ming Liu Signed-off-by: Khem Raj --- classes/cmake-native.bbclass | 47 +++++++++++++++++++++++++++++++++++++ recipes-devtools/clang/clang_git.bb | 3 ++- 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 classes/cmake-native.bbclass diff --git a/classes/cmake-native.bbclass b/classes/cmake-native.bbclass new file mode 100644 index 0000000..911476e --- /dev/null +++ b/classes/cmake-native.bbclass @@ -0,0 +1,47 @@ +# We need to unset CCACHE otherwise cmake gets too confused +CCACHE = "" + +# Native C/C++ compiler (without cpu arch/tune arguments) +OECMAKE_NATIVE_C_COMPILER ?= "`echo ${BUILD_CC} | sed 's/^\([^ ]*\).*/\1/'`" +OECMAKE_NATIVE_CXX_COMPILER ?= "`echo ${BUILD_CXX} | sed 's/^\([^ ]*\).*/\1/'`" +OECMAKE_NATIVE_AR ?= "${BUILD_AR}" + +# Native compiler flags +OECMAKE_NATIVE_C_FLAGS ?= "${BUILD_CC_ARCH} ${BUILD_CFLAGS}" +OECMAKE_NATIVE_CXX_FLAGS ?= "${BUILD_CC_ARCH} ${BUILD_CXXFLAGS}" +OECMAKE_NATIVE_C_FLAGS_RELEASE ?= "-DNDEBUG" +OECMAKE_NATIVE_CXX_FLAGS_RELEASE ?= "-DNDEBUG" +OECMAKE_NATIVE_C_LINK_FLAGS ?= "${BUILD_CC_ARCH} ${BUILD_CPPFLAGS} ${BUILD_LDFLAGS}" +OECMAKE_NATIVE_CXX_LINK_FLAGS ?= "${BUILD_CC_ARCH} ${BUILD_CXXFLAGS} ${BUILD_LDFLAGS}" +BUILD_CXXFLAGS += "${BUILD_CC_ARCH}" +BUILD_CFLAGS += "${BUILD_CC_ARCH}" + +do_generate_native_toolchain_file() { + cat > ${WORKDIR}/toolchain-native.cmake <