From da9df5ff07941351f14b2d406ffcf61b166d2cb5 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Thu, 16 Mar 2017 09:10:54 -0700 Subject: clang/compiler-rt: Use compiler-rt and libcxx as default runtime for target clang One can still use -stdlib=libstdc++ and -rtlib=libgcc to use gcc runtime Signed-off-by: Khem Raj --- ...t-search-clang-install-dir-relative-.-lib.patch | 38 -------------------- .../0004-clang-Prepend-trailing-to-sysroot.patch | 41 ++++++++++++++++++++++ recipes-devtools/clang/clang_git.bb | 17 +++++++-- .../0003-Disable-tsan-on-OE-glibc.patch | 27 ++++++++++---- recipes-devtools/clang/compiler-rt_git.bb | 4 +-- 5 files changed, 78 insertions(+), 49 deletions(-) delete mode 100644 recipes-devtools/clang/clang/0004-clang-Do-not-search-clang-install-dir-relative-.-lib.patch create mode 100644 recipes-devtools/clang/clang/0004-clang-Prepend-trailing-to-sysroot.patch diff --git a/recipes-devtools/clang/clang/0004-clang-Do-not-search-clang-install-dir-relative-.-lib.patch b/recipes-devtools/clang/clang/0004-clang-Do-not-search-clang-install-dir-relative-.-lib.patch deleted file mode 100644 index 91a3b67..0000000 --- a/recipes-devtools/clang/clang/0004-clang-Do-not-search-clang-install-dir-relative-.-lib.patch +++ /dev/null @@ -1,38 +0,0 @@ -From b6080c3e17e348464b025d34d84f5851ac9f3ba3 Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Fri, 27 Jan 2017 11:38:45 -0800 -Subject: [PATCH 4/4] clang: Do not search clang install dir relative ../lib - dir - -This in OE is installed in native sysroot and bin/../lib -contains native libraries not target libs - -Signed-off-by: Khem Raj ---- - lib/Driver/ToolChains.cpp | 1 - - 1 file changed, 1 deletion(-) - -Index: clang/lib/Driver/ToolChains.cpp -=================================================================== ---- clang.orig/lib/Driver/ToolChains.cpp -+++ clang/lib/Driver/ToolChains.cpp -@@ -4221,7 +4221,7 @@ Linux::Linux(const Driver &D, const llvm - // directory ('Dir' below) or the ResourceDir. - if (StringRef(D.Dir).startswith(SysRoot)) { - addPathIfExists(D, D.Dir + "/../lib/" + MultiarchTriple, Paths); -- addPathIfExists(D, D.Dir + "/../" + OSLibDir, Paths); -+// addPathIfExists(D, D.Dir + "/../" + OSLibDir, Paths); - } - - addPathIfExists(D, SysRoot + "/lib/" + MultiarchTriple, Paths); -@@ -4265,8 +4265,8 @@ Linux::Linux(const Driver &D, const llvm - // searched. - // FIXME: It's not clear whether we should use the driver's installed - // directory ('Dir' below) or the ResourceDir. -- if (StringRef(D.Dir).startswith(SysRoot)) -- addPathIfExists(D, D.Dir + "/../lib", Paths); -+ //if (StringRef(D.Dir).startswith(SysRoot)) -+ // addPathIfExists(D, D.Dir + "/../lib", Paths); - - addPathIfExists(D, SysRoot + "/lib", Paths); - addPathIfExists(D, SysRoot + "/usr/lib", Paths); diff --git a/recipes-devtools/clang/clang/0004-clang-Prepend-trailing-to-sysroot.patch b/recipes-devtools/clang/clang/0004-clang-Prepend-trailing-to-sysroot.patch new file mode 100644 index 0000000..fbab45e --- /dev/null +++ b/recipes-devtools/clang/clang/0004-clang-Prepend-trailing-to-sysroot.patch @@ -0,0 +1,41 @@ +From b261f7a113462c8f91e729e4dd090b93ea7528e1 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Thu, 16 Mar 2017 09:02:13 -0700 +Subject: [PATCH 4/4] clang: Prepend trailing '/' to sysroot + +This is needed to handle a case where clang +isntall and target sysroot are perilously same + +e.g. + +sysroot = /mnt/clang/recipe-sysroot +clang install = /mnt/clang/recipe-sysroot-native + +in this case it will mistakenly assume that +clang is installed under the same sysroot dir +and it will try to add relative ../lib paths +to linker steps which would then be wrong +since they will become relative to clang +installation and not sysroot + +Signed-off-by: Khem Raj +--- + lib/Driver/ToolChains.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp +index 9d2e343536..2f3aa0680f 100644 +--- a/lib/Driver/ToolChains.cpp ++++ b/lib/Driver/ToolChains.cpp +@@ -4095,7 +4095,7 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) + GCCInstallation.init(Triple, Args); + Multilibs = GCCInstallation.getMultilibs(); + llvm::Triple::ArchType Arch = Triple.getArch(); +- std::string SysRoot = computeSysRoot(); ++ std::string SysRoot = computeSysRoot() + "/"; + + // Cross-compiling binutils and GCC installations (vanilla and openSUSE at + // least) put various tools in a triple-prefixed directory off of the parent +-- +2.12.0 + diff --git a/recipes-devtools/clang/clang_git.bb b/recipes-devtools/clang/clang_git.bb index cc0d45e..29e2e8f 100644 --- a/recipes-devtools/clang/clang_git.bb +++ b/recipes-devtools/clang/clang_git.bb @@ -15,14 +15,21 @@ LIC_FILES_CHKSUM = "file://LICENSE.TXT;md5=${LLVMMD5SUM}; \ " SRC_URI = "${LLVM_GIT}/llvm.git;protocol=${LLVM_GIT_PROTOCOL};branch=${BRANCH};name=llvm \ ${LLVM_GIT}/clang.git;protocol=${LLVM_GIT_PROTOCOL};branch=${BRANCH};destsuffix=git/tools/clang;name=clang \ + " + +# llvm patches +SRC_URI += "\ file://0001-llvm-Remove-CMAKE_CROSSCOMPILING-so-it-can-cross-com.patch \ file://0002-llvm-Do-not-assume-linux-glibc.patch \ file://0003-llvm-TargetLibraryInfo-Undefine-libc-functions-if-th.patch \ - \ + " + +# Clang patches +SRC_URI += "\ file://0001-clang-driver-Use-lib-for-ldso-on-OE.patch;patchdir=tools/clang \ file://0002-clang-Driver-tools.cpp-Add-lssp-and-lssp_nonshared-o.patch;patchdir=tools/clang \ file://0003-clang-musl-ppc-does-not-support-128-bit-long-double.patch;patchdir=tools/clang \ - file://0004-clang-Do-not-search-clang-install-dir-relative-.-lib.patch;patchdir=tools/clang \ + file://0004-clang-Prepend-trailing-to-sysroot.patch;patchdir=tools/clang \ " SRCREV_FORMAT = "llvm_clang" @@ -57,6 +64,12 @@ def get_clang_target_arch(bb, d): #TUNE_CCARGS_append_class-target = " -D__extern_always_inline=inline -I${PKG_CONFIG_SYSROOT_DIR}${includedir}/libxml2 " #LDFLAGS_append_class-target = " -L${PKG_CONFIG_SYSROOT_DIR}${libdir}/libxml2 " +PACKAGECONFIG ??= "compiler-rt libcplusplus" +PACKAGECONFIG_class-native = "" + +PACKAGECONFIG[compiler-rt] = "-DCLANG_DEFAULT_RTLIB=compiler-rt,,compiler-rt" +PACKAGECONFIG[libcplusplus] = "-DCLANG_DEFAULT_CXX_STDLIB=libc++,,libcxx" + EXTRA_OECMAKE="-DLLVM_ENABLE_RTTI=True \ -DLLVM_ENABLE_FFI=False \ -DCMAKE_SYSTEM_NAME=Linux \ diff --git a/recipes-devtools/clang/compiler-rt/0003-Disable-tsan-on-OE-glibc.patch b/recipes-devtools/clang/compiler-rt/0003-Disable-tsan-on-OE-glibc.patch index 67e660d..045f8ac 100644 --- a/recipes-devtools/clang/compiler-rt/0003-Disable-tsan-on-OE-glibc.patch +++ b/recipes-devtools/clang/compiler-rt/0003-Disable-tsan-on-OE-glibc.patch @@ -1,21 +1,22 @@ -From 622ef6bbd65f71ebbaf3525d50fb357e62631a08 Mon Sep 17 00:00:00 2001 +From 00ac81c887f0f6eb31bed1e516374b6aa01b6389 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Mon, 18 Jul 2016 08:05:02 +0000 -Subject: [PATCH 3/3] Disable tsan on OE/glibc +Subject: [PATCH 3/4] Disable tsan on OE/glibc It does not build see http://lists.llvm.org/pipermail/llvm-dev/2016-July/102235.html Signed-off-by: Khem Raj --- - cmake/config-ix.cmake | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) + cmake/config-ix.cmake | 2 +- + test/sanitizer_common/CMakeLists.txt | 1 - + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake -index cb9f74b..d7e0fba 100644 +index e0e43552e..bb3c77f6d 100644 --- a/cmake/config-ix.cmake +++ b/cmake/config-ix.cmake -@@ -472,7 +472,7 @@ else() +@@ -491,7 +491,7 @@ else() endif() if (COMPILER_RT_HAS_SANITIZER_COMMON AND TSAN_SUPPORTED_ARCH AND @@ -24,6 +25,18 @@ index cb9f74b..d7e0fba 100644 set(COMPILER_RT_HAS_TSAN TRUE) else() set(COMPILER_RT_HAS_TSAN FALSE) +diff --git a/test/sanitizer_common/CMakeLists.txt b/test/sanitizer_common/CMakeLists.txt +index 9b4070b0f..e76f2680c 100644 +--- a/test/sanitizer_common/CMakeLists.txt ++++ b/test/sanitizer_common/CMakeLists.txt +@@ -8,7 +8,6 @@ if(CMAKE_SYSTEM_NAME MATCHES "Darwin|Linux|FreeBSD" AND NOT ANDROID) + list(APPEND SUPPORTED_TOOLS asan) + endif() + if(CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT ANDROID) +- list(APPEND SUPPORTED_TOOLS tsan) + list(APPEND SUPPORTED_TOOLS msan) + list(APPEND SUPPORTED_TOOLS lsan) + endif() -- -2.10.0 +2.12.0 diff --git a/recipes-devtools/clang/compiler-rt_git.bb b/recipes-devtools/clang/compiler-rt_git.bb index 9ceaff9..e8da315 100644 --- a/recipes-devtools/clang/compiler-rt_git.bb +++ b/recipes-devtools/clang/compiler-rt_git.bb @@ -56,7 +56,7 @@ do_install_append () { } FILES_SOLIBSDEV = "" -FILES_${PN} += "${libdir}/clang/${BASEPV}/lib/linux/lib*${SOLIBSDEV}" +FILES_${PN} += "${libdir}/clang/${BASEPV}/lib/linux/lib*${SOLIBSDEV} ${libdir}/clang/${BASEPV}/*.txt" FILES_${PN}-staticdev += "${libdir}/clang/${BASEPV}/lib/linux/*.a" INSANE_SKIP_${PN} = "dev-so" @@ -69,7 +69,7 @@ INSANE_SKIP_${PN} = "dev-so" # " # -FILES_${PN}-dev += "${libdir}/clang/${BASEPV}/lib/linux/*.syms ${libdir}/clang/${BASEPV}/lib/linux/*.txt" +FILES_${PN}-dev += "${libdir}/clang/${BASEPV}/lib/linux/*.syms" BBCLASSEXTEND = "native nativesdk" -- cgit v1.2.3-54-g00ecf