summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools
diff options
context:
space:
mode:
authorKhem Raj <raj.khem@gmail.com>2025-05-04 21:15:11 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2025-05-05 18:02:48 +0100
commit79030cd4c463f7fd6a716d94ab5dc7707a3fed77 (patch)
tree620b060128c3a6e1ae2d9ecd1ae6a0722aaf0ab1 /meta/recipes-devtools
parent437ad6eaa8383a2c2ab9364caa05442e99ed6efc (diff)
downloadpoky-79030cd4c463f7fd6a716d94ab5dc7707a3fed77.tar.gz
clang: Merge llvm/clang family recipes from meta-clang
This can ensure that meta-clang does not carry them and can rely on core layer while mesa can use them too. Omit time stamps in openmp from generated files to improve reproducibility fix the issue that: | file /usr/include/llvm/Config/llvm-config.h conflicts between attempted installs of lib32-llvm-dev-20.1.2-r0.core2_32 and llvm-dev-20.1.2-r0.core2_64 (From OE-Core rev: d77e398095228b34851762858a76640e3c2cb0ab) Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com> Signed-off-by: Khem Raj <raj.khem@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools')
-rw-r--r--meta/recipes-devtools/clang/clang-cross-canadian_git.bb36
-rw-r--r--meta/recipes-devtools/clang/clang-cross_git.bb39
-rw-r--r--meta/recipes-devtools/clang/clang-crosssdk_git.bb33
-rw-r--r--meta/recipes-devtools/clang/clang/0001-libcxxabi-Find-libunwind-headers-when-LIBCXXABI_LIBU.patch60
-rw-r--r--meta/recipes-devtools/clang/clang/0002-compiler-rt-support-a-new-embedded-linux-target.patch309
-rw-r--r--meta/recipes-devtools/clang/clang/0003-compiler-rt-Simplify-cross-compilation.-Don-t-use-na.patch44
-rw-r--r--meta/recipes-devtools/clang/clang/0004-llvm-TargetLibraryInfo-Undefine-libc-functions-if-th.patch90
-rw-r--r--meta/recipes-devtools/clang/clang/0005-llvm-allow-env-override-of-exe-and-libdir-path.patch71
-rw-r--r--meta/recipes-devtools/clang/clang/0006-clang-driver-Check-sysroot-for-ldso-path.patch78
-rw-r--r--meta/recipes-devtools/clang/clang/0007-clang-Driver-tools.cpp-Add-lssp_nonshared-on-musl.patch32
-rw-r--r--meta/recipes-devtools/clang/clang/0008-clang-Prepend-trailing-to-sysroot.patch39
-rw-r--r--meta/recipes-devtools/clang/clang/0009-clang-Look-inside-the-target-sysroot-for-compiler-ru.patch41
-rw-r--r--meta/recipes-devtools/clang/clang/0010-clang-Define-releative-gcc-installation-dir.patch123
-rw-r--r--meta/recipes-devtools/clang/clang/0011-clang-Add-lpthread-and-ldl-along-with-lunwind-for-st.patch35
-rw-r--r--meta/recipes-devtools/clang/clang/0012-Pass-PYTHON_EXECUTABLE-when-cross-compiling-for-nati.patch24
-rw-r--r--meta/recipes-devtools/clang/clang/0013-Check-for-atomic-double-intrinsics.patch34
-rw-r--r--meta/recipes-devtools/clang/clang/0014-cmake-Fix-configure-for-packages-using-find_package.patch (renamed from meta/recipes-devtools/llvm/llvm/0014-cmake-Fix-configure-for-packages-using-find_package.patch)2
-rw-r--r--meta/recipes-devtools/clang/clang/0015-clang-Fix-resource-dir-location-for-cross-toolchains.patch50
-rw-r--r--meta/recipes-devtools/clang/clang/0016-clang-driver-Add-dyld-prefix-when-checking-sysroot-f.patch79
-rw-r--r--meta/recipes-devtools/clang/clang/0017-clang-Use-python3-in-python-scripts.patch35
-rw-r--r--meta/recipes-devtools/clang/clang/0018-llvm-clang-Insert-anchor-for-adding-OE-distro-vendor.patch167
-rw-r--r--meta/recipes-devtools/clang/clang/0019-compiler-rt-Do-not-use-backtrace-APIs-on-non-glibc-l.patch68
-rw-r--r--meta/recipes-devtools/clang/clang/0020-clang-Fix-x86-triple-for-non-debian-multiarch-linux-.patch28
-rw-r--r--meta/recipes-devtools/clang/clang/0021-libunwind-Added-unw_backtrace-method.patch56
-rw-r--r--meta/recipes-devtools/clang/clang/0022-lldb-Link-with-libatomic-on-x86.patch33
-rw-r--r--meta/recipes-devtools/clang/clang/0023-compiler-rt-Enable-__int128-for-ppc32.patch73
-rw-r--r--meta/recipes-devtools/clang/clang/0024-llvm-Do-not-use-cmake-infra-to-detect-libzstd.patch62
-rw-r--r--meta/recipes-devtools/clang/clang/0025-compiler-rt-Fix-stat-struct-s-size-for-O32-ABI.patch46
-rw-r--r--meta/recipes-devtools/clang/clang/0026-compiler-rt-Undef-_TIME_BITS-along-with-_FILE_OFFSET.patch43
-rw-r--r--meta/recipes-devtools/clang/clang/0027-ToolChains-Gnu.cpp-ARMLibDirs-search-also-in-lib32.patch81
-rw-r--r--meta/recipes-devtools/clang/clang/0028-clang-llvm-Add-OE-specific-ABI-triple-for-N32-ABI.patch78
-rw-r--r--meta/recipes-devtools/clang/clang/0029-llvm-Add-libunwind.pc.in-and-llvm-config-scripts.patch90
-rw-r--r--meta/recipes-devtools/clang/clang/0030-scan-build-py-respect-LLVM_LIBDIR_SUFFIX-like-other-.patch92
-rw-r--r--meta/recipes-devtools/clang/clang/0031-compiler-rt-Do-not-pass-target-to-clang-compiler.patch29
-rw-r--r--meta/recipes-devtools/clang/clang/0032-Fix-build-on-ppc64-musl.patch97
-rw-r--r--meta/recipes-devtools/clang/clang/0033-clangd-Add-a-build-option-to-disable-building-dexp.patch85
-rw-r--r--meta/recipes-devtools/clang/clang/0034-AsmMatcherEmitter-sort-ClassInfo-lists-by-name-as-we.patch (renamed from meta/recipes-devtools/llvm/llvm/0001-AsmMatcherEmitter-sort-ClassInfo-lists-by-name-as-we.patch)4
-rw-r--r--meta/recipes-devtools/clang/clang/0035-llvm-config-remove-LLVM_LDFLAGS-from-ldflags-output.patch (renamed from meta/recipes-devtools/llvm/llvm/0001-llvm-config-remove-LLVM_LDFLAGS-from-ldflags-output.patch)12
-rw-r--r--meta/recipes-devtools/clang/clang/0036-openmp-Do-not-emit-date-and-time-into-generate-files.patch37
-rw-r--r--meta/recipes-devtools/clang/clang/spirv-internal-build.patch (renamed from meta/recipes-devtools/llvm/llvm/spirv-internal-build.patch)0
-rw-r--r--meta/recipes-devtools/clang/clang/spirv-shared-library.patch (renamed from meta/recipes-devtools/llvm/llvm/spirv-shared-library.patch)0
-rw-r--r--meta/recipes-devtools/clang/clang_git.bb492
-rw-r--r--meta/recipes-devtools/clang/common-clang.inc24
-rw-r--r--meta/recipes-devtools/clang/common-source.inc17
-rw-r--r--meta/recipes-devtools/clang/common.inc83
-rw-r--r--meta/recipes-devtools/clang/compiler-rt-sanitizers_git.bb131
-rw-r--r--meta/recipes-devtools/clang/compiler-rt_git.bb121
-rw-r--r--meta/recipes-devtools/clang/libcxx_git.bb115
-rw-r--r--meta/recipes-devtools/clang/llvm-project-source.bb12
-rw-r--r--meta/recipes-devtools/clang/llvm-project-source.inc99
-rw-r--r--meta/recipes-devtools/clang/nativesdk-clang-glue.bb36
-rw-r--r--meta/recipes-devtools/clang/openmp_git.bb65
-rw-r--r--meta/recipes-devtools/llvm/llvm/0007-llvm-allow-env-override-of-exe-path.patch36
-rw-r--r--meta/recipes-devtools/llvm/llvm/llvm-config54
-rw-r--r--meta/recipes-devtools/llvm/llvm_20.1.2.bb233
55 files changed, 3620 insertions, 333 deletions
diff --git a/meta/recipes-devtools/clang/clang-cross-canadian_git.bb b/meta/recipes-devtools/clang/clang-cross-canadian_git.bb
new file mode 100644
index 0000000000..456c0d61bc
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang-cross-canadian_git.bb
@@ -0,0 +1,36 @@
1# Copyright (C) 2014 Khem Raj <raj.khem@gmail.com>
2# Released under the MIT license (see COPYING.MIT for the terms)
3
4SUMMARY = "Clang/LLVM based C/C++ compiler (cross-canadian for ${TARGET_ARCH} target)"
5HOMEPAGE = "http://clang.llvm.org/"
6LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0-with-LLVM-exception;md5=0bcd48c3bdfef0c9d9fd17726e4b7dab"
7SECTION = "devel"
8
9PN = "clang-cross-canadian-${TRANSLATED_TARGET_ARCH}"
10
11require common-clang.inc
12require common-source.inc
13inherit cross-canadian
14
15DEPENDS += "nativesdk-clang binutils-cross-canadian-${TRANSLATED_TARGET_ARCH} virtual/nativesdk-cross-binutils virtual/nativesdk-libc"
16# We have to point gcc at a sysroot but we don't need to rebuild if this changes
17# e.g. we switch between different machines with different tunes.
18EXTRA_OECONF_PATHS[vardepsexclude] = "TUNE_PKGARCH"
19TARGET_ARCH[vardepsexclude] = "TUNE_ARCH"
20
21do_install() {
22 install -d ${D}${bindir}
23 for tool in clang clang++ clang-tidy lld ld.lld llvm-profdata \
24 llvm-nm llvm-ar llvm-as llvm-ranlib llvm-strip llvm-objcopy llvm-objdump llvm-readelf \
25 llvm-addr2line llvm-dwp llvm-size llvm-strings llvm-cov
26 do
27 ln -sf ../$tool ${D}${bindir}/${TARGET_PREFIX}$tool
28 done
29}
30SSTATE_SCAN_FILES += "*-clang *-clang++ *-llvm-profdata *-llvm-ar \
31 *-llvm-ranlib *-llvm-nm *-lld *-ld.lld *-llvm-as *-llvm-strip \
32 *-llvm-objcopy *-llvm-objdump *-llvm-readelf *-llvm-addr2line \
33 *-llvm-dwp *-llvm-size *-llvm-strings *-llvm-cov"
34do_install:append() {
35 cross_canadian_bindirlinks
36}
diff --git a/meta/recipes-devtools/clang/clang-cross_git.bb b/meta/recipes-devtools/clang/clang-cross_git.bb
new file mode 100644
index 0000000000..9b9b120a3d
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang-cross_git.bb
@@ -0,0 +1,39 @@
1# Copyright (C) 2014 Khem Raj <raj.khem@gmail.com>
2# Released under the MIT license (see COPYING.MIT for the terms)
3
4SUMMARY = "Cross compiler wrappers for LLVM based C/C++ compiler"
5HOMEPAGE = "http://clang.llvm.org/"
6LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0-with-LLVM-exception;md5=0bcd48c3bdfef0c9d9fd17726e4b7dab"
7SECTION = "devel"
8
9PN = "clang-cross-${TARGET_ARCH}"
10
11require common-clang.inc
12require common-source.inc
13inherit cross
14DEPENDS += "clang-native virtual/cross-binutils"
15
16#INHIBIT_PACKAGE_STRIP = "1"
17INHIBIT_SYSROOT_STRIP = "1"
18do_install() {
19 install -d ${D}${bindir}
20 for tool in clang-tidy lld ld.lld llvm-profdata \
21 llvm-nm llvm-ar llvm-as llvm-ranlib llvm-strip llvm-objcopy llvm-objdump llvm-readelf \
22 llvm-addr2line llvm-dwp llvm-size llvm-strings llvm-cov
23 do
24 ln -sf ../$tool ${D}${bindir}/${TARGET_PREFIX}$tool
25 done
26 install -m 0755 ${STAGING_BINDIR_NATIVE}/clang ${D}${bindir}/${TARGET_PREFIX}clang
27 install -m 0755 ${STAGING_BINDIR_NATIVE}/clang ${D}${bindir}/${TARGET_PREFIX}clang++
28}
29SSTATE_SCAN_FILES += "*-clang *-clang++ *-llvm-profdata *-lld *-ld.lld \
30 *-llvm-nm *-llvm-ar *-llvm-as *-llvm-ranlib *-llvm-strip \
31 *-llvm-objcopy *-llvm-objdump *-llvm-readelf *-llvm-addr2line \
32 *-llvm-dwp *-llvm-size *-llvm-strings *-llvm-cov"
33
34SYSROOT_PREPROCESS_FUNCS += "clangcross_sysroot_preprocess"
35
36clangcross_sysroot_preprocess () {
37 sysroot_stage_dir ${D}${bindir} ${SYSROOT_DESTDIR}${bindir}
38}
39PACKAGES = ""
diff --git a/meta/recipes-devtools/clang/clang-crosssdk_git.bb b/meta/recipes-devtools/clang/clang-crosssdk_git.bb
new file mode 100644
index 0000000000..47ac96f4f9
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang-crosssdk_git.bb
@@ -0,0 +1,33 @@
1# Copyright (C) 2014 Khem Raj <raj.khem@gmail.com>
2# Released under the MIT license (see COPYING.MIT for the terms)
3
4SUMMARY = "SDK Cross compiler wrappers for LLVM based C/C++ compiler"
5HOMEPAGE = "http://clang.llvm.org/"
6LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0-with-LLVM-exception;md5=0bcd48c3bdfef0c9d9fd17726e4b7dab"
7SECTION = "devel"
8
9PN = "clang-crosssdk-${SDK_SYS}"
10
11require common-clang.inc
12require common-source.inc
13inherit crosssdk
14DEPENDS += "clang-native nativesdk-clang-glue virtual/nativesdk-cross-binutils virtual/nativesdk-libc"
15
16do_install() {
17 install -d ${D}${bindir}
18 for tool in clang clang++ clang-tidy lld ld.lld llvm-profdata \
19 llvm-nm llvm-ar llvm-as llvm-ranlib llvm-strip llvm-objcopy llvm-objdump llvm-readelf \
20 llvm-addr2line llvm-dwp llvm-size llvm-strings llvm-cov
21 do
22 ln -sf ../$tool ${D}${bindir}/${TARGET_PREFIX}$tool
23 done
24}
25SSTATE_SCAN_FILES += "*-clang *-clang++ *-llvm-profdata *-lld *-ld.lld \
26 *-llvm-nm *-llvm-ar *-llvm-as *-llvm-ranlib *-llvm-strip \
27 *-llvm-objcopy *-llvm-objdump *-llvm-readelf *-llvm-addr2line \
28 *-llvm-dwp *-llvm-size *-llvm-strings *-llvm-cov"
29sysroot_stage_all () {
30 sysroot_stage_dir ${D}${bindir} ${SYSROOT_DESTDIR}${bindir}
31}
32
33PACKAGES = ""
diff --git a/meta/recipes-devtools/clang/clang/0001-libcxxabi-Find-libunwind-headers-when-LIBCXXABI_LIBU.patch b/meta/recipes-devtools/clang/clang/0001-libcxxabi-Find-libunwind-headers-when-LIBCXXABI_LIBU.patch
new file mode 100644
index 0000000000..21b033b498
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0001-libcxxabi-Find-libunwind-headers-when-LIBCXXABI_LIBU.patch
@@ -0,0 +1,60 @@
1From ec9babfa91931042e7aa771915e2f1d4dc8d15e0 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Sun, 27 Aug 2017 10:37:49 -0700
4Subject: [PATCH] libcxxabi: Find libunwind headers when
5 LIBCXXABI_LIBUNWIND_INCLUDES is set
6
7Currently, when LIBCXXABI_LIBUNWIND_INCLUDES is set via CMake arguments
8then it ends up not searching the specified dir and unwind.h is not found
9especially for ARM targets
10
11This patch makes the searching synthesized directories and then set
12LIBCXXABI_LIBUNWIND_INCLUDES if its there in environment
13
14Upstream-Status: Pending
15Signed-off-by: Khem Raj <raj.khem@gmail.com>
16---
17 libcxxabi/CMakeLists.txt | 15 ++++++++++-----
18 1 file changed, 10 insertions(+), 5 deletions(-)
19
20diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt
21index 6dcfc51e5532..32478a62a058 100644
22--- a/libcxxabi/CMakeLists.txt
23+++ b/libcxxabi/CMakeLists.txt
24@@ -465,7 +465,7 @@ set(LIBCXXABI_LIBUNWIND_PATH "${LIBCXXABI_LIBUNWIND_PATH}" CACHE PATH
25 "Specify path to libunwind source." FORCE)
26
27 if (LIBCXXABI_USE_LLVM_UNWINDER OR LLVM_NATIVE_ARCH MATCHES ARM)
28- find_path(LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL libunwind.h
29+ find_path(LIBCXXABI_LIBUNWIND_INCLUDES libunwind.h
30 PATHS ${LIBCXXABI_LIBUNWIND_INCLUDES}
31 ${LIBCXXABI_LIBUNWIND_PATH}/include
32 ${CMAKE_BINARY_DIR}/${LIBCXXABI_LIBUNWIND_INCLUDES}
33@@ -476,18 +476,23 @@ if (LIBCXXABI_USE_LLVM_UNWINDER OR LLVM_NATIVE_ARCH MATCHES ARM)
34 NO_CMAKE_FIND_ROOT_PATH
35 )
36
37- if (LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL STREQUAL "LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL-NOTFOUND")
38- set(LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL "")
39+ if (LIBCXXABI_LIBUNWIND_INCLUDES STREQUAL "LIBCXXABI_LIBUNWIND_INCLUDES-NOTFOUND")
40+ set(LIBCXXABI_LIBUNWIND_INCLUDES "")
41 endif()
42 endif()
43
44-if (NOT "${LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL}" STREQUAL "")
45- include_directories("${LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL}")
46+if (NOT "${LIBCXXABI_LIBUNWIND_INCLUDES}" STREQUAL "")
47+ include_directories("${LIBCXXABI_LIBUNWIND_INCLUDES}")
48 endif()
49
50 add_custom_target(cxxabi-test-depends
51 COMMENT "Build dependencies required to run the libc++abi test suite.")
52
53+set(LIBCXXABI_LIBUNWIND_INCLUDES "${LIBCXXABI_LIBUNWIND_INCLUDES}" CACHE PATH
54+ "Specify path to libunwind includes." FORCE)
55+set(LIBCXXABI_LIBUNWIND_PATH "${LIBCXXABI_LIBUNWIND_PATH}" CACHE PATH
56+ "Specify path to libunwind source." FORCE)
57+
58 # Add source code. This also contains all of the logic for deciding linker flags
59 # soname, etc...
60 add_subdirectory(include)
diff --git a/meta/recipes-devtools/clang/clang/0002-compiler-rt-support-a-new-embedded-linux-target.patch b/meta/recipes-devtools/clang/clang/0002-compiler-rt-support-a-new-embedded-linux-target.patch
new file mode 100644
index 0000000000..88cef402da
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0002-compiler-rt-support-a-new-embedded-linux-target.patch
@@ -0,0 +1,309 @@
1From 8cdfcfb9102c4008758bb844856e553d4fe4ae79 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Sun, 19 Apr 2015 15:16:23 -0700
4Subject: [PATCH] compiler-rt: support a new embedded linux target
5
6Upstream-Status: Pending
7Signed-off-by: Khem Raj <raj.khem@gmail.com>
8---
9 .../make/platform/clang_linux_embedded.mk | 286 ++++++++++++++++++
10 .../clang_linux_embedded_test_input.c | 0
11 2 files changed, 286 insertions(+)
12 create mode 100644 compiler-rt/make/platform/clang_linux_embedded.mk
13 create mode 100644 compiler-rt/make/platform/clang_linux_embedded_test_input.c
14
15diff --git a/compiler-rt/make/platform/clang_linux_embedded.mk b/compiler-rt/make/platform/clang_linux_embedded.mk
16new file mode 100644
17index 000000000000..d0a890075a1c
18--- /dev/null
19+++ b/compiler-rt/make/platform/clang_linux_embedded.mk
20@@ -0,0 +1,286 @@
21+# These are the functions which clang needs when it is targeting a previous
22+# version of the OS. The issue is that the backend may use functions which were
23+# not present in the libgcc that shipped on the platform. In such cases, we link
24+# with a version of the library which contains private_extern definitions of all
25+# the extra functions which might be referenced.
26+
27+Description := Static runtime libraries for embedded clang/Linux
28+
29+# A function that ensures we don't try to build for architectures that we
30+# don't have working toolchains for.
31+CheckArches = \
32+ $(shell \
33+ result=""; \
34+ for arch in $(1); do \
35+ if $(CC) -arch $$arch -c \
36+ -integrated-as \
37+ $(ProjSrcRoot)/make/platform/clang_linux_embedded_test_input.c \
38+ -o /dev/null > /dev/null 2> /dev/null; then \
39+ result="$$result$$arch "; \
40+ else \
41+ printf 1>&2 \
42+ "warning: clang_linux_embedded.mk: dropping arch '$$arch' from lib '$(2)'\n"; \
43+ fi; \
44+ done; \
45+ echo $$result)
46+
47+XCRun = \
48+ $(shell \
49+ result=`xcrun -find $(1) 2> /dev/null`; \
50+ if [ "$$?" != "0" ]; then result=$(1); fi; \
51+ echo $$result)
52+
53+###
54+
55+CC := $(call XCRun,clang)
56+AR := $(call XCRun,ar)
57+RANLIB := $(call XCRun,ranlib)
58+STRIP := $(call XCRun,strip)
59+LIPO := $(call XCRun,lipo)
60+DSYMUTIL := $(call XCRun,dsymutil)
61+Configs :=
62+UniversalArchs :=
63+
64+# Soft-float version of the runtime. No floating-point instructions will be used
65+# and the ABI (out of necessity) passes floating values in normal registers:
66+# non-VFP variant of the AAPCS.
67+UniversalArchs.soft_static := $(call CheckArches,arm armv7m armv7em armv7,soft_static)
68+Configs += $(if $(UniversalArchs.soft_static),soft_static)
69+
70+# Hard-float version of the runtime. On ARM VFP instructions and registers are
71+# allowed, and floating point values get passed in them. VFP variant of the
72+# AAPCS.
73+UniversalArchs.hard_static := $(call CheckArches,armv7em armv7 i386 x86_64,hard_static)
74+Configs += $(if $(UniversalArchs.hard_static),hard_static)
75+
76+UniversalArchs.soft_pic := $(call CheckArches,armv6m armv7m armv7em armv7,soft_pic)
77+Configs += $(if $(UniversalArchs.soft_pic),soft_pic)
78+
79+UniversalArchs.hard_pic := $(call CheckArches,armv7em armv7 i386 x86_64,hard_pic)
80+Configs += $(if $(UniversalArchs.hard_pic),hard_pic)
81+
82+CFLAGS := -Wall -Werror -Oz -fomit-frame-pointer -ffreestanding
83+
84+PIC_CFLAGS := -fPIC
85+STATIC_CFLAGS := -static
86+
87+CFLAGS_SOFT := -mfloat-abi=soft
88+CFLAGS_HARD := -mfloat-abi=hard
89+
90+CFLAGS_I386 := -march=pentium
91+
92+CFLAGS.soft_static := $(CFLAGS) $(STATIC_CFLAGS) $(CFLAGS_SOFT)
93+CFLAGS.hard_static := $(CFLAGS) $(STATIC_CFLAGS) $(CFLAGS_HARD)
94+CFLAGS.soft_pic := $(CFLAGS) $(PIC_CFLAGS) $(CFLAGS_SOFT)
95+CFLAGS.hard_pic := $(CFLAGS) $(PIC_CFLAGS) $(CFLAGS_HARD)
96+
97+CFLAGS.soft_static.armv7 := $(CFLAGS.soft_static) $(CFLAGS_ARMV7)
98+CFLAGS.hard_static.armv7 := $(CFLAGS.hard_static) $(CFLAGS_ARMV7)
99+CFLAGS.soft_pic.armv7 := $(CFLAGS.soft_pic) $(CFLAGS_ARMV7)
100+CFLAGS.hard_pic.armv7 := $(CFLAGS.hard_pic) $(CFLAGS_ARMV7)
101+
102+# x86 platforms ignore -mfloat-abi options and complain about doing so. Despite
103+# this they're hard-float.
104+CFLAGS.hard_static.i386 := $(CFLAGS) $(STATIC_CFLAGS) $(CFLAGS_I386)
105+CFLAGS.hard_pic.i386 := $(CFLAGS) $(PIC_CFLAGS) $(CFLAGS_I386)
106+CFLAGS.hard_static.x86_64 := $(CFLAGS) $(STATIC_CFLAGS)
107+CFLAGS.hard_pic.x86_64 := $(CFLAGS) $(PIC_CFLAGS)
108+
109+# Functions not wanted:
110+# + eprintf is obsolete anyway
111+# + *vfp: designed for Thumb1 CPUs with VFPv2
112+
113+COMMON_FUNCTIONS := \
114+ absvdi2 \
115+ absvsi2 \
116+ addvdi3 \
117+ addvsi3 \
118+ ashldi3 \
119+ ashrdi3 \
120+ bswapdi2 \
121+ bswapsi2 \
122+ clzdi2 \
123+ clzsi2 \
124+ cmpdi2 \
125+ ctzdi2 \
126+ ctzsi2 \
127+ divdc3 \
128+ divdi3 \
129+ divsc3 \
130+ divmodsi4 \
131+ udivmodsi4 \
132+ do_global_dtors \
133+ ffsdi2 \
134+ fixdfdi \
135+ fixsfdi \
136+ fixunsdfdi \
137+ fixunsdfsi \
138+ fixunssfdi \
139+ fixunssfsi \
140+ floatdidf \
141+ floatdisf \
142+ floatundidf \
143+ floatundisf \
144+ gcc_bcmp \
145+ lshrdi3 \
146+ moddi3 \
147+ muldc3 \
148+ muldi3 \
149+ mulsc3 \
150+ mulvdi3 \
151+ mulvsi3 \
152+ negdi2 \
153+ negvdi2 \
154+ negvsi2 \
155+ paritydi2 \
156+ paritysi2 \
157+ popcountdi2 \
158+ popcountsi2 \
159+ powidf2 \
160+ powisf2 \
161+ subvdi3 \
162+ subvsi3 \
163+ ucmpdi2 \
164+ udiv_w_sdiv \
165+ udivdi3 \
166+ udivmoddi4 \
167+ umoddi3 \
168+ adddf3 \
169+ addsf3 \
170+ cmpdf2 \
171+ cmpsf2 \
172+ div0 \
173+ divdf3 \
174+ divsf3 \
175+ divsi3 \
176+ extendsfdf2 \
177+ ffssi2 \
178+ fixdfsi \
179+ fixsfsi \
180+ floatsidf \
181+ floatsisf \
182+ floatunsidf \
183+ floatunsisf \
184+ comparedf2 \
185+ comparesf2 \
186+ modsi3 \
187+ muldf3 \
188+ mulsf3 \
189+ negdf2 \
190+ negsf2 \
191+ subdf3 \
192+ subsf3 \
193+ truncdfsf2 \
194+ udivsi3 \
195+ umodsi3 \
196+ unorddf2 \
197+ unordsf2
198+
199+ARM_FUNCTIONS := \
200+ aeabi_cdcmpeq \
201+ aeabi_cdrcmple \
202+ aeabi_cfcmpeq \
203+ aeabi_cfrcmple \
204+ aeabi_dcmpeq \
205+ aeabi_dcmpge \
206+ aeabi_dcmpgt \
207+ aeabi_dcmple \
208+ aeabi_dcmplt \
209+ aeabi_drsub \
210+ aeabi_fcmpeq \
211+ aeabi_fcmpge \
212+ aeabi_fcmpgt \
213+ aeabi_fcmple \
214+ aeabi_fcmplt \
215+ aeabi_frsub \
216+ aeabi_idivmod \
217+ aeabi_uidivmod \
218+
219+# ARM Assembly implementation which requires Thumb2 (i.e. won't work on v6M).
220+THUMB2_FUNCTIONS := \
221+ switch16 \
222+ switch32 \
223+ switch8 \
224+ switchu8 \
225+ sync_fetch_and_add_4 \
226+ sync_fetch_and_sub_4 \
227+ sync_fetch_and_and_4 \
228+ sync_fetch_and_or_4 \
229+ sync_fetch_and_xor_4 \
230+ sync_fetch_and_nand_4 \
231+ sync_fetch_and_max_4 \
232+ sync_fetch_and_umax_4 \
233+ sync_fetch_and_min_4 \
234+ sync_fetch_and_umin_4 \
235+ sync_fetch_and_add_8 \
236+ sync_fetch_and_sub_8 \
237+ sync_fetch_and_and_8 \
238+ sync_fetch_and_or_8 \
239+ sync_fetch_and_xor_8 \
240+ sync_fetch_and_nand_8 \
241+ sync_fetch_and_max_8 \
242+ sync_fetch_and_umax_8 \
243+ sync_fetch_and_min_8 \
244+ sync_fetch_and_umin_8
245+
246+I386_FUNCTIONS := \
247+ i686.get_pc_thunk.eax \
248+ i686.get_pc_thunk.ebp \
249+ i686.get_pc_thunk.ebx \
250+ i686.get_pc_thunk.ecx \
251+ i686.get_pc_thunk.edi \
252+ i686.get_pc_thunk.edx \
253+ i686.get_pc_thunk.esi
254+
255+# FIXME: Currently, compiler-rt is missing implementations for a number of the
256+# functions. Filter them out for now.
257+MISSING_FUNCTIONS := \
258+ cmpdf2 cmpsf2 div0 \
259+ ffssi2 \
260+ udiv_w_sdiv unorddf2 unordsf2 bswapdi2 \
261+ bswapsi2 \
262+ gcc_bcmp \
263+ do_global_dtors \
264+ i686.get_pc_thunk.eax i686.get_pc_thunk.ebp i686.get_pc_thunk.ebx \
265+ i686.get_pc_thunk.ecx i686.get_pc_thunk.edi i686.get_pc_thunk.edx \
266+ i686.get_pc_thunk.esi \
267+ aeabi_cdcmpeq aeabi_cdrcmple aeabi_cfcmpeq aeabi_cfrcmple aeabi_dcmpeq \
268+ aeabi_dcmpge aeabi_dcmpgt aeabi_dcmple aeabi_dcmplt aeabi_drsub \
269+ aeabi_fcmpeq \ aeabi_fcmpge aeabi_fcmpgt aeabi_fcmple aeabi_fcmplt \
270+ aeabi_frsub aeabi_idivmod aeabi_uidivmod
271+
272+FUNCTIONS_ARMV6M := $(COMMON_FUNCTIONS) $(ARM_FUNCTIONS)
273+FUNCTIONS_ARM_ALL := $(COMMON_FUNCTIONS) $(ARM_FUNCTIONS) $(THUMB2_FUNCTIONS)
274+FUNCTIONS_I386 := $(COMMON_FUNCTIONS) $(I386_FUNCTIONS)
275+FUNCTIONS_X86_64 := $(COMMON_FUNCTIONS)
276+
277+FUNCTIONS_ARMV6M := \
278+ $(filter-out $(MISSING_FUNCTIONS),$(FUNCTIONS_ARMV6M))
279+FUNCTIONS_ARM_ALL := \
280+ $(filter-out $(MISSING_FUNCTIONS),$(FUNCTIONS_ARM_ALL))
281+FUNCTIONS_I386 := \
282+ $(filter-out $(MISSING_FUNCTIONS),$(FUNCTIONS_I386))
283+FUNCTIONS_X86_64 := \
284+ $(filter-out $(MISSING_FUNCTIONS),$(FUNCTIONS_X86_64))
285+
286+FUNCTIONS.soft_static.armv6m := $(FUNCTIONS_ARMV6M)
287+FUNCTIONS.soft_pic.armv6m := $(FUNCTIONS_ARMV6M)
288+
289+FUNCTIONS.soft_static.armv7m := $(FUNCTIONS_ARM_ALL)
290+FUNCTIONS.soft_pic.armv7m := $(FUNCTIONS_ARM_ALL)
291+
292+FUNCTIONS.soft_static.armv7em := $(FUNCTIONS_ARM_ALL)
293+FUNCTIONS.hard_static.armv7em := $(FUNCTIONS_ARM_ALL)
294+FUNCTIONS.soft_pic.armv7em := $(FUNCTIONS_ARM_ALL)
295+FUNCTIONS.hard_pic.armv7em := $(FUNCTIONS_ARM_ALL)
296+
297+FUNCTIONS.soft_static.armv7 := $(FUNCTIONS_ARM_ALL)
298+FUNCTIONS.hard_static.armv7 := $(FUNCTIONS_ARM_ALL)
299+FUNCTIONS.soft_pic.armv7 := $(FUNCTIONS_ARM_ALL)
300+FUNCTIONS.hard_pic.armv7 := $(FUNCTIONS_ARM_ALL)
301+
302+FUNCTIONS.hard_static.i386 := $(FUNCTIONS_I386)
303+FUNCTIONS.hard_pic.i386 := $(FUNCTIONS_I386)
304+
305+FUNCTIONS.hard_static.x86_64 := $(FUNCTIONS_X86_64)
306+FUNCTIONS.hard_pic.x86_64 := $(FUNCTIONS_X86_64)
307diff --git a/compiler-rt/make/platform/clang_linux_embedded_test_input.c b/compiler-rt/make/platform/clang_linux_embedded_test_input.c
308new file mode 100644
309index 000000000000..e69de29bb2d1
diff --git a/meta/recipes-devtools/clang/clang/0003-compiler-rt-Simplify-cross-compilation.-Don-t-use-na.patch b/meta/recipes-devtools/clang/clang/0003-compiler-rt-Simplify-cross-compilation.-Don-t-use-na.patch
new file mode 100644
index 0000000000..a153624860
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0003-compiler-rt-Simplify-cross-compilation.-Don-t-use-na.patch
@@ -0,0 +1,44 @@
1From c105a2efab08776d1f4df6b9b8d26d0f89d14b41 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Thu, 19 May 2016 23:11:45 -0700
4Subject: [PATCH] compiler-rt: Simplify cross-compilation. Don't use
5 native-compiled llvm-config.
6
7 Note: AddLLVM.cmake does not expose the LLVM source directory.
8 So if you want to run the test suite, you need to either:
9
10 1) set LLVM_MAIN_SRC_DIR explicitly (to find lit.py)
11 2) change AddLLVM.cmake to point to an installed 'lit'.
12 3) add_subdirectory(compiler-rt/test) from clang instead of compiler-rt.
13
14https://us.codeaurora.org/patches/quic/llvm/50683/compiler-rt-cross-compilation.patch
15
16Upstream-Status: Pending
17Signed-off-by: Greg Fitzgerald <gregf@codeaurora.org>
18Signed-off-by: Khem Raj <raj.khem@gmail.com>
19---
20 compiler-rt/CMakeLists.txt | 11 ++++++++++-
21 1 file changed, 10 insertions(+), 1 deletion(-)
22
23diff --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt
24index 2c52788de56a..fe409704acc3 100644
25--- a/compiler-rt/CMakeLists.txt
26+++ b/compiler-rt/CMakeLists.txt
27@@ -107,7 +107,16 @@ if (COMPILER_RT_STANDALONE_BUILD)
28 set(CMAKE_CXX_EXTENSIONS NO)
29
30 if (NOT LLVM_RUNTIMES_BUILD)
31- load_llvm_config()
32+ find_package(LLVM REQUIRED)
33+ list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
34+
35+ # Variables that AddLLVM.cmake depends on (included by AddCompilerRT)
36+ set(LLVM_TOOLS_BINARY_DIR "${LLVM_INSTALL_PREFIX}/bin")
37+ set(LLVM_LIBRARY_DIR "${LLVM_INSTALL_PREFIX}/lib")
38+
39+ set(LLVM_LIBRARY_OUTPUT_INTDIR
40+ ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX})
41+
42 endif()
43 if (TARGET intrinsics_gen)
44 # Loading the llvm config causes this target to be imported so place it
diff --git a/meta/recipes-devtools/clang/clang/0004-llvm-TargetLibraryInfo-Undefine-libc-functions-if-th.patch b/meta/recipes-devtools/clang/clang/0004-llvm-TargetLibraryInfo-Undefine-libc-functions-if-th.patch
new file mode 100644
index 0000000000..c70f740222
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0004-llvm-TargetLibraryInfo-Undefine-libc-functions-if-th.patch
@@ -0,0 +1,90 @@
1From 388a70b4a8f828b7c58a0fb7bc3ee18001bc5f9b Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Sat, 21 May 2016 00:33:20 +0000
4Subject: [PATCH] llvm: TargetLibraryInfo: Undefine libc functions if they are
5 macros
6
7musl defines some functions as macros and not inline functions
8if this is the case then make sure to undefine them
9
10Upstream-Status: Pending
11Signed-off-by: Khem Raj <raj.khem@gmail.com>
12---
13 .../llvm/Analysis/TargetLibraryInfo.def | 22 ++++++++++++++++++-
14 1 file changed, 21 insertions(+), 1 deletion(-)
15
16diff --git a/llvm/include/llvm/Analysis/TargetLibraryInfo.def b/llvm/include/llvm/Analysis/TargetLibraryInfo.def
17index db566b8ee610..578161f9c978 100644
18--- a/llvm/include/llvm/Analysis/TargetLibraryInfo.def
19+++ b/llvm/include/llvm/Analysis/TargetLibraryInfo.def
20@@ -1467,6 +1467,9 @@ TLI_DEFINE_STRING_INTERNAL("fopen")
21 TLI_DEFINE_SIG_INTERNAL(Ptr, Ptr, Ptr)
22
23 /// FILE *fopen64(const char *filename, const char *opentype)
24+#ifdef fopen64
25+#undef fopen64
26+#endif
27 TLI_DEFINE_ENUM_INTERNAL(fopen64)
28 TLI_DEFINE_STRING_INTERNAL("fopen64")
29 TLI_DEFINE_SIG_INTERNAL(Ptr, Ptr, Ptr)
30@@ -1545,7 +1548,9 @@ TLI_DEFINE_SIG_INTERNAL(Int, Ptr, Long, Int)
31 TLI_DEFINE_ENUM_INTERNAL(fseeko)
32 TLI_DEFINE_STRING_INTERNAL("fseeko")
33 TLI_DEFINE_SIG_INTERNAL(Int, Ptr, IntX, Int)
34-
35+#ifdef fseeko64
36+#undef fseeko64
37+#endif
38 /// int fseeko64(FILE *stream, off64_t offset, int whence)
39 TLI_DEFINE_ENUM_INTERNAL(fseeko64)
40 TLI_DEFINE_STRING_INTERNAL("fseeko64")
41@@ -1562,6 +1567,9 @@ TLI_DEFINE_STRING_INTERNAL("fstat")
42 TLI_DEFINE_SIG_INTERNAL(Int, Int, Ptr)
43
44 /// int fstat64(int filedes, struct stat64 *buf)
45+#ifdef fstat64
46+#undef fstat64
47+#endif
48 TLI_DEFINE_ENUM_INTERNAL(fstat64)
49 TLI_DEFINE_STRING_INTERNAL("fstat64")
50 TLI_DEFINE_SIG_INTERNAL(Int, Int, Ptr)
51@@ -1587,6 +1595,9 @@ TLI_DEFINE_STRING_INTERNAL("ftello")
52 TLI_DEFINE_SIG_INTERNAL(IntPlus, Ptr)
53
54 /// off64_t ftello64(FILE *stream)
55+#ifdef ftello64
56+#undef ftello64
57+#endif
58 TLI_DEFINE_ENUM_INTERNAL(ftello64)
59 TLI_DEFINE_STRING_INTERNAL("ftello64")
60 TLI_DEFINE_SIG_INTERNAL(Int64, Ptr)
61@@ -1827,6 +1838,9 @@ TLI_DEFINE_STRING_INTERNAL("lstat")
62 TLI_DEFINE_SIG_INTERNAL(Int, Ptr, Ptr)
63
64 /// int lstat64(const char *path, struct stat64 *buf);
65+#ifdef lstat64
66+#undef lstat64
67+#endif
68 TLI_DEFINE_ENUM_INTERNAL(lstat64)
69 TLI_DEFINE_STRING_INTERNAL("lstat64")
70 TLI_DEFINE_SIG_INTERNAL(Int, Ptr, Ptr)
71@@ -2334,6 +2348,9 @@ TLI_DEFINE_STRING_INTERNAL("stat")
72 TLI_DEFINE_SIG_INTERNAL(Int, Ptr, Ptr)
73
74 /// int stat64(const char *path, struct stat64 *buf);
75+#ifdef stat64
76+#undef stat64
77+#endif
78 TLI_DEFINE_ENUM_INTERNAL(stat64)
79 TLI_DEFINE_STRING_INTERNAL("stat64")
80 TLI_DEFINE_SIG_INTERNAL(Int, Ptr, Ptr)
81@@ -2559,6 +2576,9 @@ TLI_DEFINE_STRING_INTERNAL("tmpfile")
82 TLI_DEFINE_SIG_INTERNAL(Ptr)
83
84 /// FILE *tmpfile64(void)
85+#ifdef tmpfile64
86+#undef tmpfile64
87+#endif
88 TLI_DEFINE_ENUM_INTERNAL(tmpfile64)
89 TLI_DEFINE_STRING_INTERNAL("tmpfile64")
90 TLI_DEFINE_SIG_INTERNAL(Ptr)
diff --git a/meta/recipes-devtools/clang/clang/0005-llvm-allow-env-override-of-exe-and-libdir-path.patch b/meta/recipes-devtools/clang/clang/0005-llvm-allow-env-override-of-exe-and-libdir-path.patch
new file mode 100644
index 0000000000..6d3f5293aa
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0005-llvm-allow-env-override-of-exe-and-libdir-path.patch
@@ -0,0 +1,71 @@
1From 0b344231c49d8c145bc3ad882d259d36fb19e827 Mon Sep 17 00:00:00 2001
2From: Martin Kelly <mkelly@xevo.com>
3Date: Fri, 19 May 2017 00:22:57 -0700
4Subject: [PATCH] llvm: allow env override of exe and libdir path
5
6When using a native llvm-config from inside a sysroot, we need llvm-config to
7return the libraries, include directories, etc. from inside the sysroot rather
8than from the native sysroot. Thus provide an env override for calling
9llvm-config from a target sysroot.
10
11Add YOCTO_ALTERNATE_LIBDIR and YOCTO_ALTERNATE_EXE_PATH env variables
12
13Upstream-Status: Inappropriate [OE-specific]
14
15Signed-off-by: Martin Kelly <mkelly@xevo.com>
16Signed-off-by: Khem Raj <raj.khem@gmail.com>
17---
18 llvm/tools/llvm-config/llvm-config.cpp | 25 +++++++++++++++++++------
19 1 file changed, 19 insertions(+), 6 deletions(-)
20
21diff --git a/llvm/tools/llvm-config/llvm-config.cpp b/llvm/tools/llvm-config/llvm-config.cpp
22index d5b76b1bb6c1..a739f0d8dbea 100644
23--- a/llvm/tools/llvm-config/llvm-config.cpp
24+++ b/llvm/tools/llvm-config/llvm-config.cpp
25@@ -246,6 +246,13 @@ Typical components:\n\
26
27 /// Compute the path to the main executable.
28 std::string GetExecutablePath(const char *Argv0) {
29+ // Hack for Yocto: we need to override the root path when we are using
30+ // llvm-config from within a target sysroot.
31+ const char *Sysroot = std::getenv("YOCTO_ALTERNATE_EXE_PATH");
32+ if (Sysroot != nullptr) {
33+ return Sysroot;
34+ }
35+
36 // This just needs to be some symbol in the binary; C++ doesn't
37 // allow taking the address of ::main however.
38 void *P = (void *)(intptr_t)GetExecutablePath;
39@@ -325,7 +332,7 @@ int main(int argc, char **argv) {
40 // Compute various directory locations based on the derived location
41 // information.
42 std::string ActivePrefix, ActiveBinDir, ActiveIncludeDir, ActiveLibDir,
43- ActiveCMakeDir;
44+ ActiveCMakeDir, BaseLibDir;
45 std::string ActiveIncludeOption;
46 if (IsInDevelopmentTree) {
47 ActiveIncludeDir = std::string(LLVM_SRC_ROOT) + "/include";
48@@ -366,12 +373,18 @@ int main(int argc, char **argv) {
49 sys::fs::make_absolute(ActivePrefix, Path);
50 ActiveBinDir = std::string(Path);
51 }
52- ActiveLibDir = ActivePrefix + "/lib" + LLVM_LIBDIR_SUFFIX;
53- {
54- SmallString<256> Path(LLVM_INSTALL_PACKAGE_DIR);
55- sys::fs::make_absolute(ActivePrefix, Path);
56- ActiveCMakeDir = std::string(Path);
57+ // Hack for Yocto: we need to override the lib path when we are using
58+ // llvm-config from within a target sysroot since LLVM_LIBDIR_SUFFIX
59+ // maybe different for host llvm vs target e.g. ppc64 Libdir=lib64 but
60+ // x86_64 Libdir = lib
61+ const char *YoctoLibDir = std::getenv("YOCTO_ALTERNATE_LIBDIR");
62+ if (YoctoLibDir != nullptr) {
63+ BaseLibDir = std::string(YoctoLibDir);
64+ } else {
65+ BaseLibDir = std::string("/lib") + LLVM_LIBDIR_SUFFIX;
66 }
67+ ActiveLibDir = ActivePrefix + BaseLibDir;
68+ ActiveCMakeDir = ActiveLibDir + "/cmake/llvm";
69 ActiveIncludeOption = "-I" + ActiveIncludeDir;
70 }
71
diff --git a/meta/recipes-devtools/clang/clang/0006-clang-driver-Check-sysroot-for-ldso-path.patch b/meta/recipes-devtools/clang/clang/0006-clang-driver-Check-sysroot-for-ldso-path.patch
new file mode 100644
index 0000000000..0258687820
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0006-clang-driver-Check-sysroot-for-ldso-path.patch
@@ -0,0 +1,78 @@
1From 80cacc04e4c0d34f79ee2f112b302c4fbb797d72 Mon Sep 17 00:00:00 2001
2From: Dan McGregor <dan.mcgregor@usask.ca>
3Date: Wed, 26 Apr 2017 20:29:41 -0600
4Subject: [PATCH] clang: driver: Check sysroot for ldso path
5
6when we build multilib the ldso has different paths than clangs defaults,
7every distro kind of does that so OE is not the only one,
8it happens especially on ppc64, where OE does not necessarily follow the
9default path for the dynamic linker, therefore adjust it for OE. Check
10for the default path, and if it isn't there, check /lib.
11
12Upstream-Status: Pending
13Signed-off-by: Dan McGregor <dan.mcgregor@usask.ca>
14Signed-off-by: Khem Raj <raj.khem@gmail.com>
15---
16 clang/lib/Driver/ToolChains/Linux.cpp | 22 +++++++++++++++++++++-
17 1 file changed, 21 insertions(+), 1 deletion(-)
18
19diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp
20index 0767fe6c5879..e5a696f63fd0 100644
21--- a/clang/lib/Driver/ToolChains/Linux.cpp
22+++ b/clang/lib/Driver/ToolChains/Linux.cpp
23@@ -523,8 +523,12 @@ std::string Linux::getDynamicLinker(const ArgList &Args) const {
24 Triple.getEnvironment() == llvm::Triple::GNUEABIHFT64 ||
25 tools::arm::getARMFloatABI(*this, Args) == tools::arm::FloatABI::Hard;
26
27- LibDir = "lib";
28 Loader = HF ? "ld-linux-armhf.so.3" : "ld-linux.so.3";
29+ LibDir = "lib32";
30+ if (!getVFS().exists(getDriver().SysRoot + "/" + LibDir + "/" + Loader) &&
31+ getVFS().exists(getDriver().SysRoot + "/lib/" + Loader)) {
32+ LibDir = "lib";
33+ }
34 break;
35 }
36 case llvm::Triple::loongarch32: {
37@@ -578,11 +582,19 @@ std::string Linux::getDynamicLinker(const ArgList &Args) const {
38 LibDir = "lib64";
39 Loader =
40 (tools::ppc::hasPPCAbiArg(Args, "elfv2")) ? "ld64.so.2" : "ld64.so.1";
41+ if (!getVFS().exists(getDriver().SysRoot + "/" + LibDir + "/" + Loader) &&
42+ getVFS().exists(getDriver().SysRoot + "/lib/" + Loader)) {
43+ LibDir = "lib";
44+ }
45 break;
46 case llvm::Triple::ppc64le:
47 LibDir = "lib64";
48 Loader =
49 (tools::ppc::hasPPCAbiArg(Args, "elfv1")) ? "ld64.so.1" : "ld64.so.2";
50+ if (!getVFS().exists(getDriver().SysRoot + "/" + LibDir + "/" + Loader) &&
51+ getVFS().exists(getDriver().SysRoot + "/lib/" + Loader)) {
52+ LibDir = "lib";
53+ }
54 break;
55 case llvm::Triple::riscv32:
56 case llvm::Triple::riscv64: {
57@@ -600,6 +612,10 @@ std::string Linux::getDynamicLinker(const ArgList &Args) const {
58 case llvm::Triple::sparcv9:
59 LibDir = "lib64";
60 Loader = "ld-linux.so.2";
61+ if (!getVFS().exists(getDriver().SysRoot + "/" + LibDir + "/" + Loader) &&
62+ getVFS().exists(getDriver().SysRoot + "/lib/" + Loader)) {
63+ LibDir = "lib";
64+ }
65 break;
66 case llvm::Triple::systemz:
67 LibDir = "lib";
68@@ -614,6 +630,10 @@ std::string Linux::getDynamicLinker(const ArgList &Args) const {
69
70 LibDir = X32 ? "libx32" : "lib64";
71 Loader = X32 ? "ld-linux-x32.so.2" : "ld-linux-x86-64.so.2";
72+ if (!getVFS().exists(getDriver().SysRoot + "/" + LibDir + "/" + Loader) &&
73+ getVFS().exists(getDriver().SysRoot + "/lib/" + Loader)) {
74+ LibDir = "lib";
75+ }
76 break;
77 }
78 case llvm::Triple::ve:
diff --git a/meta/recipes-devtools/clang/clang/0007-clang-Driver-tools.cpp-Add-lssp_nonshared-on-musl.patch b/meta/recipes-devtools/clang/clang/0007-clang-Driver-tools.cpp-Add-lssp_nonshared-on-musl.patch
new file mode 100644
index 0000000000..1681080ece
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0007-clang-Driver-tools.cpp-Add-lssp_nonshared-on-musl.patch
@@ -0,0 +1,32 @@
1From 47dfdd42687c403c044fdb830472d7bedc1b3d39 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Thu, 19 May 2016 21:11:06 -0700
4Subject: [PATCH] clang: Driver/tools.cpp: Add -lssp_nonshared on musl
5
6musl driver will need to add ssp_nonshared for stack_check_local
7on the linker cmdline when using stack protector commands on
8compiler cmdline
9
10Upstream-Status: Pending
11Signed-off-by: Khem Raj <raj.khem@gmail.com>
12---
13 clang/lib/Driver/ToolChains/Gnu.cpp | 6 ++++++
14 1 file changed, 6 insertions(+)
15
16diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp
17index f56eeda3cb5f..9f7b9e8d42a8 100644
18--- a/clang/lib/Driver/ToolChains/Gnu.cpp
19+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
20@@ -631,6 +631,12 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
21 if (IsIAMCU)
22 CmdArgs.push_back("-lgloss");
23
24+ if (ToolChain.getTriple().isMusl() &&
25+ (Args.hasArg(options::OPT_fstack_protector) ||
26+ Args.hasArg(options::OPT_fstack_protector_strong) ||
27+ Args.hasArg(options::OPT_fstack_protector_all))) {
28+ CmdArgs.push_back("-lssp_nonshared");
29+ }
30 if (IsStatic || IsStaticPIE)
31 CmdArgs.push_back("--end-group");
32 else
diff --git a/meta/recipes-devtools/clang/clang/0008-clang-Prepend-trailing-to-sysroot.patch b/meta/recipes-devtools/clang/clang/0008-clang-Prepend-trailing-to-sysroot.patch
new file mode 100644
index 0000000000..12f670034e
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0008-clang-Prepend-trailing-to-sysroot.patch
@@ -0,0 +1,39 @@
1From 4b64a243ce69f782964d4841d1079689a62ebdc1 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Thu, 16 Mar 2017 09:02:13 -0700
4Subject: [PATCH] clang: Prepend trailing '/' to sysroot
5
6This is needed to handle a case where clang
7isntall and target sysroot are perilously same
8
9e.g.
10
11sysroot = /mnt/clang/recipe-sysroot
12clang install = /mnt/clang/recipe-sysroot-native
13
14in this case it will mistakenly assume that
15clang is installed under the same sysroot dir
16and it will try to add relative ../lib paths
17to linker steps which would then be wrong
18since they will become relative to clang
19installation and not sysroot
20
21Upstream-Status: Pending
22Signed-off-by: Khem Raj <raj.khem@gmail.com>
23---
24 clang/lib/Driver/ToolChains/Linux.cpp | 2 +-
25 1 file changed, 1 insertion(+), 1 deletion(-)
26
27diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp
28index e5a696f63fd0..621fa17e0603 100644
29--- a/clang/lib/Driver/ToolChains/Linux.cpp
30+++ b/clang/lib/Driver/ToolChains/Linux.cpp
31@@ -216,7 +216,7 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
32 Multilibs = GCCInstallation.getMultilibs();
33 SelectedMultilibs.assign({GCCInstallation.getMultilib()});
34 llvm::Triple::ArchType Arch = Triple.getArch();
35- std::string SysRoot = computeSysRoot();
36+ std::string SysRoot = computeSysRoot() + "/";
37 ToolChain::path_list &PPaths = getProgramPaths();
38
39 Generic_GCC::PushPPaths(PPaths);
diff --git a/meta/recipes-devtools/clang/clang/0009-clang-Look-inside-the-target-sysroot-for-compiler-ru.patch b/meta/recipes-devtools/clang/clang/0009-clang-Look-inside-the-target-sysroot-for-compiler-ru.patch
new file mode 100644
index 0000000000..5d7a292fcf
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0009-clang-Look-inside-the-target-sysroot-for-compiler-ru.patch
@@ -0,0 +1,41 @@
1From edc111019281ed898add2c3f86ebfd54b0fa46d9 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Thu, 16 Mar 2017 19:06:26 -0700
4Subject: [PATCH] clang: Look inside the target sysroot for compiler runtime
5
6In OE compiler-rt and libc++ are built and staged into target
7sysroot and not into resourcedir which is relative to clang
8driver installation where the libraries are not instlled
9
10Specific to cross compiling the way yocto/OE works
11
12Upstream-Status: Pending
13Signed-off-by: Khem Raj <raj.khem@gmail.com>
14---
15 clang/lib/Driver/ToolChain.cpp | 6 +++++-
16 1 file changed, 5 insertions(+), 1 deletion(-)
17
18diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
19index acf9d264d631..3e46c88e95cb 100644
20--- a/clang/lib/Driver/ToolChain.cpp
21+++ b/clang/lib/Driver/ToolChain.cpp
22@@ -16,6 +16,7 @@
23 #include "ToolChains/InterfaceStubs.h"
24 #include "clang/Basic/ObjCRuntime.h"
25 #include "clang/Basic/Sanitizers.h"
26+#include "clang/Basic/Version.h"
27 #include "clang/Config/config.h"
28 #include "clang/Driver/Action.h"
29 #include "clang/Driver/Driver.h"
30@@ -708,7 +709,10 @@ StringRef ToolChain::getOSLibName() const {
31 }
32
33 std::string ToolChain::getCompilerRTPath() const {
34- SmallString<128> Path(getDriver().ResourceDir);
35+ SmallString<128> Path(getDriver().SysRoot);
36+ StringRef ClangLibdirBasename(CLANG_INSTALL_LIBDIR_BASENAME);
37+ llvm::sys::path::append(Path, "/usr/", ClangLibdirBasename, "clang",
38+ CLANG_VERSION_STRING);
39 if (isBareMetal()) {
40 llvm::sys::path::append(Path, "lib", getOSLibName());
41 if (!SelectedMultilibs.empty()) {
diff --git a/meta/recipes-devtools/clang/clang/0010-clang-Define-releative-gcc-installation-dir.patch b/meta/recipes-devtools/clang/clang/0010-clang-Define-releative-gcc-installation-dir.patch
new file mode 100644
index 0000000000..c4fbaee956
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0010-clang-Define-releative-gcc-installation-dir.patch
@@ -0,0 +1,123 @@
1From e79d44241dfd0f4b4ec25547e6a65e61d2a0b4b2 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Sat, 20 Mar 2021 16:09:16 -0700
4Subject: [PATCH] clang: Define / releative gcc installation dir
5
6This is required for OE gcc installation to work.
7Without this its not able to find the paths for libgcc
8and other standard headers and libraries from gcc
9installation in OE
10
11* Do not use install relative libc++ headers
12In OE we use same clang for native and cross builds, therefore we need
13to ensure that native sysroot install of libc++ is not searched for
14headers when doing cross compile instead it searches the target sysroot
15this is especially troublesome when libcxx-native is staged along with
16libcxx e.g. chromium
17
18 * Fix lib paths for OpenEmbedded Host
19
20Under OpenEmbedded Host, while building with clang-native, it cannot find
21the GCCInstallPath, which causing following error:
22[snip]
23compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/bin/clang
24-target x86_64-linux
25-isystem/path/to/x86_64-linux/compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/include
26-O2 -pipe
27/path/to/compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/share/cmake-3.21/Modules/CMakeCCompilerABI.c`
28hosttools/ld: cannot find crtbeginS.o: No such file or directory
29[snip]
30
31Before this patch:
32compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/bin/clang
33clang version 13.0.1 (https://github.com/llvm/llvm-project 08e3a5ccd952edee36b3c002e3a29c6b1b5153de)
34Target: x86_64-unknown-linux-gnu
35Thread model: posix
36InstalledDir: /build/tmp-glibc/work/x86_64-linux/compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/bin
37Found candidate GCC installation: /usr/lib/gcc/x86_64-wrs-linux/10.2.0
38
39After this patch:
40compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/bin/clang
41clang version 13.0.1 (https://github.com/llvm/llvm-project 08e3a5ccd952edee36b3c002e3a29c6b1b5153de)
42Thread model: posix
43InstalledDir: /build/tmp-glibc/work/x86_64-linux/compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/bin
44Found candidate GCC installation: /usr/lib/gcc/x86_64-wrs-linux/10.2.0
45Found candidate GCC installation: /usr/lib/x86_64-wrs-linux/10.2.0
46Selected GCC installation: /usr/lib/x86_64-wrs-linux/10.2.0
47Candidate multilib: .;@m64
48Selected multilib: .;@m64
49
50For OpenEmbedded Host, sysroots are of the form<sysroot>/usr/lib/<triple>/x.y.z.
51Take x86-64 as example, the default triple is x86_64-unknown-linux-gnu.
52For clang-native, the target vendor is '-unknown', need to test current distro
53to follow above form.
54
55Upstream-Status: Inappropriate [oe specific]
56
57Signed-off-by: Changqing Li <changqing.li@windriver.com>
58Signed-off-by: Khem Raj <raj.khem@gmail.com>
59---
60 clang/lib/Driver/ToolChains/Gnu.cpp | 22 ++++++++++++++--------
61 1 file changed, 14 insertions(+), 8 deletions(-)
62
63diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp
64index 9f7b9e8d42a8..268fb7bf7167 100644
65--- a/clang/lib/Driver/ToolChains/Gnu.cpp
66+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
67@@ -19,6 +19,7 @@
68 #include "Linux.h"
69 #include "clang/Config/config.h" // for GCC_INSTALL_PREFIX
70 #include "clang/Driver/Compilation.h"
71+#include "clang/Driver/Distro.h"
72 #include "clang/Driver/Driver.h"
73 #include "clang/Driver/DriverDiagnostic.h"
74 #include "clang/Driver/MultilibBuilder.h"
75@@ -2860,6 +2861,7 @@ void Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple(
76 const llvm::Triple &TargetTriple, const ArgList &Args,
77 const std::string &LibDir, StringRef CandidateTriple,
78 bool NeedsBiarchSuffix, bool GCCDirExists, bool GCCCrossDirExists) {
79+ Distro Distro(D.getVFS(), TargetTriple);
80 // Locations relative to the system lib directory where GCC's triple-specific
81 // directories might reside.
82 struct GCCLibSuffix {
83@@ -2871,19 +2873,20 @@ void Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple(
84 // Whether this library suffix is relevant for the triple.
85 bool Active;
86 } Suffixes[] = {
87- // This is the normal place.
88- {"gcc/" + CandidateTriple.str(), "../..", GCCDirExists},
89-
90- // Debian puts cross-compilers in gcc-cross.
91- {"gcc-cross/" + CandidateTriple.str(), "../..", GCCCrossDirExists},
92-
93 // The Freescale PPC SDK has the gcc libraries in
94 // <sysroot>/usr/lib/<triple>/x.y.z so have a look there as well. Only do
95 // this on Freescale triples, though, since some systems put a *lot* of
96 // files in that location, not just GCC installation data.
97 {CandidateTriple.str(), "..",
98 TargetTriple.getVendor() == llvm::Triple::Freescale ||
99- TargetTriple.getVendor() == llvm::Triple::OpenEmbedded}};
100+ TargetTriple.getVendor() == llvm::Triple::OpenEmbedded ||
101+ Distro.IsOpenEmbedded()},
102+
103+ // This is the normal place.
104+ {"gcc/" + CandidateTriple.str(), "../..", GCCDirExists},
105+
106+ // Debian puts cross-compilers in gcc-cross.
107+ {"gcc-cross/" + CandidateTriple.str(), "../..", GCCCrossDirExists}};
108
109 for (auto &Suffix : Suffixes) {
110 if (!Suffix.Active)
111@@ -3274,8 +3277,11 @@ Generic_GCC::addLibCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
112 // incompatible with the NDK libraries.
113 SmallString<128> DriverIncludeDir(getDriver().Dir);
114 llvm::sys::path::append(DriverIncludeDir, "..", "include");
115+
116+ // do not add it when --sysroot is specified, since it would expect
117+ // libc++ headers from sysroot and not relative to compiler install location
118 if (AddIncludePath(DriverIncludeDir,
119- /*TargetDirRequired=*/getTriple().isAndroid()))
120+ /*TargetDirRequired=*/getTriple().isAndroid() | !computeSysRoot().empty()))
121 return;
122 // If this is a development, non-installed, clang, libcxx will
123 // not be found at ../include/c++ but it likely to be found at
diff --git a/meta/recipes-devtools/clang/clang/0011-clang-Add-lpthread-and-ldl-along-with-lunwind-for-st.patch b/meta/recipes-devtools/clang/clang/0011-clang-Add-lpthread-and-ldl-along-with-lunwind-for-st.patch
new file mode 100644
index 0000000000..e50e3bf026
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0011-clang-Add-lpthread-and-ldl-along-with-lunwind-for-st.patch
@@ -0,0 +1,35 @@
1From 42dc7f1fd3e7bc549f87b9c28fb3024a3970e96d Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Wed, 31 Jul 2019 22:51:39 -0700
4Subject: [PATCH] clang: Add -lpthread and -ldl along with -lunwind for static
5 linking
6
7When doing static liking with --unwindlib=libunwind -static we encounter
8undefined symbols
9libunwind/src/RWMutex.hpp:68: undefined reference to `pthread_rwlock_wrlock'
10
11and
12
13libunwind/src/AddressSpace.hpp:597: undefined reference to `dladdr'
14
15therefore we need to link in libpthread and libdl to fill these symbols
16
17Upstream-Status: Pending
18Signed-off-by: Khem Raj <raj.khem@gmail.com>
19---
20 clang/lib/Driver/ToolChains/CommonArgs.cpp | 2 ++
21 1 file changed, 2 insertions(+)
22
23diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
24index ae635fb6a180..255e7e0b7150 100644
25--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
26+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
27@@ -2254,6 +2254,8 @@ static void AddUnwindLibrary(const ToolChain &TC, const Driver &D,
28 CmdArgs.push_back("-lunwind");
29 } else if (LGT == LibGccType::StaticLibGcc) {
30 CmdArgs.push_back("-l:libunwind.a");
31+ CmdArgs.push_back("-lpthread");
32+ CmdArgs.push_back("-ldl");
33 } else if (LGT == LibGccType::SharedLibGcc) {
34 if (TC.getTriple().isOSCygMing())
35 CmdArgs.push_back("-l:libunwind.dll.a");
diff --git a/meta/recipes-devtools/clang/clang/0012-Pass-PYTHON_EXECUTABLE-when-cross-compiling-for-nati.patch b/meta/recipes-devtools/clang/clang/0012-Pass-PYTHON_EXECUTABLE-when-cross-compiling-for-nati.patch
new file mode 100644
index 0000000000..0f386cd1a6
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0012-Pass-PYTHON_EXECUTABLE-when-cross-compiling-for-nati.patch
@@ -0,0 +1,24 @@
1From 0e60706bcddbb9a97ab28df6fba39bf6bd49ab27 Mon Sep 17 00:00:00 2001
2From: Anuj Mittal <anuj.mittal@intel.com>
3Date: Thu, 26 Dec 2019 12:56:16 -0800
4Subject: [PATCH] Pass PYTHON_EXECUTABLE when cross compiling for native build
5
6Upstream-Status: Pending
7Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
8Signed-off-by: Khem Raj <raj.khem@gmail.com>
9---
10 llvm/cmake/modules/CrossCompile.cmake | 1 +
11 1 file changed, 1 insertion(+)
12
13diff --git a/llvm/cmake/modules/CrossCompile.cmake b/llvm/cmake/modules/CrossCompile.cmake
14index 3b31d3e218a3..a07ab45878fd 100644
15--- a/llvm/cmake/modules/CrossCompile.cmake
16+++ b/llvm/cmake/modules/CrossCompile.cmake
17@@ -100,6 +100,7 @@ function(llvm_create_cross_target project_name target_name toolchain buildtype)
18 -DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN="${LLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN}"
19 -DLLVM_INCLUDE_BENCHMARKS=OFF
20 -DLLVM_INCLUDE_TESTS=OFF
21+ -DPYTHON_EXECUTABLE="${PYTHON_EXECUTABLE}"
22 ${build_type_flags} ${linker_flag} ${external_clang_dir} ${libc_flags}
23 ${ARGN}
24 WORKING_DIRECTORY ${${project_name}_${target_name}_BUILD}
diff --git a/meta/recipes-devtools/clang/clang/0013-Check-for-atomic-double-intrinsics.patch b/meta/recipes-devtools/clang/clang/0013-Check-for-atomic-double-intrinsics.patch
new file mode 100644
index 0000000000..3a6713a2de
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0013-Check-for-atomic-double-intrinsics.patch
@@ -0,0 +1,34 @@
1From f7ef28286dd0adfd384ef55c9039022b4f92f99c Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Mon, 18 Nov 2019 17:00:29 -0800
4Subject: [PATCH] Check for atomic<double> intrinsics
5
6On some architectures e.g. x86/32bit gcc decides to inline calls to
7double atomic variables but clang does not and defers it to libatomic
8therefore detect if clang can use built-ins for atomic<double> if not
9then link libatomic, this helps building clangd for x86 on linux systems
10with gcc runtime
11
12Upstream-Status: Pending
13Signed-off-by: Khem Raj <raj.khem@gmail.com>
14---
15 llvm/cmake/modules/CheckAtomic.cmake | 3 ++-
16 1 file changed, 2 insertions(+), 1 deletion(-)
17
18diff --git a/llvm/cmake/modules/CheckAtomic.cmake b/llvm/cmake/modules/CheckAtomic.cmake
19index f11cadf39ff6..80a18a92956a 100644
20--- a/llvm/cmake/modules/CheckAtomic.cmake
21+++ b/llvm/cmake/modules/CheckAtomic.cmake
22@@ -30,10 +30,11 @@ function(check_working_cxx_atomics64 varname)
23 #include <atomic>
24 #include <cstdint>
25 std::atomic<uint64_t> x (0);
26+std::atomic<double> y (0);
27 int main() {
28 uint64_t i = x.load(std::memory_order_relaxed);
29 (void)i;
30- return 0;
31+ return int(y);
32 }
33 " ${varname})
34 set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
diff --git a/meta/recipes-devtools/llvm/llvm/0014-cmake-Fix-configure-for-packages-using-find_package.patch b/meta/recipes-devtools/clang/clang/0014-cmake-Fix-configure-for-packages-using-find_package.patch
index 94c056ab8e..033f9e6d7c 100644
--- a/meta/recipes-devtools/llvm/llvm/0014-cmake-Fix-configure-for-packages-using-find_package.patch
+++ b/meta/recipes-devtools/clang/clang/0014-cmake-Fix-configure-for-packages-using-find_package.patch
@@ -1,4 +1,4 @@
1From 93141cee493022d9f39dbd1f5f0bb0a1110ac829 Mon Sep 17 00:00:00 2001 1From aae87f7ce9d07ba1c401de8f2981b046321fba3b Mon Sep 17 00:00:00 2001
2From: Ovidiu Panait <ovidiu.panait@windriver.com> 2From: Ovidiu Panait <ovidiu.panait@windriver.com>
3Date: Fri, 31 Jan 2020 10:56:11 +0200 3Date: Fri, 31 Jan 2020 10:56:11 +0200
4Subject: [PATCH] cmake: Fix configure for packages using find_package() 4Subject: [PATCH] cmake: Fix configure for packages using find_package()
diff --git a/meta/recipes-devtools/clang/clang/0015-clang-Fix-resource-dir-location-for-cross-toolchains.patch b/meta/recipes-devtools/clang/clang/0015-clang-Fix-resource-dir-location-for-cross-toolchains.patch
new file mode 100644
index 0000000000..479cc01004
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0015-clang-Fix-resource-dir-location-for-cross-toolchains.patch
@@ -0,0 +1,50 @@
1From e374b21872c382d0450a5813184c72fdaabcac11 Mon Sep 17 00:00:00 2001
2From: Jim Broadus <jbroadus@xevo.com>
3Date: Thu, 26 Mar 2020 16:05:53 -0700
4Subject: [PATCH] clang: Fix resource dir location for cross toolchains
5
6When clang looks for the resources directory, it does so based on the binary
7location and assumes that the containing directory is a sibling to lib. The
8Yocto cross.bbclass defines the default bindir as
9${exec_prefix}/bin/${CROSS_TARGET_SYS_DIR}. ex: /usr/bin/aarch64-poky-linux/.
10This causes clang to form a path that looks like /usr/bin/lib/clang/...
11
12As a fix for this, check the parent directory name. If that is "bin", then
13use that directory's parent.
14
15Upstream-Status: Pending
16Signed-off-by: Jim Broadus <jbroadus@xevo.com>
17Signed-off-by: Khem Raj <raj.khem@gmail.com>
18---
19 clang/lib/Driver/Driver.cpp | 9 ++++++++-
20 1 file changed, 8 insertions(+), 1 deletion(-)
21
22diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
23index 87855fdb7997..036c9d09df26 100644
24--- a/clang/lib/Driver/Driver.cpp
25+++ b/clang/lib/Driver/Driver.cpp
26@@ -176,6 +176,7 @@ std::string Driver::GetResourcesPath(StringRef BinaryPath) {
27
28 // Dir is bin/ or lib/, depending on where BinaryPath is.
29 StringRef Dir = llvm::sys::path::parent_path(BinaryPath);
30+ StringRef LastDirName = llvm::sys::path::filename(Dir);
31 SmallString<128> P(Dir);
32
33 StringRef ConfiguredResourceDir(CLANG_RESOURCE_DIR);
34@@ -187,9 +188,15 @@ std::string Driver::GetResourcesPath(StringRef BinaryPath) {
35 // With a static-library build of libclang, LibClangPath will contain the
36 // path of the embedding binary, which for LLVM binaries will be in bin/.
37 // ../lib gets us to lib/ in both cases.
38- P = llvm::sys::path::parent_path(Dir);
39 // This search path is also created in the COFF driver of lld, so any
40 // changes here also needs to happen in lld/COFF/Driver.cpp
41+
42+ // OE cross toolchains are installed, by default, in a subdir of bin.
43+ if (LastDirName == "bin") {
44+ P = llvm::sys::path::parent_path(Dir);
45+ } else {
46+ P = llvm::sys::path::parent_path(llvm::sys::path::parent_path(Dir));
47+ }
48 llvm::sys::path::append(P, CLANG_INSTALL_LIBDIR_BASENAME, "clang",
49 CLANG_VERSION_MAJOR_STRING);
50 }
diff --git a/meta/recipes-devtools/clang/clang/0016-clang-driver-Add-dyld-prefix-when-checking-sysroot-f.patch b/meta/recipes-devtools/clang/clang/0016-clang-driver-Add-dyld-prefix-when-checking-sysroot-f.patch
new file mode 100644
index 0000000000..3803603355
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0016-clang-driver-Add-dyld-prefix-when-checking-sysroot-f.patch
@@ -0,0 +1,79 @@
1From 3acdfa74ce633bfebf1c3982d86b4931b8b606c8 Mon Sep 17 00:00:00 2001
2From: Oleksandr Ocheretnyi <oocheret@cisco.com>
3Date: Wed, 15 Apr 2020 00:08:39 +0300
4Subject: [PATCH] clang: driver: Add dyld-prefix when checking sysroot for ldso
5 path
6
7 * the dyld-prefix shall be taken into account when the default
8 path for the dynamic linker has to be checked.
9
10 * this patch shall be used as annex to the next patch:
11 'clang: driver: Check sysroot for ldso path' which includes
12 the usrmerge scenario.
13
14Upstream-Status: Pending
15Signed-off-by: Oleksandr Ocheretnyi <oocheret@cisco.com>
16Signed-off-by: Khem Raj <raj.khem@gmail.com>
17---
18 clang/lib/Driver/ToolChains/Linux.cpp | 20 ++++++++++----------
19 1 file changed, 10 insertions(+), 10 deletions(-)
20
21diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp
22index 621fa17e0603..8fd454d4eff4 100644
23--- a/clang/lib/Driver/ToolChains/Linux.cpp
24+++ b/clang/lib/Driver/ToolChains/Linux.cpp
25@@ -525,8 +525,8 @@ std::string Linux::getDynamicLinker(const ArgList &Args) const {
26
27 Loader = HF ? "ld-linux-armhf.so.3" : "ld-linux.so.3";
28 LibDir = "lib32";
29- if (!getVFS().exists(getDriver().SysRoot + "/" + LibDir + "/" + Loader) &&
30- getVFS().exists(getDriver().SysRoot + "/lib/" + Loader)) {
31+ if (!getVFS().exists(getDriver().SysRoot + getDriver().DyldPrefix + "/" + LibDir + "/" + Loader) &&
32+ getVFS().exists(getDriver().SysRoot + getDriver().DyldPrefix + "/lib/" + Loader)) {
33 LibDir = "lib";
34 }
35 break;
36@@ -582,8 +582,8 @@ std::string Linux::getDynamicLinker(const ArgList &Args) const {
37 LibDir = "lib64";
38 Loader =
39 (tools::ppc::hasPPCAbiArg(Args, "elfv2")) ? "ld64.so.2" : "ld64.so.1";
40- if (!getVFS().exists(getDriver().SysRoot + "/" + LibDir + "/" + Loader) &&
41- getVFS().exists(getDriver().SysRoot + "/lib/" + Loader)) {
42+ if (!getVFS().exists(getDriver().SysRoot + getDriver().DyldPrefix + "/" + LibDir + "/" + Loader) &&
43+ getVFS().exists(getDriver().SysRoot + getDriver().DyldPrefix + "/lib/" + Loader)) {
44 LibDir = "lib";
45 }
46 break;
47@@ -591,8 +591,8 @@ std::string Linux::getDynamicLinker(const ArgList &Args) const {
48 LibDir = "lib64";
49 Loader =
50 (tools::ppc::hasPPCAbiArg(Args, "elfv1")) ? "ld64.so.1" : "ld64.so.2";
51- if (!getVFS().exists(getDriver().SysRoot + "/" + LibDir + "/" + Loader) &&
52- getVFS().exists(getDriver().SysRoot + "/lib/" + Loader)) {
53+ if (!getVFS().exists(getDriver().SysRoot + getDriver().DyldPrefix + "/" + LibDir + "/" + Loader) &&
54+ getVFS().exists(getDriver().SysRoot + getDriver().DyldPrefix + "/lib/" + Loader)) {
55 LibDir = "lib";
56 }
57 break;
58@@ -612,8 +612,8 @@ std::string Linux::getDynamicLinker(const ArgList &Args) const {
59 case llvm::Triple::sparcv9:
60 LibDir = "lib64";
61 Loader = "ld-linux.so.2";
62- if (!getVFS().exists(getDriver().SysRoot + "/" + LibDir + "/" + Loader) &&
63- getVFS().exists(getDriver().SysRoot + "/lib/" + Loader)) {
64+ if (!getVFS().exists(getDriver().SysRoot + getDriver().DyldPrefix + "/" + LibDir + "/" + Loader) &&
65+ getVFS().exists(getDriver().SysRoot + getDriver().DyldPrefix + "/lib/" + Loader)) {
66 LibDir = "lib";
67 }
68 break;
69@@ -630,8 +630,8 @@ std::string Linux::getDynamicLinker(const ArgList &Args) const {
70
71 LibDir = X32 ? "libx32" : "lib64";
72 Loader = X32 ? "ld-linux-x32.so.2" : "ld-linux-x86-64.so.2";
73- if (!getVFS().exists(getDriver().SysRoot + "/" + LibDir + "/" + Loader) &&
74- getVFS().exists(getDriver().SysRoot + "/lib/" + Loader)) {
75+ if (!getVFS().exists(getDriver().SysRoot + getDriver().DyldPrefix + "/" + LibDir + "/" + Loader) &&
76+ getVFS().exists(getDriver().SysRoot + getDriver().DyldPrefix + "/lib/" + Loader)) {
77 LibDir = "lib";
78 }
79 break;
diff --git a/meta/recipes-devtools/clang/clang/0017-clang-Use-python3-in-python-scripts.patch b/meta/recipes-devtools/clang/clang/0017-clang-Use-python3-in-python-scripts.patch
new file mode 100644
index 0000000000..329cd8b023
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0017-clang-Use-python3-in-python-scripts.patch
@@ -0,0 +1,35 @@
1From 02ce42db3325d5fab553627dfc73750270c0b665 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Wed, 14 Oct 2020 22:19:57 -0700
4Subject: [PATCH] clang: Use python3 in python scripts
5
6Some scripts ask for python, but they work fine with python3
7and in OE python symlink is not exposed to build, only python3 is
8
9Upstream-Status: Pending
10Signed-off-by: Khem Raj <raj.khem@gmail.com>
11---
12 .../find-all-symbols/tool/run-find-all-symbols.py | 2 +-
13 clang/tools/scan-view/bin/scan-view | 2 +-
14 2 files changed, 2 insertions(+), 2 deletions(-)
15
16diff --git a/clang-tools-extra/clang-include-fixer/find-all-symbols/tool/run-find-all-symbols.py b/clang-tools-extra/clang-include-fixer/find-all-symbols/tool/run-find-all-symbols.py
17index 471dbf8c110b..f98385dc6651 100755
18--- a/clang-tools-extra/clang-include-fixer/find-all-symbols/tool/run-find-all-symbols.py
19+++ b/clang-tools-extra/clang-include-fixer/find-all-symbols/tool/run-find-all-symbols.py
20@@ -1,4 +1,4 @@
21-#!/usr/bin/env python
22+#!/usr/bin/env python3
23 #
24 # =- run-find-all-symbols.py - Parallel find-all-symbols runner -*- python -*-=#
25 #
26diff --git a/clang/tools/scan-view/bin/scan-view b/clang/tools/scan-view/bin/scan-view
27index d01aebb4029a..f3375804654d 100755
28--- a/clang/tools/scan-view/bin/scan-view
29+++ b/clang/tools/scan-view/bin/scan-view
30@@ -1,4 +1,4 @@
31-#!/usr/bin/env python
32+#!/usr/bin/env python3
33
34 from __future__ import print_function
35
diff --git a/meta/recipes-devtools/clang/clang/0018-llvm-clang-Insert-anchor-for-adding-OE-distro-vendor.patch b/meta/recipes-devtools/clang/clang/0018-llvm-clang-Insert-anchor-for-adding-OE-distro-vendor.patch
new file mode 100644
index 0000000000..bf46b22f36
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0018-llvm-clang-Insert-anchor-for-adding-OE-distro-vendor.patch
@@ -0,0 +1,167 @@
1From aec307904022e138d1004ceb44b9600deaa7fbdb Mon Sep 17 00:00:00 2001
2From: Hongxu Jia <hongxu.jia@windriver.com>
3Date: Mon, 25 Jan 2021 16:14:35 +0800
4Subject: [PATCH] llvm/clang: Insert anchor for adding OE distro vendor names
5
6This helps in making right detection for OE built gcc toolchains
7
8The //CLANG_EXTRA_OE_VENDORS_CASES string is replaced with list of
9additional Ceses based on CLANG_EXTRA_OE_VENDORS variable in
10recipes-devtools/clang/llvm-project-source.inc:add_distro_vendor()
11
12* For x86_64, set Yocto based GCC install search path
13
14Under Yocto host, while using clang-native to build, it searches
15install host gcc failed which causing the include file not found
16[snip]
17|clang++ -target x86_64-linux -MMD -MF src/base/files/file_path_constants.o.d -I../../../tools/gn/src -I. \
18-isystem/tmp-glibc/work/x86_64-linux/gn-native/87.0.4280.141-r0/recipe-sysroot-native/usr/include -O2 -pipe \
19-std=c++17 -c ../../../tools/gn/src/base/files/file_path_constants.cc -o src/base/files/file_path_constants.o
20|../../../tools/gn/src/base/files/file_path_constants.cc:7:10: fatal error: 'iterator' file not found
21|#include <iterator>
22| ^~~~~~~~
23[snip]
24
25* Set three Yocto based GCC triple: poky, oe-core and wind river
26
27Before aplly the patch
28[snip]
29$ ../recipe-sysroot-native/usr/bin/clang++ -v
30clang version 11.0.1 (https://github.com/llvm/llvm-project 43ff75f2c3feef64f9d73328230d34dac8832a91)
31Target: x86_64-unknown-linux-gnu
32Thread model: posix
33InstalledDir:tmp-glibc/work/x86_64-linux/gn-native/87.0.4280.141-r0/chromium-87.0.4280.141/../recipe-sysroot-native/usr/bin
34[snip]
35
36After this patch:
37[snip]
38$ ../recipe-sysroot-native/usr/bin/clang++ -v
39clang version 11.0.1 (https://github.com/llvm/llvm-project 22c3241ff9a6224261df48d0258957fd8acc3d64)
40Target: x86_64-unknown-linux-gnu
41Thread model: posix
42InstalledDir:tmp-glibc/work/x86_64-linux/gn-native/87.0.4280.141-r0/chromium-87.0.4280.141/../recipe-sysroot-native/usr/bin
43Found candidate GCC installation: /usr/lib//x86_64-wrs-linux/10.1.0
44Found candidate GCC installation: /usr/lib/gcc/x86_64-wrs-linux/10.1.0
45Selected GCC installation: /usr/lib//x86_64-wrs-linux/10.1.0
46Candidate multilib: .;@m64
47Selected multilib: .;@m64
48[snip]
49
50BTW, it is hardly to insert a triple by the replacement of TARGET_SYS
51(=${TARGET_ARCH}${TARGET_VENDOR}-${TARGET_OS}), since TARGET_VENDOR
52is different between clang and clang-native
53
54* The //CLANG_EXTRA_OE_VENDORS_TRIPLES string is replaced with list of
55additional triples based on CLANG_EXTRA_OE_VENDORS variable in
56recipes-devtools/clang/llvm-project-source.inc:add_distro_vendor()
57
58* Correct library search path for OpenEmbedded Host
59
60For OpenEmbedded Host, the gcc install path is
61/usr/lib/x86_64-[distroname]-linux/[gcc-version].
62So the library search path is not found with default triple
63'x86_64-linux-gnu' for x86_64. Causing following error:
64[snip]
65compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/bin/clang
66-target x86_64-linux
67-isystem/path/to/x86_64-linux/compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/include
68-O2 -pipe
69/path/to/compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/share/cmake-3.21/Modules/CMakeCCompilerABI.c`
70| /build/tmp-glibc/hosttools/ld: cannot find -lgcc
71| /build/tmp-glibc/hosttools/ld: cannot find -lgcc
72| clang-13: error: linker command failed with exit code 1 (use -v to see invocation)
73[snip]
74
75before this patch:
76b59da142f2b0:$ /path/to/x86_64-linux/compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/bin/clang --print-search-dirs
77programs: =/build/tmp-glibc/work/x86_64-linux/compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/bin
78libraries: =/build/tmp-glibc/work/x86_64-linux/compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/lib/clang/13.0.1:/build/tmp-glibc/work/x86_64-linux/compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/bin/../lib://lib://usr/lib
79
80after this patch:
81b59da142f2b0:$ /path/to/x86_64-linux/compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/bin/clang --print-search-dirs
82programs: =/build/tmp-glibc/work/x86_64-linux/compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/bin
83libraries: =/build/tmp-glibc/work/x84_64-linux/compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/lib/clang/13.0.1:/usr/lib/x86_64-wrs-linux/10.2.0://lib/x86_64-wrs-linux://usr/lib/x86_64-wrs-linux:/build/tmp-glibc/work/x86_64-linux/compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/bin/../lib://lib://usr/lib
84
85Upstream-Status: Inappropriate [oe specific]
86
87Signed-off-by: Martin Jansa <martin.jansa@gmail.com>
88Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
89Signed-off-by: Changqing Li <changqing.li@windriver.com>
90Signed-off-by: Khem Raj <raj.khem@gmail.com>
91---
92 clang/include/clang/Driver/Distro.h | 2 ++
93 clang/lib/Driver/Distro.cpp | 1 +
94 clang/lib/Driver/ToolChains/Gnu.cpp | 1 +
95 clang/lib/Driver/ToolChains/Linux.cpp | 1 +
96 llvm/lib/TargetParser/Triple.cpp | 2 +-
97 5 files changed, 6 insertions(+), 1 deletion(-)
98
99diff --git a/clang/include/clang/Driver/Distro.h b/clang/include/clang/Driver/Distro.h
100index b4d485dac8a2..ac0bf25b7c63 100644
101--- a/clang/include/clang/Driver/Distro.h
102+++ b/clang/include/clang/Driver/Distro.h
103@@ -45,6 +45,7 @@ public:
104 RHEL7,
105 Fedora,
106 Gentoo,
107+ //CLANG_EXTRA_OE_DISTRO_NAME
108 OpenSUSE,
109 UbuntuHardy,
110 UbuntuIntrepid,
111@@ -139,6 +140,7 @@ public:
112
113 bool IsGentoo() const { return DistroVal == Gentoo; }
114
115+ //CLANG_EXTRA_OE_DISTRO_CHECK
116 /// @}
117 };
118
119diff --git a/clang/lib/Driver/Distro.cpp b/clang/lib/Driver/Distro.cpp
120index 3cc79535de8d..595656179bdc 100644
121--- a/clang/lib/Driver/Distro.cpp
122+++ b/clang/lib/Driver/Distro.cpp
123@@ -43,6 +43,7 @@ static Distro::DistroType DetectOsRelease(llvm::vfs::FileSystem &VFS) {
124 .Case("sles", Distro::OpenSUSE)
125 .Case("opensuse", Distro::OpenSUSE)
126 .Case("exherbo", Distro::Exherbo)
127+ //CLANG_EXTRA_OE_DISTRO_CASE
128 .Default(Distro::UnknownDistro);
129 return Version;
130 }
131diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp
132index 268fb7bf7167..868d32f501e8 100644
133--- a/clang/lib/Driver/ToolChains/Gnu.cpp
134+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
135@@ -2452,6 +2452,7 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
136 "x86_64-pc-linux-gnu", "x86_64-redhat-linux6E",
137 "x86_64-redhat-linux", "x86_64-suse-linux",
138 "x86_64-manbo-linux-gnu", "x86_64-slackware-linux",
139+ "x86_64-oe-linux",//CLANG_EXTRA_OE_VENDORS_TRIPLES
140 "x86_64-unknown-linux", "x86_64-amazon-linux"};
141 static const char *const X32Triples[] = {"x86_64-linux-gnux32",
142 "x86_64-pc-linux-gnux32"};
143diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp
144index 8fd454d4eff4..fb9d433a80be 100644
145--- a/clang/lib/Driver/ToolChains/Linux.cpp
146+++ b/clang/lib/Driver/ToolChains/Linux.cpp
147@@ -82,6 +82,7 @@ std::string Linux::getMultiarchTriple(const Driver &D,
148 return "x86_64-linux-android";
149 if (TargetEnvironment == llvm::Triple::GNUX32)
150 return "x86_64-linux-gnux32";
151+ //CLANG_EXTRA_OE_DISTRO_TRIPLE
152 return "x86_64-linux-gnu";
153 case llvm::Triple::aarch64:
154 if (IsAndroid)
155diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp
156index e9e6f130f757..97f426dd863b 100644
157--- a/llvm/lib/TargetParser/Triple.cpp
158+++ b/llvm/lib/TargetParser/Triple.cpp
159@@ -663,7 +663,7 @@ static Triple::VendorType parseVendor(StringRef VendorName) {
160 .Case("mesa", Triple::Mesa)
161 .Case("suse", Triple::SUSE)
162 .Case("oe", Triple::OpenEmbedded)
163- .Case("intel", Triple::Intel)
164+ .Case("intel", Triple::Intel) //CLANG_EXTRA_OE_VENDORS_CASES
165 .Default(Triple::UnknownVendor);
166 }
167
diff --git a/meta/recipes-devtools/clang/clang/0019-compiler-rt-Do-not-use-backtrace-APIs-on-non-glibc-l.patch b/meta/recipes-devtools/clang/clang/0019-compiler-rt-Do-not-use-backtrace-APIs-on-non-glibc-l.patch
new file mode 100644
index 0000000000..9518716c00
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0019-compiler-rt-Do-not-use-backtrace-APIs-on-non-glibc-l.patch
@@ -0,0 +1,68 @@
1From d0f40e9309a3f5734fa76c00994c5ebb70570c6c Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Wed, 19 May 2021 17:32:13 -0700
4Subject: [PATCH] compiler-rt: Do not use backtrace APIs on non-glibc linux
5
6musl e.g. does not provide backtrace APIs
7
8Upstream-Status: Pending
9Signed-off-by: Khem Raj <raj.khem@gmail.com>
10---
11 .../lib/gwp_asan/optional/backtrace_linux_libc.cpp | 13 ++++++++++++-
12 1 file changed, 12 insertions(+), 1 deletion(-)
13
14diff --git a/compiler-rt/lib/gwp_asan/optional/backtrace_linux_libc.cpp b/compiler-rt/lib/gwp_asan/optional/backtrace_linux_libc.cpp
15index ea8e72be287d..0344074dd254 100644
16--- a/compiler-rt/lib/gwp_asan/optional/backtrace_linux_libc.cpp
17+++ b/compiler-rt/lib/gwp_asan/optional/backtrace_linux_libc.cpp
18@@ -7,7 +7,9 @@
19 //===----------------------------------------------------------------------===//
20
21 #include <assert.h>
22+#ifdef __GLIBC__
23 #include <execinfo.h>
24+#endif
25 #include <stddef.h>
26 #include <stdint.h>
27 #include <stdlib.h>
28@@ -21,8 +23,11 @@
29 namespace {
30 size_t Backtrace(uintptr_t *TraceBuffer, size_t Size) {
31 static_assert(sizeof(uintptr_t) == sizeof(void *), "uintptr_t is not void*");
32-
33+#ifdef __GLIBC__
34 return backtrace(reinterpret_cast<void **>(TraceBuffer), Size);
35+#else
36+ return -1;
37+#endif
38 }
39
40 // We don't need any custom handling for the Segv backtrace - the libc unwinder
41@@ -30,7 +35,11 @@ size_t Backtrace(uintptr_t *TraceBuffer, size_t Size) {
42 // to avoid the additional frame.
43 GWP_ASAN_ALWAYS_INLINE size_t SegvBacktrace(uintptr_t *TraceBuffer, size_t Size,
44 void * /*Context*/) {
45+#ifdef __GLIBC__
46 return Backtrace(TraceBuffer, Size);
47+#else
48+ return -1;
49+#endif
50 }
51
52 static void PrintBacktrace(uintptr_t *Trace, size_t TraceLength,
53@@ -40,6 +49,7 @@ static void PrintBacktrace(uintptr_t *Trace, size_t TraceLength,
54 return;
55 }
56
57+#ifdef __GLIBC__
58 char **BacktraceSymbols =
59 backtrace_symbols(reinterpret_cast<void **>(Trace), TraceLength);
60
61@@ -53,6 +63,7 @@ static void PrintBacktrace(uintptr_t *Trace, size_t TraceLength,
62 Printf("\n");
63 if (BacktraceSymbols)
64 free(BacktraceSymbols);
65+#endif
66 }
67 } // anonymous namespace
68
diff --git a/meta/recipes-devtools/clang/clang/0020-clang-Fix-x86-triple-for-non-debian-multiarch-linux-.patch b/meta/recipes-devtools/clang/clang/0020-clang-Fix-x86-triple-for-non-debian-multiarch-linux-.patch
new file mode 100644
index 0000000000..fd2b434fe2
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0020-clang-Fix-x86-triple-for-non-debian-multiarch-linux-.patch
@@ -0,0 +1,28 @@
1From 1ef38e252a55d2cdb00c3b29154387fce02e9911 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Wed, 19 May 2021 17:56:03 -0700
4Subject: [PATCH] clang: Fix x86 triple for non-debian multiarch linux distros
5
6OpenEmbedded does not hardcode mutli-arch like debian therefore ensure
7that it still uses the proper tuple
8
9Upstream-Status: Pending
10Signed-off-by: Khem Raj <raj.khem@gmail.com>
11---
12 clang/lib/Driver/ToolChains/Linux.cpp | 3 +++
13 1 file changed, 3 insertions(+)
14
15diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp
16index fb9d433a80be..ee0b4acbcef0 100644
17--- a/clang/lib/Driver/ToolChains/Linux.cpp
18+++ b/clang/lib/Driver/ToolChains/Linux.cpp
19@@ -728,6 +728,9 @@ void Linux::addLibStdCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
20 GCCInstallation.getTriple().getArch() == llvm::Triple::x86
21 ? "i386-linux-gnu"
22 : TripleStr;
23+ // OpenEmbedded does not hardcode the triple to i386-linux-gnu like debian
24+ if (GCCInstallation.getTriple().getVendor() == llvm::Triple::OpenEmbedded)
25+ DebianMultiarch = TripleStr;
26
27 // Try generic GCC detection first.
28 if (Generic_GCC::addGCCLibStdCxxIncludePaths(DriverArgs, CC1Args,
diff --git a/meta/recipes-devtools/clang/clang/0021-libunwind-Added-unw_backtrace-method.patch b/meta/recipes-devtools/clang/clang/0021-libunwind-Added-unw_backtrace-method.patch
new file mode 100644
index 0000000000..2f0479bdd4
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0021-libunwind-Added-unw_backtrace-method.patch
@@ -0,0 +1,56 @@
1From 5782e495684d6c056175ea16be83cfe788742d0a Mon Sep 17 00:00:00 2001
2From: Maksim Kita <maksim-kita@yandex-team.ru>
3Date: Sun, 23 May 2021 10:27:29 +0000
4Subject: [PATCH] libunwind: Added unw_backtrace method
5
6Source: https://github.com/ClickHouse-Extras/libunwind/commit/52f0f7861926cbfaef7e6c97d8a6d7ba2a1f6747#diff-a82fc885e2e4facf4b92d26171c13aa4aa5db296f77e1158ba2f8664e3bd1f5c
7Upstream-Status: Pending
8Signed-off-by: Khem Raj <raj.khem@gmail.com>
9---
10 libunwind/include/libunwind.h | 1 +
11 libunwind/src/libunwind.cpp | 20 ++++++++++++++++++++
12 2 files changed, 21 insertions(+)
13
14diff --git a/libunwind/include/libunwind.h b/libunwind/include/libunwind.h
15index b2dae8feed9a..0ab974c9bfa4 100644
16--- a/libunwind/include/libunwind.h
17+++ b/libunwind/include/libunwind.h
18@@ -130,6 +130,7 @@ extern int unw_is_fpreg(unw_cursor_t *, unw_regnum_t) LIBUNWIND_AVAIL;
19 extern int unw_is_signal_frame(unw_cursor_t *) LIBUNWIND_AVAIL;
20 extern int unw_get_proc_name(unw_cursor_t *, char *, size_t, unw_word_t *) LIBUNWIND_AVAIL;
21 //extern int unw_get_save_loc(unw_cursor_t*, int, unw_save_loc_t*);
22+extern int unw_backtrace(void **, int) LIBUNWIND_AVAIL;
23
24 extern unw_addr_space_t unw_local_addr_space;
25
26diff --git a/libunwind/src/libunwind.cpp b/libunwind/src/libunwind.cpp
27index cf39ec5f7dbd..1896f20d57f8 100644
28--- a/libunwind/src/libunwind.cpp
29+++ b/libunwind/src/libunwind.cpp
30@@ -431,6 +431,26 @@ int __unw_remove_find_dynamic_unwind_sections(
31
32 #endif // __APPLE__
33
34+int unw_backtrace(void **buffer, int size) {
35+ unw_context_t context;
36+ unw_cursor_t cursor;
37+ if (unw_getcontext(&context) || unw_init_local(&cursor, &context)) {
38+ return 0;
39+ }
40+
41+ unw_word_t ip;
42+ int current = 0;
43+ while (unw_step(&cursor) > 0) {
44+ if (current >= size || unw_get_reg(&cursor, UNW_REG_IP, &ip)) {
45+ break;
46+ }
47+
48+ buffer[current++] = reinterpret_cast<void *>(static_cast<uintptr_t>(ip));
49+ }
50+
51+ return current;
52+}
53+
54 // Add logging hooks in Debug builds only
55 #ifndef NDEBUG
56 #include <stdlib.h>
diff --git a/meta/recipes-devtools/clang/clang/0022-lldb-Link-with-libatomic-on-x86.patch b/meta/recipes-devtools/clang/clang/0022-lldb-Link-with-libatomic-on-x86.patch
new file mode 100644
index 0000000000..4996bc1c87
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0022-lldb-Link-with-libatomic-on-x86.patch
@@ -0,0 +1,33 @@
1From f4f9b07a41449a0acbe5ea1717bb0e2ceabbfaab Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Tue, 8 Feb 2022 01:31:26 -0800
4Subject: [PATCH] lldb: Link with libatomic on x86
5
6cmake atomic check is not sufficient for i686 target where clang14 still
7generates __atomic_store calls but the check does not entail this
8function and happily thinks that compiler can resolve all atomic via intrinsics
9on i686, but thats not the case, ideally the check for determining
10atomic operation should be make more robust but until then lets ask to
11link with libatomic on i686/linux
12
13Upstream-Status: Inappropriate [OE-Specific]
14Signed-off-by: Khem Raj <raj.khem@gmail.com>
15---
16 lldb/source/Utility/CMakeLists.txt | 4 ++++
17 1 file changed, 4 insertions(+)
18
19diff --git a/lldb/source/Utility/CMakeLists.txt b/lldb/source/Utility/CMakeLists.txt
20index 6954a2508ffe..b8bf8c07fefb 100644
21--- a/lldb/source/Utility/CMakeLists.txt
22+++ b/lldb/source/Utility/CMakeLists.txt
23@@ -19,6 +19,10 @@ if (CMAKE_SYSTEM_NAME MATCHES "Windows")
24 list(APPEND LLDB_SYSTEM_LIBS ws2_32 rpcrt4)
25 endif ()
26
27+if (CMAKE_SYSTEM_PROCESSOR MATCHES "i686" AND CMAKE_SYSTEM_NAME MATCHES "Linux")
28+ list(APPEND LLDB_SYSTEM_LIBS atomic)
29+endif()
30+
31 if (NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB )
32 list(APPEND LLDB_SYSTEM_LIBS atomic)
33 endif()
diff --git a/meta/recipes-devtools/clang/clang/0023-compiler-rt-Enable-__int128-for-ppc32.patch b/meta/recipes-devtools/clang/clang/0023-compiler-rt-Enable-__int128-for-ppc32.patch
new file mode 100644
index 0000000000..eeaca43ae0
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0023-compiler-rt-Enable-__int128-for-ppc32.patch
@@ -0,0 +1,73 @@
1From a63acbeb8db17aa113dc2b2058540c61c2a16ac6 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Wed, 9 Mar 2022 16:28:16 -0800
4Subject: [PATCH] compiler-rt: Enable __int128 for ppc32
5
6Upstream-Status: Pending
7Signed-off-by: Khem Raj <raj.khem@gmail.com>
8---
9 compiler-rt/lib/builtins/CMakeLists.txt | 15 +++++++--------
10 compiler-rt/lib/builtins/int_types.h | 2 +-
11 2 files changed, 8 insertions(+), 9 deletions(-)
12
13diff --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt
14index 19316c52d12c..cb276311b290 100644
15--- a/compiler-rt/lib/builtins/CMakeLists.txt
16+++ b/compiler-rt/lib/builtins/CMakeLists.txt
17@@ -720,11 +720,9 @@ set(mips64el_SOURCES ${GENERIC_TF_SOURCES}
18
19 set(nvptx64_SOURCES ${GENERIC_SOURCES})
20
21-set(powerpc_SOURCES ${GENERIC_SOURCES})
22-
23 set(powerpcspe_SOURCES ${GENERIC_SOURCES})
24
25-set(powerpc64_SOURCES
26+set(powerpc_SOURCES
27 ppc/divtc3.c
28 ppc/fixtfdi.c
29 ppc/fixunstfdi.c
30@@ -739,14 +737,15 @@ set(powerpc64_SOURCES
31 )
32 # These routines require __int128, which isn't supported on AIX.
33 if (NOT OS_NAME MATCHES "AIX")
34- set(powerpc64_SOURCES
35+ set(powerpc_SOURCES
36 ppc/floattitf.c
37 ppc/fixtfti.c
38 ppc/fixunstfti.c
39- ${powerpc64_SOURCES}
40+ ${powerpc_SOURCES}
41 )
42 endif()
43-set(powerpc64le_SOURCES ${powerpc64_SOURCES})
44+set(powerpc64le_SOURCES ${powerpc_SOURCES})
45+set(powerpc64_SOURCES ${powerpc_SOURCES})
46
47 set(riscv_SOURCES
48 cpu_model/riscv.c
49@@ -904,9 +903,9 @@ else ()
50 list(APPEND BUILTIN_CFLAGS_${arch} -fomit-frame-pointer -DCOMPILER_RT_ARMHF_TARGET)
51 endif()
52
53- # For RISCV32, we must force enable int128 for compiling long
54+ # For RISCV32/PPC32, we must force enable int128 for compiling long
55 # double routines.
56- if(COMPILER_RT_ENABLE_SOFTWARE_INT128 OR "${arch}" STREQUAL "riscv32")
57+ if(COMPILER_RT_ENABLE_SOFTWARE_INT128 OR "${arch}" STREQUAL "riscv32" OR "${arch}" STREQUAL "powerpc")
58 list(APPEND BUILTIN_CFLAGS_${arch} -fforce-enable-int128)
59 endif()
60
61diff --git a/compiler-rt/lib/builtins/int_types.h b/compiler-rt/lib/builtins/int_types.h
62index 48862f364217..cc47d3e33f67 100644
63--- a/compiler-rt/lib/builtins/int_types.h
64+++ b/compiler-rt/lib/builtins/int_types.h
65@@ -64,7 +64,7 @@ typedef union {
66 } udwords;
67
68 #if defined(__LP64__) || defined(__wasm__) || defined(__mips64) || \
69- defined(__SIZEOF_INT128__) || defined(_WIN64)
70+ defined(__SIZEOF_INT128__) || defined(_WIN64) || defined(__powerpc__)
71 #define CRT_HAS_128BIT
72 #endif
73
diff --git a/meta/recipes-devtools/clang/clang/0024-llvm-Do-not-use-cmake-infra-to-detect-libzstd.patch b/meta/recipes-devtools/clang/clang/0024-llvm-Do-not-use-cmake-infra-to-detect-libzstd.patch
new file mode 100644
index 0000000000..831e3e7d3a
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0024-llvm-Do-not-use-cmake-infra-to-detect-libzstd.patch
@@ -0,0 +1,62 @@
1From abe955ac96370a16258fba1348edb938f3649096 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 12 Aug 2022 11:50:57 -0700
4Subject: [PATCH] llvm: Do not use cmake infra to detect libzstd
5
6OE's version is build using plain make not cmake as a result we do not
7have the cmake support files and this probing method can get this info
8from build host and force linking with libzstd from /usr/lib which is
9not what we want when cross building.
10
11Fixes errors building llvm-config like
12/usr/lib/libzstd.so.1.5.2: error adding symbols: file in wrong
13format
14| clang-15: error: linker command failed with exit code 1 (use -v to see invocation)
15| ninja: build stopped: subcommand failed.
16
17Upstream-Status: Inappropriate [OE-Specific]
18Signed-off-by: Khem Raj <raj.khem@gmail.com>
19---
20 llvm/lib/Support/CMakeLists.txt | 8 ++++----
21 1 file changed, 4 insertions(+), 4 deletions(-)
22
23diff --git a/llvm/lib/Support/CMakeLists.txt b/llvm/lib/Support/CMakeLists.txt
24index a6d8a2581886..5b461547bdde 100644
25--- a/llvm/lib/Support/CMakeLists.txt
26+++ b/llvm/lib/Support/CMakeLists.txt
27@@ -22,7 +22,7 @@ if (HAS_WERROR_GLOBAL_CTORS)
28 endif()
29
30 if(LLVM_ENABLE_ZLIB)
31- list(APPEND imported_libs ZLIB::ZLIB)
32+ list(APPEND imported_libs z)
33 endif()
34
35 if(LLVM_ENABLE_ZSTD)
36@@ -34,7 +34,7 @@ if(LLVM_ENABLE_ZSTD)
37 endif()
38
39 if(LLVM_ENABLE_ZSTD)
40- list(APPEND imported_libs ${zstd_target})
41+ list(APPEND imported_libs zstd)
42 endif()
43
44 if( WIN32 )
45@@ -325,7 +325,7 @@ if(LLVM_ENABLE_ZLIB)
46 get_property(zlib_library TARGET ZLIB::ZLIB PROPERTY LOCATION)
47 endif()
48 get_library_name(${zlib_library} zlib_library)
49- set(llvm_system_libs ${llvm_system_libs} "${zlib_library}")
50+ set(llvm_system_libs ${llvm_system_libs} z)
51 endif()
52
53 if(LLVM_ENABLE_ZSTD)
54@@ -339,7 +339,7 @@ if(LLVM_ENABLE_ZSTD)
55 endif()
56 if (zstd_target STREQUAL zstd::libzstd_shared)
57 get_library_name(${zstd_library} zstd_library)
58- set(llvm_system_libs ${llvm_system_libs} "${zstd_library}")
59+ set(llvm_system_libs ${llvm_system_libs} zstd)
60 else()
61 set(llvm_system_libs ${llvm_system_libs} "${zstd_STATIC_LIBRARY}")
62 endif()
diff --git a/meta/recipes-devtools/clang/clang/0025-compiler-rt-Fix-stat-struct-s-size-for-O32-ABI.patch b/meta/recipes-devtools/clang/clang/0025-compiler-rt-Fix-stat-struct-s-size-for-O32-ABI.patch
new file mode 100644
index 0000000000..4b8a915837
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0025-compiler-rt-Fix-stat-struct-s-size-for-O32-ABI.patch
@@ -0,0 +1,46 @@
1From 7cafe5615d91a429048c8baa824769cdf34aafd1 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Tue, 3 Jan 2023 18:44:34 -0800
4Subject: [PATCH] compiler-rt: Fix stat struct's size for O32 ABI
5
6stat struct size differs on glibc based on ABI choices e.g. 64bit off_t
7and/or 64bit time_t will make this size different. Therefore separate
8out the O32 case out, makes it more readable.
9
10Upstream-Status: Pending
11Signed-off-by: Khem Raj <raj.khem@gmail.com>
12---
13 .../sanitizer_platform_limits_posix.h | 13 +++++++++++++
14 1 file changed, 13 insertions(+)
15
16diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
17index 1a7d9e64048e..854a87e17236 100644
18--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
19+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
20@@ -98,6 +98,18 @@ const unsigned struct_kernel_stat64_sz = 104;
21 const unsigned struct_kernel_stat_sz = 144;
22 const unsigned struct_kernel_stat64_sz = 104;
23 #elif defined(__mips__)
24+#if defined(__mips_o32) // O32 ABI
25+#if _TIME_BITS == 64
26+const unsigned struct_kernel_stat_sz = 112;
27+const unsigned struct_kernel_stat64_sz = 112;
28+#elif _FILE_OFFSET_BITS == 64
29+const unsigned struct_kernel_stat_sz = 160;
30+const unsigned struct_kernel_stat64_sz = 160;
31+#else
32+const unsigned struct_kernel_stat_sz = 144;
33+const unsigned struct_kernel_stat64_sz = 160;
34+#endif
35+#else // __mips_o32
36 const unsigned struct_kernel_stat_sz = SANITIZER_ANDROID
37 ? FIRST_32_SECOND_64(104, 128)
38 # if defined(_ABIN32) && _MIPS_SIM == _ABIN32
39@@ -106,6 +118,7 @@ const unsigned struct_kernel_stat_sz = SANITIZER_ANDROID
40 : FIRST_32_SECOND_64(160, 216);
41 # endif
42 const unsigned struct_kernel_stat64_sz = 104;
43+#endif
44 #elif defined(__s390__) && !defined(__s390x__)
45 const unsigned struct_kernel_stat_sz = 64;
46 const unsigned struct_kernel_stat64_sz = 104;
diff --git a/meta/recipes-devtools/clang/clang/0026-compiler-rt-Undef-_TIME_BITS-along-with-_FILE_OFFSET.patch b/meta/recipes-devtools/clang/clang/0026-compiler-rt-Undef-_TIME_BITS-along-with-_FILE_OFFSET.patch
new file mode 100644
index 0000000000..0e67129705
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0026-compiler-rt-Undef-_TIME_BITS-along-with-_FILE_OFFSET.patch
@@ -0,0 +1,43 @@
1From 92bf97247bb0df984410a6c1ee6b0d2577e82013 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Tue, 21 Feb 2023 12:46:10 -0800
4Subject: [PATCH] compiler-rt: Undef _TIME_BITS along with _FILE_OFFSET_BITS in
5 sanitizers
6
7On 32bit systems using 64bit time_t build fails because
8_FILE_OFFSET_BITS is undefined here but _TIME_BITS is still set to 64
9
10Fixes
11In file included from compiler-rt/lib/sanitizer_common/sanitizer_procmaps_solaris.cpp:17:
12In file included from compiler-rt/lib/sanitizer_common/sanitizer_platform.h:25:
13In file included from /usr/include/features.h:393:
14/usr/include/features-time64.h:26:5: error: "_TIME_BITS=64 is allowed only with _FILE_OFFSET_BITS=64"
15 ^
161 error generated.
17
18Upstream-Status: Submitted [https://reviews.llvm.org/D144514]
19Signed-off-by: Khem Raj <raj.khem@gmail.com>
20---
21 compiler-rt/lib/sanitizer_common/sanitizer_platform.h | 9 +++++++++
22 1 file changed, 9 insertions(+)
23
24diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform.h b/compiler-rt/lib/sanitizer_common/sanitizer_platform.h
25index 57966403c92a..efa83f30eca0 100644
26--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform.h
27+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform.h
28@@ -22,6 +22,15 @@
29 // function declarations into a .S file which doesn't compile.
30 // https://crbug.com/1162741
31 #if __has_include(<features.h>) && !defined(__ANDROID__)
32+// Some sources undefine _FILE_OFFSET_BITS deliberately e.g.
33+// sanitizer_procmaps_solaris.cpp. This is problematic on glibc systems with
34+// 32-bit architectures using 64-bit time_t and users passing _TIME_BITS=64
35+// from build environment, therefore both _FILE_OFFSET_BITS and _TIME_BITS
36+// need to be undefined together since features.h will check for both being 64
37+// if one is set to 64.
38+# if !defined(_FILE_OFFSET_BITS)
39+# undef _TIME_BITS
40+# endif
41 # include <features.h>
42 #endif
43
diff --git a/meta/recipes-devtools/clang/clang/0027-ToolChains-Gnu.cpp-ARMLibDirs-search-also-in-lib32.patch b/meta/recipes-devtools/clang/clang/0027-ToolChains-Gnu.cpp-ARMLibDirs-search-also-in-lib32.patch
new file mode 100644
index 0000000000..8362acf8d4
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0027-ToolChains-Gnu.cpp-ARMLibDirs-search-also-in-lib32.patch
@@ -0,0 +1,81 @@
1From 86a5a81c556e27cd097493a040580362d0217721 Mon Sep 17 00:00:00 2001
2From: Martin Jansa <Martin.Jansa@gmail.com>
3Date: Thu, 31 Aug 2023 18:14:47 +0200
4Subject: [PATCH] ToolChains/Gnu.cpp: ARMLibDirs search also in lib32
5
6* in some strange multilib configs we build lib32-image where
7 32bit libs are in /usr/lib32 and 64bit in /usr/lib64 but in such
8 setup the clang search for GCC candidate installation doesn't
9 check lib32 directory in sysroot and fails to find the installation
10
11 X86LibDirs was already searching in lib32 for very long time:
12 https://github.com/llvm/llvm-project/commit/621fed5f5a051a0333415aaed75b8f2ed2350dbd
13 but ARMLibDirs didn't include it for some reason.
14
15* if we don't add lib32 for arm in getOSLibDir(), then it will
16 find -lgcc, crtbeginS.o, crtendS.o, but still fail to find
17 -lgcc_s, -lc, Scrt1.o, crti.o, crtn.o
18
19* fixes lib32-compiler-rt build failure:
20
21-- Configuring incomplete, errors occurred!
22CMake Error at TOPDIR/BUILD/work/raspberrypi4_64-oemllib32-linux-gnueabi/lib32-compiler-rt/16.0.6/recipe-sysroot-native/usr/share/cmake-3.26/Modules/CMakeTestCCompiler.cmake:67 (message):
23 The C compiler
24
25 "TOPDIR/BUILD/work/raspberrypi4_64-oemllib32-linux-gnueabi/lib32-compiler-rt/16.0.6/recipe-sysroot-native/usr/bin/arm-oemllib32-linux-gnueabi/arm-oemllib32-linux-gnueabi-clang"
26
27 is not able to compile a simple test program.
28
29 It fails with the following output:
30
31 Change Dir: TOPDIR/BUILD/work/raspberrypi4_64-oemllib32-linux-gnueabi/lib32-compiler-rt/16.0.6/build/CMakeFiles/CMakeScratch/TryCompile-rWXyQZ
32
33 Run Build Command(s):ninja -v cmTC_84d18 && [1/2] TOPDIR/BUILD/work/raspberrypi4_64-oemllib32-linux-gnueabi/lib32-compiler-rt/16.0.6/recipe-sysroot-native/usr/bin/arm-oemllib32-linux-gnueabi/arm-oemllib32-linux-gnueabi-clang --target=arm-oemllib32-linux-gnueabi --sysroot=TOPDIR/BUILD/work/raspberrypi4_64-oemllib32-linux-gnueabi/lib32-compiler-rt/16.0.6/lib32-recipe-sysroot -target arm-oemllib32-linux-gnueabi -march=armv7ve -mthumb -mfpu=neon-vfpv4 -mfloat-abi=softfp -mlittle-endian --dyld-prefix=/usr -Qunused-arguments -funwind-tables -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security -Werror=return-type -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 --sysroot=TOPDIR/BUILD/work/raspberrypi4_64-oemllib32-linux-gnueabi/lib32-compiler-rt/16.0.6/lib32-recipe-sysroot -O2 -pipe -g -feliminate-unused-debug-types -fmacro-prefix-map=TOPDIR/BUILD/work-shared/llvm-project-source-16.0.6-r0/git=/usr/src/debug/lib32-compiler-rt/16.0.6-r0 -fdebug-prefix-map=TOPDIR/BUILD/work-shared/llvm-project-source-16.0.6-r0/git=/usr/src/debug/lib32-compiler-rt/16.0.6-r0 -fmacro-prefix-map=TOPDIR/BUILD/work/raspberrypi4_64-oemllib32-linux-gnueabi/lib32-compiler-rt/16.0.6/build=/usr/src/debug/lib32-compiler-rt/16.0.6-r0 -fdebug-prefix-map=TOPDIR/BUILD/work/raspberrypi4_64-oemllib32-linux-gnueabi/lib32-compiler-rt/16.0.6/build=/usr/src/debug/lib32-compiler-rt/16.0.6-r0 -fdebug-prefix-map=TOPDIR/BUILD/work/raspberrypi4_64-oemllib32-linux-gnueabi/lib32-compiler-rt/16.0.6/lib32-recipe-sysroot= -fmacro-prefix-map=TOPDIR/BUILD/work/raspberrypi4_64-oemllib32-linux-gnueabi/lib32-compiler-rt/16.0.6/lib32-recipe-sysroot= -fdebug-prefix-map=TOPDIR/BUILD/work/raspberrypi4_64-oemllib32-linux-gnueabi/lib32-compiler-rt/16.0.6/recipe-sysroot-native= -fPIE -MD -MT CMakeFiles/cmTC_84d18.dir/testCCompiler.c.o -MF CMakeFiles/cmTC_84d18.dir/testCCompiler.c.o.d -o CMakeFiles/cmTC_84d18.dir/testCCompiler.c.o -c TOPDIR/BUILD/work/raspberrypi4_64-oemllib32-linux-gnueabi/lib32-compiler-rt/16.0.6/build/CMakeFiles/CMakeScratch/TryCompile-rWXyQZ/testCCompiler.c
34 [2/2] : && TOPDIR/BUILD/work/raspberrypi4_64-oemllib32-linux-gnueabi/lib32-compiler-rt/16.0.6/recipe-sysroot-native/usr/bin/arm-oemllib32-linux-gnueabi/arm-oemllib32-linux-gnueabi-clang --target=arm-oemllib32-linux-gnueabi --sysroot=TOPDIR/BUILD/work/raspberrypi4_64-oemllib32-linux-gnueabi/lib32-compiler-rt/16.0.6/lib32-recipe-sysroot -target arm-oemllib32-linux-gnueabi -march=armv7ve -mthumb -mfpu=neon-vfpv4 -mfloat-abi=softfp -mlittle-endian --dyld-prefix=/usr -Qunused-arguments -funwind-tables -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security -Werror=return-type -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 --sysroot=TOPDIR/BUILD/work/raspberrypi4_64-oemllib32-linux-gnueabi/lib32-compiler-rt/16.0.6/lib32-recipe-sysroot -O2 -pipe -g -feliminate-unused-debug-types -fmacro-prefix-map=TOPDIR/BUILD/work-shared/llvm-project-source-16.0.6-r0/git=/usr/src/debug/lib32-compiler-rt/16.0.6-r0 -fdebug-prefix-map=TOPDIR/BUILD/work-shared/llvm-project-source-16.0.6-r0/git=/usr/src/debug/lib32-compiler-rt/16.0.6-r0 -fmacro-prefix-map=TOPDIR/BUILD/work/raspberrypi4_64-oemllib32-linux-gnueabi/lib32-compiler-rt/16.0.6/build=/usr/src/debug/lib32-compiler-rt/16.0.6-r0 -fdebug-prefix-map=TOPDIR/BUILD/work/raspberrypi4_64-oemllib32-linux-gnueabi/lib32-compiler-rt/16.0.6/build=/usr/src/debug/lib32-compiler-rt/16.0.6-r0 -fdebug-prefix-map=TOPDIR/BUILD/work/raspberrypi4_64-oemllib32-linux-gnueabi/lib32-compiler-rt/16.0.6/lib32-recipe-sysroot= -fmacro-prefix-map=TOPDIR/BUILD/work/raspberrypi4_64-oemllib32-linux-gnueabi/lib32-compiler-rt/16.0.6/lib32-recipe-sysroot= -fdebug-prefix-map=TOPDIR/BUILD/work/raspberrypi4_64-oemllib32-linux-gnueabi/lib32-compiler-rt/16.0.6/recipe-sysroot-native= -target arm-oemllib32-linux-gnueabi -march=armv7ve -mthumb -mfpu=neon-vfpv4 -mfloat-abi=softfp -mlittle-endian --dyld-prefix=/usr -Qunused-arguments -funwind-tables -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security -Werror=return-type -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 --sysroot=TOPDIR/BUILD/work/raspberrypi4_64-oemllib32-linux-gnueabi/lib32-compiler-rt/16.0.6/lib32-recipe-sysroot -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -fmacro-prefix-map=TOPDIR/BUILD/work-shared/llvm-project-source-16.0.6-r0/git=/usr/src/debug/lib32-compiler-rt/16.0.6-r0 -fdebug-prefix-map=TOPDIR/BUILD/work-shared/llvm-project-source-16.0.6-r0/git=/usr/src/debug/lib32-compiler-rt/16.0.6-r0 -fmacro-prefix-map=TOPDIR/BUILD/work/raspberrypi4_64-oemllib32-linux-gnueabi/lib32-compiler-rt/16.0.6/build=/usr/src/debug/lib32-compiler-rt/16.0.6-r0 -fdebug-prefix-map=TOPDIR/BUILD/work/raspberrypi4_64-oemllib32-linux-gnueabi/lib32-compiler-rt/16.0.6/build=/usr/src/debug/lib32-compiler-rt/16.0.6-r0 -fdebug-prefix-map=TOPDIR/BUILD/work/raspberrypi4_64-oemllib32-linux-gnueabi/lib32-compiler-rt/16.0.6/lib32-recipe-sysroot= -fmacro-prefix-map=TOPDIR/BUILD/work/raspberrypi4_64-oemllib32-linux-gnueabi/lib32-compiler-rt/16.0.6/lib32-recipe-sysroot= -fdebug-prefix-map=TOPDIR/BUILD/work/raspberrypi4_64-oemllib32-linux-gnueabi/lib32-compiler-rt/16.0.6/recipe-sysroot-native= -Wl,-z,relro,-z,now -unwindlib=libgcc -rtlib=libgcc -stdlib=libstdc++ -fuse-ld=lld -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -fmacro-prefix-map=TOPDIR/BUILD/work-shared/llvm-project-source-16.0.6-r0/git=/usr/src/debug/lib32-compiler-rt/16.0.6-r0 -fdebug-prefix-map=TOPDIR/BUILD/work-shared/llvm-project-source-16.0.6-r0/git=/usr/src/debug/lib32-compiler-rt/16.0.6-r0 -fmacro-prefix-map=TOPDIR/BUILD/work/raspberrypi4_64-oemllib32-linux-gnueabi/lib32-compiler-rt/16.0.6/build=/usr/src/debug/lib32-compiler-rt/16.0.6-r0 -fdebug-prefix-map=TOPDIR/BUILD/work/raspberrypi4_64-oemllib32-linux-gnueabi/lib32-compiler-rt/16.0.6/build=/usr/src/debug/lib32-compiler-rt/16.0.6-r0 -fdebug-prefix-map=TOPDIR/BUILD/work/raspberrypi4_64-oemllib32-linux-gnueabi/lib32-compiler-rt/16.0.6/lib32-recipe-sysroot= -fmacro-prefix-map=TOPDIR/BUILD/work/raspberrypi4_64-oemllib32-linux-gnueabi/lib32-compiler-rt/16.0.6/lib32-recipe-sysroot= -fdebug-prefix-map=TOPDIR/BUILD/work/raspberrypi4_64-oemllib32-linux-gnueabi/lib32-compiler-rt/16.0.6/recipe-sysroot-native= -Wl,-z,relro,-z,now -unwindlib=libgcc -rtlib=libgcc -stdlib=libstdc++ -fuse-ld=lld CMakeFiles/cmTC_84d18.dir/testCCompiler.c.o -o cmTC_84d18 && :
35 FAILED: cmTC_84d18
36 : && TOPDIR/BUILD/work/raspberrypi4_64-oemllib32-linux-gnueabi/lib32-compiler-rt/16.0.6/recipe-sysroot-native/usr/bin/arm-oemllib32-linux-gnueabi/arm-oemllib32-linux-gnueabi-clang --target=arm-oemllib32-linux-gnueabi --sysroot=TOPDIR/BUILD/work/raspberrypi4_64-oemllib32-linux-gnueabi/lib32-compiler-rt/16.0.6/lib32-recipe-sysroot -target arm-oemllib32-linux-gnueabi -march=armv7ve -mthumb -mfpu=neon-vfpv4 -mfloat-abi=softfp -mlittle-endian --dyld-prefix=/usr -Qunused-arguments -funwind-tables -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security -Werror=return-type -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 --sysroot=TOPDIR/BUILD/work/raspberrypi4_64-oemllib32-linux-gnueabi/lib32-compiler-rt/16.0.6/lib32-recipe-sysroot -O2 -pipe -g -feliminate-unused-debug-types -fmacro-prefix-map=TOPDIR/BUILD/work-shared/llvm-project-source-16.0.6-r0/git=/usr/src/debug/lib32-compiler-rt/16.0.6-r0 -fdebug-prefix-map=TOPDIR/BUILD/work-shared/llvm-project-source-16.0.6-r0/git=/usr/src/debug/lib32-compiler-rt/16.0.6-r0 -fmacro-prefix-map=TOPDIR/BUILD/work/raspberrypi4_64-oemllib32-linux-gnueabi/lib32-compiler-rt/16.0.6/build=/usr/src/debug/lib32-compiler-rt/16.0.6-r0 -fdebug-prefix-map=TOPDIR/BUILD/work/raspberrypi4_64-oemllib32-linux-gnueabi/lib32-compiler-rt/16.0.6/build=/usr/src/debug/lib32-compiler-rt/16.0.6-r0 -fdebug-prefix-map=TOPDIR/BUILD/work/raspberrypi4_64-oemllib32-linux-gnueabi/lib32-compiler-rt/16.0.6/lib32-recipe-sysroot= -fmacro-prefix-map=TOPDIR/BUILD/work/raspberrypi4_64-oemllib32-linux-gnueabi/lib32-compiler-rt/16.0.6/lib32-recipe-sysroot= -fdebug-prefix-map=TOPDIR/BUILD/work/raspberrypi4_64-oemllib32-linux-gnueabi/lib32-compiler-rt/16.0.6/recipe-sysroot-native= -target arm-oemllib32-linux-gnueabi -march=armv7ve -mthumb -mfpu=neon-vfpv4 -mfloat-abi=softfp -mlittle-endian --dyld-prefix=/usr -Qunused-arguments -funwind-tables -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security -Werror=return-type -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 --sysroot=TOPDIR/BUILD/work/raspberrypi4_64-oemllib32-linux-gnueabi/lib32-compiler-rt/16.0.6/lib32-recipe-sysroot -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -fmacro-prefix-map=TOPDIR/BUILD/work-shared/llvm-project-source-16.0.6-r0/git=/usr/src/debug/lib32-compiler-rt/16.0.6-r0 -fdebug-prefix-map=TOPDIR/BUILD/work-shared/llvm-project-source-16.0.6-r0/git=/usr/src/debug/lib32-compiler-rt/16.0.6-r0 -fmacro-prefix-map=TOPDIR/BUILD/work/raspberrypi4_64-oemllib32-linux-gnueabi/lib32-compiler-rt/16.0.6/build=/usr/src/debug/lib32-compiler-rt/16.0.6-r0 -fdebug-prefix-map=TOPDIR/BUILD/work/raspberrypi4_64-oemllib32-linux-gnueabi/lib32-compiler-rt/16.0.6/build=/usr/src/debug/lib32-compiler-rt/16.0.6-r0 -fdebug-prefix-map=TOPDIR/BUILD/work/raspberrypi4_64-oemllib32-linux-gnueabi/lib32-compiler-rt/16.0.6/lib32-recipe-sysroot= -fmacro-prefix-map=TOPDIR/BUILD/work/raspberrypi4_64-oemllib32-linux-gnueabi/lib32-compiler-rt/16.0.6/lib32-recipe-sysroot= -fdebug-prefix-map=TOPDIR/BUILD/work/raspberrypi4_64-oemllib32-linux-gnueabi/lib32-compiler-rt/16.0.6/recipe-sysroot-native= -Wl,-z,relro,-z,now -unwindlib=libgcc -rtlib=libgcc -stdlib=libstdc++ -fuse-ld=lld -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -fmacro-prefix-map=TOPDIR/BUILD/work-shared/llvm-project-source-16.0.6-r0/git=/usr/src/debug/lib32-compiler-rt/16.0.6-r0 -fdebug-prefix-map=TOPDIR/BUILD/work-shared/llvm-project-source-16.0.6-r0/git=/usr/src/debug/lib32-compiler-rt/16.0.6-r0 -fmacro-prefix-map=TOPDIR/BUILD/work/raspberrypi4_64-oemllib32-linux-gnueabi/lib32-compiler-rt/16.0.6/build=/usr/src/debug/lib32-compiler-rt/16.0.6-r0 -fdebug-prefix-map=TOPDIR/BUILD/work/raspberrypi4_64-oemllib32-linux-gnueabi/lib32-compiler-rt/16.0.6/build=/usr/src/debug/lib32-compiler-rt/16.0.6-r0 -fdebug-prefix-map=TOPDIR/BUILD/work/raspberrypi4_64-oemllib32-linux-gnueabi/lib32-compiler-rt/16.0.6/lib32-recipe-sysroot= -fmacro-prefix-map=TOPDIR/BUILD/work/raspberrypi4_64-oemllib32-linux-gnueabi/lib32-compiler-rt/16.0.6/lib32-recipe-sysroot= -fdebug-prefix-map=TOPDIR/BUILD/work/raspberrypi4_64-oemllib32-linux-gnueabi/lib32-compiler-rt/16.0.6/recipe-sysroot-native= -Wl,-z,relro,-z,now -unwindlib=libgcc -rtlib=libgcc -stdlib=libstdc++ -fuse-ld=lld CMakeFiles/cmTC_84d18.dir/testCCompiler.c.o -o cmTC_84d18 && :
37 arm-oemllib32-linux-gnueabi-ld.lld: error: cannot open Scrt1.o: No such file or directory
38 arm-oemllib32-linux-gnueabi-ld.lld: error: cannot open crti.o: No such file or directory
39 arm-oemllib32-linux-gnueabi-ld.lld: error: cannot open crtbeginS.o: No such file or directory
40 arm-oemllib32-linux-gnueabi-ld.lld: error: unable to find library -lgcc
41 arm-oemllib32-linux-gnueabi-ld.lld: error: unable to find library -lgcc_s
42 arm-oemllib32-linux-gnueabi-ld.lld: error: unable to find library -lc
43 arm-oemllib32-linux-gnueabi-ld.lld: error: unable to find library -lgcc
44 arm-oemllib32-linux-gnueabi-ld.lld: error: unable to find library -lgcc_s
45 arm-oemllib32-linux-gnueabi-ld.lld: error: cannot open crtendS.o: No such file or directory
46 arm-oemllib32-linux-gnueabi-ld.lld: error: cannot open crtn.o: No such file or directory
47 clang-16: error: linker command failed with exit code 1 (use -v to see invocation)
48 ninja: build stopped: subcommand failed.
49
50Upstream-Status: Pending
51Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
52---
53 clang/lib/Driver/ToolChains/Gnu.cpp | 2 +-
54 clang/lib/Driver/ToolChains/Linux.cpp | 1 +
55 2 files changed, 2 insertions(+), 1 deletion(-)
56
57diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp
58index 868d32f501e8..beed8d34a127 100644
59--- a/clang/lib/Driver/ToolChains/Gnu.cpp
60+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
61@@ -2428,7 +2428,7 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
62 static const char *const AArch64beLibDirs[] = {"/lib"};
63 static const char *const AArch64beTriples[] = {"aarch64_be-none-linux-gnu"};
64
65- static const char *const ARMLibDirs[] = {"/lib"};
66+ static const char *const ARMLibDirs[] = {"/lib", "/lib32"};
67 static const char *const ARMTriples[] = {"arm-linux-gnueabi"};
68 static const char *const ARMHFTriples[] = {"arm-linux-gnueabihf",
69 "armv7hl-redhat-linux-gnueabi",
70diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp
71index ee0b4acbcef0..b02409fd72ee 100644
72--- a/clang/lib/Driver/ToolChains/Linux.cpp
73+++ b/clang/lib/Driver/ToolChains/Linux.cpp
74@@ -199,6 +199,7 @@ static StringRef getOSLibDir(const llvm::Triple &Triple, const ArgList &Args) {
75 // reasoning about oslibdir spellings with the lib dir spellings in the
76 // GCCInstallationDetector, but that is a more significant refactoring.
77 if (Triple.getArch() == llvm::Triple::x86 || Triple.isPPC32() ||
78+ Triple.getArch() == llvm::Triple::arm || Triple.getArch() == llvm::Triple::thumb ||
79 Triple.getArch() == llvm::Triple::sparc)
80 return "lib32";
81
diff --git a/meta/recipes-devtools/clang/clang/0028-clang-llvm-Add-OE-specific-ABI-triple-for-N32-ABI.patch b/meta/recipes-devtools/clang/clang/0028-clang-llvm-Add-OE-specific-ABI-triple-for-N32-ABI.patch
new file mode 100644
index 0000000000..a919a983c3
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0028-clang-llvm-Add-OE-specific-ABI-triple-for-N32-ABI.patch
@@ -0,0 +1,78 @@
1From 721b7868a57fe3943557c405dd88365526d3728f Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Sat, 3 Feb 2024 16:47:10 -0800
4Subject: [PATCH] clang/llvm: Add OE specific ABI triple for N32 ABI
5
6Its gnun32 when using OE
7
8Upstream-Status: Inappropriate [OE-Specific]
9Signed-off-by: Khem Raj <raj.khem@gmail.com>
10---
11 clang/lib/Driver/ToolChains/Gnu.cpp | 1 +
12 clang/lib/Driver/ToolChains/Linux.cpp | 4 ++--
13 llvm/lib/TargetParser/Triple.cpp | 4 +++-
14 3 files changed, 6 insertions(+), 3 deletions(-)
15
16diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp
17index beed8d34a127..c47b93a4e142 100644
18--- a/clang/lib/Driver/ToolChains/Gnu.cpp
19+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
20@@ -2491,6 +2491,7 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
21
22 static const char *const MIPSN32LibDirs[] = {"/lib32"};
23 static const char *const MIPSN32Triples[] = {"mips64-linux-gnuabin32",
24+ "mips64-linux-gnun32",
25 "mipsisa64r6-linux-gnuabin32"};
26 static const char *const MIPSN32ELLibDirs[] = {"/lib32"};
27 static const char *const MIPSN32ELTriples[] = {
28diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp
29index b02409fd72ee..4999b0fc17a6 100644
30--- a/clang/lib/Driver/ToolChains/Linux.cpp
31+++ b/clang/lib/Driver/ToolChains/Linux.cpp
32@@ -139,7 +139,7 @@ std::string Linux::getMultiarchTriple(const Driver &D,
33 return IsMipsR6 ? "mipsisa32r6el-linux-gnu" : "mipsel-linux-gnu";
34 case llvm::Triple::mips64: {
35 std::string MT = std::string(IsMipsR6 ? "mipsisa64r6" : "mips64") +
36- "-linux-" + (IsMipsN32Abi ? "gnuabin32" : "gnuabi64");
37+ "-linux-" + (IsMipsN32Abi ? "gnun32" : "gnu");
38 if (D.getVFS().exists(concat(SysRoot, "/lib", MT)))
39 return MT;
40 if (D.getVFS().exists(concat(SysRoot, "/lib/mips64-linux-gnu")))
41@@ -148,7 +148,7 @@ std::string Linux::getMultiarchTriple(const Driver &D,
42 }
43 case llvm::Triple::mips64el: {
44 std::string MT = std::string(IsMipsR6 ? "mipsisa64r6el" : "mips64el") +
45- "-linux-" + (IsMipsN32Abi ? "gnuabin32" : "gnuabi64");
46+ "-linux-" + (IsMipsN32Abi ? "gnun32" : "gnu");
47 if (D.getVFS().exists(concat(SysRoot, "/lib", MT)))
48 return MT;
49 if (D.getVFS().exists(concat(SysRoot, "/lib/mips64el-linux-gnu")))
50diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp
51index 97f426dd863b..dc57d5ff2d4a 100644
52--- a/llvm/lib/TargetParser/Triple.cpp
53+++ b/llvm/lib/TargetParser/Triple.cpp
54@@ -336,7 +336,7 @@ StringRef Triple::getEnvironmentTypeName(EnvironmentType Kind) {
55 case GNU: return "gnu";
56 case GNUT64: return "gnut64";
57 case GNUABI64: return "gnuabi64";
58- case GNUABIN32: return "gnuabin32";
59+ case GNUABIN32: return "gnun32";
60 case GNUEABI: return "gnueabi";
61 case GNUEABIT64: return "gnueabit64";
62 case GNUEABIHF: return "gnueabihf";
63@@ -719,6 +719,7 @@ static Triple::EnvironmentType parseEnvironment(StringRef EnvironmentName) {
64 .StartsWith("eabihf", Triple::EABIHF)
65 .StartsWith("eabi", Triple::EABI)
66 .StartsWith("gnuabin32", Triple::GNUABIN32)
67+ .StartsWith("gnun32", Triple::GNUABIN32)
68 .StartsWith("gnuabi64", Triple::GNUABI64)
69 .StartsWith("gnueabihft64", Triple::GNUEABIHFT64)
70 .StartsWith("gnueabihf", Triple::GNUEABIHF)
71@@ -1035,6 +1036,7 @@ Triple::Triple(const Twine &Str)
72 Environment =
73 StringSwitch<Triple::EnvironmentType>(Components[0])
74 .StartsWith("mipsn32", Triple::GNUABIN32)
75+ .StartsWith("mips64-n32", Triple::GNUABIN32)
76 .StartsWith("mips64", Triple::GNUABI64)
77 .StartsWith("mipsisa64", Triple::GNUABI64)
78 .StartsWith("mipsisa32", Triple::GNU)
diff --git a/meta/recipes-devtools/clang/clang/0029-llvm-Add-libunwind.pc.in-and-llvm-config-scripts.patch b/meta/recipes-devtools/clang/clang/0029-llvm-Add-libunwind.pc.in-and-llvm-config-scripts.patch
new file mode 100644
index 0000000000..8eda4fb205
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0029-llvm-Add-libunwind.pc.in-and-llvm-config-scripts.patch
@@ -0,0 +1,90 @@
1From cc2fb22ae8e64f65fd726b476c3bf85b4d31906d Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Tue, 14 May 2024 22:04:43 -0700
4Subject: [PATCH] llvm: Add libunwind.pc.in and llvm-config scripts
5
6These are added by OE project
7
8Upstream-Status: Inappropriate [ OE-Specific ]
9
10Signed-off-by: Khem Raj <raj.khem@gmail.com>
11---
12 libunwind/libunwind.pc.in | 9 ++++++
13 llvm/tools/llvm-config/llvm-config | 52 ++++++++++++++++++++++++++++++
14 2 files changed, 61 insertions(+)
15 create mode 100644 libunwind/libunwind.pc.in
16 create mode 100644 llvm/tools/llvm-config/llvm-config
17
18diff --git a/libunwind/libunwind.pc.in b/libunwind/libunwind.pc.in
19new file mode 100644
20index 000000000000..a93d676604f9
21--- /dev/null
22+++ b/libunwind/libunwind.pc.in
23@@ -0,0 +1,9 @@
24+prefix=/usr
25+exec_prefix=/usr
26+libdir=@LIBDIR@
27+includedir=/usr/include
28+
29+Name: libunwind
30+Description: libunwind base library
31+Version: @VERSION@
32+Libs: -lunwind
33diff --git a/llvm/tools/llvm-config/llvm-config b/llvm/tools/llvm-config/llvm-config
34new file mode 100644
35index 000000000000..6a0dd54b8eab
36--- /dev/null
37+++ b/llvm/tools/llvm-config/llvm-config
38@@ -0,0 +1,52 @@
39+#!/bin/bash
40+#
41+# Wrapper script for llvm-config. Supplies the right environment variables
42+# for the target and delegates to the native llvm-config for anything else. This
43+# is needed because arguments like --ldflags, --cxxflags, etc. are set by the
44+# native compile rather than the target compile.
45+#
46+SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
47+NEXT_LLVM_CONFIG="$(which -a llvm-config | sed -n 2p)"
48+export YOCTO_ALTERNATE_EXE_PATH="${YOCTO_ALTERNATE_EXE_PATH:="$(readlink -f "$SCRIPT_DIR/../llvm-config")"}"
49+if [ -n "$( echo $base_libdir | sed -n '/lib64/p')" ]; then
50+ export YOCTO_ALTERNATE_LIBDIR="${YOCTO_ALTERNATE_LIBDIR:="/lib64"}"
51+else
52+ export YOCTO_ALTERNATE_LIBDIR="${YOCTO_ALTERNATE_LIBDIR:="/lib"}"
53+fi
54+if [[ $# == 0 ]]; then
55+ exec "$NEXT_LLVM_CONFIG"
56+fi
57+
58+remain=""
59+output=""
60+for arg in "$@"; do
61+ case "$arg" in
62+ --cppflags)
63+ output="${output} ${CPPFLAGS}"
64+ ;;
65+ --cflags)
66+ output="${output} ${CFLAGS}"
67+ ;;
68+ --cxxflags)
69+ output="${output} ${CXXFLAGS}"
70+ ;;
71+ --ldflags)
72+ output="${output} ${LDFLAGS}"
73+ ;;
74+ --shared-mode)
75+ output="${output} shared"
76+ ;;
77+ --link-shared)
78+ break
79+ ;;
80+ *)
81+ remain="${remain} ${arg}"
82+ ;;
83+ esac
84+done
85+
86+if [ "${remain}" != "" ]; then
87+ output="${output} "$("$NEXT_LLVM_CONFIG" ${remain})
88+fi
89+
90+echo "${output}"
diff --git a/meta/recipes-devtools/clang/clang/0030-scan-build-py-respect-LLVM_LIBDIR_SUFFIX-like-other-.patch b/meta/recipes-devtools/clang/clang/0030-scan-build-py-respect-LLVM_LIBDIR_SUFFIX-like-other-.patch
new file mode 100644
index 0000000000..01d054512f
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0030-scan-build-py-respect-LLVM_LIBDIR_SUFFIX-like-other-.patch
@@ -0,0 +1,92 @@
1From e468c9f5b5cf85583c0435ad934affd5b900caec Mon Sep 17 00:00:00 2001
2From: Martin Jansa <martin.jansa@gmail.com>
3Date: Fri, 13 Sep 2024 13:38:08 +0200
4Subject: [PATCH] scan-build-py: respect LLVM_LIBDIR_SUFFIX like other tools do
5
6* other libraries are installed in 'lib64' or 'lib32' based on
7 LLVM_LIBDIR_SUFFIX value, but libscanbuild files were always
8 installed in 'lib'
9
10Upstream-Status: Submitted [https://github.com/llvm/llvm-project/pull/108549]
11
12Signed-off-by: Martin Jansa <martin.jansa@gmail.com>
13---
14 clang/tools/scan-build-py/CMakeLists.txt | 38 ++++++++++++------------
15 1 file changed, 19 insertions(+), 19 deletions(-)
16
17diff --git a/clang/tools/scan-build-py/CMakeLists.txt b/clang/tools/scan-build-py/CMakeLists.txt
18index 9273eb5ed977..9033786d2da5 100644
19--- a/clang/tools/scan-build-py/CMakeLists.txt
20+++ b/clang/tools/scan-build-py/CMakeLists.txt
21@@ -77,52 +77,52 @@ foreach(lib ${LibExecs})
22 endforeach()
23
24 foreach(lib ${LibScanbuild})
25- add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/lib/libscanbuild/${lib}
26+ add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/libscanbuild/${lib}
27 COMMAND ${CMAKE_COMMAND} -E make_directory
28- ${CMAKE_BINARY_DIR}/lib
29+ ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}
30 COMMAND ${CMAKE_COMMAND} -E make_directory
31- ${CMAKE_BINARY_DIR}/lib/libscanbuild
32+ ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/libscanbuild
33 COMMAND ${CMAKE_COMMAND} -E copy
34 ${CMAKE_CURRENT_SOURCE_DIR}/lib/libscanbuild/${lib}
35- ${CMAKE_BINARY_DIR}/lib/libscanbuild/
36+ ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/libscanbuild/
37 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/lib/libscanbuild/${lib})
38- list(APPEND Depends ${CMAKE_BINARY_DIR}/lib/libscanbuild/${lib})
39+ list(APPEND Depends ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/libscanbuild/${lib})
40 install(FILES lib/libscanbuild/${lib}
41- DESTINATION lib/libscanbuild
42+ DESTINATION lib${LLVM_LIBDIR_SUFFIX}/libscanbuild
43 COMPONENT scan-build-py)
44 endforeach()
45
46 foreach(resource ${LibScanbuildResources})
47- add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/lib/libscanbuild/resources/${resource}
48+ add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/libscanbuild/resources/${resource}
49 COMMAND ${CMAKE_COMMAND} -E make_directory
50- ${CMAKE_BINARY_DIR}/lib
51+ ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}
52 COMMAND ${CMAKE_COMMAND} -E make_directory
53- ${CMAKE_BINARY_DIR}/lib/libscanbuild
54+ ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/libscanbuild
55 COMMAND ${CMAKE_COMMAND} -E make_directory
56- ${CMAKE_BINARY_DIR}/lib/libscanbuild/resources
57+ ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/libscanbuild/resources
58 COMMAND ${CMAKE_COMMAND} -E copy
59 ${CMAKE_CURRENT_SOURCE_DIR}/lib/libscanbuild/resources/${resource}
60- ${CMAKE_BINARY_DIR}/lib/libscanbuild/resources
61+ ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/libscanbuild/resources
62 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/lib/libscanbuild/resources/${resource})
63- list(APPEND Depends ${CMAKE_BINARY_DIR}/lib/libscanbuild/resources/${resource})
64+ list(APPEND Depends ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/libscanbuild/resources/${resource})
65 install(FILES lib/libscanbuild/resources/${resource}
66- DESTINATION lib/libscanbuild/resources
67+ DESTINATION lib${LLVM_LIBDIR_SUFFIX}/libscanbuild/resources
68 COMPONENT scan-build-py)
69 endforeach()
70
71 foreach(lib ${LibEar})
72- add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/lib/libear/${lib}
73+ add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/libear/${lib}
74 COMMAND ${CMAKE_COMMAND} -E make_directory
75- ${CMAKE_BINARY_DIR}/lib
76+ ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}
77 COMMAND ${CMAKE_COMMAND} -E make_directory
78- ${CMAKE_BINARY_DIR}/lib/libear
79+ ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/libear
80 COMMAND ${CMAKE_COMMAND} -E copy
81 ${CMAKE_CURRENT_SOURCE_DIR}/lib/libear/${lib}
82- ${CMAKE_BINARY_DIR}/lib/libear/
83+ ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/libear/
84 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/lib/libear/${lib})
85- list(APPEND Depends ${CMAKE_BINARY_DIR}/lib/libear/${lib})
86+ list(APPEND Depends ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/libear/${lib})
87 install(FILES lib/libear/${lib}
88- DESTINATION lib/libear
89+ DESTINATION lib${LLVM_LIBDIR_SUFFIX}/libear
90 COMPONENT scan-build-py)
91 endforeach()
92
diff --git a/meta/recipes-devtools/clang/clang/0031-compiler-rt-Do-not-pass-target-to-clang-compiler.patch b/meta/recipes-devtools/clang/clang/0031-compiler-rt-Do-not-pass-target-to-clang-compiler.patch
new file mode 100644
index 0000000000..01fcc0689d
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0031-compiler-rt-Do-not-pass-target-to-clang-compiler.patch
@@ -0,0 +1,29 @@
1From cbb5bca513714f539c899a123bf5dc17651c9737 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Thu, 13 Mar 2025 00:30:38 -0700
4Subject: [PATCH] compiler-rt: Do not pass --target to clang compiler
5
6In OE we use <tuple>-clang and <tuple>-clang++ which
7should resolve the --target correctly.
8
9Upstream-Status: Inappropriate [ OE-Specific ]
10Signed-off-by: Khem Raj <raj.khem@gmail.com>
11---
12 compiler-rt/lib/fuzzer/CMakeLists.txt | 4 ----
13 1 file changed, 4 deletions(-)
14
15diff --git a/compiler-rt/lib/fuzzer/CMakeLists.txt b/compiler-rt/lib/fuzzer/CMakeLists.txt
16index 6db24610df1f..692e194c2a98 100644
17--- a/compiler-rt/lib/fuzzer/CMakeLists.txt
18+++ b/compiler-rt/lib/fuzzer/CMakeLists.txt
19@@ -140,10 +140,6 @@ if(OS_NAME MATCHES "Android|Linux|Fuchsia" AND
20 COMPILER_RT_LIBCXXABI_PATH)
21 macro(partially_link_libcxx name dir arch)
22 get_target_flags_for_arch(${arch} target_cflags)
23- if(CMAKE_CXX_COMPILER_ID MATCHES Clang)
24- get_compiler_rt_target(${arch} target)
25- set(target_cflags --target=${target} ${target_cflags})
26- endif()
27 set(cxx_${arch}_merge_dir "${CMAKE_CURRENT_BINARY_DIR}/cxx_${arch}_merge.dir")
28 file(MAKE_DIRECTORY ${cxx_${arch}_merge_dir})
29 add_custom_command(TARGET clang_rt.${name}-${arch} POST_BUILD
diff --git a/meta/recipes-devtools/clang/clang/0032-Fix-build-on-ppc64-musl.patch b/meta/recipes-devtools/clang/clang/0032-Fix-build-on-ppc64-musl.patch
new file mode 100644
index 0000000000..e1fcb3a203
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0032-Fix-build-on-ppc64-musl.patch
@@ -0,0 +1,97 @@
1From bb99b65d884185a2eb1d4601e5135da582cbd8a9 Mon Sep 17 00:00:00 2001
2From: mojyack <mojyack@gmail.com>
3Date: Mon, 16 Dec 2024 13:42:04 +0900
4Subject: [PATCH] Fix build on ppc64+musl
5
6In powerpc64-unknown-linux-musl, signal.h does not include asm/ptrace.h,
7which causes "member access into incomplete type 'struct pt_regs'" errors.
8Include the header explicitly to fix this.
9
10Also in sanitizer_linux_libcdep.cpp, there is a usage of
11TlsPreTcbSize which is not defined in such a platform.
12Guard the branch with macro.
13
14Upstream-Status: Backport [https://github.com/llvm/llvm-project/pull/120036]
15Signed-off-by: Khem Raj <raj.khem@gmail.com>
16---
17 .../lib/sanitizer_common/sanitizer_linux.cpp | 4 ++++
18 .../sanitizer_common/sanitizer_linux_libcdep.cpp | 13 +++++++------
19 .../sanitizer_platform_limits_posix.cpp | 2 +-
20 .../sanitizer_stoptheworld_linux_libcdep.cpp | 3 ++-
21 4 files changed, 14 insertions(+), 8 deletions(-)
22
23diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
24index 7aa48d29d2d5..a4d526b4466c 100644
25--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
26+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
27@@ -86,6 +86,10 @@
28 # include <sys/sysmacros.h>
29 # endif
30
31+# if SANITIZER_LINUX && defined(__powerpc64__)
32+# include <asm/ptrace.h>
33+# endif
34+
35 # if SANITIZER_FREEBSD
36 # include <machine/atomic.h>
37 # include <sys/exec.h>
38diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
39index e11eff13cd32..331e1c7d8d15 100644
40--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
41+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
42@@ -619,21 +619,22 @@ static void GetTls(uptr *addr, uptr *size) {
43 *addr = tp - RoundUpTo(*size, align);
44 *size = tp - *addr + ThreadDescriptorSize();
45 # else
46- if (SANITIZER_GLIBC)
47- *size += 1664;
48- else if (SANITIZER_FREEBSD)
49- *size += 128; // RTLD_STATIC_TLS_EXTRA
50-# if defined(__mips__) || defined(__powerpc64__) || SANITIZER_RISCV64
51+# if SANITIZER_GLIBC
52+ *size += 1664;
53+# elif SANITIZER_FREEBSD
54+ *size += 128; // RTLD_STATIC_TLS_EXTRA
55+# if defined(__mips__) || defined(__powerpc64__) || SANITIZER_RISCV64
56 const uptr pre_tcb_size = TlsPreTcbSize();
57 *addr -= pre_tcb_size;
58 *size += pre_tcb_size;
59-# else
60+# else
61 // arm and aarch64 reserve two words at TP, so this underestimates the range.
62 // However, this is sufficient for the purpose of finding the pointers to
63 // thread-specific data keys.
64 const uptr tcb_size = ThreadDescriptorSize();
65 *addr -= tcb_size;
66 *size += tcb_size;
67+# endif
68 # endif
69 # endif
70 # elif SANITIZER_NETBSD
71diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
72index a5311d266b0c..ec5f2edab6a6 100644
73--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
74+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
75@@ -96,7 +96,7 @@
76 # include <sys/ptrace.h>
77 # if defined(__mips64) || defined(__aarch64__) || defined(__arm__) || \
78 defined(__hexagon__) || defined(__loongarch__) || SANITIZER_RISCV64 || \
79- defined(__sparc__)
80+ defined(__sparc__) || defined(__powerpc64__)
81 # include <asm/ptrace.h>
82 # ifdef __arm__
83 typedef struct user_fpregs elf_fpregset_t;
84diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp
85index 945da99d41f4..58d17d90c343 100644
86--- a/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp
87+++ b/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp
88@@ -31,7 +31,8 @@
89 #include <sys/types.h> // for pid_t
90 #include <sys/uio.h> // for iovec
91 #include <elf.h> // for NT_PRSTATUS
92-#if (defined(__aarch64__) || SANITIZER_RISCV64 || SANITIZER_LOONGARCH64) && \
93+#if (defined(__aarch64__) || defined(__powerpc64__) || \
94+ SANITIZER_RISCV64 || SANITIZER_LOONGARCH64) && \
95 !SANITIZER_ANDROID
96 // GLIBC 2.20+ sys/user does not include asm/ptrace.h
97 # include <asm/ptrace.h>
diff --git a/meta/recipes-devtools/clang/clang/0033-clangd-Add-a-build-option-to-disable-building-dexp.patch b/meta/recipes-devtools/clang/clang/0033-clangd-Add-a-build-option-to-disable-building-dexp.patch
new file mode 100644
index 0000000000..198989cd42
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0033-clangd-Add-a-build-option-to-disable-building-dexp.patch
@@ -0,0 +1,85 @@
1From 49fbbb928d5cafba3d367e3750d402b53425943a Mon Sep 17 00:00:00 2001
2From: Yoann Congal <yoann.congal@smile.fr>
3Date: Tue, 25 Mar 2025 22:25:55 +0100
4Subject: [PATCH] clangd: Add a build option to disable building dexp
5
6Building dexp on Debian 11 currently causes intermittent failure[0][1].
7
8Adding the CLANGD_BUILD_DEXP option to disable dexp from the build
9allows Debian 11 users to build clang (albeit without the dexp tool).
10
11This option is set to "Build Dexp" by default so, no change is expected
12without manual setting.
13
14[0]: https://bugzilla.yoctoproject.org/show_bug.cgi?id=15803
15[1]: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1101322
16
17Upstream-Status: Submitted [https://github.com/llvm/llvm-project/pull/133124]
18Signed-off-by: Yoann Congal <yoann.congal@smile.fr>
19Signed-off-by: Khem Raj <raj.khem@gmail.com>
20---
21 clang-tools-extra/clangd/CMakeLists.txt | 8 +++++++-
22 clang-tools-extra/clangd/test/CMakeLists.txt | 7 +++++--
23 clang-tools-extra/clangd/test/lit.site.cfg.py.in | 1 +
24 3 files changed, 13 insertions(+), 3 deletions(-)
25
26diff --git a/clang-tools-extra/clangd/CMakeLists.txt b/clang-tools-extra/clangd/CMakeLists.txt
27index 6f10afe4a562..a1e9da41b4b3 100644
28--- a/clang-tools-extra/clangd/CMakeLists.txt
29+++ b/clang-tools-extra/clangd/CMakeLists.txt
30@@ -210,6 +210,9 @@ if (CLANGD_ENABLE_REMOTE)
31 include(AddGRPC)
32 endif()
33
34+option(CLANGD_BUILD_DEXP "Build the dexp tool as part of Clangd" ON)
35+llvm_canonicalize_cmake_booleans(CLANGD_BUILD_DEXP)
36+
37 if(CLANG_INCLUDE_TESTS)
38 add_subdirectory(test)
39 add_subdirectory(unittests)
40@@ -220,4 +223,7 @@ option(CLANGD_ENABLE_REMOTE "Use gRPC library to enable remote index support for
41 set(GRPC_INSTALL_PATH "" CACHE PATH "Path to gRPC library manual installation.")
42
43 add_subdirectory(index/remote)
44-add_subdirectory(index/dex/dexp)
45+
46+if(CLANGD_BUILD_DEXP)
47+ add_subdirectory(index/dex/dexp)
48+endif()
49diff --git a/clang-tools-extra/clangd/test/CMakeLists.txt b/clang-tools-extra/clangd/test/CMakeLists.txt
50index b51f461a4986..42fc3506641f 100644
51--- a/clang-tools-extra/clangd/test/CMakeLists.txt
52+++ b/clang-tools-extra/clangd/test/CMakeLists.txt
53@@ -3,8 +3,6 @@ set(CLANGD_TEST_DEPS
54 ClangdTests
55 clangd-indexer
56 split-file
57- # No tests for it, but we should still make sure they build.
58- dexp
59 )
60
61 if(CLANGD_BUILD_XPC)
62@@ -12,6 +10,11 @@ if(CLANGD_BUILD_XPC)
63 list(APPEND CLANGD_TEST_DEPS ClangdXpcUnitTests)
64 endif()
65
66+if(CLANGD_BUILD_DEXP)
67+ # No tests for it, but we should still make sure they build.
68+ list(APPEND CLANGD_TEST_DEPS dexp)
69+endif()
70+
71 if(CLANGD_ENABLE_REMOTE)
72 list(APPEND CLANGD_TEST_DEPS clangd-index-server clangd-index-server-monitor)
73 endif()
74diff --git a/clang-tools-extra/clangd/test/lit.site.cfg.py.in b/clang-tools-extra/clangd/test/lit.site.cfg.py.in
75index 1fe7c8d0f324..a0bb3561e19e 100644
76--- a/clang-tools-extra/clangd/test/lit.site.cfg.py.in
77+++ b/clang-tools-extra/clangd/test/lit.site.cfg.py.in
78@@ -15,6 +15,7 @@ config.llvm_shlib_dir = "@SHLIBDIR@"
79 config.clangd_source_dir = "@CMAKE_CURRENT_SOURCE_DIR@/.."
80 config.clangd_binary_dir = "@CMAKE_CURRENT_BINARY_DIR@/.."
81 config.clangd_build_xpc = @CLANGD_BUILD_XPC@
82+config.clangd_build_dexp = @CLANGD_BUILD_DEXP@
83 config.clangd_enable_remote = @CLANGD_ENABLE_REMOTE@
84 config.clangd_tidy_checks = @CLANGD_TIDY_CHECKS@
85 config.have_zlib = @LLVM_ENABLE_ZLIB@
diff --git a/meta/recipes-devtools/llvm/llvm/0001-AsmMatcherEmitter-sort-ClassInfo-lists-by-name-as-we.patch b/meta/recipes-devtools/clang/clang/0034-AsmMatcherEmitter-sort-ClassInfo-lists-by-name-as-we.patch
index f71c5d4bd4..7545ba365b 100644
--- a/meta/recipes-devtools/llvm/llvm/0001-AsmMatcherEmitter-sort-ClassInfo-lists-by-name-as-we.patch
+++ b/meta/recipes-devtools/clang/clang/0034-AsmMatcherEmitter-sort-ClassInfo-lists-by-name-as-we.patch
@@ -1,4 +1,4 @@
1From 001d56983078842c5aa2a1786b84dc429bd46abd Mon Sep 17 00:00:00 2001 1From 59921cb127dcfb2c655b357e8deb95004f3da41f Mon Sep 17 00:00:00 2001
2From: Alexander Kanavin <alex.kanavin@gmail.com> 2From: Alexander Kanavin <alex.kanavin@gmail.com>
3Date: Fri, 27 Nov 2020 10:11:08 +0000 3Date: Fri, 27 Nov 2020 10:11:08 +0000
4Subject: [PATCH] AsmMatcherEmitter: sort ClassInfo lists by name as well 4Subject: [PATCH] AsmMatcherEmitter: sort ClassInfo lists by name as well
@@ -14,7 +14,7 @@ Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
14 1 file changed, 4 insertions(+), 1 deletion(-) 14 1 file changed, 4 insertions(+), 1 deletion(-)
15 15
16diff --git a/llvm/utils/TableGen/AsmMatcherEmitter.cpp b/llvm/utils/TableGen/AsmMatcherEmitter.cpp 16diff --git a/llvm/utils/TableGen/AsmMatcherEmitter.cpp b/llvm/utils/TableGen/AsmMatcherEmitter.cpp
17index 7684387d8..d225a3b6d 100644 17index 7684387d80fe..d225a3b6dfa9 100644
18--- a/llvm/utils/TableGen/AsmMatcherEmitter.cpp 18--- a/llvm/utils/TableGen/AsmMatcherEmitter.cpp
19+++ b/llvm/utils/TableGen/AsmMatcherEmitter.cpp 19+++ b/llvm/utils/TableGen/AsmMatcherEmitter.cpp
20@@ -361,7 +361,10 @@ public: 20@@ -361,7 +361,10 @@ public:
diff --git a/meta/recipes-devtools/llvm/llvm/0001-llvm-config-remove-LLVM_LDFLAGS-from-ldflags-output.patch b/meta/recipes-devtools/clang/clang/0035-llvm-config-remove-LLVM_LDFLAGS-from-ldflags-output.patch
index 2320399d5f..81820eeaca 100644
--- a/meta/recipes-devtools/llvm/llvm/0001-llvm-config-remove-LLVM_LDFLAGS-from-ldflags-output.patch
+++ b/meta/recipes-devtools/clang/clang/0035-llvm-config-remove-LLVM_LDFLAGS-from-ldflags-output.patch
@@ -1,4 +1,4 @@
1From caff2482f786dd7fd5f1f46f2667f7ed847cb8f8 Mon Sep 17 00:00:00 2001 1From e414f6489e055c981970b7210b941c2a41cc322b Mon Sep 17 00:00:00 2001
2From: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com> 2From: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
3Date: Wed, 2 Apr 2025 17:05:17 +0300 3Date: Wed, 2 Apr 2025 17:05:17 +0300
4Subject: [PATCH] llvm-config: remove LLVM_LDFLAGS from --ldflags output 4Subject: [PATCH] llvm-config: remove LLVM_LDFLAGS from --ldflags output
@@ -10,17 +10,18 @@ behaviour in llvm-config since crossscripts are not being used for
10native builds. As a OE-specific modification ignore LLVM_LDFLAGS for 10native builds. As a OE-specific modification ignore LLVM_LDFLAGS for
11native builds. 11native builds.
12 12
13Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
14Upstream-Status: Inappropriate [OE-Specific] 13Upstream-Status: Inappropriate [OE-Specific]
14Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
15Signed-off-by: Khem Raj <raj.khem@gmail.com>
15--- 16---
16 llvm/tools/llvm-config/llvm-config.cpp | 2 +- 17 llvm/tools/llvm-config/llvm-config.cpp | 2 +-
17 1 file changed, 1 insertion(+), 1 deletion(-) 18 1 file changed, 1 insertion(+), 1 deletion(-)
18 19
19diff --git a/llvm/tools/llvm-config/llvm-config.cpp b/llvm/tools/llvm-config/llvm-config.cpp 20diff --git a/llvm/tools/llvm-config/llvm-config.cpp b/llvm/tools/llvm-config/llvm-config.cpp
20index d5b76b1bb6c1..29f7c2eaa419 100644 21index a739f0d8dbea..3120f95fba9d 100644
21--- a/llvm/tools/llvm-config/llvm-config.cpp 22--- a/llvm/tools/llvm-config/llvm-config.cpp
22+++ b/llvm/tools/llvm-config/llvm-config.cpp 23+++ b/llvm/tools/llvm-config/llvm-config.cpp
23@@ -529,7 +529,7 @@ int main(int argc, char **argv) { 24@@ -542,7 +542,7 @@ int main(int argc, char **argv) {
24 OS << ActiveIncludeOption << ' ' << LLVM_CXXFLAGS << '\n'; 25 OS << ActiveIncludeOption << ' ' << LLVM_CXXFLAGS << '\n';
25 } else if (Arg == "--ldflags") { 26 } else if (Arg == "--ldflags") {
26 OS << ((HostTriple.isWindowsMSVCEnvironment()) ? "-LIBPATH:" : "-L") 27 OS << ((HostTriple.isWindowsMSVCEnvironment()) ? "-LIBPATH:" : "-L")
@@ -29,6 +30,3 @@ index d5b76b1bb6c1..29f7c2eaa419 100644
29 } else if (Arg == "--system-libs") { 30 } else if (Arg == "--system-libs") {
30 PrintSystemLibs = true; 31 PrintSystemLibs = true;
31 } else if (Arg == "--libs") { 32 } else if (Arg == "--libs") {
32--
332.39.5
34
diff --git a/meta/recipes-devtools/clang/clang/0036-openmp-Do-not-emit-date-and-time-into-generate-files.patch b/meta/recipes-devtools/clang/clang/0036-openmp-Do-not-emit-date-and-time-into-generate-files.patch
new file mode 100644
index 0000000000..91c718e2a4
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0036-openmp-Do-not-emit-date-and-time-into-generate-files.patch
@@ -0,0 +1,37 @@
1From f79ebc5bc696e8747c79a2277ffcf8d91bdadfd5 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Wed, 23 Apr 2025 11:52:48 -0700
4Subject: [PATCH] openmp: Do not emit date and time into generate files
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9This improves reproducibility where the generated files do not
10contain time stamps e.g.
11
12//·The·file·was·generated·from·en_US.txt·by·message-converter.py·on·Wed·Apr·23·16:00:53·2025.·//
13./usr/src/debug/openmp/20.1.2/runtime/src/kmp_i18n_id.inc
14
15Upstream-Status: Pending
16Signed-off-by: Khem Raj <raj.khem@gmail.com>
17---
18 openmp/runtime/tools/message-converter.py | 3 +--
19 1 file changed, 1 insertion(+), 2 deletions(-)
20
21diff --git a/openmp/runtime/tools/message-converter.py b/openmp/runtime/tools/message-converter.py
22index a493d64c1692..0bd5f929fab6 100644
23--- a/openmp/runtime/tools/message-converter.py
24+++ b/openmp/runtime/tools/message-converter.py
25@@ -188,11 +188,10 @@ def insert_header(f, data, commentChar="//"):
26 f.write(
27 "{0} Do not edit this file! {0}\n"
28 "{0} The file was generated from"
29- " {1} by {2} on {3}. {0}\n\n".format(
30+ " {1} by {2} {0}\n\n".format(
31 commentChar,
32 os.path.basename(data.filename),
33 os.path.basename(__file__),
34- datetime.datetime.now().ctime(),
35 )
36 )
37
diff --git a/meta/recipes-devtools/llvm/llvm/spirv-internal-build.patch b/meta/recipes-devtools/clang/clang/spirv-internal-build.patch
index 555d40f4fb..555d40f4fb 100644
--- a/meta/recipes-devtools/llvm/llvm/spirv-internal-build.patch
+++ b/meta/recipes-devtools/clang/clang/spirv-internal-build.patch
diff --git a/meta/recipes-devtools/llvm/llvm/spirv-shared-library.patch b/meta/recipes-devtools/clang/clang/spirv-shared-library.patch
index edc595d576..edc595d576 100644
--- a/meta/recipes-devtools/llvm/llvm/spirv-shared-library.patch
+++ b/meta/recipes-devtools/clang/clang/spirv-shared-library.patch
diff --git a/meta/recipes-devtools/clang/clang_git.bb b/meta/recipes-devtools/clang/clang_git.bb
new file mode 100644
index 0000000000..8ae67c8c66
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang_git.bb
@@ -0,0 +1,492 @@
1# Copyright (C) 2014 Khem Raj <raj.khem@gmail.com>
2# Released under the MIT license (see COPYING.MIT for the terms)
3
4SUMMARY = "LLVM based C/C++ compiler"
5DESCRIPTION = "Clang is an LLVM based C/C++/Objective-C compiler, \
6 which aims to deliver amazingly fast compiles, \
7 extremely useful error and warning messages and \
8 to provide a platform for building great source \
9 level tools. The Clang Static Analyzer and \
10 clang-tidy are tools that automatically find bugs \
11 in your code, and are great examples of the sort \
12 of tools that can be built using the Clang frontend \
13 as a library to parse C/C++ code"
14HOMEPAGE = "http://clang.llvm.org/"
15SECTION = "devel"
16
17require common-clang.inc
18require common-source.inc
19
20INHIBIT_DEFAULT_DEPS:class-native = "1"
21
22LDFLAGS:append:class-target:riscv32 = " -Wl,--no-as-needed -latomic -Wl,--as-needed"
23LDFLAGS:append:class-target:mips = " -Wl,--no-as-needed -latomic -Wl,--as-needed"
24
25inherit cmake pkgconfig python3native python3targetconfig
26
27OECMAKE_FIND_ROOT_PATH_MODE_PROGRAM = "BOTH"
28
29def get_clang_arch(bb, d, arch_var):
30 import re
31 a = d.getVar(arch_var)
32 if re.match('(i.86|athlon|x86.64)$', a): return 'X86'
33 elif re.match('arm$', a): return 'ARM'
34 elif re.match('armeb$', a): return 'ARM'
35 elif re.match('aarch64$', a): return 'AArch64'
36 elif re.match('aarch64_be$', a): return 'AArch64'
37 elif re.match('mips(isa|)(32|64|)(r6|)(el|)$', a): return 'Mips'
38 elif re.match('riscv32$', a): return 'riscv32'
39 elif re.match('riscv64$', a): return 'riscv64'
40 elif re.match('p(pc|owerpc)(|64)', a): return 'PowerPC'
41 elif re.match('loongarch64$', a): return 'loongarch64'
42 else:
43 bb.note("'%s' is not a primary llvm architecture" % a)
44 return ""
45
46def get_clang_host_arch(bb, d):
47 return get_clang_arch(bb, d, 'HOST_ARCH')
48
49def get_clang_target_arch(bb, d):
50 return get_clang_arch(bb, d, 'TARGET_ARCH')
51
52PACKAGECONFIG_CLANG_COMMON = "build-id eh libedit rtti shared-libs \
53 ${@bb.utils.contains('TC_CXX_RUNTIME', 'llvm', 'compiler-rt libcplusplus libomp unwindlib', '', d)} \
54 "
55
56PACKAGECONFIG ??= "lldb-wchar terminfo \
57 ${PACKAGECONFIG_CLANG_COMMON} \
58 ${@bb.utils.filter('DISTRO_FEATURES', 'lto thin-lto', d)} \
59 "
60PACKAGECONFIG:class-native = "clangd \
61 ${PACKAGECONFIG_CLANG_COMMON} \
62 "
63PACKAGECONFIG:class-nativesdk = "clangd \
64 ${PACKAGECONFIG_CLANG_COMMON} \
65 ${@bb.utils.filter('DISTRO_FEATURES', 'lto thin-lto', d)} \
66 "
67
68PACKAGECONFIG[bootstrap] = "-DCLANG_ENABLE_BOOTSTRAP=On -DCLANG_BOOTSTRAP_PASSTHROUGH='${PASSTHROUGH}' -DBOOTSTRAP_LLVM_ENABLE_LTO=Thin -DBOOTSTRAP_LLVM_ENABLE_LLD=ON,,,"
69PACKAGECONFIG[build-id] = "-DENABLE_LINKER_BUILD_ID=ON,-DENABLE_LINKER_BUILD_ID=OFF,,"
70PACKAGECONFIG[clangd] = "-DCLANG_ENABLE_CLANGD=ON,-DCLANG_ENABLE_CLANGD=OFF,,"
71
72# Activate to build the dexp tool in clangd
73# Disabled by default for -native since it is known to trigger compiler failure on Debian 11
74# See: https://bugzilla.yoctoproject.org/show_bug.cgi?id=15803
75PACKAGECONFIG[clangd-dexp] = "-DCLANGD_BUILD_DEXP=ON,-DCLANGD_BUILD_DEXP=OFF,,"
76
77PACKAGECONFIG[compiler-rt] = "-DCLANG_DEFAULT_RTLIB=compiler-rt,,"
78PACKAGECONFIG[eh] = "-DLLVM_ENABLE_EH=ON,-DLLVM_ENABLE_EH=OFF,,"
79PACKAGECONFIG[libcplusplus] = "-DCLANG_DEFAULT_CXX_STDLIB=libc++,,"
80PACKAGECONFIG[libedit] = "-DLLVM_ENABLE_LIBEDIT=ON -DLLDB_ENABLE_LIBEDIT=ON,-DLLVM_ENABLE_LIBEDIT=OFF -DLLDB_ENABLE_LIBEDIT=OFF,libedit libedit-native"
81PACKAGECONFIG[libomp] = "-DCLANG_DEFAULT_OPENMP_RUNTIME=libomp,,"
82PACKAGECONFIG[lld] = "-DCLANG_DEFAULT_LINKER=lld,,"
83PACKAGECONFIG[lldb-lua] = "-DLLDB_ENABLE_LUA=ON,-DLLDB_ENABLE_LUA=OFF,lua"
84PACKAGECONFIG[lldb-wchar] = "-DLLDB_EDITLINE_USE_WCHAR=1,-DLLDB_EDITLINE_USE_WCHAR=0,"
85PACKAGECONFIG[lto] = "-DLLVM_ENABLE_LTO=Full -DLLVM_BINUTILS_INCDIR=${STAGING_INCDIR},,binutils,"
86PACKAGECONFIG[pfm] = "-DLLVM_ENABLE_LIBPFM=ON,-DLLVM_ENABLE_LIBPFM=OFF,libpfm,"
87PACKAGECONFIG[rtti] = "-DLLVM_ENABLE_RTTI=ON,-DLLVM_ENABLE_RTTI=OFF,,"
88PACKAGECONFIG[shared-libs] = "-DLLVM_BUILD_LLVM_DYLIB=ON -DLLVM_LINK_LLVM_DYLIB=ON,,,"
89PACKAGECONFIG[split-dwarf] = "-DLLVM_USE_SPLIT_DWARF=ON,-DLLVM_USE_SPLIT_DWARF=OFF,,"
90PACKAGECONFIG[terminfo] = "-DLLVM_ENABLE_TERMINFO=ON -DCOMPILER_RT_TERMINFO_LIB=ON,-DLLVM_ENABLE_TERMINFO=OFF -DCOMPILER_RT_TERMINFO_LIB=OFF,ncurses,"
91PACKAGECONFIG[thin-lto] = "-DLLVM_ENABLE_LTO=Thin -DLLVM_BINUTILS_INCDIR=${STAGING_INCDIR},,binutils,"
92PACKAGECONFIG[unwindlib] = "-DCLANG_DEFAULT_UNWINDLIB=libunwind,-DCLANG_DEFAULT_UNWINDLIB=libgcc,,"
93
94OECMAKE_SOURCEPATH = "${S}/llvm"
95
96OECMAKE_TARGET_COMPILE = "${@bb.utils.contains('PACKAGECONFIG', 'bootstrap', 'stage2', 'all', d)}"
97OECMAKE_TARGET_INSTALL = "${@bb.utils.contains('PACKAGECONFIG', 'bootstrap', 'stage2-install', 'install', d)}"
98BINPATHPREFIX = "${@bb.utils.contains('PACKAGECONFIG', 'bootstrap', '/tools/clang/stage2-bins/NATIVE', '', d)}"
99
100PASSTHROUGH = "\
101CLANG_DEFAULT_RTLIB;CLANG_DEFAULT_CXX_STDLIB;LLVM_BUILD_LLVM_DYLIB;LLVM_LINK_LLVM_DYLIB;\
102LLVM_ENABLE_ASSERTIONS;LLVM_ENABLE_EXPENSIVE_CHECKS;LLVM_ENABLE_PIC;\
103LLVM_BINDINGS_LIST;LLVM_ENABLE_FFI;FFI_INCLUDE_DIR;LLVM_OPTIMIZED_TABLEGEN;\
104LLVM_ENABLE_RTTI;LLVM_ENABLE_EH;LLVM_BUILD_EXTERNAL_COMPILER_RT;CMAKE_SYSTEM_NAME;\
105CMAKE_BUILD_TYPE;BUILD_SHARED_LIBS;LLVM_ENABLE_PROJECTS;LLVM_ENABLE_RUNTIMES;LLVM_BINUTILS_INCDIR;\
106LLVM_TARGETS_TO_BUILD;LLVM_EXPERIMENTAL_TARGETS_TO_BUILD;PYTHON_EXECUTABLE;\
107PYTHON_LIBRARY;PYTHON_INCLUDE_DIR;LLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN;LLDB_EDITLINE_USE_WCHAR;\
108LLVM_ENABLE_LIBEDIT;LLDB_ENABLE_LIBEDIT;LLDB_PYTHON_RELATIVE_PATH;LLDB_PYTHON_EXE_RELATIVE_PATH;\
109LLDB_PYTHON_EXT_SUFFIX;CMAKE_C_FLAGS_RELEASE;CMAKE_CXX_FLAGS_RELEASE;CMAKE_ASM_FLAGS_RELEASE;\
110CLANG_DEFAULT_CXX_STDLIB;CLANG_DEFAULT_RTLIB;CLANG_DEFAULT_UNWINDLIB;\
111CLANG_DEFAULT_OPENMP_RUNTIME;LLVM_ENABLE_PER_TARGET_RUNTIME_DIR;\
112LLVM_BUILD_TOOLS;LLVM_USE_HOST_TOOLS;LLVM_CONFIG_PATH;LLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR;\
113"
114#
115# Default to build all OE-Core supported target arches (user overridable).
116# Gennerally setting LLVM_TARGETS_TO_BUILD = "" in local.conf is ok in most simple situations
117# where only one target architecture is needed along with just one build arch (usually X86)
118#
119LLVM_TARGETS_TO_BUILD ?= "AMDGPU;AArch64;ARM;BPF;Mips;PowerPC;RISCV;X86;LoongArch;NVPTX;SPIRV"
120
121LLVM_EXPERIMENTAL_TARGETS_TO_BUILD ?= ""
122
123HF = ""
124HF:class-target = "${@ bb.utils.contains('TUNE_CCARGS_MFLOAT', 'hard', 'hf', '', d)}"
125HF[vardepvalue] = "${HF}"
126
127# Ensure that LLVM_PROJECTS does not contain compiler runtime components e.g. libcxx etc
128# they are enabled via LLVM_ENABLE_RUNTIMES
129LLVM_PROJECTS ?= "clang;clang-tools-extra;libclc;lld${LLDB}"
130LLDB ?= ";lldb"
131# LLDB support for RISCV32/Mips32 does not work yet
132LLDB:riscv32 = ""
133LLDB:mips = ""
134LLDB:mipsel = ""
135LLDB:powerpc = ""
136
137# linux hosts (.so) on Windows .pyd
138SOLIBSDEV:mingw32 = ".pyd"
139
140#CMAKE_VERBOSE = "VERBOSE=1"
141
142EXTRA_OECMAKE += "-DLLVM_ENABLE_ASSERTIONS=OFF \
143 -DLLVM_APPEND_VC_REV=OFF \
144 -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF \
145 -DLLVM_ENABLE_EXPENSIVE_CHECKS=OFF \
146 -DLLVM_ENABLE_PIC=ON \
147 -DCLANG_DEFAULT_PIE_ON_LINUX=ON \
148 -DLLVM_BINDINGS_LIST='' \
149 -DLLVM_ENABLE_FFI=ON \
150 -DLLVM_ENABLE_ZSTD=ON \
151 -DFFI_INCLUDE_DIR=$(pkg-config --variable=includedir libffi) \
152 -DLLVM_OPTIMIZED_TABLEGEN=ON \
153 -DLLVM_BUILD_EXTERNAL_COMPILER_RT=ON \
154 -DCMAKE_SYSTEM_NAME=Linux \
155 -DCMAKE_BUILD_TYPE=Release \
156 -DCMAKE_CXX_FLAGS_RELEASE='${CXXFLAGS} -DNDEBUG -g0' \
157 -DCMAKE_C_FLAGS_RELEASE='${CFLAGS} -DNDEBUG -g0' \
158 -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=${S}/llvm/projects/SPIRV-LLVM-Translator/SPIRV-Headers \
159 -DLLVM_ENABLE_PROJECTS='${LLVM_PROJECTS}' \
160 -DLLVM_BINUTILS_INCDIR=${STAGING_INCDIR} \
161 -DLLVM_VERSION_SUFFIX='${VER_SUFFIX}' \
162 -DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN=ON \
163 -DLLVM_TARGETS_TO_BUILD='${LLVM_TARGETS_TO_BUILD}' \
164 -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD='${LLVM_EXPERIMENTAL_TARGETS_TO_BUILD}' \
165"
166
167EXTRA_OECMAKE:append:class-native = "\
168 -DPYTHON_EXECUTABLE='${PYTHON}' \
169"
170EXTRA_OECMAKE:append:class-nativesdk = "\
171 -DCROSS_TOOLCHAIN_FLAGS_NATIVE='-DLLDB_PYTHON_RELATIVE_PATH=${PYTHON_SITEPACKAGES_DIR} \
172 -DLLDB_PYTHON_EXE_RELATIVE_PATH=${PYTHON_PN} \
173 -DLLDB_PYTHON_EXT_SUFFIX=${SOLIBSDEV} \
174 -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=${S}/llvm/projects/SPIRV-LLVM-Translator/SPIRV-Headers \
175 -DCMAKE_TOOLCHAIN_FILE=${WORKDIR}/toolchain-native.cmake' \
176 -DCMAKE_RANLIB=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-ranlib \
177 -DCMAKE_AR=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-ar \
178 -DCMAKE_NM=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-nm \
179 -DCMAKE_STRIP=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-strip \
180 -DLLVM_NATIVE_TOOL_DIR=${STAGING_BINDIR_NATIVE} \
181 -DLLVM_HEADERS_TABLEGEN=${STAGING_BINDIR_NATIVE}/llvm-min-tblgen \
182 -DPYTHON_LIBRARY=${STAGING_LIBDIR}/lib${PYTHON_DIR}${PYTHON_ABI}.so \
183 -DLLDB_PYTHON_RELATIVE_PATH=${PYTHON_SITEPACKAGES_DIR} \
184 -DLLDB_PYTHON_EXE_RELATIVE_PATH=${PYTHON_PN} \
185 -DLLDB_PYTHON_EXT_SUFFIX=${SOLIBSDEV} \
186 -DPYTHON_INCLUDE_DIR=${STAGING_INCDIR}/${PYTHON_DIR}${PYTHON_ABI} \
187 -DPYTHON_EXECUTABLE='${PYTHON}' \
188"
189EXTRA_OECMAKE:append:class-target = "\
190 -DCROSS_TOOLCHAIN_FLAGS_NATIVE='-DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=${S}/llvm/projects/SPIRV-LLVM-Translator/SPIRV-Headers \
191' \
192 -DLLVM_NATIVE_TOOL_DIR=${STAGING_BINDIR_NATIVE} \
193 -DLLVM_HEADERS_TABLEGEN=${STAGING_BINDIR_NATIVE}/llvm-min-tblgen \
194 -DCMAKE_RANLIB=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-ranlib \
195 -DCMAKE_AR=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-ar \
196 -DCMAKE_NM=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-nm \
197 -DCMAKE_STRIP=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-strip \
198 -DLLVM_TARGET_ARCH=${@get_clang_target_arch(bb, d)} \
199 -DLLVM_DEFAULT_TARGET_TRIPLE=${TARGET_SYS}${HF} \
200 -DLLVM_HOST_TRIPLE=${TARGET_SYS}${HF} \
201 -DPYTHON_LIBRARY=${STAGING_LIBDIR}/lib${PYTHON_DIR}${PYTHON_ABI}.so \
202 -DPYTHON_INCLUDE_DIR=${STAGING_INCDIR}/${PYTHON_DIR}${PYTHON_ABI} \
203 -DLLVM_LIBDIR_SUFFIX=${LLVM_LIBDIR_SUFFIX} \
204 -DLLDB_PYTHON_RELATIVE_PATH=${PYTHON_SITEPACKAGES_DIR} \
205 -DLLDB_PYTHON_EXE_RELATIVE_PATH=${bindir} \
206 -DLLDB_PYTHON_EXT_SUFFIX=${SOLIBSDEV} \
207"
208
209DEPENDS = "binutils zlib zstd libffi libxml2 libxml2-native ninja-native swig-native spirv-tools-native"
210DEPENDS:append:class-nativesdk = " clang-crosssdk-${SDK_SYS} virtual/nativesdk-cross-binutils nativesdk-python3"
211DEPENDS:append:class-target = " clang-cross-${TARGET_ARCH} python3 ${@bb.utils.contains('TC_CXX_RUNTIME', 'llvm', 'compiler-rt libcxx', '', d)}"
212
213RRECOMMENDS:${PN} = "binutils"
214RRECOMMENDS:${PN}:append:class-target = "${@bb.utils.contains('TC_CXX_RUNTIME', 'llvm', ' libcxx-dev', '', d)}"
215
216# patch out build host paths for reproducibility
217reproducible_build_variables() {
218 sed -i -e "s,${DEBUG_PREFIX_MAP},,g" \
219 -e "s,--sysroot=${RECIPE_SYSROOT},,g" \
220 -e "s,${STAGING_DIR_HOST},,g" \
221 -e "s,${S}/llvm,,g" \
222 -e "s,${B},,g" \
223 ${B}/tools/llvm-config/BuildVariables.inc
224}
225
226do_configure:append:class-target() {
227 reproducible_build_variables
228}
229
230do_configure:append:class-nativesdk() {
231 reproducible_build_variables
232}
233
234do_install:append() {
235 rm -rf ${D}${libdir}/python*/site-packages/six.py
236 for t in clang-pseudo clang-pseudo-gen clang-rename; do
237 if [ -e ${B}${BINPATHPREFIX}/bin/$t ]; then
238 install -Dm 0755 ${B}${BINPATHPREFIX}/bin/$t ${D}${bindir}/$t
239 fi
240 done
241}
242
243do_install:append:class-target () {
244 # Allow bin path to change based on YOCTO_ALTERNATE_EXE_PATH
245 sed -i 's;${_IMPORT_PREFIX}/bin;${_IMPORT_PREFIX_BIN};g' ${D}${libdir}/cmake/llvm/LLVMExports-release.cmake
246
247 # Insert function to populate Import Variables
248 sed -i "4i\
249if(DEFINED ENV{YOCTO_ALTERNATE_EXE_PATH})\n\
250 execute_process(COMMAND \"llvm-config\" \"--bindir\" OUTPUT_VARIABLE _IMPORT_PREFIX_BIN OUTPUT_STRIP_TRAILING_WHITESPACE)\n\
251else()\n\
252 set(_IMPORT_PREFIX_BIN \"\${_IMPORT_PREFIX}/bin\")\n\
253endif()\n" ${D}${libdir}/cmake/llvm/LLVMExports-release.cmake
254
255 if [ -n "${LLVM_LIBDIR_SUFFIX}" ]; then
256 mkdir -p ${D}${nonarch_libdir}
257 mv ${D}${libdir}/clang ${D}${nonarch_libdir}/clang
258 ln -rs ${D}${nonarch_libdir}/clang ${D}${libdir}/clang
259 rmdir --ignore-fail-on-non-empty ${D}${libdir}
260 fi
261 for t in clang clang++ llvm-nm llvm-ar llvm-as llvm-ranlib llvm-strip llvm-objcopy llvm-objdump llvm-readelf \
262 llvm-addr2line llvm-dwp llvm-size llvm-strings llvm-cov; do
263 ln -sf $t ${D}${bindir}/${TARGET_PREFIX}$t
264 done
265
266 # reproducibility
267 sed -i -e 's,${B},,g' ${D}${libdir}/cmake/llvm/LLVMConfig.cmake
268}
269
270do_install:append:class-native () {
271 if ${@bb.utils.contains('PACKAGECONFIG', 'clangd', 'true', 'false', d)}; then
272 install -Dm 0755 ${B}${BINPATHPREFIX}/bin/clangd-indexer ${D}${bindir}/clangd-indexer
273 fi
274 install -Dm 0755 ${B}${BINPATHPREFIX}/bin/clang-tidy-confusable-chars-gen ${D}${bindir}/clang-tidy-confusable-chars-gen
275 install -Dm 0755 ${B}${BINPATHPREFIX}/bin/clang-tblgen ${D}${bindir}/clang-tblgen
276 install -Dm 0755 ${B}${BINPATHPREFIX}/bin/lldb-tblgen ${D}${bindir}/lldb-tblgen
277 install -Dm 0755 ${B}${BINPATHPREFIX}/bin/llvm-min-tblgen ${D}${bindir}/llvm-min-tblgen
278 install -Dm 0755 ${B}${BINPATHPREFIX}/bin/prepare_builtins ${D}${bindir}/prepare_builtins
279
280 for f in `find ${D}${bindir} -executable -type f -not -type l`; do
281 test -n "`file -b $f|grep -i ELF`" && ${STRIP} $f
282 echo "stripped $f"
283 done
284 ln -sf clang-tblgen ${D}${bindir}/clang-tblgen${PV}
285 ln -sf llvm-tblgen ${D}${bindir}/llvm-tblgen${PV}
286 ln -sf llvm-config ${D}${bindir}/llvm-config${PV}
287}
288
289do_install:append:class-nativesdk () {
290 if [ -e ${D}${libdir}/cmake/llvm/LLVMConfig.cmake ] ; then
291 sed -i -e "s|${B}/./bin/||g" ${D}${libdir}/cmake/llvm/LLVMConfig.cmake
292 fi
293 if ${@bb.utils.contains('PACKAGECONFIG', 'clangd', 'true', 'false', d)}; then
294 install -Dm 0755 ${B}${BINPATHPREFIX}/bin/clangd-indexer ${D}${bindir}/clangd-indexer
295 fi
296 install -Dm 0755 ${B}${BINPATHPREFIX}/bin/clang-tblgen ${D}${bindir}/clang-tblgen
297 install -Dm 0755 ${B}${BINPATHPREFIX}/bin/clang-tidy-confusable-chars-gen ${D}${bindir}/clang-tidy-confusable-chars-gen
298 for f in `find ${D}${bindir} -executable -type f -not -type l`; do
299 test -n "`file -b $f|grep -i ELF`" && ${STRIP} $f
300 done
301 ln -sf clang-tblgen ${D}${bindir}/clang-tblgen${PV}
302 ln -sf llvm-tblgen ${D}${bindir}/llvm-tblgen${PV}
303 ln -sf llvm-config ${D}${bindir}/llvm-config${PV}
304 rm -rf ${D}${datadir}/llvm/cmake
305 rm -rf ${D}${datadir}/llvm
306
307 #reproducibility
308 if [ -e ${D}${libdir}/cmake/llvm/LLVMConfig.cmake ] ; then
309 sed -i -e 's,${B},,g' ${D}${libdir}/cmake/llvm/LLVMConfig.cmake
310 fi
311}
312
313PROVIDES:append:class-native = " llvm-native libclc-native spirv-llvm-translator-native"
314PROVIDES:append:class-target = " llvm libclc spirv-llvm-translator"
315PROVIDES:append:class-nativesdk = " nativesdk-llvm nativesdk-libclc nativesdk-spirv-llvm-translator"
316
317PACKAGES =+ "${PN}-libllvm ${PN}-lldb-python ${PN}-libclang-cpp ${PN}-tidy ${PN}-format ${PN}-tools ${PN}-clc ${PN}-spirv \
318 libclang lldb lldb-server liblldb llvm-linker-tools"
319
320
321BBCLASSEXTEND = "native nativesdk"
322
323RDEPENDS:lldb += "${PN}-lldb-python lldb-server"
324
325RDEPENDS:${PN}-tools += "\
326 perl-module-digest-md5 \
327 perl-module-file-basename \
328 perl-module-file-copy \
329 perl-module-file-find \
330 perl-module-file-path \
331 perl-module-findbin \
332 perl-module-hash-util \
333 perl-module-sys-hostname \
334 perl-module-term-ansicolor \
335"
336
337RRECOMMENDS:${PN}-tidy += "${PN}-tools"
338
339FILES:llvm-linker-tools = "${libdir}/LLVMgold* ${libdir}/libLTO.so.* ${libdir}/LLVMPolly*"
340
341FILES:${PN}-libclang-cpp = "${libdir}/libclang-cpp.so.*"
342
343FILES:${PN}-lldb-python = "${libdir}/python*/site-packages/lldb/*"
344
345FILES:${PN}-tidy = "${bindir}/*clang-tidy*"
346FILES:${PN}-format = "${bindir}/*clang-format*"
347
348FILES:${PN}-tools = "${bindir}/analyze-build \
349 ${bindir}/c-index-test \
350 ${bindir}/clang-apply-replacements \
351 ${bindir}/clang-change-namespace \
352 ${bindir}/clang-check \
353 ${bindir}/clang-doc \
354 ${bindir}/clang-extdef-mapping \
355 ${bindir}/clang-include-fixer \
356 ${bindir}/clang-linker-wrapper \
357 ${bindir}/clang-move \
358 ${bindir}/clang-nvlink-wrapper \
359 ${bindir}/clang-offload-bundler \
360 ${bindir}/clang-offload-packager \
361 ${bindir}/clang-pseudo* \
362 ${bindir}/clang-query \
363 ${bindir}/clang-refactor \
364 ${bindir}/clang-rename* \
365 ${bindir}/clang-reorder-fields \
366 ${bindir}/clang-repl \
367 ${bindir}/clang-scan-deps \
368 ${bindir}/diagtool \
369 ${bindir}/find-all-symbols \
370 ${bindir}/hmaptool \
371 ${bindir}/hwasan_symbolize \
372 ${bindir}/intercept-build \
373 ${bindir}/modularize \
374 ${bindir}/pp-trace \
375 ${bindir}/sancov \
376 ${bindir}/scan-build \
377 ${bindir}/scan-build-py \
378 ${bindir}/scan-view \
379 ${bindir}/split-file \
380 ${libdir}/libscanbuild/* \
381 ${libdir}/libear/* \
382 ${libexecdir}/analyze-c++ \
383 ${libexecdir}/analyze-cc \
384 ${libexecdir}/c++-analyzer \
385 ${libexecdir}/ccc-analyzer \
386 ${libexecdir}/intercept-c++ \
387 ${libexecdir}/intercept-cc \
388 ${datadir}/scan-build/* \
389 ${datadir}/scan-view/* \
390 ${datadir}/opt-viewer/* \
391 ${datadir}/clang/* \
392"
393
394FILES:${PN} += "\
395 ${bindir}/clang-cl \
396 ${libdir}/BugpointPasses.so \
397 ${libdir}/LLVMHello.so \
398 ${libdir}/*Plugin.so \
399 ${libdir}/${BPN} \
400 ${nonarch_libdir}/${BPN}/*/include/ \
401"
402
403FILES:${PN}-clc += "${datadir}/clc"
404
405FILES:${PN}-spirv = " \
406 ${bindir}/llvm-spirv \
407 ${libdir}/libLLVMSPIRV.so.* \
408"
409
410FILES:lldb = "\
411 ${bindir}/lldb \
412 ${bindir}/lldb-argdumper \
413 ${bindir}/lldb-instr \
414 ${bindir}/lldb-vscode \
415"
416
417FILES:lldb-server = "\
418 ${bindir}/lldb-server \
419"
420
421FILES:liblldb = "\
422 ${libdir}/liblldbIntelFeatures.so.* \
423 ${libdir}/liblldb.so.* \
424"
425
426FILES:${PN}-libllvm =+ "\
427 ${libdir}/libLLVM.so.${MAJOR_VER}.${MINOR_VER} \
428 ${libdir}/libLLVM-${MAJOR_VER}.so \
429 ${libdir}/libRemarks.so.* \
430"
431
432FILES:libclang = "\
433 ${libdir}/libclang.so.* \
434"
435
436FILES:${PN}-dev += "\
437 ${datadir}/llvm/cmake \
438 ${libdir}/cmake \
439 ${nonarch_libdir}/libear \
440 ${nonarch_libdir}/${BPN}/*.la \
441"
442FILES:${PN}-doc += "${datadir}/clang-doc"
443
444FILES:${PN}-staticdev += "${nonarch_libdir}/${BPN}/*.a"
445
446FILES:${PN}-staticdev:remove = "${libdir}/${BPN}/*.a"
447FILES:${PN}-dev:remove = "${libdir}/${BPN}/*.la"
448FILES:${PN}:remove = "${libdir}/${BPN}/*"
449
450INSANE_SKIP:${PN} += "already-stripped"
451#INSANE_SKIP:${PN}-dev += "dev-elf"
452INSANE_SKIP:${PN}-lldb-python += "dev-so dev-deps"
453INSANE_SKIP:${MLPREFIX}liblldb = "dev-so"
454INSANE_SKIP:${PN}-libllvm = "dev-so"
455
456# SPIRV-LLVM-Translator provides only static libraries, they are included into
457# the clang-spirv package.
458INSANE_SKIP:${PN}-spirv += "dev-so"
459
460#Avoid SSTATE_SCAN_COMMAND running sed over llvm-config.
461SSTATE_SCAN_FILES:remove = "*-config"
462
463COMPILER_RT:class-nativesdk:toolchain-clang:runtime-llvm = "-rtlib=libgcc --unwindlib=libgcc"
464LIBCPLUSPLUS:class-nativesdk:toolchain-clang:runtime-llvm = "-stdlib=libstdc++"
465
466SYSROOT_DIRS:append:class-target = " ${nonarch_libdir}"
467
468SYSROOT_PREPROCESS_FUNCS:append:class-target = " clang_sysroot_preprocess"
469SYSROOT_PREPROCESS_FUNCS:append:class-nativesdk = " clang_sysroot_preprocess"
470
471clang_sysroot_preprocess() {
472 install -d ${SYSROOT_DESTDIR}${bindir_crossscripts}/
473 install -m 0755 ${S}/llvm/tools/llvm-config/llvm-config ${SYSROOT_DESTDIR}${bindir_crossscripts}/
474 ln -sf llvm-config ${SYSROOT_DESTDIR}${bindir_crossscripts}/llvm-config${PV}
475 # LLDTargets.cmake references the lld executable(!) that some modules/plugins link to
476 install -d ${SYSROOT_DESTDIR}${bindir}
477
478 binaries="lld diagtool clang-${MAJOR_VER} clang-format clang-offload-packager
479 clang-offload-bundler clang-scan-deps clang-repl
480 clang-refactor clang-check clang-extdef-mapping clang-apply-replacements
481 clang-reorder-fields clang-tidy clang-change-namespace clang-doc clang-include-fixer
482 find-all-symbols clang-move clang-query pp-trace modularize"
483
484 if ${@bb.utils.contains('PACKAGECONFIG', 'clangd', 'true', 'false', d)}; then
485 binaries="${binaries} clangd"
486 fi
487
488 for f in ${binaries}
489 do
490 install -m 755 ${D}${bindir}/$f ${SYSROOT_DESTDIR}${bindir}/
491 done
492}
diff --git a/meta/recipes-devtools/clang/common-clang.inc b/meta/recipes-devtools/clang/common-clang.inc
new file mode 100644
index 0000000000..bb152d2c56
--- /dev/null
+++ b/meta/recipes-devtools/clang/common-clang.inc
@@ -0,0 +1,24 @@
1LLVM_RELEASE = ""
2LLVM_DIR = "llvm${LLVM_RELEASE}"
3
4LLVM_HTTP ?= "https://github.com/llvm"
5
6MAJOR_VER = "20"
7MINOR_VER = "1"
8PATCH_VER = "2"
9# could be 'rcX' or 'git' or empty ( for release )
10VER_SUFFIX = ""
11
12PV = "${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}${VER_SUFFIX}"
13
14LLVMMD5SUM = "8a15a0759ef07f2682d2ba4b893c9afe"
15CLANGMD5SUM = "ff42885ed2ab98f1ecb8c1fc41205343"
16LLDMD5SUM = "ae7dc7c027b1fa89b5b013d391d3ee2b"
17LLDBMD5SUM = "2e0d44968471fcde980034dbb826bea9"
18
19LLVM_LIBDIR_SUFFIX = "${@d.getVar('baselib').replace('lib', '')}"
20
21# set the default pigz thread
22export PIGZ = "-p ${@oe.utils.cpu_count(at_least=2)}"
23
24require common.inc
diff --git a/meta/recipes-devtools/clang/common-source.inc b/meta/recipes-devtools/clang/common-source.inc
new file mode 100644
index 0000000000..d8a0f68175
--- /dev/null
+++ b/meta/recipes-devtools/clang/common-source.inc
@@ -0,0 +1,17 @@
1do_fetch() {
2 :
3}
4do_fetch[noexec] = "1"
5deltask do_unpack
6deltask do_patch
7
8SRC_URI = ""
9
10do_configure[depends] += "llvm-project-source-${PV}:do_preconfigure"
11do_populate_lic[depends] += "llvm-project-source-${PV}:do_unpack"
12do_create_spdx[depends] += "llvm-project-source-${PV}:do_preconfigure"
13
14# spdx shared workdir detection fails as not WORKDIR is altered but S and B
15# return always true to fix that
16def is_work_shared_spdx(d):
17 return True
diff --git a/meta/recipes-devtools/clang/common.inc b/meta/recipes-devtools/clang/common.inc
new file mode 100644
index 0000000000..5a1fa0bacf
--- /dev/null
+++ b/meta/recipes-devtools/clang/common.inc
@@ -0,0 +1,83 @@
1FILESEXTRAPATHS =. "${FILE_DIRNAME}/clang:"
2
3LIC_FILES_CHKSUM = "file://llvm/LICENSE.TXT;md5=${LLVMMD5SUM} \
4 file://clang/LICENSE.TXT;md5=${CLANGMD5SUM} \
5"
6LICENSE = "Apache-2.0-with-LLVM-exception"
7
8# Snapshot
9#RELEASE ?= "a69568efe6c4972e71af295c6577b3412dd57c22"
10#BASEURI ?= "https://api.github.com/repos/llvm/llvm-project/tarball/${RELEASE};downloadfilename=llvm-${PV}-${RELEASE}.tar.gz"
11#SOURCEDIR ?= "llvm-llvm-project-${@'${RELEASE}'[0:7]}"
12#SRC_URI[sha256sum] = "aed4f66cd72867b36cc55a0588436933c3d58d3e61ca782b6bf57605d3fdcb09"
13
14# GA Release
15RELEASE ?= "${PV}"
16BASEURI ?= "${LLVM_HTTP}/llvm-project/releases/download/llvmorg-${PV}/llvm-project-${PV}.src.tar.xz"
17SOURCEDIR ?= "llvm-project-${PV}.src"
18SRC_URI[sha256sum] = "f0a4a240aabc9b056142d14d5478bb6d962aeac549cbd75b809f5499240a8b38"
19
20SRCREV_spirv = "6dd8f2a1681a27f16c53d932d2765920f312aeb2"
21SRCREV_spirvheaders = "09913f088a1197aba4aefd300a876b2ebbaa3391"
22SRCREV_FORMAT .= "spirv_spirvheaders"
23# pattern: llvm_branch_200, currently there are no minor releases, so, no llvm_branch_201
24SPIRV_BRANCH = "llvm_release_${@oe.utils.trim_version('${PV}', 1).replace('.', '')}0"
25SPIRVURI = " \
26 git://github.com/KhronosGroup/SPIRV-LLVM-Translator;protocol=https;name=spirv;branch=${SPIRV_BRANCH};destsuffix=llvm-project-${PV}.src/llvm/projects/SPIRV-LLVM-Translator \
27 git://github.com/KhronosGroup/SPIRV-Headers;protocol=https;destsuffix=llvm-project-${PV}.src/llvm/projects/SPIRV-LLVM-Translator/SPIRV-Headers;name=spirvheaders;branch=main \
28 file://spirv-internal-build.patch \
29 file://spirv-shared-library.patch \
30"
31
32SRC_URI = "\
33 ${BASEURI} \
34 ${SPIRVURI} \
35 file://0001-libcxxabi-Find-libunwind-headers-when-LIBCXXABI_LIBU.patch \
36 file://0002-compiler-rt-support-a-new-embedded-linux-target.patch \
37 file://0003-compiler-rt-Simplify-cross-compilation.-Don-t-use-na.patch \
38 file://0004-llvm-TargetLibraryInfo-Undefine-libc-functions-if-th.patch \
39 file://0005-llvm-allow-env-override-of-exe-and-libdir-path.patch \
40 file://0006-clang-driver-Check-sysroot-for-ldso-path.patch \
41 file://0007-clang-Driver-tools.cpp-Add-lssp_nonshared-on-musl.patch \
42 file://0008-clang-Prepend-trailing-to-sysroot.patch \
43 file://0009-clang-Look-inside-the-target-sysroot-for-compiler-ru.patch \
44 file://0010-clang-Define-releative-gcc-installation-dir.patch \
45 file://0011-clang-Add-lpthread-and-ldl-along-with-lunwind-for-st.patch \
46 file://0012-Pass-PYTHON_EXECUTABLE-when-cross-compiling-for-nati.patch \
47 file://0013-Check-for-atomic-double-intrinsics.patch \
48 file://0014-cmake-Fix-configure-for-packages-using-find_package.patch \
49 file://0015-clang-Fix-resource-dir-location-for-cross-toolchains.patch \
50 file://0016-clang-driver-Add-dyld-prefix-when-checking-sysroot-f.patch \
51 file://0017-clang-Use-python3-in-python-scripts.patch \
52 file://0018-llvm-clang-Insert-anchor-for-adding-OE-distro-vendor.patch \
53 file://0019-compiler-rt-Do-not-use-backtrace-APIs-on-non-glibc-l.patch \
54 file://0020-clang-Fix-x86-triple-for-non-debian-multiarch-linux-.patch \
55 file://0021-libunwind-Added-unw_backtrace-method.patch \
56 file://0022-lldb-Link-with-libatomic-on-x86.patch \
57 file://0023-compiler-rt-Enable-__int128-for-ppc32.patch \
58 file://0024-llvm-Do-not-use-cmake-infra-to-detect-libzstd.patch \
59 file://0025-compiler-rt-Fix-stat-struct-s-size-for-O32-ABI.patch \
60 file://0026-compiler-rt-Undef-_TIME_BITS-along-with-_FILE_OFFSET.patch \
61 file://0027-ToolChains-Gnu.cpp-ARMLibDirs-search-also-in-lib32.patch \
62 file://0028-clang-llvm-Add-OE-specific-ABI-triple-for-N32-ABI.patch \
63 file://0029-llvm-Add-libunwind.pc.in-and-llvm-config-scripts.patch \
64 file://0030-scan-build-py-respect-LLVM_LIBDIR_SUFFIX-like-other-.patch \
65 file://0031-compiler-rt-Do-not-pass-target-to-clang-compiler.patch \
66 file://0032-Fix-build-on-ppc64-musl.patch \
67 file://0033-clangd-Add-a-build-option-to-disable-building-dexp.patch \
68 file://0034-AsmMatcherEmitter-sort-ClassInfo-lists-by-name-as-we.patch \
69 file://0035-llvm-config-remove-LLVM_LDFLAGS-from-ldflags-output.patch \
70 file://0036-openmp-Do-not-emit-date-and-time-into-generate-files.patch \
71"
72# Fallback to no-PIE if not set
73GCCPIE ??= ""
74
75S = "${TMPDIR}/work-shared/llvm-project-source-${PV}-${PR}/${SOURCEDIR}"
76B ?= "${WORKDIR}/llvm-project-source-${PV}/build.${HOST_SYS}.${TARGET_SYS}"
77
78# We need to ensure that for the shared work directory, the do_patch signatures match
79# The real WORKDIR location isn't a dependency for the shared workdir.
80src_patches[vardepsexclude] = "WORKDIR"
81should_apply[vardepsexclude] += "PN"
82
83BPN = "clang"
diff --git a/meta/recipes-devtools/clang/compiler-rt-sanitizers_git.bb b/meta/recipes-devtools/clang/compiler-rt-sanitizers_git.bb
new file mode 100644
index 0000000000..b3c4bfcffd
--- /dev/null
+++ b/meta/recipes-devtools/clang/compiler-rt-sanitizers_git.bb
@@ -0,0 +1,131 @@
1# Copyright (C) 2021 Khem Raj <raj.khem@gmail.com>
2# Released under the MIT license (see COPYING.MIT for the terms)
3
4SUMMARY = "LLVM based C/C++ compiler Sanitizers Runtime"
5DESCRIPTION = "Runtime libraries that are required \
6 to run the code with sanitizer instrumentation"
7HOMEPAGE = "http://compiler-rt.llvm.org/"
8SECTION = "base"
9
10require common-clang.inc
11require common-source.inc
12
13BPN = "compiler-rt-sanitizers"
14
15inherit cmake pkgconfig python3native
16
17
18LIC_FILES_CHKSUM = "file://compiler-rt/LICENSE.TXT;md5=d846d1d65baf322d4c485d6ee54e877a"
19
20TUNE_CCARGS:remove = "-no-integrated-as"
21
22CC = "${CCACHE}${HOST_PREFIX}clang ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}"
23CXX = "${CCACHE}${HOST_PREFIX}clang++ ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}"
24
25DEPENDS += "ninja-native virtual/crypt compiler-rt"
26DEPENDS:append:class-native = " clang-native libxcrypt-native libcxx-native"
27DEPENDS:append:class-nativesdk = " virtual/cross-c++ clang-native clang-crosssdk-${SDK_SYS} nativesdk-libxcrypt nativesdk-gcc-runtime"
28DEPENDS:append:class-target = " virtual/cross-c++ clang-cross-${TARGET_ARCH} virtual/${MLPREFIX}libc gcc-runtime"
29
30PACKAGECONFIG ??= ""
31PACKAGECONFIG[crt] = "-DCOMPILER_RT_BUILD_CRT:BOOL=ON,-DCOMPILER_RT_BUILD_CRT:BOOL=OFF"
32PACKAGECONFIG[static-libcxx] = "-DSANITIZER_USE_STATIC_CXX_ABI=ON -DSANITIZER_USE_STATIC_LLVM_UNWINDER=ON -DCOMPILER_RT_ENABLE_STATIC_UNWINDER=ON,,"
33# Context Profiling
34PACKAGECONFIG[ctx-profile] = "-DCOMPILER_RT_BUILD_CTX_PROFILE=ON,-DCOMPILER_RT_BUILD_CTX_PROFILE=OFF"
35
36CXXFLAGS:append:libc-musl = " -D_LARGEFILE64_SOURCE"
37
38OECMAKE_TARGET_COMPILE = "compiler-rt"
39OECMAKE_TARGET_INSTALL = "install-compiler-rt install-compiler-rt-headers"
40OECMAKE_SOURCEPATH = "${S}/llvm"
41EXTRA_OECMAKE += "-DCMAKE_BUILD_TYPE=RelWithDebInfo \
42 -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF \
43 -DCOMPILER_RT_STANDALONE_BUILD=ON \
44 -DCOMPILER_RT_USE_BUILTINS_LIBRARY=ON \
45 -DCOMPILER_RT_BUILD_BUILTINS=OFF \
46 -DCOMPILER_RT_INCLUDE_TESTS=OFF \
47 -DSANITIZER_CXX_ABI_LIBNAME=${@bb.utils.contains("TC_CXX_RUNTIME", "llvm", "libc++", "libstdc++", d)} \
48 -DCOMPILER_RT_BUILD_XRAY=ON \
49 -DCOMPILER_RT_BUILD_SANITIZERS=ON \
50 -DCOMPILER_RT_BUILD_LIBFUZZER=ON \
51 -DCOMPILER_RT_BUILD_PROFILE=ON \
52 -DCOMPILER_RT_BUILD_MEMPROF=ON \
53 -DLLVM_ENABLE_RUNTIMES='compiler-rt' \
54 -DLLVM_LIBDIR_SUFFIX=${LLVM_LIBDIR_SUFFIX} \
55 -DLLVM_APPEND_VC_REV=OFF \
56 -S ${S}/runtimes \
57"
58
59EXTRA_OECMAKE:append:class-native = "\
60 -DCOMPILER_RT_USE_BUILTINS_LIBRARY=OFF \
61 -DCMAKE_C_COMPILER_TARGET=${HOST_ARCH}${HOST_VENDOR}-${HOST_OS} \
62 -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON \
63 -DCOMPILER_RT_DEFAULT_TARGET_ARCH=${HOST_ARCH} \
64"
65
66EXTRA_OECMAKE:append:class-target = "\
67 -DCMAKE_RANLIB=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-ranlib \
68 -DCMAKE_AR=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-ar \
69 -DCMAKE_NM=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-nm \
70 -DCMAKE_C_COMPILER_TARGET=${HOST_ARCH}${HOST_VENDOR}-${HOST_OS} \
71 -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON \
72 -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
73"
74
75EXTRA_OECMAKE:append:class-nativesdk = "\
76 -DCMAKE_RANLIB=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-ranlib \
77 -DCMAKE_AR=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-ar \
78 -DCMAKE_NM=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-nm \
79 -DLLVM_TABLEGEN=${STAGING_BINDIR_NATIVE}/llvm-tblgen \
80 -DCLANG_TABLEGEN=${STAGING_BINDIR_NATIVE}/clang-tblgen \
81 -DCMAKE_C_COMPILER_TARGET=${HOST_ARCH}${HOST_VENDOR}-${HOST_OS} \
82 -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON \
83"
84
85EXTRA_OECMAKE:append:libc-musl = " -DLIBCXX_HAS_MUSL_LIBC=ON "
86EXTRA_OECMAKE:append:powerpc = " -DCOMPILER_RT_DEFAULT_TARGET_ARCH=powerpc "
87
88do_install:append () {
89 mkdir -p ${D}${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/lib
90 mv ${D}${nonarch_libdir}/linux ${D}${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/lib
91 # Already shipped with compile-rt Orc support
92 rm -rf ${D}${nonarch_libdir}/clang/${MAJOR_VER}/lib/linux/liborc_rt-*.a
93 rm -rf ${D}${nonarch_libdir}/clang/${MAJOR_VER}/include/orc/
94}
95
96FILES_SOLIBSDEV = ""
97FILES:${PN} += "${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER} \
98 ${nonarch_libdir}/clang/${MAJOR_VER}/lib/linux/lib*${SOLIBSDEV} \
99 ${nonarch_libdir}/clang/${MAJOR_VER}/*.txt \
100 ${nonarch_libdir}/clang/${MAJOR_VER}/share/*.txt"
101FILES:${PN}-staticdev += "${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/lib/linux/*.a"
102FILES:${PN}-dev += "${datadir} ${nonarch_libdir}/clang/${MAJOR_VER}/lib/linux/*.syms \
103 ${nonarch_libdir}/clang/${MAJOR_VER}/include \
104 ${nonarch_libdir}/clang/${MAJOR_VER}/lib/linux/clang_rt.crt*.o \
105 ${nonarch_libdir}/clang/${MAJOR_VER}/lib/linux/libclang_rt.asan-preinit*.a"
106INSANE_SKIP:${PN} = "dev-so libdir"
107INSANE_SKIP:${PN}-dbg = "libdir"
108
109#PROVIDES:append:class-target = "\
110# virtual/${MLPREFIX}compilerlibs \
111# libgcc \
112# libgcc-initial \
113# libgcc-dev \
114# libgcc-initial-dev \
115# "
116#
117
118RDEPENDS:${PN}-dev += "${PN}-staticdev"
119
120BBCLASSEXTEND = "native nativesdk"
121
122ALLOW_EMPTY:${PN} = "1"
123ALLOW_EMPTY:${PN}-dev = "1"
124
125SYSROOT_DIRS:append:class-target = " ${nonarch_libdir}"
126
127# riscv and x86_64 Sanitizers work on musl too
128COMPATIBLE_HOST:libc-musl:x86-64 = "(.*)"
129COMPATIBLE_HOST:libc-musl:riscv64 = "(.*)"
130COMPATIBLE_HOST:libc-musl:riscv32 = "(.*)"
131COMPATIBLE_HOST:libc-musl = "null"
diff --git a/meta/recipes-devtools/clang/compiler-rt_git.bb b/meta/recipes-devtools/clang/compiler-rt_git.bb
new file mode 100644
index 0000000000..9392854127
--- /dev/null
+++ b/meta/recipes-devtools/clang/compiler-rt_git.bb
@@ -0,0 +1,121 @@
1# Copyright (C) 2015 Khem Raj <raj.khem@gmail.com>
2# Released under the MIT license (see COPYING.MIT for the terms)
3
4SUMMARY = "LLVM based C/C++ compiler Runtime"
5DESCRIPTIOM = "Simple builtin library that provides an \
6 implementation of the low-level target-specific \
7 hooks required by code generation and other runtime \
8 components"
9HOMEPAGE = "http://compiler-rt.llvm.org/"
10SECTION = "base"
11
12require common-clang.inc
13require common-source.inc
14
15BPN = "compiler-rt"
16
17inherit cmake pkgconfig python3native
18
19
20LIC_FILES_CHKSUM = "file://compiler-rt/LICENSE.TXT;md5=d846d1d65baf322d4c485d6ee54e877a"
21
22LIBCPLUSPLUS = ""
23COMPILER_RT = ""
24
25TUNE_CCARGS:remove = "-no-integrated-as"
26
27INHIBIT_DEFAULT_DEPS = "1"
28
29DEPENDS += "ninja-native libgcc"
30DEPENDS:append:class-target = " virtual/cross-c++ clang-cross-${TARGET_ARCH} virtual/${MLPREFIX}libc gcc-runtime"
31DEPENDS:append:class-nativesdk = " virtual/cross-c++ clang-native clang-crosssdk-${SDK_SYS} nativesdk-gcc-runtime"
32DEPENDS:append:class-native = " clang-native"
33
34# Trick clang.bbclass into not creating circular dependencies
35UNWINDLIB:class-nativesdk:toolchain-clang = "--unwindlib=libgcc"
36COMPILER_RT:class-nativesdk:toolchain-clang = "-rtlib=libgcc --unwindlib=libgcc"
37LIBCPLUSPLUS:class-nativesdk:toolchain-clang = "-stdlib=libstdc++"
38UNWINDLIB:class-native:toolchain-clang = "--unwindlib=libgcc"
39COMPILER_RT:class-native:toolchain-clang = "-rtlib=libgcc --unwindlib=libgcc"
40LIBCPLUSPLUS:class-native:toolchain-clang = "-stdlib=libstdc++"
41UNWINDLIB:class-target:toolchain-clang = "--unwindlib=libgcc"
42COMPILER_RT:class-target:toolchain-clang = "-rtlib=libgcc --unwindlib=libgcc"
43LIBCPLUSPLUS:class-target:toolchain-clang = "-stdlib=libstdc++"
44
45PACKAGECONFIG ??= ""
46PACKAGECONFIG[crt] = "-DCOMPILER_RT_BUILD_CRT:BOOL=ON,-DCOMPILER_RT_BUILD_CRT:BOOL=OFF"
47PACKAGECONFIG[profile] = "-DCOMPILER_RT_BUILD_PROFILE=ON,-DCOMPILER_RT_BUILD_PROFILE=OFF"
48# Context Profiling, might need to enable 'profile' too
49PACKAGECONFIG[ctx-profile] = "-DCOMPILER_RT_BUILD_CTX_PROFILE=ON,-DCOMPILER_RT_BUILD_CTX_PROFILE=OFF"
50
51HF = ""
52HF:class-target = "${@ bb.utils.contains('TUNE_CCARGS_MFLOAT', 'hard', 'hf', '', d)}"
53HF[vardepvalue] = "${HF}"
54
55OECMAKE_TARGET_COMPILE = "compiler-rt"
56OECMAKE_TARGET_INSTALL = "install-compiler-rt install-compiler-rt-headers"
57OECMAKE_SOURCEPATH = "${S}/llvm"
58EXTRA_OECMAKE += "-DCMAKE_BUILD_TYPE=RelWithDebInfo \
59 -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF \
60 -DCOMPILER_RT_STANDALONE_BUILD=ON \
61 -DCOMPILER_RT_INCLUDE_TESTS=OFF \
62 -DCOMPILER_RT_BUILD_XRAY=OFF \
63 -DCOMPILER_RT_BUILD_SANITIZERS=OFF \
64 -DCOMPILER_RT_BUILD_MEMPROF=OFF \
65 -DCOMPILER_RT_BUILD_LIBFUZZER=OFF \
66 -DLLVM_ENABLE_RUNTIMES='compiler-rt' \
67 -DLLVM_LIBDIR_SUFFIX=${LLVM_LIBDIR_SUFFIX} \
68 -DLLVM_APPEND_VC_REV=OFF \
69 -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON \
70 -S ${S}/runtimes \
71"
72
73EXTRA_OECMAKE:append:class-native = "\
74 -DCOMPILER_RT_DEFAULT_TARGET_ARCH=${HOST_ARCH} \
75 -DCMAKE_C_COMPILER_TARGET=${HOST_ARCH} \
76"
77
78EXTRA_OECMAKE:append:class-target = "\
79 -DCMAKE_RANLIB=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-ranlib \
80 -DCMAKE_AR=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-ar \
81 -DCMAKE_NM=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-nm \
82 -DCMAKE_C_COMPILER_TARGET=${HOST_ARCH}${HOST_VENDOR}-${HOST_OS}${HF} \
83 -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
84"
85
86EXTRA_OECMAKE:append:class-nativesdk = "\
87 -DCMAKE_RANLIB=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-ranlib \
88 -DCMAKE_AR=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-ar \
89 -DCMAKE_NM=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-nm \
90 -DLLVM_TABLEGEN=${STAGING_BINDIR_NATIVE}/llvm-tblgen \
91 -DCLANG_TABLEGEN=${STAGING_BINDIR_NATIVE}/clang-tblgen \
92 -DCMAKE_C_COMPILER_TARGET=${HOST_ARCH}${HOST_VENDOR}-${HOST_OS}${HF} \
93"
94EXTRA_OECMAKE:append:powerpc = " -DCOMPILER_RT_DEFAULT_TARGET_ARCH=powerpc "
95
96do_install:append () {
97 mkdir -p ${D}${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/lib
98 mv ${D}${nonarch_libdir}/linux ${D}${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/lib
99}
100
101FILES_SOLIBSDEV = ""
102
103FILES:${PN} += "${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/lib/linux/lib*${SOLIBSDEV} \
104 ${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/*.txt \
105 ${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/share/*.txt"
106FILES:${PN}-staticdev += "${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/lib/linux/*.a"
107FILES:${PN}-dev += "${datadir} ${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/lib/linux/*.syms \
108 ${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/include \
109 ${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/lib/linux/clang_rt.crt*.o \
110 ${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/lib/linux/libclang_rt.asan-preinit*.a"
111
112INSANE_SKIP:${PN} = "dev-so libdir"
113INSANE_SKIP:${PN}-dbg = "libdir"
114
115RDEPENDS:${PN}-dev += "${PN}-staticdev"
116
117BBCLASSEXTEND = "native nativesdk"
118
119ALLOW_EMPTY:${PN} = "1"
120
121SYSROOT_DIRS:append:class-target = " ${nonarch_libdir}"
diff --git a/meta/recipes-devtools/clang/libcxx_git.bb b/meta/recipes-devtools/clang/libcxx_git.bb
new file mode 100644
index 0000000000..d2655d9da9
--- /dev/null
+++ b/meta/recipes-devtools/clang/libcxx_git.bb
@@ -0,0 +1,115 @@
1# Copyright (C) 2015 Khem Raj <raj.khem@gmail.com>
2# Released under the MIT license (see COPYING.MIT for the terms)
3
4SUMMARY = "libc++ is a new implementation of the C++ standard library, targeting C++11 and above"
5HOMEPAGE = "http://libcxx.llvm.org/"
6SECTION = "base"
7
8require common-clang.inc
9require common-source.inc
10
11inherit cmake python3native
12
13BPN = "libcxx"
14
15PACKAGECONFIG ??= "compiler-rt exceptions ${@bb.utils.contains("TC_CXX_RUNTIME", "llvm", "unwind unwind-shared", "", d)}"
16PACKAGECONFIG:append:armv5 = " no-atomics"
17PACKAGECONFIG:remove:class-native = "compiler-rt"
18PACKAGECONFIG[unwind] = "-DLIBCXXABI_USE_LLVM_UNWINDER=ON -DLIBCXXABI_ENABLE_STATIC_UNWINDER=ON,-DLIBCXXABI_USE_LLVM_UNWINDER=OFF,,"
19PACKAGECONFIG[exceptions] = "-DLIBCXXABI_ENABLE_EXCEPTIONS=ON -DLIBCXX_ENABLE_EXCEPTIONS=ON,-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF -DLIBCXX_ENABLE_EXCEPTIONS=OFF -DCMAKE_REQUIRED_FLAGS='-fno-exceptions',"
20PACKAGECONFIG[no-atomics] = "-D_LIBCXXABI_HAS_ATOMIC_BUILTINS=OFF -DCMAKE_SHARED_LINKER_FLAGS='-latomic',,"
21PACKAGECONFIG[compiler-rt] = "-DLIBCXX_USE_COMPILER_RT=ON -DLIBCXXABI_USE_COMPILER_RT=ON -DLIBUNWIND_USE_COMPILER_RT=ON,,compiler-rt"
22PACKAGECONFIG[unwind-shared] = "-DLIBUNWIND_ENABLE_SHARED=ON,-DLIBUNWIND_ENABLE_SHARED=OFF,,"
23
24DEPENDS += "ninja-native"
25DEPENDS:append:class-target = " virtual/cross-c++ clang-cross-${TARGET_ARCH} virtual/${MLPREFIX}libc virtual/${MLPREFIX}compilerlibs"
26DEPENDS:append:class-nativesdk = " virtual/cross-c++ clang-crosssdk-${SDK_SYS} nativesdk-compiler-rt"
27DEPENDS:append:class-native = " clang-native compiler-rt-native"
28
29COMPILER_RT ?= "${@bb.utils.contains("PACKAGECONFIG", "compiler-rt", "-rtlib=compiler-rt", "-rtlib=libgcc", d)}"
30UNWINDLIB ?= "${@bb.utils.contains("PACKAGECONFIG", "unwind", "-unwindlib=none", "-unwindlib=libgcc", d)}"
31LIBCPLUSPLUS ?= "-stdlib=libstdc++"
32# Trick clang.bbclass into not creating circular dependencies
33UNWINDLIB:class-nativesdk = "-unwindlib=libgcc"
34LIBCPLUSPLUS:class-nativesdk = "-stdlib=libstdc++"
35UNWINDLIB:class-native = "-unwindlib=libgcc"
36LIBCPLUSPLUS:class-native = "-stdlib=libstdc++"
37
38LDFLAGS:append = " ${UNWINDLIB}"
39
40INHIBIT_DEFAULT_DEPS = "1"
41
42LIC_FILES_CHKSUM = "file://libcxx/LICENSE.TXT;md5=55d89dd7eec8d3b4204b680e27da3953 \
43 file://libcxxabi/LICENSE.TXT;md5=7b9334635b542c56868400a46b272b1e \
44 file://libunwind/LICENSE.TXT;md5=f66970035d12f196030658b11725e1a1 \
45"
46
47OECMAKE_TARGET_COMPILE = "${@bb.utils.contains("TC_CXX_RUNTIME", "llvm", "unwind", "", d)} cxxabi cxx"
48OECMAKE_TARGET_INSTALL = "${@bb.utils.contains("TC_CXX_RUNTIME", "llvm", "install-unwind", "", d)} install-cxxabi install-cxx"
49
50CC = "${CCACHE}${HOST_PREFIX}clang ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}"
51CXX = "${CCACHE}${HOST_PREFIX}clang++ ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}"
52OECMAKE_SOURCEPATH = "${S}/llvm"
53EXTRA_OECMAKE += "\
54 -DCMAKE_BUILD_TYPE=RelWithDebInfo \
55 -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF \
56 -DCMAKE_CROSSCOMPILING=ON \
57 -DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN=ON \
58 -DLLVM_ENABLE_RTTI=ON \
59 -DLIBUNWIND_ENABLE_CROSS_UNWINDING=ON \
60 -DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON \
61 -DLIBCXXABI_INCLUDE_TESTS=OFF \
62 -DLIBCXXABI_ENABLE_SHARED=ON \
63 -DLIBCXXABI_LIBCXX_INCLUDES=${S}/libcxx/include \
64 -DLIBCXX_CXX_ABI=libcxxabi \
65 -DLIBCXX_CXX_ABI_INCLUDE_PATHS=${S}/libcxxabi/include \
66 -DLIBCXX_CXX_ABI_LIBRARY_PATH=${B}/lib${LLVM_LIBDIR_SUFFIX} \
67 -S ${S}/runtimes \
68 -DLLVM_ENABLE_RUNTIMES='libcxx;libcxxabi;libunwind' \
69 -DLLVM_RUNTIME_TARGETS=${HOST_SYS} \
70 -DLLVM_LIBDIR_SUFFIX=${LLVM_LIBDIR_SUFFIX} \
71 -DLLVM_APPEND_VC_REV=OFF \
72 -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
73"
74
75EXTRA_OECMAKE:append:class-target = " \
76 -DCMAKE_AR=${STAGING_BINDIR_TOOLCHAIN}/${AR} \
77 -DCMAKE_NM=${STAGING_BINDIR_TOOLCHAIN}/${NM} \
78 -DCMAKE_RANLIB=${STAGING_BINDIR_TOOLCHAIN}/${RANLIB} \
79 -DLLVM_DEFAULT_TARGET_TRIPLE=${HOST_SYS} \
80 -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
81"
82
83EXTRA_OECMAKE:append:class-nativesdk = " \
84 -DCMAKE_AR=${STAGING_BINDIR_TOOLCHAIN}/${AR} \
85 -DCMAKE_NM=${STAGING_BINDIR_TOOLCHAIN}/${NM} \
86 -DCMAKE_RANLIB=${STAGING_BINDIR_TOOLCHAIN}/${RANLIB} \
87 -DLLVM_DEFAULT_TARGET_TRIPLE=${HOST_SYS} \
88"
89
90EXTRA_OECMAKE:append:libc-musl = " -DLIBCXX_HAS_MUSL_LIBC=ON "
91
92CXXFLAGS:append:armv5 = " -mfpu=vfp2"
93
94ALLOW_EMPTY:${PN} = "1"
95
96PROVIDES:append:runtime-llvm = " libunwind"
97
98do_install:append() {
99 if ${@bb.utils.contains("TC_CXX_RUNTIME", "llvm", "true", "false", d)}
100 then
101 for f in libunwind.h __libunwind_config.h unwind.h unwind_itanium.h unwind_arm_ehabi.h
102 do
103 install -Dm 0644 ${S}/libunwind/include/$f ${D}${includedir}/$f
104 done
105 install -d ${D}${libdir}/pkgconfig
106 sed -e 's,@LIBDIR@,${libdir},g;s,@VERSION@,${PV},g' ${S}/libunwind/libunwind.pc.in > ${D}${libdir}/pkgconfig/libunwind.pc
107 fi
108}
109
110PACKAGES:append:runtime-llvm = " libunwind"
111FILES:libunwind:runtime-llvm = "${libdir}/libunwind.so.*"
112# Package library module manifest path
113FILES:${PN}-dev += "${datadir}/libc++/v1/ ${libdir}/libc++.modules.json"
114
115BBCLASSEXTEND = "native nativesdk"
diff --git a/meta/recipes-devtools/clang/llvm-project-source.bb b/meta/recipes-devtools/clang/llvm-project-source.bb
new file mode 100644
index 0000000000..ba945fb591
--- /dev/null
+++ b/meta/recipes-devtools/clang/llvm-project-source.bb
@@ -0,0 +1,12 @@
1# Copyright (C) 2018 Khem Raj <raj.khem@gmail.com>
2# Released under the MIT license (see COPYING.MIT for the terms)
3
4SUMMARY = "This is the canonical git mirror of the LLVM subversion repository."
5HOMEPAGE = "https://github.com/llvm/llvm-project"
6
7require llvm-project-source.inc
8require common-clang.inc
9
10BPN = "llvm-project-source"
11
12EXCLUDE_FROM_WORLD = "1"
diff --git a/meta/recipes-devtools/clang/llvm-project-source.inc b/meta/recipes-devtools/clang/llvm-project-source.inc
new file mode 100644
index 0000000000..0820dd3492
--- /dev/null
+++ b/meta/recipes-devtools/clang/llvm-project-source.inc
@@ -0,0 +1,99 @@
1deltask do_configure
2deltask do_compile
3deltask do_install
4deltask do_populate_sysroot
5deltask do_populate_lic
6RM_WORK_EXCLUDE += "${PN}"
7
8inherit nopackages
9
10PN = "llvm-project-source-${PV}"
11WORKDIR = "${TMPDIR}/work-shared/llvm-project-source-${PV}-${PR}"
12SSTATE_SWSPEC = "sstate:llvm-project-source::${PV}:${PR}::${SSTATE_VERSION}:"
13
14STAMP = "${STAMPS_DIR}/work-shared/llvm-project-source-${PV}-${PR}"
15STAMPCLEAN = "${STAMPS_DIR}/work-shared/llvm-project-source-${PV}-*"
16
17INHIBIT_DEFAULT_DEPS = "1"
18DEPENDS = ""
19PACKAGES = ""
20TARGET_ARCH = "allarch"
21TARGET_AS_ARCH = "none"
22TARGET_CC_ARCH = "none"
23TARGET_LD_ARCH = "none"
24TARGET_OS = "linux"
25baselib = "lib"
26PACKAGE_ARCH = "all"
27
28B = "${WORKDIR}/build"
29
30# space separated list of additional distro vendor values we want to support e.g.
31# "yoe webos" or "-yoe -webos" '-' is optional
32CLANG_EXTRA_OE_VENDORS ?= "${TARGET_VENDOR} ${SDK_VENDOR}"
33# Extra OE DISTRO that want to support as build host. space separated list of additional distro.
34# ":" separated the ID in "/etc/os-release" and the triple for finding gcc on this OE DISTRO.
35# eg: "poky:poky wrlinux:wrs"
36CLANG_EXTRA_OE_DISTRO ?= "poky:poky"
37# Match with MULTILIB_GLOBAL_VARIANTS
38ML_VARIANTS = "lib32 lib64 libx32"
39
40python do_preconfigure() {
41 import subprocess
42 case = ""
43 triple = ""
44 vendors = d.getVar('CLANG_EXTRA_OE_VENDORS')
45 multilib_variants = (d.getVar("ML_VARIANTS") or "").split()
46 vendors_to_add = []
47 for vendor in vendors.split():
48 # convert -yoe into yoe
49 vendor = vendor.lstrip('-')
50 # generate possible multilib vendor names for yoe
51 # such as yoemllib32
52 vendors_to_add.extend([vendor + 'ml' + variant for variant in multilib_variants])
53 # skip oe since already part of the cpp file
54 if vendor != "oe":
55 vendors_to_add.append(vendor)
56
57 for vendor_to_add in vendors_to_add:
58 case += '\\n .Case("' + vendor_to_add + '", Triple::OpenEmbedded)'
59 triple += ' "x86_64-' + vendor_to_add + '-linux",'
60
61 bb.note("Adding support following TARGET_VENDOR values")
62 bb.note(str(vendors_to_add))
63 bb.note("in llvm/lib/TargetParser/Triple.cpp and ${S}/clang/lib/Driver/ToolChains/Gnu.cpp")
64 cmd = d.expand("sed -i 's#//CLANG_EXTRA_OE_VENDORS_TRIPLES#%s#g' ${S}/clang/lib/Driver/ToolChains/Gnu.cpp" % (triple))
65 subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
66 cmd = d.expand("sed -i 's#//CLANG_EXTRA_OE_VENDORS_CASES#%s#g' -i ${S}/llvm/lib/TargetParser/Triple.cpp" % (case))
67 subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
68
69
70 case = ""
71 triple = ""
72 name = ""
73 check = ""
74 oe_names = ""
75 distros = d.getVar('CLANG_EXTRA_OE_DISTRO')
76 for distro in distros.split():
77 distro_id = distro.split(":")[0].replace('-','_')
78 distro_triple = distro.split(":")[1]
79 case += '\\n .Case("' + distro_id + '", Distro::' + distro_id.upper() + ')'
80 triple += '\\n if (Distro.Is' + distro_id.upper() + '())\\n return "x86_64-' + distro_triple + '-linux",'
81 name += '\\n '+ distro_id.upper() + ','
82 check += '\\nbool Is' + distro_id.upper() + '() const { return DistroVal == ' + distro_id.upper() + '; }'
83 oe_names += distro_id.upper() + ' ||'
84
85 check += '\\nbool IsOpenEmbedded() const { return DistroVal == ' + oe_names[0:-3] + '; }'
86
87 cmd = d.expand("sed -i 's#//CLANG_EXTRA_OE_DISTRO_NAME#%s#g' ${S}/clang/include/clang/Driver/Distro.h" % (name))
88 subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
89 cmd = d.expand("sed -i 's#//CLANG_EXTRA_OE_DISTRO_CHECK#%s#g' ${S}/clang/include/clang/Driver/Distro.h" % (check))
90 subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
91 cmd = d.expand("sed -i 's#//CLANG_EXTRA_OE_DISTRO_TRIPLES#%s#g' ${S}/clang/lib/Driver/ToolChains/Linux.cpp" % (triple))
92 subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
93 cmd = d.expand("sed -i 's#//CLANG_EXTRA_OE_DISTRO_CASES#%s#g' -i ${S}/clang/lib/Driver/Distro.cpp" % (case))
94 subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
95}
96
97do_patch[vardepsexclude] += "MULTILIBS MULTILIB_VARIANTS"
98addtask do_preconfigure after do_patch
99do_create_spdx[depends] += "${PN}:do_preconfigure"
diff --git a/meta/recipes-devtools/clang/nativesdk-clang-glue.bb b/meta/recipes-devtools/clang/nativesdk-clang-glue.bb
new file mode 100644
index 0000000000..8e5622f6c1
--- /dev/null
+++ b/meta/recipes-devtools/clang/nativesdk-clang-glue.bb
@@ -0,0 +1,36 @@
1# Copyright (C) 2014 Khem Raj <raj.khem@gmail.com>
2# Released under the MIT license (see COPYING.MIT for the terms)
3
4SUMMARY = "SDK Cross compiler wrappers for LLVM based C/C++ compiler"
5HOMEPAGE = "http://clang.llvm.org/"
6LICENSE = "Apache-2.0-with-LLVM-exception"
7LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0-with-LLVM-exception;md5=0bcd48c3bdfef0c9d9fd17726e4b7dab"
8SECTION = "devel"
9
10inherit_defer nativesdk
11DEPENDS += "nativesdk-clang"
12
13do_install() {
14 install -d ${D}${prefix_nativesdk}
15 cd ${D}${prefix_nativesdk}
16 ln -s ..${libdir} .
17 ln -s ..${includedir} .
18 cd ..
19 ln -s .${base_libdir} .
20}
21
22sysroot_stage_all () {
23 sysroot_stage_dir ${D} ${SYSROOT_DESTDIR}
24}
25
26FILES:${PN} += "${prefix_nativesdk} ${base_libdir_nativesdk}"
27FILES:${PN}-dbg = ""
28
29deltask do_configure
30deltask do_compile
31deltask do_patch
32deltask do_fetch
33deltask do_unpack
34deltask do_create_spdx
35deltask do_create_package_spdx
36deltask do_create_runtime_spdx
diff --git a/meta/recipes-devtools/clang/openmp_git.bb b/meta/recipes-devtools/clang/openmp_git.bb
new file mode 100644
index 0000000000..cc0c7fbcd4
--- /dev/null
+++ b/meta/recipes-devtools/clang/openmp_git.bb
@@ -0,0 +1,65 @@
1# Copyright (C) 2017 Khem Raj <raj.khem@gmail.com>
2# Released under the MIT license (see COPYING.MIT for the terms)
3
4SUMMARY = "LLVM OpenMP compiler Runtime"
5HOMEPAGE = "https://openmp.llvm.org/"
6SECTION = "libs"
7
8require common-clang.inc
9require common-source.inc
10
11BPN = "openmp"
12
13LIC_FILES_CHKSUM = "file://openmp/LICENSE.TXT;md5=d75288d1ce0450b28b8d58a284c09c79"
14
15inherit cmake pkgconfig perlnative python3native python3targetconfig
16
17DEPENDS += "elfutils libffi clang"
18
19EXTRA_OECMAKE += "-DCMAKE_BUILD_TYPE=RelWithDebInfo \
20 -DLLVM_APPEND_VC_REV=OFF \
21 -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF \
22 -DOPENMP_LIBDIR_SUFFIX=${@d.getVar('baselib').replace('lib', '')} \
23 -DOPENMP_STANDALONE_BUILD=ON \
24 -DCLANG_TOOL=${STAGING_BINDIR_NATIVE}/clang \
25 -DLINK_TOOL=${STAGING_BINDIR_NATIVE}/llvm-link \
26 -DOPT_TOOL=${STAGING_BINDIR_NATIVE}/opt \
27 -DOPENMP_LLVM_LIT_EXECUTABLE=${STAGING_BINDIR_NATIVE}/llvm-lit \
28 -DEXTRACT_TOOL=${STAGING_BINDIR_NATIVE}/llvm-extract \
29 -DPACKAGER_TOOL=${STAGING_BINDIR_NATIVE}/clang-offload-packager \
30 -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
31 "
32
33OECMAKE_SOURCEPATH = "${S}/openmp"
34
35PACKAGECONFIG ?= "ompt-tools offloading-plugin"
36
37PACKAGECONFIG:remove:arm = "ompt-tools offloading-plugin"
38PACKAGECONFIG:remove:powerpc = "ompt-tools offloading-plugin"
39
40PACKAGECONFIG:append:mipsarcho32 = " no-atomics"
41
42PACKAGECONFIG[ompt-tools] = "-DOPENMP_ENABLE_OMPT_TOOLS=ON,-DOPENMP_ENABLE_OMPT_TOOLS=OFF,"
43PACKAGECONFIG[aliases] = "-DLIBOMP_INSTALL_ALIASES=ON,-DLIBOMP_INSTALL_ALIASES=OFF,"
44PACKAGECONFIG[offloading-plugin] = ",,elfutils libffi,libelf libffi"
45PACKAGECONFIG[no-atomics] = "-DLIBOMP_HAVE_BUILTIN_ATOMIC=OFF -DLIBOMP_LIBFLAGS='-latomic',,"
46
47PACKAGES += "${PN}-libomptarget ${PN}-gdb-plugin"
48FILES_SOLIBSDEV = ""
49FILES:${PN} += "${libdir}/lib*${SOLIBSDEV}"
50FILES:${PN}-libomptarget = "${libdir}/libomptarget-*.bc"
51FILES:${PN}-gdb-plugin = "${datadir}/gdb/python/ompd"
52
53RDEPENDS:${PN}-gdb-plugin += "python3-core"
54
55INSANE_SKIP:${PN} = "dev-so"
56# Currently the static libraries contain buildpaths
57INSANE_SKIP:${PN}-staticdev += "buildpaths"
58
59COMPATIBLE_HOST:mips64 = "null"
60COMPATIBLE_HOST:riscv32 = "null"
61COMPATIBLE_HOST:powerpc = "null"
62
63BBCLASSEXTEND = "native nativesdk"
64
65CVE_STATUS[CVE-2022-26345] = "cpe-incorrect: specific to the Intel distribution before 2022.1"
diff --git a/meta/recipes-devtools/llvm/llvm/0007-llvm-allow-env-override-of-exe-path.patch b/meta/recipes-devtools/llvm/llvm/0007-llvm-allow-env-override-of-exe-path.patch
deleted file mode 100644
index f1ab005464..0000000000
--- a/meta/recipes-devtools/llvm/llvm/0007-llvm-allow-env-override-of-exe-path.patch
+++ /dev/null
@@ -1,36 +0,0 @@
1From 3eb1eefed6fc654d19ab97bbc748454c22a29009 Mon Sep 17 00:00:00 2001
2From: Martin Kelly <mkelly@xevo.com>
3Date: Fri, 19 May 2017 00:22:57 -0700
4Subject: [PATCH] llvm: allow env override of exe and libdir path
5
6When using a native llvm-config from inside a sysroot, we need llvm-config to
7return the libraries, include directories, etc. from inside the sysroot rather
8than from the native sysroot. Thus provide an env override for calling
9llvm-config from a target sysroot.
10
11Upstream-Status: Inappropriate [OE-specific]
12
13Signed-off-by: Martin Kelly <mkelly@xevo.com>
14Signed-off-by: Khem Raj <raj.khem@gmail.com>
15---
16 llvm/tools/llvm-config/llvm-config.cpp | 7 +++++++
17 1 file changed, 7 insertions(+)
18
19diff --git a/llvm/tools/llvm-config/llvm-config.cpp b/llvm/tools/llvm-config/llvm-config.cpp
20index d5b76b1bb..6c28c34bc 100644
21--- a/llvm/tools/llvm-config/llvm-config.cpp
22+++ b/llvm/tools/llvm-config/llvm-config.cpp
23@@ -246,6 +246,13 @@ Typical components:\n\
24
25 /// Compute the path to the main executable.
26 std::string GetExecutablePath(const char *Argv0) {
27+ // Hack for Yocto: we need to override the root path when we are using
28+ // llvm-config from within a target sysroot.
29+ const char *Sysroot = std::getenv("YOCTO_ALTERNATE_EXE_PATH");
30+ if (Sysroot != nullptr) {
31+ return Sysroot;
32+ }
33+
34 // This just needs to be some symbol in the binary; C++ doesn't
35 // allow taking the address of ::main however.
36 void *P = (void *)(intptr_t)GetExecutablePath;
diff --git a/meta/recipes-devtools/llvm/llvm/llvm-config b/meta/recipes-devtools/llvm/llvm/llvm-config
deleted file mode 100644
index 6cf3e7578f..0000000000
--- a/meta/recipes-devtools/llvm/llvm/llvm-config
+++ /dev/null
@@ -1,54 +0,0 @@
1#!/bin/bash
2#
3# Copyright OpenEmbedded Contributors
4#
5# SPDX-License-Identifier: MIT
6#
7# Wrap llvm-config since the native llvm-config will remap some values correctly
8# if placed in the target sysroot but for flags, it would provide the native ones.
9# Provide ours from the environment instead.
10
11NEXT_LLVM_CONFIG="$(which -a llvm-config | sed -n 2p)"
12if [[ $# == 0 ]]; then
13 exec "$NEXT_LLVM_CONFIG"
14fi
15
16remain=""
17output=""
18for arg in "$@"; do
19 case "$arg" in
20 --cppflags)
21 output="${output} ${CPPFLAGS}"
22 ;;
23 --cflags)
24 output="${output} ${CFLAGS}"
25 ;;
26 --cxxflags)
27 output="${output} ${CXXFLAGS}"
28 ;;
29 --ldflags)
30 output="${output} ${LDFLAGS}"
31 ;;
32 --shared-mode)
33 output="${output} shared"
34 ;;
35 --libs)
36 output="${output} -lLLVM"
37 ;;
38 --libdir)
39 output="${output} ${libdir}"
40 ;;
41 --link-shared)
42 break
43 ;;
44 *)
45 remain="${remain} ${arg}"
46 ;;
47 esac
48done
49
50if [ "${remain}" != "" ]; then
51 output="${output} "$("$NEXT_LLVM_CONFIG" ${remain})
52fi
53
54echo "${output}"
diff --git a/meta/recipes-devtools/llvm/llvm_20.1.2.bb b/meta/recipes-devtools/llvm/llvm_20.1.2.bb
deleted file mode 100644
index 98855fa4c1..0000000000
--- a/meta/recipes-devtools/llvm/llvm_20.1.2.bb
+++ /dev/null
@@ -1,233 +0,0 @@
1# Copyright (C) 2017 Khem Raj <raj.khem@gmail.com>
2# Released under the MIT license (see COPYING.MIT for the terms)
3
4SUMMARY = "The LLVM Compiler Infrastructure"
5HOMEPAGE = "http://llvm.org"
6LICENSE = "Apache-2.0-with-LLVM-exception"
7SECTION = "devel"
8
9LIC_FILES_CHKSUM = "file://LICENSE.TXT;md5=8a15a0759ef07f2682d2ba4b893c9afe"
10
11DEPENDS = "libffi libxml2 zlib zstd libedit ninja-native llvm-native"
12
13RDEPENDS:${PN}:append:class-target = " ncurses-terminfo"
14
15inherit cmake pkgconfig
16# could be 'rcX' or 'git' or empty ( for release )
17VER_SUFFIX = ""
18
19PV .= "${VER_SUFFIX}"
20
21MAJOR_VERSION = "${@oe.utils.trim_version("${PV}", 1)}"
22MAJ_MIN_VERSION = "${@oe.utils.trim_version("${PV}", 2)}"
23
24LLVM_RELEASE = "${PV}"
25
26SRCREV_spirv = "68edc9d3d10ff6ec6353803a1bc60a5c25e7b715"
27# pattern: llvm_branch_200, currently there are no minor releases, so, no llvm_branch_201
28SPIRV_BRANCH = "llvm_release_${@oe.utils.trim_version('${PV}', 1).replace('.', '')}0"
29
30SRC_URI_SPIRV = " \
31 git://github.com/KhronosGroup/SPIRV-LLVM-Translator;protocol=https;name=spirv;branch=${SPIRV_BRANCH};destsuffix=llvm-project-${PV}.src/llvm/projects/SPIRV-LLVM-Translator \
32 file://spirv-internal-build.patch \
33"
34
35SRC_URI_SPIRV:append:class-native = " \
36 file://spirv-shared-library.patch \
37"
38
39SRC_URI = "https://github.com/llvm/llvm-project/releases/download/llvmorg-${PV}/llvm-project-${PV}.src.tar.xz \
40 file://0007-llvm-allow-env-override-of-exe-path.patch \
41 file://0001-AsmMatcherEmitter-sort-ClassInfo-lists-by-name-as-we.patch \
42 file://0014-cmake-Fix-configure-for-packages-using-find_package.patch \
43 ${@bb.utils.contains('PACKAGECONFIG', 'spirv-llvm-translator', '${SRC_URI_SPIRV}', '', d)} \
44 file://llvm-config \
45 "
46SRC_URI[sha256sum] = "f0a4a240aabc9b056142d14d5478bb6d962aeac549cbd75b809f5499240a8b38"
47UPSTREAM_CHECK_URI = "https://github.com/llvm/llvm-project"
48UPSTREAM_CHECK_REGEX = "llvmorg-(?P<pver>\d+(\.\d+)+)"
49
50SRC_URI:append:class-native = " file://0001-llvm-config-remove-LLVM_LDFLAGS-from-ldflags-output.patch"
51
52S = "${WORKDIR}/llvm-project-${PV}.src"
53
54OECMAKE_SOURCEPATH = "${S}/llvm"
55
56LLVM_INSTALL_DIR = "${WORKDIR}/llvm-install"
57
58PACKAGECONFIG ??= "libllvm libclc spirv-llvm-translator"
59# if optviewer OFF, force the modules to be not found or the ones on the host would be found
60PACKAGECONFIG[optviewer] = ",-DPY_PYGMENTS_FOUND=OFF -DPY_PYGMENTS_LEXERS_C_CPP_FOUND=OFF -DPY_YAML_FOUND=OFF,python3-pygments python3-pyyaml,python3-pygments python3-pyyaml"
61PACKAGECONFIG[libllvm] = ""
62PACKAGECONFIG[libclc] = ""
63PACKAGECONFIG[spirv-llvm-translator] = "-DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=${STAGING_INCDIR}/.. ,,spirv-tools-native spirv-headers"
64
65#
66# Default to build all OE-Core supported target arches (user overridable).
67#
68LLVM_TARGETS ?= "AMDGPU;AArch64;ARM;BPF;Mips;PowerPC;RISCV;X86;LoongArch;NVPTX;SPIRV"
69
70ARM_INSTRUCTION_SET:armv5 = "arm"
71ARM_INSTRUCTION_SET:armv4t = "arm"
72
73LLVM_PROJECTS_CLANG = "${@bb.utils.contains_any('PACKAGECONFIG', 'libclc spirv-llvm-translator', 'clang', '', d)}"
74LLVM_PROJECTS_CLC = "${@bb.utils.contains('PACKAGECONFIG', 'libclc', ';libclc', '', d)}"
75LLVM_PROJECTS = "${LLVM_PROJECTS_CLANG}${LLVM_PROJECTS_CLC}"
76
77EXTRA_OECMAKE += "-DLLVM_ENABLE_ASSERTIONS=OFF \
78 -DLLVM_ENABLE_EXPENSIVE_CHECKS=OFF \
79 -DLLVM_ENABLE_PIC=ON \
80 -DLLVM_BINDINGS_LIST='' \
81 -DLLVM_LINK_LLVM_DYLIB=ON \
82 -DLLVM_ENABLE_FFI=ON \
83 -DLLVM_ENABLE_RTTI=ON \
84 -DFFI_INCLUDE_DIR=$(pkg-config --variable=includedir libffi) \
85 -DLLVM_OPTIMIZED_TABLEGEN=ON \
86 -DLLVM_TARGETS_TO_BUILD='${LLVM_TARGETS}' \
87 -DLLVM_VERSION_SUFFIX='${VER_SUFFIX}' \
88 -DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN=ON \
89 -DCMAKE_BUILD_TYPE=Release \
90 -DLLVM_ENABLE_PROJECTS='${LLVM_PROJECTS}' \
91 "
92
93EXTRA_OECMAKE:append:class-target = "\
94 -DCMAKE_CROSSCOMPILING:BOOL=ON \
95 -DLLVM_HOST_TRIPLE=${TARGET_SYS} \
96 -DLLVM_TABLEGEN=${STAGING_BINDIR_NATIVE}/llvm-tblgen${PV} \
97 -DLLVM_CONFIG_PATH=${STAGING_BINDIR_NATIVE}/llvm-config${PV} \
98 -DLLVM_NATIVE_TOOL_DIR=${STAGING_BINDIR_NATIVE} \
99 "
100
101EXTRA_OECMAKE:append:class-nativesdk = "\
102 -DCMAKE_CROSSCOMPILING:BOOL=ON \
103 -DLLVM_HOST_TRIPLE=${SDK_SYS} \
104 -DLLVM_TABLEGEN=${STAGING_BINDIR_NATIVE}/llvm-tblgen${PV} \
105 -DLLVM_CONFIG_PATH=${STAGING_BINDIR_NATIVE}/llvm-config${PV} \
106 -DLLVM_NATIVE_TOOL_DIR=${STAGING_BINDIR_NATIVE} \
107 "
108
109# patch out build host paths for reproducibility
110do_compile:prepend:class-target() {
111 sed -i -e "s,${WORKDIR},,g" ${B}/tools/llvm-config/BuildVariables.inc
112}
113
114do_compile:prepend:class-nativesdk() {
115 sed -i -e "s,${WORKDIR},,g" ${B}/tools/llvm-config/BuildVariables.inc
116}
117
118do_compile() {
119 if ${@bb.utils.contains('PACKAGECONFIG', 'libllvm', 'true', 'false', d)}; then
120 ninja -v ${PARALLEL_MAKE}
121 else
122 ninja -v ${PARALLEL_MAKE} llvm-config llvm-tblgen
123 fi
124}
125
126do_install() {
127 if ${@bb.utils.contains('PACKAGECONFIG', 'libllvm', 'true', 'false', d)}; then
128 DESTDIR=${D} ninja -v install
129
130 # llvm harcodes usr/lib as install path, so this corrects it to actual libdir
131 mv -T -n ${D}/${prefix}/lib ${D}/${libdir} || true
132
133 # Remove opt-viewer: https://llvm.org/docs/Remarks.html
134 rm -rf ${D}${datadir}/opt-viewer
135
136 # reproducibility
137 sed -i -e 's,${WORKDIR},,g' ${D}/${libdir}/cmake/llvm/LLVMConfig.cmake
138 fi
139
140 # Remove clang bits from target packages, we are not providing it for the system
141 if ${@bb.utils.contains_any('PACKAGECONFIG', 'libclc spirv-llvm-translator', 'true', 'false', d)} &&
142 [ "${CLASSOVERRIDE}" != "class-native" ] ; then
143 rm -f ${D}${bindir}/clang*
144 rm -fr ${D}${libdir}/clang
145 rm -fr ${D}${datadir}/clang
146
147 rm -f ${D}${bindir}/scan*
148 rm -fr ${D}${libdir}/libscanbuild
149 rm -fr ${D}${datadir}/scan-build
150 rm -fr ${D}${datadir}/scan-view
151
152 rm -fr ${D}${libdir}/libear
153 fi
154
155 # Try to clean up datadir if it is empty, but don't fail if there are
156 # libclc files there
157 rmdir ${D}${datadir} || true
158}
159
160do_install:append:class-native() {
161 install -D -m 0755 ${B}/bin/llvm-tblgen ${D}${bindir}/llvm-tblgen${PV}
162 install -D -m 0755 ${B}/bin/llvm-min-tblgen ${D}${bindir}/llvm-min-tblgen
163 install -D -m 0755 ${B}/bin/llvm-config ${D}${bindir}/llvm-config${PV}
164 ln -sf llvm-config${PV} ${D}${bindir}/llvm-config
165
166 if ${@bb.utils.contains('PACKAGECONFIG', 'libclc', 'true', 'false', d)} ; then
167 install -D -m 0755 ${B}/bin/prepare_builtins ${D}${bindir}/prepare_builtins
168 fi
169}
170
171SYSROOT_PREPROCESS_FUNCS:append:class-target = " llvm_sysroot_preprocess"
172SYSROOT_PREPROCESS_FUNCS:append:class-nativesdk = " llvm_sysroot_preprocess"
173
174llvm_sysroot_preprocess() {
175 install -d ${SYSROOT_DESTDIR}${bindir_crossscripts}/
176 install -m 0755 ${UNPACKDIR}/llvm-config ${SYSROOT_DESTDIR}${bindir_crossscripts}/
177 ln -sf llvm-config ${SYSROOT_DESTDIR}${bindir_crossscripts}/llvm-config${PV}
178}
179
180PACKAGES =+ "${PN}-bugpointpasses ${PN}-llvmhello ${PN}-libllvm ${PN}-liboptremarks ${PN}-liblto ${PN}-clc ${PN}-spirv"
181PROVIDES = "${@bb.utils.filter('PACKAGECONFIG', 'libclc spirv-llvm-translator', d)}"
182
183RRECOMMENDS:${PN}-dev += "${PN}-bugpointpasses ${PN}-llvmhello ${PN}-liboptremarks"
184RPROVIDES:${PN}-clc = "${@bb.utils.filter('PACKAGECONFIG', 'libclc', d)}"
185RPROVIDES:${PN}-spirv = "${@bb.utils.filter('PACKAGECONFIG', 'spirv-llvm-translator', d)}"
186
187FILES:${PN}-bugpointpasses = "\
188 ${libdir}/BugpointPasses.so \
189"
190
191FILES:${PN}-libllvm = "\
192 ${libdir}/libLLVM-${MAJOR_VERSION}.so \
193 ${libdir}/libLLVM.so.${MAJ_MIN_VERSION} \
194"
195
196FILES:${PN}-liblto += "\
197 ${libdir}/libLTO.so.* \
198"
199
200FILES:${PN}-liboptremarks += "\
201 ${libdir}/libRemarks.so.* \
202"
203
204FILES:${PN}-llvmhello = "\
205 ${libdir}/LLVMHello.so \
206"
207
208FILES:${PN}-dev += " \
209 ${libdir}/llvm-config \
210 ${libdir}/libRemarks.so \
211 ${libdir}/libLLVM-${PV}.so \
212"
213
214FILES:${PN}-staticdev += "\
215 ${libdir}/*.a \
216"
217
218FILES:${PN}-clc += "${datadir}/clc"
219
220FILES:${PN}-spirv = " \
221 ${bindir}/llvm-spirv \
222 ${includedir}/LLVMSPIRVLib \
223 ${libdir}/pkgconfig/LLVMSPIRVLib.pc \
224 ${libdir}/libLLVMSPIRV* \
225"
226
227INSANE_SKIP:${PN}-libllvm += "dev-so"
228
229# SPIRV-LLVM-Translator provides only static libraries, they are included into
230# the llvm-spirv package.
231INSANE_SKIP:${PN}-spirv += "staticdev"
232
233BBCLASSEXTEND = "native nativesdk"