summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/clang
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/clang')
-rw-r--r--meta/recipes-devtools/clang/clang-cross-canadian_git.bb36
-rw-r--r--meta/recipes-devtools/clang/clang-cross_git.bb40
-rw-r--r--meta/recipes-devtools/clang/clang-crosssdk_git.bb34
-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.patch117
-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-clangd-Add-a-build-option-to-disable-building-dexp.patch85
-rw-r--r--meta/recipes-devtools/clang/clang/0033-AsmMatcherEmitter-sort-ClassInfo-lists-by-name-as-we.patch31
-rw-r--r--meta/recipes-devtools/clang/clang/0034-llvm-config-remove-LLVM_LDFLAGS-from-ldflags-output.patch32
-rw-r--r--meta/recipes-devtools/clang/clang/0035-openmp-Do-not-emit-date-and-time-into-generate-files.patch37
-rw-r--r--meta/recipes-devtools/clang/clang/0036-libunwind-Use-gcs-instead-of-gcs-target-attribute.patch56
-rw-r--r--meta/recipes-devtools/clang/clang/0037-compiler-rt-Exclude-sync_fetch_and_-for-any-pre-ARMv.patch63
-rw-r--r--meta/recipes-devtools/clang/clang/0038-compiler-rt-Hardcode-uptr-sptr-typedefs-on-Mips-Linu.patch35
-rw-r--r--meta/recipes-devtools/clang/clang_git.bb488
-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.inc75
-rw-r--r--meta/recipes-devtools/clang/compiler-rt-sanitizers_git.bb138
-rw-r--r--meta/recipes-devtools/clang/compiler-rt_git.bb139
-rw-r--r--meta/recipes-devtools/clang/libcxx_git.bb122
-rw-r--r--meta/recipes-devtools/clang/llvm-project-source.bb12
-rw-r--r--meta/recipes-devtools/clang/llvm-project-source.inc98
-rw-r--r--meta/recipes-devtools/clang/nativesdk-clang-glue.bb36
-rw-r--r--meta/recipes-devtools/clang/openmp_git.bb65
52 files changed, 3870 insertions, 0 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..323cc0d880
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang-cross_git.bb
@@ -0,0 +1,40 @@
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
14TOOLCHAIN = "clang"
15DEPENDS += "clang-native virtual/cross-binutils"
16
17#INHIBIT_PACKAGE_STRIP = "1"
18INHIBIT_SYSROOT_STRIP = "1"
19do_install() {
20 install -d ${D}${bindir}
21 for tool in clang-tidy lld ld.lld llvm-profdata \
22 llvm-nm llvm-ar llvm-as llvm-ranlib llvm-strip llvm-objcopy llvm-objdump llvm-readelf \
23 llvm-addr2line llvm-dwp llvm-size llvm-strings llvm-cov
24 do
25 ln -sf ../$tool ${D}${bindir}/${TARGET_PREFIX}$tool
26 done
27 install -m 0755 ${STAGING_BINDIR_NATIVE}/clang ${D}${bindir}/${TARGET_PREFIX}clang
28 install -m 0755 ${STAGING_BINDIR_NATIVE}/clang ${D}${bindir}/${TARGET_PREFIX}clang++
29}
30SSTATE_SCAN_FILES += "*-clang *-clang++ *-llvm-profdata *-lld *-ld.lld \
31 *-llvm-nm *-llvm-ar *-llvm-as *-llvm-ranlib *-llvm-strip \
32 *-llvm-objcopy *-llvm-objdump *-llvm-readelf *-llvm-addr2line \
33 *-llvm-dwp *-llvm-size *-llvm-strings *-llvm-cov"
34
35SYSROOT_PREPROCESS_FUNCS += "clangcross_sysroot_preprocess"
36
37clangcross_sysroot_preprocess () {
38 sysroot_stage_dir ${D}${bindir} ${SYSROOT_DESTDIR}${bindir}
39}
40PACKAGES = ""
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..ef162ef153
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang-crosssdk_git.bb
@@ -0,0 +1,34 @@
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
14TOOLCHAIN = "clang"
15DEPENDS += "clang-native nativesdk-clang-glue virtual/nativesdk-cross-binutils virtual/nativesdk-libc"
16
17do_install() {
18 install -d ${D}${bindir}
19 for tool in clang clang++ clang-tidy lld ld.lld llvm-profdata \
20 llvm-nm llvm-ar llvm-as llvm-ranlib llvm-strip llvm-objcopy llvm-objdump llvm-readelf \
21 llvm-addr2line llvm-dwp llvm-size llvm-strings llvm-cov
22 do
23 ln -sf ../$tool ${D}${bindir}/${TARGET_PREFIX}$tool
24 done
25}
26SSTATE_SCAN_FILES += "*-clang *-clang++ *-llvm-profdata *-lld *-ld.lld \
27 *-llvm-nm *-llvm-ar *-llvm-as *-llvm-ranlib *-llvm-strip \
28 *-llvm-objcopy *-llvm-objdump *-llvm-readelf *-llvm-addr2line \
29 *-llvm-dwp *-llvm-size *-llvm-strings *-llvm-cov"
30sysroot_stage_all () {
31 sysroot_stage_dir ${D}${bindir} ${SYSROOT_DESTDIR}${bindir}
32}
33
34PACKAGES = ""
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..3853d7648b
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0001-libcxxabi-Find-libunwind-headers-when-LIBCXXABI_LIBU.patch
@@ -0,0 +1,60 @@
1From 1fa8ec110c67714cff009b481c430e3d004bfaad 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..d5d6a2c6d7
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0002-compiler-rt-support-a-new-embedded-linux-target.patch
@@ -0,0 +1,309 @@
1From 6e8c6c53281fdd3b11d29d706905a3fe959afd11 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..0ee7090290
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0003-compiler-rt-Simplify-cross-compilation.-Don-t-use-na.patch
@@ -0,0 +1,44 @@
1From 419855642e4a48d09e7b3b1e02593b6d9a506089 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..60b5360057
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0004-llvm-TargetLibraryInfo-Undefine-libc-functions-if-th.patch
@@ -0,0 +1,90 @@
1From 2603da5f1fce88f6c7f6134faf7757f17b7e14f5 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..7aea73e611
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0005-llvm-allow-env-override-of-exe-and-libdir-path.patch
@@ -0,0 +1,71 @@
1From 13a9ce5a34060abaa6d5da5176eb1dab271dac4e 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..44fa980ab8
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0006-clang-driver-Check-sysroot-for-ldso-path.patch
@@ -0,0 +1,78 @@
1From a804903ed85707d9a06c7e01aef536b3042790d0 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..6374ec7bf5
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0007-clang-Driver-tools.cpp-Add-lssp_nonshared-on-musl.patch
@@ -0,0 +1,32 @@
1From 703e5acbeaad6eeb316740dd8b92b34db99bb1b3 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..16d8c9bae5
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0008-clang-Prepend-trailing-to-sysroot.patch
@@ -0,0 +1,39 @@
1From b1d4a42b6078502530924cd0d15052671c760eb6 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..2ad1130355
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0009-clang-Look-inside-the-target-sysroot-for-compiler-ru.patch
@@ -0,0 +1,41 @@
1From 3edfe16c0d8bb3d135465038cb07c8122baac698 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..346a4fcbb0
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0010-clang-Define-releative-gcc-installation-dir.patch
@@ -0,0 +1,123 @@
1From dc2de98d70a763f30347df2d76df1c70cc464b87 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..25dade4389
--- /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 0712b0f0fa8c9cf27016e8b1ef8391f6c9cfa4ff 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..b55740e0d6
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0012-Pass-PYTHON_EXECUTABLE-when-cross-compiling-for-nati.patch
@@ -0,0 +1,24 @@
1From a6055a858f6e54cac2b427101fb43c83599b9072 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..99952fe182
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0013-Check-for-atomic-double-intrinsics.patch
@@ -0,0 +1,34 @@
1From c9e8942cace57d9d222e8f005408631e1cd06c5c 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/clang/clang/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
new file mode 100644
index 0000000000..f6df85538d
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0014-cmake-Fix-configure-for-packages-using-find_package.patch
@@ -0,0 +1,117 @@
1From a6bf17d7eb64bd7beabc73b5fe319b7a375bbcce Mon Sep 17 00:00:00 2001
2From: Ovidiu Panait <ovidiu.panait@windriver.com>
3Date: Fri, 31 Jan 2020 10:56:11 +0200
4Subject: [PATCH] cmake: Fix configure for packages using find_package()
5
6Currently, when a package (i.e. bcc [https://github.com/iovisor/bcc.git])
7that depends on LLVM/Clang tries to run cmake find_package() during
8do_configure, it will fail with a similar error:
9
10| The imported target "llvm-tblgen" references the file
11| ".../recipe-sysroot/usr/bin/llvm-tblgen"
12|
13| but this file does not exist. Possible reasons include:
14| * The file was deleted, renamed, or moved to another location.
15| * An install or uninstall procedure did not complete successfully.
16| * The installation package was faulty and contained
17| ".../recipe-sysroot/usr/lib/cmake/LLVMExports.cmake"
18| but not all the files it references.
19
20This is due to the fact that currently the cmake scripts look for target
21binaries in sysroot. Work around this by not exporting the target binaries in
22Exports-* cmake files.
23
24Upstream-Status: Inappropriate [oe-specific]
25
26Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
27---
28 clang/cmake/modules/AddClang.cmake | 2 --
29 llvm/cmake/modules/AddLLVM.cmake | 9 ++-------
30 llvm/cmake/modules/TableGen.cmake | 6 ------
31 3 files changed, 2 insertions(+), 15 deletions(-)
32
33diff --git a/clang/cmake/modules/AddClang.cmake b/clang/cmake/modules/AddClang.cmake
34index cdc8bd5cd503..5faa9117a30f 100644
35--- a/clang/cmake/modules/AddClang.cmake
36+++ b/clang/cmake/modules/AddClang.cmake
37@@ -182,7 +182,6 @@ macro(add_clang_tool name)
38 if (CLANG_BUILD_TOOLS)
39 get_target_export_arg(${name} Clang export_to_clangtargets)
40 install(TARGETS ${name}
41- ${export_to_clangtargets}
42 RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
43 COMPONENT ${name})
44
45@@ -191,7 +190,6 @@ macro(add_clang_tool name)
46 DEPENDS ${name}
47 COMPONENT ${name})
48 endif()
49- set_property(GLOBAL APPEND PROPERTY CLANG_EXPORTS ${name})
50 endif()
51 endif()
52 set_target_properties(${name} PROPERTIES XCODE_GENERATE_SCHEME ON)
53diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
54index d3e9377c8d2f..fe22d6f2b35a 100644
55--- a/llvm/cmake/modules/AddLLVM.cmake
56+++ b/llvm/cmake/modules/AddLLVM.cmake
57@@ -1492,7 +1492,6 @@ macro(llvm_add_tool project name)
58 if( LLVM_BUILD_TOOLS )
59 get_target_export_arg(${name} ${project} export_to_llvmexports)
60 install(TARGETS ${name}
61- ${export_to_llvmexports}
62 RUNTIME DESTINATION ${${project}_TOOLS_INSTALL_DIR}
63 COMPONENT ${name})
64
65@@ -1503,10 +1502,8 @@ macro(llvm_add_tool project name)
66 endif()
67 endif()
68 endif()
69- if( LLVM_BUILD_TOOLS )
70- string(TOUPPER "${project}" project_upper)
71- set_property(GLOBAL APPEND PROPERTY ${project_upper}_EXPORTS ${name})
72- endif()
73+ string(TOUPPER "${project}" project_upper)
74+ set_target_properties(${name} PROPERTIES FOLDER "Tools")
75 endif()
76 get_subproject_title(subproject_title)
77 set_target_properties(${name} PROPERTIES FOLDER "${subproject_title}/Tools")
78@@ -1556,7 +1553,6 @@ macro(add_llvm_utility name)
79 if (LLVM_INSTALL_UTILS AND LLVM_BUILD_UTILS)
80 get_target_export_arg(${name} LLVM export_to_llvmexports)
81 install(TARGETS ${name}
82- ${export_to_llvmexports}
83 RUNTIME DESTINATION ${LLVM_UTILS_INSTALL_DIR}
84 COMPONENT ${name})
85
86@@ -1565,7 +1561,6 @@ macro(add_llvm_utility name)
87 DEPENDS ${name}
88 COMPONENT ${name})
89 endif()
90- set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name})
91 elseif(LLVM_BUILD_UTILS)
92 set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS_BUILDTREE_ONLY ${name})
93 endif()
94diff --git a/llvm/cmake/modules/TableGen.cmake b/llvm/cmake/modules/TableGen.cmake
95index ffcc718b4777..a76f28e74b86 100644
96--- a/llvm/cmake/modules/TableGen.cmake
97+++ b/llvm/cmake/modules/TableGen.cmake
98@@ -232,12 +232,7 @@ macro(add_tablegen target project)
99
100 if (ADD_TABLEGEN_DESTINATION AND NOT LLVM_INSTALL_TOOLCHAIN_ONLY AND
101 (LLVM_BUILD_UTILS OR ${target} IN_LIST LLVM_DISTRIBUTION_COMPONENTS))
102- set(export_arg)
103- if(ADD_TABLEGEN_EXPORT)
104- get_target_export_arg(${target} ${ADD_TABLEGEN_EXPORT} export_arg)
105- endif()
106 install(TARGETS ${target}
107- ${export_arg}
108 COMPONENT ${target}
109 RUNTIME DESTINATION "${ADD_TABLEGEN_DESTINATION}")
110 if(NOT LLVM_ENABLE_IDE)
111@@ -248,6 +243,5 @@ macro(add_tablegen target project)
112 endif()
113 if(ADD_TABLEGEN_EXPORT)
114 string(TOUPPER ${ADD_TABLEGEN_EXPORT} export_upper)
115- set_property(GLOBAL APPEND PROPERTY ${export_upper}_EXPORTS ${target})
116 endif()
117 endmacro()
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..4841d6c1bc
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0015-clang-Fix-resource-dir-location-for-cross-toolchains.patch
@@ -0,0 +1,50 @@
1From f3c6f924525179ca190fecce2889997250ca8705 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..6bbbb5a259
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0016-clang-driver-Add-dyld-prefix-when-checking-sysroot-f.patch
@@ -0,0 +1,79 @@
1From 7c70f891fb94f2d8c88bc6af4514d8dcd6488658 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..8677c5ca13
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0017-clang-Use-python3-in-python-scripts.patch
@@ -0,0 +1,35 @@
1From f06bb3e20e47ab5a76efa76f50f0bbef682cd263 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..7ae88b870d
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0018-llvm-clang-Insert-anchor-for-adding-OE-distro-vendor.patch
@@ -0,0 +1,167 @@
1From cfe5ec616f1bbbe7d20409b552428e43e282f115 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 c544a8c00219..3cd687ede458 100644
101--- a/clang/include/clang/Driver/Distro.h
102+++ b/clang/include/clang/Driver/Distro.h
103@@ -47,6 +47,7 @@ public:
104 RHEL7,
105 Fedora,
106 Gentoo,
107+ //CLANG_EXTRA_OE_DISTRO_NAME
108 OpenSUSE,
109 UbuntuHardy,
110 UbuntuIntrepid,
111@@ -141,6 +142,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 71ba71fa1837..f64d0abddf6d 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..05937b06c1
--- /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 4a23e833e66896f40bb36c3c13b4a4bb1b79162f 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..7ce60e0efd
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0020-clang-Fix-x86-triple-for-non-debian-multiarch-linux-.patch
@@ -0,0 +1,28 @@
1From 739e65a126178e4c4d8452297ac13c119ae79403 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..fe7157df47
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0021-libunwind-Added-unw_backtrace-method.patch
@@ -0,0 +1,56 @@
1From f60c6ade92826cea1c3d63d70f1168f4048a624b 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..128666b8fb
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0022-lldb-Link-with-libatomic-on-x86.patch
@@ -0,0 +1,33 @@
1From 45d44576a0dbaf843a9795519cafa944801c4679 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..861064f4f4
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0023-compiler-rt-Enable-__int128-for-ppc32.patch
@@ -0,0 +1,73 @@
1From b676d7d93fa35e095595fc1f967e4c6a3b58414b 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..d49af8aeb9
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0024-llvm-Do-not-use-cmake-infra-to-detect-libzstd.patch
@@ -0,0 +1,62 @@
1From 9cf5cc6d4378ad7918f338aa65ce79178d8a84f2 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..bca28cd7db
--- /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 744dbb6cf6925796e2bc5c028af08c40445bbb1c 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..e129aa245d
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0026-compiler-rt-Undef-_TIME_BITS-along-with-_FILE_OFFSET.patch
@@ -0,0 +1,43 @@
1From 6b6a518bc7686af7680f45fcdea7c414a22a2f53 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..b6852a124d
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0027-ToolChains-Gnu.cpp-ARMLibDirs-search-also-in-lib32.patch
@@ -0,0 +1,81 @@
1From a83b407a9c1b04d95e6cda74059744fe815fde17 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..0136039358
--- /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 3572a4425844ef77131fd2635ea570eafc1df958 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..a42ac2484d
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0029-llvm-Add-libunwind.pc.in-and-llvm-config-scripts.patch
@@ -0,0 +1,90 @@
1From e5223f6013c7c70a7f6e35ecec046cfdc0c15c2a 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..85d3ce9ed3
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0030-scan-build-py-respect-LLVM_LIBDIR_SUFFIX-like-other-.patch
@@ -0,0 +1,92 @@
1From 3f03bd4a5a16f2b5525f4dc32c7b196840b96856 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..621c3653f0
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0031-compiler-rt-Do-not-pass-target-to-clang-compiler.patch
@@ -0,0 +1,29 @@
1From 518c0025921b0bd21e69bf4c38f369778032f4e0 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-clangd-Add-a-build-option-to-disable-building-dexp.patch b/meta/recipes-devtools/clang/clang/0032-clangd-Add-a-build-option-to-disable-building-dexp.patch
new file mode 100644
index 0000000000..3e0603477e
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0032-clangd-Add-a-build-option-to-disable-building-dexp.patch
@@ -0,0 +1,85 @@
1From 12abcd058e2aa468054708b0ca7a06f2638eabab 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/clang/clang/0033-AsmMatcherEmitter-sort-ClassInfo-lists-by-name-as-we.patch b/meta/recipes-devtools/clang/clang/0033-AsmMatcherEmitter-sort-ClassInfo-lists-by-name-as-we.patch
new file mode 100644
index 0000000000..1901efeae4
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0033-AsmMatcherEmitter-sort-ClassInfo-lists-by-name-as-we.patch
@@ -0,0 +1,31 @@
1From 9e389e1dc73a2f5601cfbab34249aedffd053235 Mon Sep 17 00:00:00 2001
2From: Alexander Kanavin <alex.kanavin@gmail.com>
3Date: Fri, 27 Nov 2020 10:11:08 +0000
4Subject: [PATCH] AsmMatcherEmitter: sort ClassInfo lists by name as well
5
6Otherwise, there are instances which are identical in
7every other field and therefore sort non-reproducibly
8(which breaks binary and source reproducibiliy).
9
10Upstream-Status: Submitted [https://reviews.llvm.org/D97477]
11Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
12---
13 llvm/utils/TableGen/AsmMatcherEmitter.cpp | 5 ++++-
14 1 file changed, 4 insertions(+), 1 deletion(-)
15
16diff --git a/llvm/utils/TableGen/AsmMatcherEmitter.cpp b/llvm/utils/TableGen/AsmMatcherEmitter.cpp
17index 7684387d80fe..d225a3b6dfa9 100644
18--- a/llvm/utils/TableGen/AsmMatcherEmitter.cpp
19+++ b/llvm/utils/TableGen/AsmMatcherEmitter.cpp
20@@ -361,7 +361,10 @@ public:
21 // name of a class shouldn't be significant. However, some of the backends
22 // accidentally rely on this behaviour, so it will have to stay like this
23 // until they are fixed.
24- return ValueName < RHS.ValueName;
25+ if (ValueName != RHS.ValueName)
26+ return ValueName < RHS.ValueName;
27+ // All else being equal, we should sort by name, for source and binary reproducibility
28+ return Name < RHS.Name;
29 }
30 };
31
diff --git a/meta/recipes-devtools/clang/clang/0034-llvm-config-remove-LLVM_LDFLAGS-from-ldflags-output.patch b/meta/recipes-devtools/clang/clang/0034-llvm-config-remove-LLVM_LDFLAGS-from-ldflags-output.patch
new file mode 100644
index 0000000000..2618f5ac40
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0034-llvm-config-remove-LLVM_LDFLAGS-from-ldflags-output.patch
@@ -0,0 +1,32 @@
1From 81db296472e146995c3c5728981cdc0cc065ab9c Mon Sep 17 00:00:00 2001
2From: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
3Date: Wed, 2 Apr 2025 17:05:17 +0300
4Subject: [PATCH] llvm-config: remove LLVM_LDFLAGS from --ldflags output
5
6On native OE builds the LLVM_LDFLAGS gets a lot of extra flags which may
7depend on exact build dir and as such be inappropriate to binaries
8shared through sstate-cache. It is not possible to override this
9behaviour in llvm-config since crossscripts are not being used for
10native builds. As a OE-specific modification ignore LLVM_LDFLAGS for
11native builds.
12
13Upstream-Status: Inappropriate [OE-Specific]
14Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
15Signed-off-by: Khem Raj <raj.khem@gmail.com>
16---
17 llvm/tools/llvm-config/llvm-config.cpp | 2 +-
18 1 file changed, 1 insertion(+), 1 deletion(-)
19
20diff --git a/llvm/tools/llvm-config/llvm-config.cpp b/llvm/tools/llvm-config/llvm-config.cpp
21index a739f0d8dbea..3120f95fba9d 100644
22--- a/llvm/tools/llvm-config/llvm-config.cpp
23+++ b/llvm/tools/llvm-config/llvm-config.cpp
24@@ -542,7 +542,7 @@ int main(int argc, char **argv) {
25 OS << ActiveIncludeOption << ' ' << LLVM_CXXFLAGS << '\n';
26 } else if (Arg == "--ldflags") {
27 OS << ((HostTriple.isWindowsMSVCEnvironment()) ? "-LIBPATH:" : "-L")
28- << ActiveLibDir << ' ' << LLVM_LDFLAGS << '\n';
29+ << ActiveLibDir << '\n';
30 } else if (Arg == "--system-libs") {
31 PrintSystemLibs = true;
32 } else if (Arg == "--libs") {
diff --git a/meta/recipes-devtools/clang/clang/0035-openmp-Do-not-emit-date-and-time-into-generate-files.patch b/meta/recipes-devtools/clang/clang/0035-openmp-Do-not-emit-date-and-time-into-generate-files.patch
new file mode 100644
index 0000000000..f33d8851ea
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0035-openmp-Do-not-emit-date-and-time-into-generate-files.patch
@@ -0,0 +1,37 @@
1From c439de272b3f983c6d97b8f6fec0135323e3363c 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/clang/clang/0036-libunwind-Use-gcs-instead-of-gcs-target-attribute.patch b/meta/recipes-devtools/clang/clang/0036-libunwind-Use-gcs-instead-of-gcs-target-attribute.patch
new file mode 100644
index 0000000000..fe2bd77b33
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0036-libunwind-Use-gcs-instead-of-gcs-target-attribute.patch
@@ -0,0 +1,56 @@
1From 8c839483915183a9c1ca4f74646ca4f478900e77 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Wed, 30 Apr 2025 19:51:19 -0700
4Subject: [PATCH] libunwind: Use +gcs instead of gcs target attribute
5
6__attribute__((target("gcs"))) does not work with gcc
7
8GCC-15 has added gcs intrinsics [1] but the syntax for enabling it is
9slightly different. This syntax works with clang too.
10
11With gcc15 compiler libunwind's check for this macros is succeeding and it
12ends up enabling 'gcs' by using function attribute, this works with clang
13but not with gcc but '+gcs' works with both
14
15We can see this in rust compiler bootstrap for aarch64/musl when system
16uses gcc15, it ends up with these errors
17
18Building libunwind.a for aarch64-poky-linux-musl
19cargo:warning=/mnt/b/yoe/master/sources/poky/build/tmp/work/cortexa57-poky-linux-musl/rust/1.85.1/rustc-1.85.1-src/src/llvm-project/libunwind/src/UnwindLevel1.c:191:1: error: arch extension 'gcs' should be prefixed by '+'
20cargo:warning= 191 | unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *exception_object) {
21cargo:warning= | ^~~~~~~~~~~~~
22cargo:warning=/mnt/b/yoe/master/sources/poky/build/tmp/work/cortexa57-poky-linux-musl/rust/1.85.1/rustc-1.85.1-src/src/llvm-project/libunwind/src/UnwindLevel1.c:337:22: error: arch extension 'gcs' should be prefixed by '+'
23cargo:warning= 337 | _Unwind_Stop_Fn stop, void *stop_parameter) {
24cargo:warning= | ^~~~~~~~~~~~~~~
25
26[1] https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=5a6af707f0af
27
28Upstream-Status: Submitted [https://github.com/llvm/llvm-project/pull/138077]
29
30Signed-off-by: Khem Raj <raj.khem@gmail.com>
31---
32 libunwind/src/UnwindLevel1.c | 4 ++--
33 1 file changed, 2 insertions(+), 2 deletions(-)
34
35diff --git a/libunwind/src/UnwindLevel1.c b/libunwind/src/UnwindLevel1.c
36index 7e785f4d31e7..ed2c8239824c 100644
37--- a/libunwind/src/UnwindLevel1.c
38+++ b/libunwind/src/UnwindLevel1.c
39@@ -185,7 +185,7 @@ extern int __unw_step_stage2(unw_cursor_t *);
40
41 #if defined(_LIBUNWIND_USE_GCS)
42 // Enable the GCS target feature to permit gcspop instructions to be used.
43-__attribute__((target("gcs")))
44+__attribute__((target("+gcs")))
45 #endif
46 static _Unwind_Reason_Code
47 unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *exception_object) {
48@@ -329,7 +329,7 @@ unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except
49
50 #if defined(_LIBUNWIND_USE_GCS)
51 // Enable the GCS target feature to permit gcspop instructions to be used.
52-__attribute__((target("gcs")))
53+__attribute__((target("+gcs")))
54 #endif
55 static _Unwind_Reason_Code
56 unwind_phase2_forced(unw_context_t *uc, unw_cursor_t *cursor,
diff --git a/meta/recipes-devtools/clang/clang/0037-compiler-rt-Exclude-sync_fetch_and_-for-any-pre-ARMv.patch b/meta/recipes-devtools/clang/clang/0037-compiler-rt-Exclude-sync_fetch_and_-for-any-pre-ARMv.patch
new file mode 100644
index 0000000000..a7e5c5a859
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0037-compiler-rt-Exclude-sync_fetch_and_-for-any-pre-ARMv.patch
@@ -0,0 +1,63 @@
1From d2360096db2da00121f4e653b39ca1f7eb2801eb Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Sat, 10 May 2025 14:03:12 -0700
4Subject: [PATCH] compiler-rt: Exclude sync_fetch_and_* for any pre-ARMv6 targets
5
6Sometimes builds may happen where ABI is not indidated by host_triple
7e.g. on Yocto the compiler used is called arm-poky-linux-gnueabi-clang
8for all arm32 cross compilers, it passed the ABI flags on cmdline in
9addition. e.g.
10
11-march=armv5te -mfloat-abi=soft
12or
13-march=armv7-a -mfloat-abi=hard
14
15compiler-rt's makery tries to add arm to COMPILER_RT_SUPPORTED_ARCH
16deducing it from triple name.
17
18which ends up choosing `arm` as one of compiler-rt arch to build for.
19This arch is however using armv7+ defaults and then tried to build sync
20builtins using
21
22arm-poky-linux-gnueabi-clang -march=armv5te -mfloat-abi=soft ...
23
24Which does not compile correctly, in such cases it should simply
25remove the sync builtins from list of things to build similar to what
26is done when we use armv4t or armv5t
27
28set(armv4t_SOURCES ${arm_min_SOURCES})
29set(armv5te_SOURCES ${arm_min_SOURCES})
30
31This lets compiler-rt build for arm architectures without depending
32upong compiler triple, but instead of poking the compiler for what
33it is building for
34
35Upstream-Status: Submitted [https://github.com/llvm/llvm-project/pull/139411]
36Signed-off-by: Khem Raj <raj.khem@gmail.com>
37---
38 compiler-rt/lib/builtins/CMakeLists.txt | 12 ++++++++++++
39 1 file changed, 12 insertions(+)
40
41diff --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt
42index cb276311b290..53a3cd1dc81f 100644
43--- a/compiler-rt/lib/builtins/CMakeLists.txt
44+++ b/compiler-rt/lib/builtins/CMakeLists.txt
45@@ -864,6 +864,18 @@ else ()
46 list(JOIN BUILTIN_CFLAGS " " CMAKE_REQUIRED_FLAGS)
47 set(CMAKE_REQUIRED_FLAGS "${TARGET_${arch}_CFLAGS} ${BUILTIN_CFLAGS_${arch}}")
48 message(STATUS "Performing additional configure checks with target flags: ${CMAKE_REQUIRED_FLAGS}")
49+ # For ARM archs, exclude any sync builtins if dmb or mcr p15, #0, r0, c7, c10, #5
50+ # is not supported
51+ if (${arch} MATCHES "^(arm|armhf)$")
52+ try_compile_only(COMPILER_RT_HAS_${arch}_SYNC
53+ SOURCE "#if __ARM_ARCH < 6
54+ #error DMB is only supported on ARMv6+ !
55+ #endif
56+ int main(void) { return 0; }")
57+ if(NOT COMPILER_RT_HAS_${arch}_SYNC)
58+ list(REMOVE_ITEM ${arch}_SOURCES ${arm_sync_SOURCES})
59+ endif()
60+ endif()
61 # For ARM archs, exclude any VFP builtins if VFP is not supported
62 if (${arch} MATCHES "^(arm|armhf|armv7|armv7s|armv7k|armv7m|armv7em|armv8m.main|armv8.1m.main)$")
63 string(REPLACE ";" " " _TARGET_${arch}_CFLAGS "${TARGET_${arch}_CFLAGS}")
diff --git a/meta/recipes-devtools/clang/clang/0038-compiler-rt-Hardcode-uptr-sptr-typedefs-on-Mips-Linu.patch b/meta/recipes-devtools/clang/clang/0038-compiler-rt-Hardcode-uptr-sptr-typedefs-on-Mips-Linu.patch
new file mode 100644
index 0000000000..b54c163857
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0038-compiler-rt-Hardcode-uptr-sptr-typedefs-on-Mips-Linu.patch
@@ -0,0 +1,35 @@
1From 9f88f2e4efa56e53c78f9b67775c71afa711a69c Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Thu, 22 May 2025 21:50:45 -0700
4Subject: [PATCH] [compiler-rt] Hardcode uptr/sptr typedefs on Mips/Linux
5
6Sanitizer build on Mips/Linux faills to build due to assertion errors
7mismatched definitions. This is due to inconsistent definitions of
8`uptr` of either `unsigned long` or `unsigned int` in compiler-rt. This
9is caused by clang defining
10
11__UINTPTR_TYPE__ long unsigned int where as gcc defines it as
12unsigned int
13
14As a workaround, this hardcodes `uptr`/`sptr` in compiler-rt to
15`unsigned int`/`int` on Linux Mips, matching gcc.
16
17Upstream-Status: Submitted [https://github.com/llvm/llvm-project/pull/141201]
18Signed-off-by: Khem Raj <raj.khem@gmail.com>
19---
20 compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h | 2 +-
21 1 file changed, 1 insertion(+), 1 deletion(-)
22
23diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h b/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h
24index fff60c96f632..511ee8fe49cc 100644
25--- a/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h
26+++ b/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h
27@@ -139,7 +139,7 @@
28 namespace __sanitizer {
29
30 #if defined(__UINTPTR_TYPE__)
31-# if defined(__arm__) && defined(__linux__)
32+# if (defined(__arm__) || _ABIO32 == 1) && defined(__linux__)
33 // Linux Arm headers redefine __UINTPTR_TYPE__ and disagree with clang/gcc.
34 typedef unsigned int uptr;
35 typedef int sptr;
diff --git a/meta/recipes-devtools/clang/clang_git.bb b/meta/recipes-devtools/clang/clang_git.bb
new file mode 100644
index 0000000000..23dfbb5deb
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang_git.bb
@@ -0,0 +1,488 @@
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 multilib_header
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 'RISCV'
39 elif re.match('riscv64$', a): return 'RISCV'
40 elif re.match('p(pc|owerpc)(|64)', a): return 'PowerPC'
41 elif re.match('loongarch64$', a): return 'LoongArch'
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 libclang-python \
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,,"
93PACKAGECONFIG[libclang-python] = "-DCLANG_PYTHON_BINDINGS_VERSIONS=${PYTHON_BASEVERSION},,"
94
95OECMAKE_SOURCEPATH = "${S}/llvm"
96
97OECMAKE_TARGET_COMPILE = "${@bb.utils.contains('PACKAGECONFIG', 'bootstrap', 'stage2', 'all', d)}"
98OECMAKE_TARGET_INSTALL = "${@bb.utils.contains('PACKAGECONFIG', 'bootstrap', 'stage2-install', 'install', d)}"
99BINPATHPREFIX = "${@bb.utils.contains('PACKAGECONFIG', 'bootstrap', '/tools/clang/stage2-bins/NATIVE', '', d)}"
100
101PASSTHROUGH = "\
102CLANG_DEFAULT_RTLIB;CLANG_DEFAULT_CXX_STDLIB;LLVM_BUILD_LLVM_DYLIB;LLVM_LINK_LLVM_DYLIB;\
103LLVM_ENABLE_ASSERTIONS;LLVM_ENABLE_EXPENSIVE_CHECKS;LLVM_ENABLE_PIC;\
104LLVM_BINDINGS_LIST;LLVM_ENABLE_FFI;FFI_INCLUDE_DIR;LLVM_OPTIMIZED_TABLEGEN;\
105LLVM_ENABLE_RTTI;LLVM_ENABLE_EH;LLVM_BUILD_EXTERNAL_COMPILER_RT;CMAKE_SYSTEM_NAME;\
106CMAKE_BUILD_TYPE;BUILD_SHARED_LIBS;LLVM_ENABLE_PROJECTS;LLVM_ENABLE_RUNTIMES;LLVM_BINUTILS_INCDIR;\
107LLVM_TARGETS_TO_BUILD;LLVM_EXPERIMENTAL_TARGETS_TO_BUILD;PYTHON_EXECUTABLE;\
108PYTHON_LIBRARY;PYTHON_INCLUDE_DIR;LLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN;LLDB_EDITLINE_USE_WCHAR;\
109LLVM_ENABLE_LIBEDIT;LLDB_ENABLE_LIBEDIT;LLDB_PYTHON_RELATIVE_PATH;LLDB_PYTHON_EXE_RELATIVE_PATH;\
110LLDB_PYTHON_EXT_SUFFIX;CMAKE_C_FLAGS_RELEASE;CMAKE_CXX_FLAGS_RELEASE;CMAKE_ASM_FLAGS_RELEASE;\
111CLANG_DEFAULT_CXX_STDLIB;CLANG_DEFAULT_RTLIB;CLANG_DEFAULT_UNWINDLIB;\
112CLANG_DEFAULT_OPENMP_RUNTIME;LLVM_ENABLE_PER_TARGET_RUNTIME_DIR;\
113LLVM_BUILD_TOOLS;LLVM_USE_HOST_TOOLS;LLVM_CONFIG_PATH;LLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR;\
114"
115#
116# Default to build all OE-Core supported target arches (user overridable).
117# Gennerally setting LLVM_TARGETS_TO_BUILD = "" in local.conf is ok in most simple situations
118# where only one target architecture is needed along with just one build arch (usually X86)
119# Core tier targets:
120# AArch64;AMDGPU;ARM;AVR;BPF;Hexagon;Lanai;LoongArch;Mips;MSP430;NVPTX;PowerPC;RISCV;Sparc;SPIRV;SystemZ;VE;WebAssembly;X86;XCore
121# Known experimental targets: ARC;CSKY;DirectX;M68k;Xtensa
122
123LLVM_TARGETS_TO_BUILD ?= "AMDGPU;AArch64;ARM;BPF;Mips;PowerPC;RISCV;X86;LoongArch;NVPTX;SPIRV"
124LLVM_TARGETS_TO_BUILD:class-target ?= "${@get_clang_host_arch(bb, d)};AMDGPU;BPF;NVPTX;SPIRV"
125
126LLVM_EXPERIMENTAL_TARGETS_TO_BUILD ?= ""
127
128HF = ""
129HF:class-target = "${@ bb.utils.contains('TUNE_CCARGS_MFLOAT', 'hard', 'hf', '', d)}"
130HF[vardepvalue] = "${HF}"
131
132# Ensure that LLVM_PROJECTS does not contain compiler runtime components e.g. libcxx etc
133# they are enabled via LLVM_ENABLE_RUNTIMES
134LLVM_PROJECTS ?= "clang;clang-tools-extra;libclc;lld${LLDB}"
135LLDB ?= ";lldb"
136# LLDB support for RISCV32/Mips32 does not work yet
137LLDB:riscv32 = ""
138LLDB:mips = ""
139LLDB:mipsel = ""
140LLDB:powerpc = ""
141
142# linux hosts (.so) on Windows .pyd
143SOLIBSDEV:mingw32 = ".pyd"
144
145#CMAKE_VERBOSE = "VERBOSE=1"
146
147EXTRA_OECMAKE += "-DLLVM_ENABLE_ASSERTIONS=OFF \
148 -DLLVM_APPEND_VC_REV=OFF \
149 -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF \
150 -DLLVM_ENABLE_EXPENSIVE_CHECKS=OFF \
151 -DLLVM_ENABLE_PIC=ON \
152 -DCLANG_DEFAULT_PIE_ON_LINUX=ON \
153 -DLLVM_BINDINGS_LIST='' \
154 -DLLVM_ENABLE_FFI=ON \
155 -DLLVM_ENABLE_ZSTD=ON \
156 -DFFI_INCLUDE_DIR=$(pkg-config --variable=includedir libffi) \
157 -DLLVM_OPTIMIZED_TABLEGEN=ON \
158 -DLLVM_BUILD_EXTERNAL_COMPILER_RT=ON \
159 -DCMAKE_SYSTEM_NAME=Linux \
160 -DCMAKE_BUILD_TYPE=Release \
161 -DLLVM_ENABLE_PROJECTS='${LLVM_PROJECTS}' \
162 -DLLVM_BINUTILS_INCDIR=${STAGING_INCDIR} \
163 -DLLVM_VERSION_SUFFIX='${VER_SUFFIX}' \
164 -DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN=ON \
165 -DLLVM_TARGETS_TO_BUILD='${LLVM_TARGETS_TO_BUILD}' \
166 -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD='${LLVM_EXPERIMENTAL_TARGETS_TO_BUILD}' \
167"
168
169EXTRA_OECMAKE:append:class-native = "\
170 -DPYTHON_EXECUTABLE='${PYTHON}' \
171"
172EXTRA_OECMAKE:append:class-nativesdk = "\
173 -DCROSS_TOOLCHAIN_FLAGS_NATIVE='-DLLDB_PYTHON_RELATIVE_PATH=${PYTHON_SITEPACKAGES_DIR} \
174 -DLLDB_PYTHON_EXE_RELATIVE_PATH=${PYTHON_PN} \
175 -DLLDB_PYTHON_EXT_SUFFIX=${SOLIBSDEV} \
176 -DCMAKE_TOOLCHAIN_FILE=${WORKDIR}/toolchain-native.cmake' \
177 -DCMAKE_RANLIB=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-ranlib \
178 -DCMAKE_AR=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-ar \
179 -DCMAKE_NM=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-nm \
180 -DCMAKE_STRIP=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-strip \
181 -DLLVM_NATIVE_TOOL_DIR=${STAGING_BINDIR_NATIVE} \
182 -DLLVM_HEADERS_TABLEGEN=${STAGING_BINDIR_NATIVE}/llvm-min-tblgen \
183 -DPYTHON_LIBRARY=${STAGING_LIBDIR}/lib${PYTHON_DIR}${PYTHON_ABI}.so \
184 -DLLDB_PYTHON_RELATIVE_PATH=${PYTHON_SITEPACKAGES_DIR} \
185 -DLLDB_PYTHON_EXE_RELATIVE_PATH=${PYTHON_PN} \
186 -DLLDB_PYTHON_EXT_SUFFIX=${SOLIBSDEV} \
187 -DPYTHON_INCLUDE_DIR=${STAGING_INCDIR}/${PYTHON_DIR}${PYTHON_ABI} \
188 -DPYTHON_EXECUTABLE='${PYTHON}' \
189"
190EXTRA_OECMAKE:append:class-target = "\
191 -DLLVM_NATIVE_TOOL_DIR=${STAGING_BINDIR_NATIVE} \
192 -DLLVM_HEADERS_TABLEGEN=${STAGING_BINDIR_NATIVE}/llvm-min-tblgen \
193 -DCMAKE_RANLIB=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-ranlib \
194 -DCMAKE_AR=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-ar \
195 -DCMAKE_NM=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-nm \
196 -DCMAKE_STRIP=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-strip \
197 -DLLVM_TARGET_ARCH=${HOST_ARCH} \
198 -DLLVM_DEFAULT_TARGET_TRIPLE=${TARGET_SYS}${HF} \
199 -DLLVM_HOST_TRIPLE=${TARGET_SYS}${HF} \
200 -DPYTHON_LIBRARY=${STAGING_LIBDIR}/lib${PYTHON_DIR}${PYTHON_ABI}.so \
201 -DPYTHON_INCLUDE_DIR=${STAGING_INCDIR}/${PYTHON_DIR}${PYTHON_ABI} \
202 -DLLVM_LIBDIR_SUFFIX=${LLVM_LIBDIR_SUFFIX} \
203 -DLLDB_PYTHON_RELATIVE_PATH=${PYTHON_SITEPACKAGES_DIR} \
204 -DLLDB_PYTHON_EXE_RELATIVE_PATH=${bindir} \
205 -DLLDB_PYTHON_EXT_SUFFIX=${SOLIBSDEV} \
206"
207
208DEPENDS = "binutils zlib zstd libffi libxml2 libxml2-native ninja-native swig-native spirv-tools-native"
209DEPENDS:append:class-nativesdk = " clang-crosssdk-${SDK_SYS} virtual/nativesdk-cross-binutils nativesdk-python3"
210DEPENDS:append:class-target = " clang-cross-${TARGET_ARCH} python3 ${@bb.utils.contains('TC_CXX_RUNTIME', 'llvm', 'compiler-rt libcxx', '', d)} spirv-llvm-translator-native"
211
212RRECOMMENDS:${PN} = "binutils"
213RRECOMMENDS:${PN}:append:class-target = "${@bb.utils.contains('TC_CXX_RUNTIME', 'llvm', ' libcxx-dev', '', d)}"
214
215# patch out build host paths for reproducibility
216reproducible_build_variables() {
217 sed -i -e "s,${DEBUG_PREFIX_MAP},,g" \
218 -e "s,--sysroot=${RECIPE_SYSROOT},,g" \
219 -e "s,${STAGING_DIR_HOST},,g" \
220 -e "s,${S}/llvm,,g" \
221 -e "s,${B},,g" \
222 ${B}/tools/llvm-config/BuildVariables.inc
223}
224
225do_configure:append:class-target() {
226 reproducible_build_variables
227}
228
229do_configure:append:class-nativesdk() {
230 reproducible_build_variables
231}
232
233do_install:append() {
234 rm -rf ${D}${libdir}/python*/site-packages/six.py
235 for t in clang-pseudo clang-pseudo-gen clang-rename; do
236 if [ -e ${B}${BINPATHPREFIX}/bin/$t ]; then
237 install -Dm 0755 ${B}${BINPATHPREFIX}/bin/$t ${D}${bindir}/$t
238 fi
239 done
240
241 oe_multilib_header llvm/Config/llvm-config.h
242 oe_multilib_header clang/Config/config.h
243}
244
245do_install:append:class-target () {
246 # Allow bin path to change based on YOCTO_ALTERNATE_EXE_PATH
247 sed -i 's;${_IMPORT_PREFIX}/bin;${_IMPORT_PREFIX_BIN};g' ${D}${libdir}/cmake/llvm/LLVMExports-release.cmake
248
249 # Insert function to populate Import Variables
250 sed -i "4i\
251if(DEFINED ENV{YOCTO_ALTERNATE_EXE_PATH})\n\
252 execute_process(COMMAND \"llvm-config\" \"--bindir\" OUTPUT_VARIABLE _IMPORT_PREFIX_BIN OUTPUT_STRIP_TRAILING_WHITESPACE)\n\
253else()\n\
254 set(_IMPORT_PREFIX_BIN \"\${_IMPORT_PREFIX}/bin\")\n\
255endif()\n" ${D}${libdir}/cmake/llvm/LLVMExports-release.cmake
256
257 if [ -n "${LLVM_LIBDIR_SUFFIX}" ]; then
258 mkdir -p ${D}${nonarch_libdir}
259 mv ${D}${libdir}/clang ${D}${nonarch_libdir}/clang
260 ln -rs ${D}${nonarch_libdir}/clang ${D}${libdir}/clang
261 rmdir --ignore-fail-on-non-empty ${D}${libdir}
262 fi
263 for t in clang clang++ llvm-nm llvm-ar llvm-as llvm-ranlib llvm-strip llvm-objcopy llvm-objdump llvm-readelf \
264 llvm-addr2line llvm-dwp llvm-size llvm-strings llvm-cov; do
265 ln -sf $t ${D}${bindir}/${TARGET_PREFIX}$t
266 done
267
268 # reproducibility
269 sed -i -e 's,${B},,g' ${D}${libdir}/cmake/llvm/LLVMConfig.cmake
270}
271
272do_install:append:class-native () {
273 if ${@bb.utils.contains('PACKAGECONFIG', 'clangd', 'true', 'false', d)}; then
274 install -Dm 0755 ${B}${BINPATHPREFIX}/bin/clangd-indexer ${D}${bindir}/clangd-indexer
275 fi
276 install -Dm 0755 ${B}${BINPATHPREFIX}/bin/clang-tidy-confusable-chars-gen ${D}${bindir}/clang-tidy-confusable-chars-gen
277 install -Dm 0755 ${B}${BINPATHPREFIX}/bin/clang-tblgen ${D}${bindir}/clang-tblgen
278 install -Dm 0755 ${B}${BINPATHPREFIX}/bin/lldb-tblgen ${D}${bindir}/lldb-tblgen
279 install -Dm 0755 ${B}${BINPATHPREFIX}/bin/llvm-min-tblgen ${D}${bindir}/llvm-min-tblgen
280 install -Dm 0755 ${B}${BINPATHPREFIX}/bin/prepare_builtins ${D}${bindir}/prepare_builtins
281
282 for f in `find ${D}${bindir} -executable -type f -not -type l`; do
283 test -n "`file -b $f|grep -i ELF`" && ${STRIP} $f
284 echo "stripped $f"
285 done
286 ln -sf clang-tblgen ${D}${bindir}/clang-tblgen${PV}
287 ln -sf llvm-tblgen ${D}${bindir}/llvm-tblgen${PV}
288 ln -sf llvm-config ${D}${bindir}/llvm-config${PV}
289}
290
291do_install:append:class-nativesdk () {
292 if [ -e ${D}${libdir}/cmake/llvm/LLVMConfig.cmake ] ; then
293 sed -i -e "s|${B}/./bin/||g" ${D}${libdir}/cmake/llvm/LLVMConfig.cmake
294 fi
295 if ${@bb.utils.contains('PACKAGECONFIG', 'clangd', 'true', 'false', d)}; then
296 install -Dm 0755 ${B}${BINPATHPREFIX}/bin/clangd-indexer ${D}${bindir}/clangd-indexer
297 fi
298 install -Dm 0755 ${B}${BINPATHPREFIX}/bin/clang-tblgen ${D}${bindir}/clang-tblgen
299 install -Dm 0755 ${B}${BINPATHPREFIX}/bin/clang-tidy-confusable-chars-gen ${D}${bindir}/clang-tidy-confusable-chars-gen
300 for f in `find ${D}${bindir} -executable -type f -not -type l`; do
301 test -n "`file -b $f|grep -i ELF`" && ${STRIP} $f
302 done
303 ln -sf clang-tblgen ${D}${bindir}/clang-tblgen${PV}
304 ln -sf llvm-tblgen ${D}${bindir}/llvm-tblgen${PV}
305 ln -sf llvm-config ${D}${bindir}/llvm-config${PV}
306 rm -rf ${D}${datadir}/llvm/cmake
307 rm -rf ${D}${datadir}/llvm
308
309 #reproducibility
310 if [ -e ${D}${libdir}/cmake/llvm/LLVMConfig.cmake ] ; then
311 sed -i -e 's,${B},,g' ${D}${libdir}/cmake/llvm/LLVMConfig.cmake
312 fi
313}
314
315PROVIDES:append:class-native = " llvm-native libclc-native"
316PROVIDES:append:class-target = " llvm libclc"
317PROVIDES:append:class-nativesdk = " nativesdk-llvm nativesdk-libclc"
318
319PACKAGES =+ "${PN}-libllvm ${PN}-lldb-python ${PN}-libclang-python ${PN}-libclang-cpp ${PN}-tidy ${PN}-format ${PN}-tools ${PN}-clc \
320 libclang lldb lldb-server liblldb llvm-linker-tools"
321
322BBCLASSEXTEND = "native nativesdk"
323
324RDEPENDS:lldb += "${PN}-lldb-python lldb-server"
325
326RDEPENDS:${PN}-tools += "\
327 perl-module-digest-md5 \
328 perl-module-file-basename \
329 perl-module-file-copy \
330 perl-module-file-find \
331 perl-module-file-path \
332 perl-module-findbin \
333 perl-module-hash-util \
334 perl-module-sys-hostname \
335 perl-module-term-ansicolor \
336"
337
338RPROVIDES:${PN}-clc = "${MLPREFIX}libclc"
339
340RRECOMMENDS:${PN}-tidy += "${PN}-tools"
341
342FILES:llvm-linker-tools = "${libdir}/LLVMgold* ${libdir}/libLTO.so.* ${libdir}/LLVMPolly*"
343
344FILES:${PN}-libclang-cpp = "${libdir}/libclang-cpp.so.*"
345
346FILES:${PN}-lldb-python = "${libdir}/python*/site-packages/lldb/*"
347
348FILES:${PN}-libclang-python = "${PYTHON_SITEPACKAGES_DIR}/clang/*"
349
350FILES:${PN}-tidy = "${bindir}/*clang-tidy*"
351FILES:${PN}-format = "${bindir}/*clang-format*"
352
353FILES:${PN}-tools = "${bindir}/analyze-build \
354 ${bindir}/c-index-test \
355 ${bindir}/clang-apply-replacements \
356 ${bindir}/clang-change-namespace \
357 ${bindir}/clang-check \
358 ${bindir}/clang-doc \
359 ${bindir}/clang-extdef-mapping \
360 ${bindir}/clang-include-fixer \
361 ${bindir}/clang-linker-wrapper \
362 ${bindir}/clang-move \
363 ${bindir}/clang-nvlink-wrapper \
364 ${bindir}/clang-offload-bundler \
365 ${bindir}/clang-offload-packager \
366 ${bindir}/clang-pseudo* \
367 ${bindir}/clang-query \
368 ${bindir}/clang-refactor \
369 ${bindir}/clang-rename* \
370 ${bindir}/clang-reorder-fields \
371 ${bindir}/clang-repl \
372 ${bindir}/clang-scan-deps \
373 ${bindir}/diagtool \
374 ${bindir}/find-all-symbols \
375 ${bindir}/hmaptool \
376 ${bindir}/hwasan_symbolize \
377 ${bindir}/intercept-build \
378 ${bindir}/modularize \
379 ${bindir}/pp-trace \
380 ${bindir}/sancov \
381 ${bindir}/scan-build \
382 ${bindir}/scan-build-py \
383 ${bindir}/scan-view \
384 ${bindir}/split-file \
385 ${libdir}/libscanbuild/* \
386 ${libdir}/libear/* \
387 ${libexecdir}/analyze-c++ \
388 ${libexecdir}/analyze-cc \
389 ${libexecdir}/c++-analyzer \
390 ${libexecdir}/ccc-analyzer \
391 ${libexecdir}/intercept-c++ \
392 ${libexecdir}/intercept-cc \
393 ${datadir}/scan-build/* \
394 ${datadir}/scan-view/* \
395 ${datadir}/opt-viewer/* \
396 ${datadir}/clang/* \
397"
398
399FILES:${PN} += "\
400 ${bindir}/clang-cl \
401 ${libdir}/BugpointPasses.so \
402 ${libdir}/LLVMHello.so \
403 ${libdir}/*Plugin.so \
404 ${libdir}/${BPN} \
405 ${nonarch_libdir}/${BPN}/*/include/ \
406"
407
408FILES:${PN}-clc += "${datadir}/clc"
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#Avoid SSTATE_SCAN_COMMAND running sed over llvm-config.
457SSTATE_SCAN_FILES:remove = "*-config"
458
459COMPILER_RT:class-nativesdk:toolchain-clang:runtime-llvm = "-rtlib=libgcc --unwindlib=libgcc"
460LIBCPLUSPLUS:class-nativesdk:toolchain-clang:runtime-llvm = "-stdlib=libstdc++"
461
462SYSROOT_DIRS:append:class-target = " ${nonarch_libdir}"
463
464SYSROOT_PREPROCESS_FUNCS:append:class-target = " clang_sysroot_preprocess"
465SYSROOT_PREPROCESS_FUNCS:append:class-nativesdk = " clang_sysroot_preprocess"
466
467clang_sysroot_preprocess() {
468 install -d ${SYSROOT_DESTDIR}${bindir_crossscripts}/
469 install -m 0755 ${S}/llvm/tools/llvm-config/llvm-config ${SYSROOT_DESTDIR}${bindir_crossscripts}/
470 ln -sf llvm-config ${SYSROOT_DESTDIR}${bindir_crossscripts}/llvm-config${PV}
471 # LLDTargets.cmake references the lld executable(!) that some modules/plugins link to
472 install -d ${SYSROOT_DESTDIR}${bindir}
473
474 binaries="lld diagtool clang-${MAJOR_VER} clang-format clang-offload-packager
475 clang-offload-bundler clang-scan-deps clang-repl
476 clang-refactor clang-check clang-extdef-mapping clang-apply-replacements
477 clang-reorder-fields clang-tidy clang-change-namespace clang-doc clang-include-fixer
478 find-all-symbols clang-move clang-query pp-trace modularize"
479
480 if ${@bb.utils.contains('PACKAGECONFIG', 'clangd', 'true', 'false', d)}; then
481 binaries="${binaries} clangd"
482 fi
483
484 for f in ${binaries}
485 do
486 install -m 755 ${D}${bindir}/$f ${SYSROOT_DESTDIR}${bindir}/
487 done
488}
diff --git a/meta/recipes-devtools/clang/common-clang.inc b/meta/recipes-devtools/clang/common-clang.inc
new file mode 100644
index 0000000000..cbea6b4d75
--- /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 = "7"
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..37d37ec197
--- /dev/null
+++ b/meta/recipes-devtools/clang/common.inc
@@ -0,0 +1,75 @@
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"
17UPSTREAM_CHECK_URI = "${LLVM_HTTP}/llvm-project/releases/"
18UPSTREAM_CHECK_REGEX = "releases/tag/llvmorg-?(?P<pver>\d+(\.\d+)+)"
19SOURCEDIR ?= "llvm-project-${PV}.src"
20SRC_URI[sha256sum] = "cd8fd55d97ad3e360b1d5aaf98388d1f70dfffb7df36beee478be3b839ff9008"
21
22SRC_URI = "\
23 ${BASEURI} \
24 file://0001-libcxxabi-Find-libunwind-headers-when-LIBCXXABI_LIBU.patch \
25 file://0002-compiler-rt-support-a-new-embedded-linux-target.patch \
26 file://0003-compiler-rt-Simplify-cross-compilation.-Don-t-use-na.patch \
27 file://0004-llvm-TargetLibraryInfo-Undefine-libc-functions-if-th.patch \
28 file://0005-llvm-allow-env-override-of-exe-and-libdir-path.patch \
29 file://0006-clang-driver-Check-sysroot-for-ldso-path.patch \
30 file://0007-clang-Driver-tools.cpp-Add-lssp_nonshared-on-musl.patch \
31 file://0008-clang-Prepend-trailing-to-sysroot.patch \
32 file://0009-clang-Look-inside-the-target-sysroot-for-compiler-ru.patch \
33 file://0010-clang-Define-releative-gcc-installation-dir.patch \
34 file://0011-clang-Add-lpthread-and-ldl-along-with-lunwind-for-st.patch \
35 file://0012-Pass-PYTHON_EXECUTABLE-when-cross-compiling-for-nati.patch \
36 file://0013-Check-for-atomic-double-intrinsics.patch \
37 file://0014-cmake-Fix-configure-for-packages-using-find_package.patch \
38 file://0015-clang-Fix-resource-dir-location-for-cross-toolchains.patch \
39 file://0016-clang-driver-Add-dyld-prefix-when-checking-sysroot-f.patch \
40 file://0017-clang-Use-python3-in-python-scripts.patch \
41 file://0018-llvm-clang-Insert-anchor-for-adding-OE-distro-vendor.patch \
42 file://0019-compiler-rt-Do-not-use-backtrace-APIs-on-non-glibc-l.patch \
43 file://0020-clang-Fix-x86-triple-for-non-debian-multiarch-linux-.patch \
44 file://0021-libunwind-Added-unw_backtrace-method.patch \
45 file://0022-lldb-Link-with-libatomic-on-x86.patch \
46 file://0023-compiler-rt-Enable-__int128-for-ppc32.patch \
47 file://0024-llvm-Do-not-use-cmake-infra-to-detect-libzstd.patch \
48 file://0025-compiler-rt-Fix-stat-struct-s-size-for-O32-ABI.patch \
49 file://0026-compiler-rt-Undef-_TIME_BITS-along-with-_FILE_OFFSET.patch \
50 file://0027-ToolChains-Gnu.cpp-ARMLibDirs-search-also-in-lib32.patch \
51 file://0028-clang-llvm-Add-OE-specific-ABI-triple-for-N32-ABI.patch \
52 file://0029-llvm-Add-libunwind.pc.in-and-llvm-config-scripts.patch \
53 file://0030-scan-build-py-respect-LLVM_LIBDIR_SUFFIX-like-other-.patch \
54 file://0031-compiler-rt-Do-not-pass-target-to-clang-compiler.patch \
55 file://0032-clangd-Add-a-build-option-to-disable-building-dexp.patch \
56 file://0033-AsmMatcherEmitter-sort-ClassInfo-lists-by-name-as-we.patch \
57 file://0034-llvm-config-remove-LLVM_LDFLAGS-from-ldflags-output.patch \
58 file://0035-openmp-Do-not-emit-date-and-time-into-generate-files.patch \
59 file://0036-libunwind-Use-gcs-instead-of-gcs-target-attribute.patch \
60 file://0037-compiler-rt-Exclude-sync_fetch_and_-for-any-pre-ARMv.patch \
61 file://0038-compiler-rt-Hardcode-uptr-sptr-typedefs-on-Mips-Linu.patch \
62"
63# Fallback to no-PIE if not set
64GCCPIE ??= ""
65
66UNPACKDIR = "${TMPDIR}/work-shared/llvm-project-source-${PV}-${PR}/sources"
67S = "${UNPACKDIR}/${SOURCEDIR}"
68B ?= "${WORKDIR}/llvm-project-source-${PV}/build.${HOST_SYS}.${TARGET_SYS}"
69
70# We need to ensure that for the shared work directory, the do_patch signatures match
71# The real WORKDIR location isn't a dependency for the shared workdir.
72src_patches[vardepsexclude] = "WORKDIR"
73should_apply[vardepsexclude] += "PN"
74
75BPN = "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..47438014b2
--- /dev/null
+++ b/meta/recipes-devtools/clang/compiler-rt-sanitizers_git.bb
@@ -0,0 +1,138 @@
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
17def get_compiler_rt_arch(bb, d):
18 if bb.utils.contains('TUNE_FEATURES', 'armv5 thumb dsp', True, False, d):
19 return 'armv5te'
20 elif bb.utils.contains('TUNE_FEATURES', 'armv4 thumb', True, False, d):
21 return 'armv4t'
22 elif bb.utils.contains('TUNE_FEATURES', 'arm vfp callconvention-hard', True, False, d):
23 return 'armhf'
24 return d.getVar('HOST_ARCH')
25
26LIC_FILES_CHKSUM = "file://compiler-rt/LICENSE.TXT;md5=d846d1d65baf322d4c485d6ee54e877a"
27
28TUNE_CCARGS:remove = "-no-integrated-as"
29COMPILER_RT ??= "-rtlib=libgcc -unwindlib=libgcc"
30LIBCPLUSPLUS ??= "-stdlib=libstdc++"
31
32CC = "${CCACHE}${HOST_PREFIX}clang ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}"
33CXX = "${CCACHE}${HOST_PREFIX}clang++ ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}"
34BUILD_CC = "${CCACHE}${HOST_PREFIX}clang ${BUILD_CC_ARCH}"
35BUILD_CXX = "${CCACHE}${HOST_PREFIX}clang++ ${BUILD_CC_ARCH}$"
36CFLAGS += "${COMPILER_RT}"
37CXXFLAGS += "${COMPILER_RT} ${LIBCPLUSPLUS}"
38
39TOOLCHAIN = "clang"
40
41DEPENDS += "ninja-native virtual/crypt compiler-rt"
42DEPENDS:append:class-native = " clang-native libxcrypt-native libcxx-native"
43DEPENDS:append:class-nativesdk = " virtual/cross-c++ clang-native clang-crosssdk-${SDK_SYS} nativesdk-libxcrypt nativesdk-gcc-runtime"
44DEPENDS:append:class-target = " virtual/cross-c++ clang-cross-${TARGET_ARCH} virtual/${MLPREFIX}libc gcc-runtime"
45
46PACKAGECONFIG ??= ""
47PACKAGECONFIG[crt] = "-DCOMPILER_RT_BUILD_CRT:BOOL=ON,-DCOMPILER_RT_BUILD_CRT:BOOL=OFF"
48PACKAGECONFIG[static-libcxx] = "-DSANITIZER_USE_STATIC_CXX_ABI=ON -DSANITIZER_USE_STATIC_LLVM_UNWINDER=ON -DCOMPILER_RT_ENABLE_STATIC_UNWINDER=ON,,"
49# Context Profiling
50PACKAGECONFIG[ctx-profile] = "-DCOMPILER_RT_BUILD_CTX_PROFILE=ON,-DCOMPILER_RT_BUILD_CTX_PROFILE=OFF"
51
52CXXFLAGS:append:libc-musl = " -D_LARGEFILE64_SOURCE"
53
54OECMAKE_TARGET_COMPILE = "compiler-rt"
55OECMAKE_TARGET_INSTALL = "install-compiler-rt install-compiler-rt-headers"
56OECMAKE_SOURCEPATH = "${S}/llvm"
57EXTRA_OECMAKE += "-DCMAKE_BUILD_TYPE=RelWithDebInfo \
58 -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF \
59 -DCOMPILER_RT_STANDALONE_BUILD=ON \
60 -DCOMPILER_RT_USE_BUILTINS_LIBRARY=ON \
61 -DCOMPILER_RT_BUILD_BUILTINS=OFF \
62 -DCOMPILER_RT_INCLUDE_TESTS=OFF \
63 -DSANITIZER_CXX_ABI_LIBNAME=${@bb.utils.contains("TC_CXX_RUNTIME", "llvm", "libc++", "libstdc++", d)} \
64 -DCOMPILER_RT_BUILD_XRAY=ON \
65 -DCOMPILER_RT_BUILD_SANITIZERS=ON \
66 -DCOMPILER_RT_BUILD_LIBFUZZER=ON \
67 -DCOMPILER_RT_BUILD_PROFILE=ON \
68 -DCOMPILER_RT_BUILD_MEMPROF=ON \
69 -DCOMPILER_RT_DEFAULT_TARGET_ARCH=${@get_compiler_rt_arch(bb, d)} \
70 -DLLVM_ENABLE_RUNTIMES='compiler-rt' \
71 -DLLVM_LIBDIR_SUFFIX=${LLVM_LIBDIR_SUFFIX} \
72 -DLLVM_APPEND_VC_REV=OFF \
73 -S ${S}/runtimes \
74"
75
76EXTRA_OECMAKE:append:class-native = "\
77 -DCOMPILER_RT_USE_BUILTINS_LIBRARY=OFF \
78"
79
80EXTRA_OECMAKE:append:class-target = "\
81 -DCMAKE_RANLIB=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-ranlib \
82 -DCMAKE_AR=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-ar \
83 -DCMAKE_NM=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-nm \
84 -DCMAKE_C_COMPILER_TARGET=${HOST_SYS} \
85 -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON \
86 -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
87"
88
89EXTRA_OECMAKE:append:class-nativesdk = "\
90 -DCMAKE_RANLIB=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-ranlib \
91 -DCMAKE_AR=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-ar \
92 -DCMAKE_NM=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-nm \
93 -DLLVM_TABLEGEN=${STAGING_BINDIR_NATIVE}/llvm-tblgen \
94 -DCLANG_TABLEGEN=${STAGING_BINDIR_NATIVE}/clang-tblgen \
95 -DCMAKE_C_COMPILER_TARGET=${HOST_SYS} \
96 -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON \
97"
98
99EXTRA_OECMAKE:append:libc-musl = " -DLIBCXX_HAS_MUSL_LIBC=ON "
100
101do_install:append () {
102 mkdir -p ${D}${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/lib
103 mv ${D}${nonarch_libdir}/linux ${D}${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/lib
104 # Already shipped with compile-rt Orc support
105 rm -rf ${D}${nonarch_libdir}/clang/${MAJOR_VER}/lib/linux/liborc_rt-*.a
106 rm -rf ${D}${nonarch_libdir}/clang/${MAJOR_VER}/include/orc/
107}
108
109FILES_SOLIBSDEV = ""
110FILES:${PN} += "${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER} \
111 ${nonarch_libdir}/clang/${MAJOR_VER}/lib/linux/lib*${SOLIBSDEV} \
112 ${nonarch_libdir}/clang/${MAJOR_VER}/*.txt \
113 ${nonarch_libdir}/clang/${MAJOR_VER}/share/*.txt"
114FILES:${PN}-staticdev += "${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/lib/linux/*.a"
115FILES:${PN}-dev += "${datadir} ${nonarch_libdir}/clang/${MAJOR_VER}/lib/linux/*.syms \
116 ${nonarch_libdir}/clang/${MAJOR_VER}/include \
117 ${nonarch_libdir}/clang/${MAJOR_VER}/lib/linux/clang_rt.crt*.o \
118 ${nonarch_libdir}/clang/${MAJOR_VER}/lib/linux/libclang_rt.asan-preinit*.a"
119INSANE_SKIP:${PN} = "dev-so libdir"
120INSANE_SKIP:${PN}-dbg = "libdir"
121
122#PROVIDES:append:class-target = "\
123# virtual/${MLPREFIX}compilerlibs \
124# libgcc \
125# libgcc-initial \
126# libgcc-dev \
127# libgcc-initial-dev \
128# "
129#
130
131RDEPENDS:${PN}-dev += "${PN}-staticdev"
132
133BBCLASSEXTEND = "native nativesdk"
134
135ALLOW_EMPTY:${PN} = "1"
136ALLOW_EMPTY:${PN}-dev = "1"
137
138SYSROOT_DIRS:append:class-target = " ${nonarch_libdir}"
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..ff6cc29bf3
--- /dev/null
+++ b/meta/recipes-devtools/clang/compiler-rt_git.bb
@@ -0,0 +1,139 @@
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
19LIC_FILES_CHKSUM = "file://compiler-rt/LICENSE.TXT;md5=d846d1d65baf322d4c485d6ee54e877a"
20
21LIBCPLUSPLUS = ""
22COMPILER_RT = ""
23
24TUNE_CCARGS:remove = "-no-integrated-as"
25
26INHIBIT_DEFAULT_DEPS = "1"
27
28DEPENDS += "ninja-native libgcc"
29DEPENDS:append:class-target = " virtual/cross-c++ clang-cross-${TARGET_ARCH} virtual/${MLPREFIX}libc gcc-runtime"
30DEPENDS:append:class-nativesdk = " virtual/cross-c++ clang-native clang-crosssdk-${SDK_SYS} nativesdk-gcc-runtime"
31DEPENDS:append:class-native = " clang-native"
32
33# Trick clang.bbclass into not creating circular dependencies
34UNWINDLIB:class-nativesdk = "--unwindlib=libgcc"
35COMPILER_RT:class-nativesdk = "-rtlib=libgcc"
36LIBCPLUSPLUS:class-nativesdk = "-stdlib=libstdc++"
37UNWINDLIB:class-native = "--unwindlib=libgcc"
38COMPILER_RT:class-native = "-rtlib=libgcc"
39LIBCPLUSPLUS:class-native = "-stdlib=libstdc++"
40UNWINDLIB:class-target = "--unwindlib=libgcc"
41COMPILER_RT:class-target = "-rtlib=libgcc"
42LIBCPLUSPLUS:class-target = "-stdlib=libstdc++"
43
44PACKAGECONFIG ??= ""
45PACKAGECONFIG[crt] = "-DCOMPILER_RT_BUILD_CRT:BOOL=ON,-DCOMPILER_RT_BUILD_CRT:BOOL=OFF"
46PACKAGECONFIG[profile] = "-DCOMPILER_RT_BUILD_PROFILE=ON,-DCOMPILER_RT_BUILD_PROFILE=OFF"
47# Context Profiling, might need to enable 'profile' too
48PACKAGECONFIG[ctx-profile] = "-DCOMPILER_RT_BUILD_CTX_PROFILE=ON,-DCOMPILER_RT_BUILD_CTX_PROFILE=OFF"
49
50HF = ""
51HF:class-target = "${@ bb.utils.contains('TUNE_CCARGS_MFLOAT', 'hard', 'hf', '', d)}"
52
53CC = "${CCACHE}${HOST_PREFIX}clang ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}"
54CXX = "${CCACHE}${HOST_PREFIX}clang++ ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}"
55BUILD_CC = "${CCACHE}clang ${BUILD_CC_ARCH}"
56BUILD_CXX = "${CCACHE}clang++ ${BUILD_CC_ARCH}"
57LDFLAGS += "${COMPILER_RT} ${UNWINDLIB}"
58CXXFLAGS += "${LIBCPLUSPLUS}"
59
60TOOLCHAIN = "clang"
61
62def get_compiler_rt_arch(bb, d):
63 if bb.utils.contains('TUNE_FEATURES', 'armv5 thumb dsp', True, False, d):
64 return 'armv5te'
65 elif bb.utils.contains('TUNE_FEATURES', 'armv4 thumb', True, False, d):
66 return 'armv4t'
67 elif bb.utils.contains('TUNE_FEATURES', 'arm vfp callconvention-hard', True, False, d):
68 return 'armhf'
69 return d.getVar('HOST_ARCH')
70
71OECMAKE_TARGET_COMPILE = "compiler-rt"
72OECMAKE_TARGET_INSTALL = "install-compiler-rt install-compiler-rt-headers"
73OECMAKE_SOURCEPATH = "${S}/llvm"
74EXTRA_OECMAKE += "-DCMAKE_BUILD_TYPE=RelWithDebInfo \
75 -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF \
76 -DCOMPILER_RT_STANDALONE_BUILD=ON \
77 -DCOMPILER_RT_INCLUDE_TESTS=OFF \
78 -DCOMPILER_RT_BUILD_XRAY=OFF \
79 -DCOMPILER_RT_BUILD_SANITIZERS=OFF \
80 -DCOMPILER_RT_BUILD_MEMPROF=OFF \
81 -DCOMPILER_RT_BUILD_LIBFUZZER=OFF \
82 -DCOMPILER_RT_DEFAULT_TARGET_ARCH=${@get_compiler_rt_arch(bb, d)} \
83 -DLLVM_ENABLE_RUNTIMES='compiler-rt' \
84 -DLLVM_LIBDIR_SUFFIX=${LLVM_LIBDIR_SUFFIX} \
85 -DLLVM_APPEND_VC_REV=OFF \
86 -S ${S}/runtimes \
87"
88
89EXTRA_OECMAKE:append:class-target = "\
90 -DCMAKE_RANLIB=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-ranlib \
91 -DCMAKE_AR=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-ar \
92 -DCMAKE_NM=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-nm \
93 -DCMAKE_C_COMPILER_TARGET=${HOST_SYS} \
94 -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON \
95 -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
96"
97
98EXTRA_OECMAKE:append:class-nativesdk = "\
99 -DCMAKE_RANLIB=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-ranlib \
100 -DCMAKE_AR=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-ar \
101 -DCMAKE_NM=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-nm \
102 -DLLVM_TABLEGEN=${STAGING_BINDIR_NATIVE}/llvm-tblgen \
103 -DCLANG_TABLEGEN=${STAGING_BINDIR_NATIVE}/clang-tblgen \
104 -DCMAKE_C_COMPILER_TARGET=${HOST_SYS} \
105 -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON \
106"
107
108do_install:append () {
109 mkdir -p ${D}${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/lib
110 mv ${D}${nonarch_libdir}/linux ${D}${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/lib
111 if [ "${HF}" = "hf" ]; then
112 mv -f ${D}${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/lib/linux/libclang_rt.builtins-arm.a \
113 ${D}${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/lib/linux/libclang_rt.builtins-armhf.a
114 mv -f ${D}${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/lib/linux/liborc_rt-arm.a \
115 ${D}${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/lib/linux/liborc_rt-armhf.a
116 fi
117}
118
119FILES_SOLIBSDEV = ""
120
121FILES:${PN} += "${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/lib/linux/lib*${SOLIBSDEV} \
122 ${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/*.txt \
123 ${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/share/*.txt"
124FILES:${PN}-staticdev += "${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/lib/linux/*.a"
125FILES:${PN}-dev += "${datadir} ${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/lib/linux/*.syms \
126 ${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/include \
127 ${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/lib/linux/clang_rt.crt*.o \
128 ${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/lib/linux/libclang_rt.asan-preinit*.a"
129
130INSANE_SKIP:${PN} = "dev-so libdir"
131INSANE_SKIP:${PN}-dbg = "libdir"
132
133RDEPENDS:${PN}-dev += "${PN}-staticdev"
134
135BBCLASSEXTEND = "native nativesdk"
136
137ALLOW_EMPTY:${PN} = "1"
138
139SYSROOT_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..f5bf17f30a
--- /dev/null
+++ b/meta/recipes-devtools/clang/libcxx_git.bb
@@ -0,0 +1,122 @@
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}"
52BUILD_CC = "${CCACHE}clang ${BUILD_CC_ARCH}"
53BUILD_CXX = "${CCACHE}clang++ ${BUILD_CC_ARCH}"
54LDFLAGS += "${COMPILER_RT} ${UNWINDLIB} ${LIBCPLUSPLUS}"
55CXXFLAGS += "${LIBCPLUSPLUS}"
56
57TOOLCHAIN = "clang"
58
59OECMAKE_SOURCEPATH = "${S}/llvm"
60EXTRA_OECMAKE += "\
61 -DCMAKE_BUILD_TYPE=RelWithDebInfo \
62 -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF \
63 -DCMAKE_CROSSCOMPILING=ON \
64 -DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN=ON \
65 -DLLVM_ENABLE_RTTI=ON \
66 -DLIBUNWIND_ENABLE_CROSS_UNWINDING=ON \
67 -DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON \
68 -DLIBCXXABI_INCLUDE_TESTS=OFF \
69 -DLIBCXXABI_ENABLE_SHARED=ON \
70 -DLIBCXXABI_LIBCXX_INCLUDES=${S}/libcxx/include \
71 -DLIBCXX_CXX_ABI=libcxxabi \
72 -DLIBCXX_CXX_ABI_INCLUDE_PATHS=${S}/libcxxabi/include \
73 -DLIBCXX_CXX_ABI_LIBRARY_PATH=${B}/lib${LLVM_LIBDIR_SUFFIX} \
74 -S ${S}/runtimes \
75 -DLLVM_ENABLE_RUNTIMES='libcxx;libcxxabi;libunwind' \
76 -DLLVM_RUNTIME_TARGETS=${HOST_ARCH} \
77 -DLLVM_LIBDIR_SUFFIX=${LLVM_LIBDIR_SUFFIX} \
78 -DLLVM_APPEND_VC_REV=OFF \
79 -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
80"
81
82EXTRA_OECMAKE:append:class-target = " \
83 -DCMAKE_AR=${STAGING_BINDIR_TOOLCHAIN}/${AR} \
84 -DCMAKE_NM=${STAGING_BINDIR_TOOLCHAIN}/${NM} \
85 -DCMAKE_RANLIB=${STAGING_BINDIR_TOOLCHAIN}/${RANLIB} \
86 -DLLVM_HOST_TRIPLE=${TARGET_SYS} \
87 -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
88"
89
90EXTRA_OECMAKE:append:class-nativesdk = " \
91 -DCMAKE_AR=${STAGING_BINDIR_TOOLCHAIN}/${AR} \
92 -DCMAKE_NM=${STAGING_BINDIR_TOOLCHAIN}/${NM} \
93 -DCMAKE_RANLIB=${STAGING_BINDIR_TOOLCHAIN}/${RANLIB} \
94 -DLLVM_DEFAULT_TARGET_TRIPLE=${HOST_SYS} \
95"
96
97EXTRA_OECMAKE:append:libc-musl = " -DLIBCXX_HAS_MUSL_LIBC=ON "
98
99CXXFLAGS:append:armv5 = " -mfpu=vfp2"
100
101ALLOW_EMPTY:${PN} = "1"
102
103PROVIDES:append:runtime-llvm = " libunwind"
104
105do_install:append() {
106 if ${@bb.utils.contains("TC_CXX_RUNTIME", "llvm", "true", "false", d)}
107 then
108 for f in libunwind.h __libunwind_config.h unwind.h unwind_itanium.h unwind_arm_ehabi.h
109 do
110 install -Dm 0644 ${S}/libunwind/include/$f ${D}${includedir}/$f
111 done
112 install -d ${D}${libdir}/pkgconfig
113 sed -e 's,@LIBDIR@,${libdir},g;s,@VERSION@,${PV},g' ${S}/libunwind/libunwind.pc.in > ${D}${libdir}/pkgconfig/libunwind.pc
114 fi
115}
116
117PACKAGES:append:runtime-llvm = " libunwind"
118FILES:libunwind:runtime-llvm = "${libdir}/libunwind.so.*"
119# Package library module manifest path
120FILES:${PN}-dev += "${datadir}/libc++/v1/ ${libdir}/libc++.modules.json"
121
122BBCLASSEXTEND = "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..13e54efbc2
--- /dev/null
+++ b/meta/recipes-devtools/clang/llvm-project-source.inc
@@ -0,0 +1,98 @@
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 case = ""
70 triple = ""
71 name = ""
72 check = ""
73 oe_names = ""
74 distros = d.getVar('CLANG_EXTRA_OE_DISTRO')
75 for distro in distros.split():
76 distro_id = distro.split(":")[0].replace('-','_')
77 distro_triple = distro.split(":")[1]
78 case += '\\n .Case("' + distro_id + '", Distro::' + distro_id.upper() + ')'
79 triple += '\\n if (Distro.Is' + distro_id.upper() + '())\\n return "x86_64-' + distro_triple + '-linux",'
80 name += '\\n '+ distro_id.upper() + ','
81 check += '\\nbool Is' + distro_id.upper() + '() const { return DistroVal == ' + distro_id.upper() + '; }'
82 oe_names += distro_id.upper() + ' ||'
83
84 check += '\\nbool IsOpenEmbedded() const { return DistroVal == ' + oe_names[0:-3] + '; }'
85
86 cmd = d.expand("sed -i 's#//CLANG_EXTRA_OE_DISTRO_NAME#%s#g' ${S}/clang/include/clang/Driver/Distro.h" % (name))
87 subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
88 cmd = d.expand("sed -i 's#//CLANG_EXTRA_OE_DISTRO_CHECK#%s#g' ${S}/clang/include/clang/Driver/Distro.h" % (check))
89 subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
90 cmd = d.expand("sed -i 's#//CLANG_EXTRA_OE_DISTRO_TRIPLES#%s#g' ${S}/clang/lib/Driver/ToolChains/Linux.cpp" % (triple))
91 subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
92 cmd = d.expand("sed -i 's#//CLANG_EXTRA_OE_DISTRO_CASES#%s#g' -i ${S}/clang/lib/Driver/Distro.cpp" % (case))
93 subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
94}
95
96do_patch[vardepsexclude] += "MULTILIBS MULTILIB_VARIANTS"
97addtask do_preconfigure after do_patch
98do_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"