diff options
| author | Khem Raj <raj.khem@gmail.com> | 2025-07-10 23:42:33 -0700 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-07-14 17:49:48 +0100 |
| commit | 5a8e96ed11248ede2cc81b88ba7496db5d1a7905 (patch) | |
| tree | 2fb6318c2bb4d27715880f25f6468904d9b82ee9 | |
| parent | ef31bc3074fa51efd46a8f4b17d66a73b05b4ce3 (diff) | |
| download | poky-5a8e96ed11248ede2cc81b88ba7496db5d1a7905.tar.gz | |
compiler-rt: Fix install location for native builds
Currently, clang when used for native builds and uses --rtlib=compiler-rt
does not find the LLVM runtime because its installed in different
directory than where compiler expects it to be. As a result, build fails
for packages using clang in both capacity ( native and cross )
e.g. qtwebengine
Make the build work across native sanitizers as well.
(From OE-Core rev: 4d55698330ce6720cab5dfe9b4e00efeb40ba6e6)
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
| -rw-r--r-- | meta/recipes-devtools/clang/compiler-rt-sanitizers_git.bb | 15 | ||||
| -rw-r--r-- | meta/recipes-devtools/clang/compiler-rt_git.bb | 38 |
2 files changed, 32 insertions, 21 deletions
diff --git a/meta/recipes-devtools/clang/compiler-rt-sanitizers_git.bb b/meta/recipes-devtools/clang/compiler-rt-sanitizers_git.bb index 087a766302..198942ec35 100644 --- a/meta/recipes-devtools/clang/compiler-rt-sanitizers_git.bb +++ b/meta/recipes-devtools/clang/compiler-rt-sanitizers_git.bb | |||
| @@ -55,8 +55,11 @@ CXXFLAGS:append:libc-musl = " -D_LARGEFILE64_SOURCE" | |||
| 55 | OECMAKE_TARGET_COMPILE = "compiler-rt" | 55 | OECMAKE_TARGET_COMPILE = "compiler-rt" |
| 56 | OECMAKE_TARGET_INSTALL = "install-compiler-rt install-compiler-rt-headers" | 56 | OECMAKE_TARGET_INSTALL = "install-compiler-rt install-compiler-rt-headers" |
| 57 | OECMAKE_SOURCEPATH = "${S}/llvm" | 57 | OECMAKE_SOURCEPATH = "${S}/llvm" |
| 58 | |||
| 59 | INSTALL_VER ?= "${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}" | ||
| 60 | INSTALL_VER:class-native = "${@oe.utils.trim_version("${PV}", 1)}" | ||
| 61 | |||
| 58 | EXTRA_OECMAKE += "-DCMAKE_BUILD_TYPE=RelWithDebInfo \ | 62 | EXTRA_OECMAKE += "-DCMAKE_BUILD_TYPE=RelWithDebInfo \ |
| 59 | -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF \ | ||
| 60 | -DCOMPILER_RT_STANDALONE_BUILD=ON \ | 63 | -DCOMPILER_RT_STANDALONE_BUILD=ON \ |
| 61 | -DCOMPILER_RT_USE_BUILTINS_LIBRARY=ON \ | 64 | -DCOMPILER_RT_USE_BUILTINS_LIBRARY=ON \ |
| 62 | -DCOMPILER_RT_BUILD_BUILTINS=OFF \ | 65 | -DCOMPILER_RT_BUILD_BUILTINS=OFF \ |
| @@ -71,11 +74,13 @@ EXTRA_OECMAKE += "-DCMAKE_BUILD_TYPE=RelWithDebInfo \ | |||
| 71 | -DLLVM_ENABLE_RUNTIMES='compiler-rt' \ | 74 | -DLLVM_ENABLE_RUNTIMES='compiler-rt' \ |
| 72 | -DLLVM_LIBDIR_SUFFIX=${LLVM_LIBDIR_SUFFIX} \ | 75 | -DLLVM_LIBDIR_SUFFIX=${LLVM_LIBDIR_SUFFIX} \ |
| 73 | -DLLVM_APPEND_VC_REV=OFF \ | 76 | -DLLVM_APPEND_VC_REV=OFF \ |
| 77 | -DCOMPILER_RT_INSTALL_PATH=${nonarch_libdir}/clang/${INSTALL_VER} \ | ||
| 74 | -S ${S}/runtimes \ | 78 | -S ${S}/runtimes \ |
| 75 | " | 79 | " |
| 76 | 80 | ||
| 77 | EXTRA_OECMAKE:append:class-native = "\ | 81 | EXTRA_OECMAKE:append:class-native = "\ |
| 78 | -DCOMPILER_RT_USE_BUILTINS_LIBRARY=OFF \ | 82 | -DCOMPILER_RT_USE_BUILTINS_LIBRARY=OFF \ |
| 83 | -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON \ | ||
| 79 | " | 84 | " |
| 80 | 85 | ||
| 81 | EXTRA_OECMAKE:append:class-target = "\ | 86 | EXTRA_OECMAKE:append:class-target = "\ |
| @@ -85,6 +90,7 @@ EXTRA_OECMAKE:append:class-target = "\ | |||
| 85 | -DCMAKE_C_COMPILER_TARGET=${HOST_SYS} \ | 90 | -DCMAKE_C_COMPILER_TARGET=${HOST_SYS} \ |
| 86 | -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON \ | 91 | -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON \ |
| 87 | -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ | 92 | -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ |
| 93 | -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF \ | ||
| 88 | " | 94 | " |
| 89 | 95 | ||
| 90 | EXTRA_OECMAKE:append:class-nativesdk = "\ | 96 | EXTRA_OECMAKE:append:class-nativesdk = "\ |
| @@ -95,24 +101,23 @@ EXTRA_OECMAKE:append:class-nativesdk = "\ | |||
| 95 | -DCLANG_TABLEGEN=${STAGING_BINDIR_NATIVE}/clang-tblgen \ | 101 | -DCLANG_TABLEGEN=${STAGING_BINDIR_NATIVE}/clang-tblgen \ |
| 96 | -DCMAKE_C_COMPILER_TARGET=${HOST_SYS} \ | 102 | -DCMAKE_C_COMPILER_TARGET=${HOST_SYS} \ |
| 97 | -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON \ | 103 | -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON \ |
| 104 | -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF \ | ||
| 98 | " | 105 | " |
| 99 | 106 | ||
| 100 | EXTRA_OECMAKE:append:libc-musl = " -DLIBCXX_HAS_MUSL_LIBC=ON " | 107 | EXTRA_OECMAKE:append:libc-musl = " -DLIBCXX_HAS_MUSL_LIBC=ON " |
| 101 | 108 | ||
| 102 | do_install:append () { | 109 | do_install:append () { |
| 103 | mkdir -p ${D}${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/lib | ||
| 104 | mv ${D}${nonarch_libdir}/linux ${D}${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/lib | ||
| 105 | # Already shipped with compile-rt Orc support | 110 | # Already shipped with compile-rt Orc support |
| 106 | rm -rf ${D}${nonarch_libdir}/clang/${MAJOR_VER}/lib/linux/liborc_rt-*.a | 111 | rm -rf ${D}${nonarch_libdir}/clang/${MAJOR_VER}/lib/linux/liborc_rt-*.a |
| 107 | rm -rf ${D}${nonarch_libdir}/clang/${MAJOR_VER}/include/orc/ | 112 | rm -rf ${D}${nonarch_libdir}/clang/${MAJOR_VER}/include/orc/ |
| 108 | } | 113 | } |
| 109 | 114 | ||
| 110 | FILES_SOLIBSDEV = "" | 115 | FILES_SOLIBSDEV = "" |
| 111 | FILES:${PN} += "${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER} \ | 116 | FILES:${PN} += "${nonarch_libdir}/clang/${INSTALL_VER} \ |
| 112 | ${nonarch_libdir}/clang/${MAJOR_VER}/lib/linux/lib*${SOLIBSDEV} \ | 117 | ${nonarch_libdir}/clang/${MAJOR_VER}/lib/linux/lib*${SOLIBSDEV} \ |
| 113 | ${nonarch_libdir}/clang/${MAJOR_VER}/*.txt \ | 118 | ${nonarch_libdir}/clang/${MAJOR_VER}/*.txt \ |
| 114 | ${nonarch_libdir}/clang/${MAJOR_VER}/share/*.txt" | 119 | ${nonarch_libdir}/clang/${MAJOR_VER}/share/*.txt" |
| 115 | FILES:${PN}-staticdev += "${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/lib/linux/*.a" | 120 | FILES:${PN}-staticdev += "${nonarch_libdir}/clang/${INSTALL_VER}/lib/linux/*.a" |
| 116 | FILES:${PN}-dev += "${datadir} ${nonarch_libdir}/clang/${MAJOR_VER}/lib/linux/*.syms \ | 121 | FILES:${PN}-dev += "${datadir} ${nonarch_libdir}/clang/${MAJOR_VER}/lib/linux/*.syms \ |
| 117 | ${nonarch_libdir}/clang/${MAJOR_VER}/include \ | 122 | ${nonarch_libdir}/clang/${MAJOR_VER}/include \ |
| 118 | ${nonarch_libdir}/clang/${MAJOR_VER}/lib/linux/clang_rt.crt*.o \ | 123 | ${nonarch_libdir}/clang/${MAJOR_VER}/lib/linux/clang_rt.crt*.o \ |
diff --git a/meta/recipes-devtools/clang/compiler-rt_git.bb b/meta/recipes-devtools/clang/compiler-rt_git.bb index 4da85f2937..c88000d33b 100644 --- a/meta/recipes-devtools/clang/compiler-rt_git.bb +++ b/meta/recipes-devtools/clang/compiler-rt_git.bb | |||
| @@ -71,8 +71,11 @@ def get_compiler_rt_arch(bb, d): | |||
| 71 | OECMAKE_TARGET_COMPILE = "compiler-rt" | 71 | OECMAKE_TARGET_COMPILE = "compiler-rt" |
| 72 | OECMAKE_TARGET_INSTALL = "install-compiler-rt install-compiler-rt-headers" | 72 | OECMAKE_TARGET_INSTALL = "install-compiler-rt install-compiler-rt-headers" |
| 73 | OECMAKE_SOURCEPATH = "${S}/llvm" | 73 | OECMAKE_SOURCEPATH = "${S}/llvm" |
| 74 | |||
| 75 | INSTALL_VER ?= "${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}" | ||
| 76 | INSTALL_VER:class-native = "${@oe.utils.trim_version("${PV}", 1)}" | ||
| 77 | |||
| 74 | EXTRA_OECMAKE += "-DCMAKE_BUILD_TYPE=RelWithDebInfo \ | 78 | EXTRA_OECMAKE += "-DCMAKE_BUILD_TYPE=RelWithDebInfo \ |
| 75 | -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF \ | ||
| 76 | -DCOMPILER_RT_STANDALONE_BUILD=ON \ | 79 | -DCOMPILER_RT_STANDALONE_BUILD=ON \ |
| 77 | -DCOMPILER_RT_INCLUDE_TESTS=OFF \ | 80 | -DCOMPILER_RT_INCLUDE_TESTS=OFF \ |
| 78 | -DCOMPILER_RT_BUILD_XRAY=OFF \ | 81 | -DCOMPILER_RT_BUILD_XRAY=OFF \ |
| @@ -83,9 +86,12 @@ EXTRA_OECMAKE += "-DCMAKE_BUILD_TYPE=RelWithDebInfo \ | |||
| 83 | -DLLVM_ENABLE_RUNTIMES='compiler-rt' \ | 86 | -DLLVM_ENABLE_RUNTIMES='compiler-rt' \ |
| 84 | -DLLVM_LIBDIR_SUFFIX=${LLVM_LIBDIR_SUFFIX} \ | 87 | -DLLVM_LIBDIR_SUFFIX=${LLVM_LIBDIR_SUFFIX} \ |
| 85 | -DLLVM_APPEND_VC_REV=OFF \ | 88 | -DLLVM_APPEND_VC_REV=OFF \ |
| 89 | -DCOMPILER_RT_INSTALL_PATH=${nonarch_libdir}/clang/${INSTALL_VER} \ | ||
| 86 | -S ${S}/runtimes \ | 90 | -S ${S}/runtimes \ |
| 87 | " | 91 | " |
| 88 | 92 | EXTRA_OECMAKE:append:class-native = "\ | |
| 93 | -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON \ | ||
| 94 | " | ||
| 89 | EXTRA_OECMAKE:append:class-target = "\ | 95 | EXTRA_OECMAKE:append:class-target = "\ |
| 90 | -DCMAKE_RANLIB=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-ranlib \ | 96 | -DCMAKE_RANLIB=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-ranlib \ |
| 91 | -DCMAKE_AR=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-ar \ | 97 | -DCMAKE_AR=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-ar \ |
| @@ -93,6 +99,7 @@ EXTRA_OECMAKE:append:class-target = "\ | |||
| 93 | -DCMAKE_C_COMPILER_TARGET=${HOST_SYS} \ | 99 | -DCMAKE_C_COMPILER_TARGET=${HOST_SYS} \ |
| 94 | -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON \ | 100 | -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON \ |
| 95 | -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ | 101 | -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ |
| 102 | -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF \ | ||
| 96 | " | 103 | " |
| 97 | 104 | ||
| 98 | EXTRA_OECMAKE:append:class-nativesdk = "\ | 105 | EXTRA_OECMAKE:append:class-nativesdk = "\ |
| @@ -103,29 +110,28 @@ EXTRA_OECMAKE:append:class-nativesdk = "\ | |||
| 103 | -DCLANG_TABLEGEN=${STAGING_BINDIR_NATIVE}/clang-tblgen \ | 110 | -DCLANG_TABLEGEN=${STAGING_BINDIR_NATIVE}/clang-tblgen \ |
| 104 | -DCMAKE_C_COMPILER_TARGET=${HOST_SYS} \ | 111 | -DCMAKE_C_COMPILER_TARGET=${HOST_SYS} \ |
| 105 | -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON \ | 112 | -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON \ |
| 113 | -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF \ | ||
| 106 | " | 114 | " |
| 107 | 115 | ||
| 108 | do_install:append () { | 116 | do_install:append () { |
| 109 | mkdir -p ${D}${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/lib | ||
| 110 | mv ${D}${nonarch_libdir}/linux ${D}${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/lib | ||
| 111 | if [ "${HF}" = "hf" ]; then | 117 | if [ "${HF}" = "hf" ]; then |
| 112 | mv -f ${D}${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/lib/linux/libclang_rt.builtins-arm.a \ | 118 | mv -f ${D}${nonarch_libdir}/clang/${INSTALL_VER}/lib/linux/libclang_rt.builtins-arm.a \ |
| 113 | ${D}${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/lib/linux/libclang_rt.builtins-armhf.a | 119 | ${D}${nonarch_libdir}/clang/${INSTALL_VER}/lib/linux/libclang_rt.builtins-armhf.a |
| 114 | mv -f ${D}${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/lib/linux/liborc_rt-arm.a \ | 120 | mv -f ${D}${nonarch_libdir}/clang/${INSTALL_VER}/lib/linux/liborc_rt-arm.a \ |
| 115 | ${D}${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/lib/linux/liborc_rt-armhf.a | 121 | ${D}${nonarch_libdir}/clang/${INSTALL_VER}/lib/linux/liborc_rt-armhf.a |
| 116 | fi | 122 | fi |
| 117 | } | 123 | } |
| 118 | 124 | ||
| 119 | FILES_SOLIBSDEV = "" | 125 | FILES_SOLIBSDEV = "" |
| 120 | 126 | ||
| 121 | FILES:${PN} += "${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/lib/linux/lib*${SOLIBSDEV} \ | 127 | FILES:${PN} += "${nonarch_libdir}/clang/${INSTALL_VER}/lib/linux/lib*${SOLIBSDEV} \ |
| 122 | ${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/*.txt \ | 128 | ${nonarch_libdir}/clang/${INSTALL_VER}/*.txt \ |
| 123 | ${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/share/*.txt" | 129 | ${nonarch_libdir}/clang/${INSTALL_VER}/share/*.txt" |
| 124 | FILES:${PN}-staticdev += "${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/lib/linux/*.a" | 130 | FILES:${PN}-staticdev += "${nonarch_libdir}/clang/${INSTALL_VER}/lib/linux/*.a" |
| 125 | FILES:${PN}-dev += "${datadir} ${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/lib/linux/*.syms \ | 131 | FILES:${PN}-dev += "${datadir} ${nonarch_libdir}/clang/${INSTALL_VER}/lib/linux/*.syms \ |
| 126 | ${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/include \ | 132 | ${nonarch_libdir}/clang/${INSTALL_VER}/include \ |
| 127 | ${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/lib/linux/clang_rt.crt*.o \ | 133 | ${nonarch_libdir}/clang/${INSTALL_VER}/lib/linux/clang_rt.crt*.o \ |
| 128 | ${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/lib/linux/libclang_rt.asan-preinit*.a" | 134 | ${nonarch_libdir}/clang/${INSTALL_VER}/lib/linux/libclang_rt.asan-preinit*.a" |
| 129 | 135 | ||
| 130 | INSANE_SKIP:${PN} = "dev-so libdir" | 136 | INSANE_SKIP:${PN} = "dev-so libdir" |
| 131 | INSANE_SKIP:${PN}-dbg = "libdir" | 137 | INSANE_SKIP:${PN}-dbg = "libdir" |
