clang: Fix libgcc.so.1.0 symlink to point to libunwind.so.1
PATCH 1/6 clang: Fix libgcc.so.1.0 symlink to point to libunwind.so.1
Pointing to libunwind.so results in build QA errors since libunwind.so ends up in -dev package
--- ...symlink-path-for-libcc-when-LLVM_ENA.patch | 33 ++++++++ ...libgcc.a-symlink-path-when-LLVM_ENAB.patch | 83 +++++++++++++++++++ meta/recipes-devtools/clang/common.inc | 4 +- 3 files changed, 119 insertions(+), 1 deletion(-) create mode 100644 meta/recipes-devtools/clang/clang/0040-llvm-libgcc-Fix-symlink-path-for-libcc-when-LLVM_ENA.patch create mode 100644 meta/recipes-devtools/clang/clang/0041-llvm-libgcc-Fix-libgcc.a-symlink-path-when-LLVM_ENAB.patch
meta/recipes-devtools/clang/clang/0040-llvm-libgcc-Fix-symlink-path-for-libcc-when-LLVM_ENA.patch new file +33 -0
@@ -0,0 +1,33 @@ +From 4204fd1b62de30418433139fea1b7dad4fff9c59 Mon Sep 17 00:00:00 2001 +From: Khem Raj <[email protected]> +Date: Tue, 28 Oct 2025 15:44:49 -0700 +Subject: [PATCH] [llvm-libgcc] Fix symlink path for libgcc + +The symlink for libgcc_so.1.0 is made to point to libunwind.so +which is functionally correct but it fails some linux distro packaging +complain because libunwind.so is made part of -dev package but +libgcc_so.1.0 ends up in the real package, and creates an unneeded +package -> dev dependency + +create the symlink to point to libunwind.so.1 instead then the boundaries +of packaging are not crossed and all is well. + +Upstream-Status: Submitted [https://github.com/llvm/llvm-project/pull/165487] +Signed-off-by: Khem Raj <[email protected]> +--- + llvm-libgcc/CMakeLists.txt | 16 +++++++++++++--- + 1 file changed, 13 insertions(+), 3 deletions(-) + +diff --git a/llvm-libgcc/CMakeLists.txt b/llvm-libgcc/CMakeLists.txt +index 47208fc19869..54009c1104c3 100644 +--- a/llvm-libgcc/CMakeLists.txt ++++ b/llvm-libgcc/CMakeLists.txt +@@ -137,7 +147,7 @@ add_custom_target(llvm-libgcc ALL + DEPENDS unwind_shared unwind_static clang_rt.builtins-${COMPILER_RT_DEFAULT_TARGET_ARCH} + COMMAND ${CMAKE_COMMAND} -E create_symlink ${LLVM_LIBGCC_COMPILER_RT} libgcc.a + COMMAND ${CMAKE_COMMAND} -E create_symlink libunwind.a libgcc_eh.a +- COMMAND ${CMAKE_COMMAND} -E create_symlink libunwind.so libgcc_s.so.1.0 ++ COMMAND ${CMAKE_COMMAND} -E create_symlink libunwind.so.1 libgcc_s.so.1.0 + COMMAND ${CMAKE_COMMAND} -E create_symlink libgcc_s.so.1.0 libgcc_s.so.1 + COMMAND ${CMAKE_COMMAND} -E create_symlink libgcc_s.so.1 libgcc_s.so + )
meta/recipes-devtools/clang/clang/0041-llvm-libgcc-Fix-libgcc.a-symlink-path-when-LLVM_ENAB.patch new file +83 -0
83 lines not on this page · raw message
meta/recipes-devtools/clang/common.inc +3 -1
@@ -38,7 +38,7 @@ SRC_URI = "\ file://0016-clang-driver-Add-dyld-prefix-when-checking-sysroot-f.patch \ file://0017-clang-Use-python3-in-python-scripts.patch \ file://0018-llvm-clang-Insert-anchor-for-adding-OE-distro-vendor.patch \ - file://0019-compiler-rt-Do-not-use-backtrace-APIs-on-non-glibc-l.patch \ + file://0019-compiler-rt-Do-not-use-backtrace-APIs-on-non-glibc-l.patch \ file://0020-clang-Fix-x86-triple-for-non-debian-multiarch-linux-.patch \ file://0021-libunwind-Added-unw_backtrace-method.patch \ file://0022-lldb-Link-with-libatomic-on-x86.patch \
@@ -59,6 +59,8 @@ SRC_URI = "\ file://0037-Revert-libc-Remap-headers-in-the-debug-info-when-bui.patch \ file://0038-Prevent-revisiting-block-when-searching-for-noreturn.patch \ file://0039-Only-build-c-index-test-when-clang-tests-are-include.patch \ + file://0040-llvm-libgcc-Fix-symlink-path-for-libcc-when-LLVM_ENA.patch \ + file://0041-llvm-libgcc-Fix-libgcc.a-symlink-path-when-LLVM_ENAB.patch \ file://0001-Install-lldb-tblgen.patch \ file://0001-dont-expose-LLVM_HAVE_OPT_VIEWER_MODULES.patch \ file://0001-clang-Support-building-native-tools-when-cross-compi.patch \
PATCH 2/6 compiler-rt: Remove the need to depend on libgcc
libgcc is only used in cmake tests for compiler checks which works in contained environment like OE, add depedencies on native version of compiler-rt and libcxx for compiler to use
Do not build orc builtins, its only needed for JIT which OE does not use.
--- meta/recipes-devtools/clang/compiler-rt_git.bb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
meta/recipes-devtools/clang/compiler-rt_git.bb +6 -5
@@ -25,9 +25,8 @@ TUNE_CCARGS:remove = "-no-integrated-as" INHIBIT_DEFAULT_DEPS = "1" -DEPENDS += "libgcc" -DEPENDS:append:class-target = " virtual/cross-c++ ${MLPREFIX}clang-cross-${TARGET_ARCH} virtual/${MLPREFIX}libc gcc-runtime" -DEPENDS:append:class-nativesdk = " virtual/cross-c++ clang-native clang-crosssdk-${SDK_SYS} nativesdk-gcc-runtime" +DEPENDS:append:class-target = " virtual/cross-c++ ${MLPREFIX}clang-cross-${TARGET_ARCH} virtual/${MLPREFIX}libc libcxx-native compiler-rt-native" +DEPENDS:append:class-nativesdk = " virtual/cross-c++ clang-native clang-crosssdk-${SDK_SYS}" DEPENDS:append:class-native = " clang-native" DEPENDS:remove:class-native = "libcxx-native compiler-rt-native"
@@ -76,6 +75,8 @@ INSTALL_VER ?= "${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}${VER_SUFFIX}" INSTALL_VER:class-native = "${@oe.utils.trim_version("${PV}", 1)}" EXTRA_OECMAKE += "-DCMAKE_BUILD_TYPE=RelWithDebInfo \ + -DCMAKE_C_COMPILER_WORKS=ON \ + -DCMAKE_CXX_COMPILER_WORKS=ON \ -DCOMPILER_RT_STANDALONE_BUILD=ON \ -DCOMPILER_RT_INCLUDE_TESTS=OFF \ -DCOMPILER_RT_BUILD_XRAY=OFF \
@@ -100,6 +101,7 @@ EXTRA_OECMAKE:append:class-target = "\ -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON \ -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF \ + -DCOMPILER_RT_BUILD_ORC=OFF \ " EXTRA_OECMAKE:append:class-nativesdk = "\
@@ -111,14 +113,13 @@ EXTRA_OECMAKE:append:class-nativesdk = "\ -DCMAKE_C_COMPILER_TARGET=${HOST_SYS} \ -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON \ -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF \ + -DCOMPILER_RT_BUILD_ORC=OFF \ " do_install:append () { if [ "${HF}" = "hf" ]; then mv -f ${D}${nonarch_libdir}/clang/${INSTALL_VER}/lib/linux/libclang_rt.builtins-arm.a \ ${D}${nonarch_libdir}/clang/${INSTALL_VER}/lib/linux/libclang_rt.builtins-armhf.a - mv -f ${D}${nonarch_libdir}/clang/${INSTALL_VER}/lib/linux/liborc_rt-arm.a \ - ${D}${nonarch_libdir}/clang/${INSTALL_VER}/lib/linux/liborc_rt-armhf.a fi }
PATCH 3/6 compiler-rt: Always build c runtime (crt) files
In reply to Khem RajMakes llvm runtime provide another step towards providing platform C/C++ runtime
--- meta/recipes-devtools/clang/compiler-rt_git.bb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-devtools/clang/compiler-rt_git.bb +1 -1
@@ -41,7 +41,7 @@ UNWINDLIB:class-target = "--unwindlib=libgcc" COMPILER_RT:class-target = "-rtlib=libgcc" LIBCPLUSPLUS:class-target = "-stdlib=libstdc++" -PACKAGECONFIG ??= "" +PACKAGECONFIG ??= "crt" PACKAGECONFIG[crt] = "-DCOMPILER_RT_BUILD_CRT:BOOL=ON,-DCOMPILER_RT_BUILD_CRT:BOOL=OFF" PACKAGECONFIG[profile] = "-DCOMPILER_RT_BUILD_PROFILE=ON,-DCOMPILER_RT_BUILD_PROFILE=OFF" # Context Profiling, might need to enable 'profile' too
PATCH 4/6 libcxx: Remove gnu runtime from dependencies
In reply to Khem RajThere is no need to have these dependencies if we can cache some of cmake values, it really does not need these packages to build or run
It also simplifies the depchain a bit.
--- meta/recipes-devtools/clang/libcxx_git.bb | 25 +++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-)
meta/recipes-devtools/clang/libcxx_git.bb +17 -8
@@ -12,7 +12,7 @@ inherit cmake BPN = "libcxx" -PACKAGECONFIG ??= "compiler-rt exceptions ${@bb.utils.contains("TC_CXX_RUNTIME", "llvm", "unwind unwind-shared", "", d)}" +PACKAGECONFIG ??= "compiler-rt exceptions unwind ${@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,,"
@@ -22,19 +22,20 @@ PACKAGECONFIG[compiler-rt] = "-DLIBCXX_USE_COMPILER_RT=ON -DLIBCXXABI_USE_COMPIL PACKAGECONFIG[unwind-shared] = "-DLIBUNWIND_ENABLE_SHARED=ON,-DLIBUNWIND_ENABLE_SHARED=OFF,," PACKAGECONFIG[unwind-cross] = "-DLIBUNWIND_ENABLE_CROSS_UNWINDING=ON,-DLIBUNWIND_ENABLE_CROSS_UNWINDING=OFF,," -DEPENDS:append:class-target = " virtual/cross-c++ ${MLPREFIX}clang-cross-${TARGET_ARCH} virtual/${MLPREFIX}libc virtual/${MLPREFIX}compilerlibs" -DEPENDS:append:class-nativesdk = " virtual/cross-c++ clang-crosssdk-${SDK_SYS} nativesdk-compiler-rt" +DEPENDS:append:class-target = " virtual/cross-c++ ${MLPREFIX}clang-cross-${TARGET_ARCH} virtual/${MLPREFIX}libc" +DEPENDS:append:class-nativesdk = " virtual/cross-c++ clang-crosssdk-${SDK_SYS} nativesdk-compiler-rt virtual/nativesdk-libc" DEPENDS:append:class-native = " clang-native compiler-rt-native" DEPENDS:remove:class-native = "libcxx-native" COMPILER_RT ?= "${@bb.utils.contains("PACKAGECONFIG", "compiler-rt", "-rtlib=compiler-rt", "-rtlib=libgcc", d)}" UNWINDLIB ?= "${@bb.utils.contains("PACKAGECONFIG", "unwind", "-unwindlib=none", "-unwindlib=libgcc", d)}" -LIBCPLUSPLUS ?= "-stdlib=libstdc++" +LIBCPLUSPLUS ?= "" +#LIBCPLUSPLUS ?= "-stdlib=libstdc++" # Trick clang.bbclass into not creating circular dependencies -UNWINDLIB:class-nativesdk = "-unwindlib=libgcc" -LIBCPLUSPLUS:class-nativesdk = "-stdlib=libstdc++" +#UNWINDLIB:class-nativesdk = "-unwindlib=libgcc" +#LIBCPLUSPLUS:class-nativesdk = "-stdlib=libstdc++" UNWINDLIB:class-native = "-unwindlib=libgcc" -LIBCPLUSPLUS:class-native = "-stdlib=libstdc++" +#LIBCPLUSPLUS:class-native = "-stdlib=libstdc++" LDFLAGS:append = " ${UNWINDLIB}"
@@ -65,7 +66,7 @@ EXTRA_OECMAKE += "\ -DCMAKE_CROSSCOMPILING=ON \ -DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN=ON \ -DLLVM_ENABLE_RTTI=ON \ - -DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON \ + -DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=OFF \ -DLIBCXXABI_INCLUDE_TESTS=OFF \ -DLIBCXXABI_ENABLE_SHARED=ON \ -DLIBCXXABI_LIBCXX_INCLUDES=${S}/libcxx/include \
@@ -80,6 +81,10 @@ EXTRA_OECMAKE += "\ " EXTRA_OECMAKE:append:class-target = " \ + -DCMAKE_C_COMPILER_WORKS=ON \ + -DCMAKE_CXX_COMPILER_WORKS=ON \ + -DCXX_SUPPORTS_FNO_EXCEPTIONS_FLAG=ON \ + -DCOMPILER_RT_USE_BUILTINS_LIBRARY=ON \ -DCMAKE_AR=${STAGING_BINDIR_TOOLCHAIN}/${AR} \ -DCMAKE_NM=${STAGING_BINDIR_TOOLCHAIN}/${NM} \ -DCMAKE_RANLIB=${STAGING_BINDIR_TOOLCHAIN}/${RANLIB} \
@@ -88,6 +93,10 @@ EXTRA_OECMAKE:append:class-target = " \ " EXTRA_OECMAKE:append:class-nativesdk = " \ + -DCMAKE_C_COMPILER_WORKS=ON \ + -DCMAKE_CXX_COMPILER_WORKS=ON \ + -DCXX_SUPPORTS_FNO_EXCEPTIONS_FLAG=ON \ + -DCOMPILER_RT_USE_BUILTINS_LIBRARY=ON \ -DCMAKE_AR=${STAGING_BINDIR_TOOLCHAIN}/${AR} \ -DCMAKE_NM=${STAGING_BINDIR_TOOLCHAIN}/${NM} \ -DCMAKE_RANLIB=${STAGING_BINDIR_TOOLCHAIN}/${RANLIB} \
PATCH 5/6 compiler-rt-sanitizers: Adjust for compiler-rt changes
In reply to Khem Raj* ORC is not built with compiler-rt anymore, hence package it here
* Avoid duplication in specifying cmake sourcedir, use OECMAKE_SOURCEPATH
* Since RUNTIMES are bounded there is no need to specify build targets explicitly
--- .../clang/compiler-rt-sanitizers_git.bb | 23 ++++--------------- 1 file changed, 5 insertions(+), 18 deletions(-)
meta/recipes-devtools/clang/compiler-rt-sanitizers_git.bb +5 -18
@@ -25,24 +25,20 @@ def get_compiler_rt_arch(bb, d): LIC_FILES_CHKSUM = "file://compiler-rt/LICENSE.TXT;md5=d846d1d65baf322d4c485d6ee54e877a" -TUNE_CCARGS:remove = "-no-integrated-as" -COMPILER_RT ??= "-rtlib=libgcc -unwindlib=libgcc" -LIBCPLUSPLUS ??= "-stdlib=libstdc++" - CC = "${CCACHE}${HOST_PREFIX}clang ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}" CXX = "${CCACHE}${HOST_PREFIX}clang++ ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}" BUILD_CC = "${CCACHE}${HOST_PREFIX}clang ${BUILD_CC_ARCH}" BUILD_CXX = "${CCACHE}${HOST_PREFIX}clang++ ${BUILD_CC_ARCH}$" -CFLAGS += "${COMPILER_RT}" -CXXFLAGS += "${COMPILER_RT} ${LIBCPLUSPLUS}" TOOLCHAIN = "clang" TOOLCHAIN_NATIVE = "clang" DEPENDS += "virtual/crypt compiler-rt" DEPENDS:append:class-native = " clang-native libxcrypt-native libcxx-native" -DEPENDS:append:class-nativesdk = " virtual/cross-c++ clang-native clang-crosssdk-${SDK_SYS} nativesdk-libxcrypt nativesdk-gcc-runtime" -DEPENDS:append:class-target = " virtual/cross-c++ ${MLPREFIX}clang-cross-${TARGET_ARCH} virtual/${MLPREFIX}libc gcc-runtime" +DEPENDS:append:class-nativesdk = " virtual/cross-c++ clang-native clang-crosssdk-${SDK_SYS} nativesdk-libxcrypt" +DEPENDS:append:class-nativesdk = " ${@bb.utils.contains("TC_CXX_RUNTIME", "llvm", "nativesdk-libcxx", "nativesdk-gcc-runtime", d)}" +DEPENDS:append:class-target = " virtual/cross-c++ ${MLPREFIX}clang-cross-${TARGET_ARCH} virtual/${MLPREFIX}libc" +DEPENDS:append:class-target = " ${@bb.utils.contains("TC_CXX_RUNTIME", "llvm", "libcxx", "gcc-runtime", d)}" PACKAGECONFIG ??= "" PACKAGECONFIG[crt] = "-DCOMPILER_RT_BUILD_CRT:BOOL=ON,-DCOMPILER_RT_BUILD_CRT:BOOL=OFF"
@@ -52,9 +48,7 @@ PACKAGECONFIG[ctx-profile] = "-DCOMPILER_RT_BUILD_CTX_PROFILE=ON,-DCOMPILER_RT_B CXXFLAGS:append:libc-musl = " -D_LARGEFILE64_SOURCE" -OECMAKE_TARGET_COMPILE = "compiler-rt" -OECMAKE_TARGET_INSTALL = "install-compiler-rt install-compiler-rt-headers" -OECMAKE_SOURCEPATH = "${S}/llvm" +OECMAKE_SOURCEPATH = "${S}/runtimes" INSTALL_VER ?= "${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}${VER_SUFFIX}" INSTALL_VER:class-native = "${@oe.utils.trim_version("${PV}", 1)}"
@@ -75,7 +69,6 @@ EXTRA_OECMAKE += "-DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DLLVM_LIBDIR_SUFFIX=${LLVM_LIBDIR_SUFFIX} \ -DLLVM_APPEND_VC_REV=OFF \ -DCOMPILER_RT_INSTALL_PATH=${nonarch_libdir}/clang/${INSTALL_VER} \ - -S ${S}/runtimes \ " EXTRA_OECMAKE:append:class-native = "\
@@ -106,12 +99,6 @@ EXTRA_OECMAKE:append:class-nativesdk = "\ EXTRA_OECMAKE:append:libc-musl = " -DLIBCXX_HAS_MUSL_LIBC=ON " -do_install:append () { - # Already shipped with compile-rt Orc support - rm -rf ${D}${nonarch_libdir}/clang/${MAJOR_VER}/lib/linux/liborc_rt-*.a - rm -rf ${D}${nonarch_libdir}/clang/${MAJOR_VER}/include/orc/ -} - FILES_SOLIBSDEV = "" FILES:${PN} += "${nonarch_libdir}/clang/${INSTALL_VER} \ ${nonarch_libdir}/clang/${MAJOR_VER}/lib/linux/lib*${SOLIBSDEV} \
PATCH 6/6 libcxx/compiler-rt: Add support for llvm-libgcc
In reply to Khem Rajllvm-libgcc is a drop-in replacement for libgcc and crt* files and its API compatible as well, built out of compiler-rt and libunwind projects.
Its only enabled when TC_CXX_RUNTIME is set to 'llvm' since user intends to use LLVM provided runtime packages as default platform/system runtime.
Move libunwind out of libcxx recipe into compiler-rt recipe, to facilicate building llvm-libgcc
Package and build crt* files, creating symlinks for names as they are expected by gcc, to help build packages with gcc when and where needed.
Always use LLD linker to build compiler-rt since the versioning script to generate libgcc compatibility expects it to be LLD and not BFD linker doing the link
--- .../recipes-devtools/clang/compiler-rt_git.bb | 84 +++++++++---------- meta/recipes-devtools/clang/libcxx_git.bb | 57 +++---------- 2 files changed, 50 insertions(+), 91 deletions(-)
meta/recipes-devtools/clang/compiler-rt_git.bb +38 -46
@@ -16,32 +16,25 @@ BPN = "compiler-rt" inherit cmake pkgconfig -LIC_FILES_CHKSUM = "file://compiler-rt/LICENSE.TXT;md5=d846d1d65baf322d4c485d6ee54e877a" - -LIBCPLUSPLUS = "" -COMPILER_RT = "" - -TUNE_CCARGS:remove = "-no-integrated-as" +LIC_FILES_CHKSUM = "\ + file://compiler-rt/LICENSE.TXT;md5=d846d1d65baf322d4c485d6ee54e877a \ + file://libunwind/LICENSE.TXT;md5=f66970035d12f196030658b11725e1a1 \ +" INHIBIT_DEFAULT_DEPS = "1" DEPENDS:append:class-target = " virtual/cross-c++ ${MLPREFIX}clang-cross-${TARGET_ARCH} virtual/${MLPREFIX}libc libcxx-native compiler-rt-native" DEPENDS:append:class-nativesdk = " virtual/cross-c++ clang-native clang-crosssdk-${SDK_SYS}" DEPENDS:append:class-native = " clang-native" +DEPENDS:append:class-native = "${@bb.utils.contains("TC_CXX_RUNTIME", "llvm", " lld-native", "", d)}" DEPENDS:remove:class-native = "libcxx-native compiler-rt-native" -# Trick clang.bbclass into not creating circular dependencies -UNWINDLIB:class-nativesdk = "--unwindlib=libgcc" -COMPILER_RT:class-nativesdk = "-rtlib=libgcc" -LIBCPLUSPLUS:class-nativesdk = "-stdlib=libstdc++" -UNWINDLIB:class-native = "--unwindlib=libgcc" -COMPILER_RT:class-native = "-rtlib=libgcc" -LIBCPLUSPLUS:class-native = "-stdlib=libstdc++" -UNWINDLIB:class-target = "--unwindlib=libgcc" -COMPILER_RT:class-target = "-rtlib=libgcc" -LIBCPLUSPLUS:class-target = "-stdlib=libstdc++" - -PACKAGECONFIG ??= "crt" +PROVIDES += "${@bb.utils.contains("TC_CXX_RUNTIME", "llvm", "libgcc", "", d)}" +RPROVIDES:${PN} += "${@bb.utils.contains("TC_CXX_RUNTIME", "llvm", "libgcc", "", d)}" +RPROVIDES:${PN}-dev += "${@bb.utils.contains("TC_CXX_RUNTIME", "llvm", "libgcc-dev", "", d)}" +RPROVIDES:${PN}-dbg += "${@bb.utils.contains("TC_CXX_RUNTIME", "llvm", "libgcc-dbg", "", d)}" + +PACKAGECONFIG ??= "${@bb.utils.contains("TC_CXX_RUNTIME", "llvm", "crt", "", d)}" PACKAGECONFIG[crt] = "-DCOMPILER_RT_BUILD_CRT:BOOL=ON,-DCOMPILER_RT_BUILD_CRT:BOOL=OFF" PACKAGECONFIG[profile] = "-DCOMPILER_RT_BUILD_PROFILE=ON,-DCOMPILER_RT_BUILD_PROFILE=OFF" # Context Profiling, might need to enable 'profile' too
@@ -50,10 +43,7 @@ PACKAGECONFIG[ctx-profile] = "-DCOMPILER_RT_BUILD_CTX_PROFILE=ON,-DCOMPILER_RT_B HF = "" HF:class-target = "${@ bb.utils.contains('TUNE_CCARGS_MFLOAT', 'hard', 'hf', '', d)}" -CC = "${CCACHE}${HOST_PREFIX}clang ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}" -CXX = "${CCACHE}${HOST_PREFIX}clang++ ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}" -LDFLAGS += "${COMPILER_RT} ${UNWINDLIB}" -CXXFLAGS += "${LIBCPLUSPLUS}" +LDFLAGS += "${@bb.utils.contains("TC_CXX_RUNTIME", "llvm", " -fuse-ld=lld -unwindlib=none -nostdlib -lpthread -lc", "", d)}" TOOLCHAIN = "clang" TOOLCHAIN_NATIVE = "clang"
@@ -67,41 +57,43 @@ def get_compiler_rt_arch(bb, d): return 'armhf' return d.getVar('HOST_ARCH') -OECMAKE_TARGET_COMPILE = "compiler-rt" -OECMAKE_TARGET_INSTALL = "install-compiler-rt install-compiler-rt-headers" -OECMAKE_SOURCEPATH = "${S}/llvm" - INSTALL_VER ?= "${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}${VER_SUFFIX}" INSTALL_VER:class-native = "${@oe.utils.trim_version("${PV}", 1)}" +OECMAKE_SOURCEPATH = "${S}/runtimes" + +RUNTIMES ?= "${@bb.utils.contains("TC_CXX_RUNTIME", "llvm", "llvm-libgcc", "compiler-rt", d)}" + +LLVMLIBGCCOPTS = "-DLLVM_LIBGCC_EXPLICIT_OPT_IN=Yes" + EXTRA_OECMAKE += "-DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DCMAKE_C_COMPILER_WORKS=ON \ -DCMAKE_CXX_COMPILER_WORKS=ON \ + -DCXX_SUPPORTS_FNO_EXCEPTIONS_FLAG=ON \ + -DCXX_SUPPORTS_FUNWIND_TABLES_FLAG=ON \ -DCOMPILER_RT_STANDALONE_BUILD=ON \ + -DLLVM_LIBGCC_STANDALONE_BUILD=ON \ -DCOMPILER_RT_INCLUDE_TESTS=OFF \ -DCOMPILER_RT_BUILD_XRAY=OFF \ -DCOMPILER_RT_BUILD_SANITIZERS=OFF \ -DCOMPILER_RT_BUILD_MEMPROF=OFF \ -DCOMPILER_RT_BUILD_LIBFUZZER=OFF \ -DCOMPILER_RT_DEFAULT_TARGET_ARCH=${@get_compiler_rt_arch(bb, d)} \ - -DLLVM_ENABLE_RUNTIMES='compiler-rt' \ + -DLLVM_ENABLE_RUNTIMES=${RUNTIMES} \ -DLLVM_LIBDIR_SUFFIX=${LLVM_LIBDIR_SUFFIX} \ -DLLVM_APPEND_VC_REV=OFF \ + -DCOMPILER_RT_BUILD_ORC=OFF \ + -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON \ + -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF \ + -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ + -DCMAKE_C_COMPILER_TARGET=${HOST_SYS} \ -DCOMPILER_RT_INSTALL_PATH=${nonarch_libdir}/clang/${INSTALL_VER} \ - -S ${S}/runtimes \ -" -EXTRA_OECMAKE:append:class-native = "\ - -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON \ + ${@bb.utils.contains("TC_CXX_RUNTIME", "llvm", "${LLVMLIBGCCOPTS}", "", d)} \ " EXTRA_OECMAKE:append:class-target = "\ -DCMAKE_RANLIB=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-ranlib \ -DCMAKE_AR=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-ar \ -DCMAKE_NM=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-nm \ - -DCMAKE_C_COMPILER_TARGET=${HOST_SYS} \ - -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON \ - -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ - -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF \ - -DCOMPILER_RT_BUILD_ORC=OFF \ " EXTRA_OECMAKE:append:class-nativesdk = "\
@@ -110,28 +102,30 @@ EXTRA_OECMAKE:append:class-nativesdk = "\ -DCMAKE_NM=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-nm \ -DLLVM_TABLEGEN=${STAGING_BINDIR_NATIVE}/llvm-tblgen \ -DCLANG_TABLEGEN=${STAGING_BINDIR_NATIVE}/clang-tblgen \ - -DCMAKE_C_COMPILER_TARGET=${HOST_SYS} \ - -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON \ - -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF \ - -DCOMPILER_RT_BUILD_ORC=OFF \ " do_install:append () { if [ "${HF}" = "hf" ]; then - mv -f ${D}${nonarch_libdir}/clang/${INSTALL_VER}/lib/linux/libclang_rt.builtins-arm.a \ + install -Dm 0644 ${D}${nonarch_libdir}/clang/${INSTALL_VER}/lib/linux/libclang_rt.builtins-arm.a \ ${D}${nonarch_libdir}/clang/${INSTALL_VER}/lib/linux/libclang_rt.builtins-armhf.a fi + if ${@bb.utils.contains('TC_CXX_RUNTIME', 'llvm', 'true', 'false', d)}; then + ln -sf clang/${INSTALL_VER}/lib/linux/clang_rt.crtbegin-${@get_compiler_rt_arch(bb, d)}.o ${D}${nonarch_libdir}/crtbegin.o + ln -sf clang/${INSTALL_VER}/lib/linux/clang_rt.crtbegin-${@get_compiler_rt_arch(bb, d)}.o ${D}${nonarch_libdir}/crtbeginS.o + ln -sf clang/${INSTALL_VER}/lib/linux/clang_rt.crtend-${@get_compiler_rt_arch(bb, d)}.o ${D}${nonarch_libdir}/crtend.o + ln -sf clang/${INSTALL_VER}/lib/linux/clang_rt.crtend-${@get_compiler_rt_arch(bb, d)}.o ${D}${nonarch_libdir}/crtendS.o + fi } -FILES_SOLIBSDEV = "" - FILES:${PN} += "${nonarch_libdir}/clang/${INSTALL_VER}/lib/linux/lib*${SOLIBSDEV} \ ${nonarch_libdir}/clang/${INSTALL_VER}/*.txt \ - ${nonarch_libdir}/clang/${INSTALL_VER}/share/*.txt" + ${nonarch_libdir}/clang/${INSTALL_VER}/share/*.txt \ + ${nonarch_libdir}/*.so" FILES:${PN}-staticdev += "${nonarch_libdir}/clang/${INSTALL_VER}/lib/linux/*.a" FILES:${PN}-dev += "${datadir} ${nonarch_libdir}/clang/${INSTALL_VER}/lib/linux/*.syms \ ${nonarch_libdir}/clang/${INSTALL_VER}/include \ ${nonarch_libdir}/clang/${INSTALL_VER}/lib/linux/clang_rt.crt*.o \ + ${nonarch_libdir}/crt*.o \ ${nonarch_libdir}/clang/${INSTALL_VER}/lib/linux/libclang_rt.asan-preinit*.a" INSANE_SKIP:${PN} = "dev-so libdir"
@@ -141,6 +135,4 @@ RDEPENDS:${PN}-dev += "${PN}-staticdev" BBCLASSEXTEND = "native nativesdk" -ALLOW_EMPTY:${PN} = "1" - SYSROOT_DIRS:append:class-target = " ${nonarch_libdir}"
meta/recipes-devtools/clang/libcxx_git.bb +12 -45
115 lines not on this page · raw message