Skip to contentSkip to conversation

Oe-selftest for Clang, LLVM, LLD

PATCH Superseded [email protected] 2 participants 15 messages May 5

v5 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v5 cover Oe-selftest for Clang, LLVM, LLD

From: Deepesh Varatharajan <[email protected]>

This patch series introduces a test framework to run selftests for target builds of Clang, LLVM, and LLD.

v5 changes:
- Fix intermittent failure seen for arm64.

v4 changes:
- Fix intermittent failures.

v3 changes:
- llvm_sysroot_preprocess_testsuite function needs be added to llvm:class-target not llvm:class-nativesdk.

v2 changes:
- Enable required CMake flags only when running the testsuite.
- Ensure default build time and package sizes remain unaffected.

Summary of changes:
-Patch 1: Disable clang-tools-extra tests, as Clang's CMake cannot
detect the llvm-bcanalyzer target.
-Patch 2: Enabled the necessary CMake flags for clang, llvm & lld tests
when CLANG_ENABLE_TESTSUITE is set to "1".
-Patch 3: Set CLANG_ENABLE_TESTSUITE = "1" while running testsuite. -Patch 4: Selftest script for Clang, LLVM, and LLD including exclude list -Patch 5: Fix rust build failure by replacing target llvm-config with native

Testing:
1. The test suite has been successfully validated on x86-64, arm64, riscv64 and arm32 for all Clang, LLD & LLVM components.
2. Clang and LLD tests passed successfully on x86. LLVM tests are skipped on x86 since it's broken. A follow-up bug will be filed and addressed.
3. Clang, LLVM & LLD all together ~80K tests are there and we currently ~250 tests to exclude list which are failing (0.32%).

Impact on build time:
These builds were executed in a controlled environment without poky-sstate enabled.

Default(without changes):

+-----------+------------+------------+------------+----------------+
|  Target   | Run 1      | Run 2      | Run 3      |    Average     |
| --------- | ---------- | ---------- | ---------- | -------------- |
|   llvm    | 22m18.441s | 22m31.905s | 22m23.718s |   22m24.688s   |
|   clang   | 30m09.774s | 30m22.680s | 30m15.312s |   30m15.922s   |
|   lld     | 1m26.994s  | 1m30.415s  | 1m29.006s  |   1m28.805s    |
+-----------+------------+------------+------------+----------------+

With the testsuite changes applied:

+-----------+------------+------------+------------+----------------+
|  Target   | Run 1      | Run 2      | Run 3      |    Average     |
| --------- | ---------- | ---------- | ---------- | -------------- |
|   llvm    | 23m32.104s | 23m45.887s | 23m38.157s |   23m38.716s   |
|   clang   | 30m31.402s | 30m46.198s | 30m39.445s |   30m39.015s   |
|   lld     | 1m29.845s  | 1m34.212s  | 1m31.925s  |   1m31.994s    |
+-----------+------------+------------+------------+----------------+

Comparison:
The additional overhead is minimal and primarily due to enabling test-related build configurations.

+-----------+-------------+------------------+------------------+
|  Target   | Default Avg | With Changes Avg |     **Diff**     |
| --------- | ----------- | ---------------- | ---------------- |
|   llvm    | 22m24.688s  | 23m38.716s       |   +1m14.028s     |
|   clang   | 30m15.922s  | 30m39.015s       |   +0m23.093s     |
|   lld     | 1m28.805s   | 1m31.994s        |   +0m3.189s      |
+-----------+-------------+------------------+------------------+

Impact on package size and Fix:
The testsuite changes has a negative impact on certain package sizes, as below:

+---------------------+----------+----------+-----------+------------+
| Package             | Old (MB) | New (MB) | Diff (MB) | Change (%) |
+=====================+==========+==========+===========+============+
| clang/clang-dbg     |    44.99 |    59.79 |    +14.81 |    +32.92% |
| clang/clang-dev     |    30.22 |    30.22 |     -0.00 |     -0.00% |
| clang/clang-tools   |     5.05 |    29.58 |    +24.53 |   +485.87% |
| llvm/llvm-bin       |    16.40 |    71.77 |    +55.36 |   +337.50% |
| llvm/llvm-dbg       |   386.79 |   646.12 |   +259.33 |    +67.05% |
| llvm/llvm-dev       |    32.67 |    33.67 |     +1.00 |     +3.05% |
| llvm/llvm-src       |   387.54 |   389.44 |     +1.90 |     +0.49% |
| llvm/llvm-staticdev |   609.68 |   616.80 |     +7.12 |     +1.17% |
+---------------------+----------+----------+-----------+------------+

FIX:
All testsuite-related changes are now gated by the CLANG_ENABLE_TESTSUITE variable (default "0"), ensuring:
- Test-specific CMake flags are applied only during test execution.
- Standard builds remain fully unaffected in both build time and package size.

Deepesh Varatharajan (5):
clang-tools-extra: disable tests
clang: Enable cmake flags for llvm, clang, lld tests
clang: Set CLANG_ENABLE_TESTSUITE = "1" oeqa/selftest/clang: Add oe-seltests for Clang/LLVM/LLD
rust: Fix rust build failure

 .../recipes-devtools/clang/clang_%.bbappend   |   2 +
 .../recipes-devtools/clang/lld_%.bbappend     |   2 +
 .../recipes-devtools/clang/llvm_%.bbappend    |   2 +
 meta/lib/oeqa/selftest/cases/clang.py         | 325 ++++++++++++++++++
 .../0042-guard-clang-tools-extra-test.patch   |  74 ++++
 meta/recipes-devtools/clang/clang_git.bb      |   8 +
 meta/recipes-devtools/clang/common.inc        |   1 +
 meta/recipes-devtools/clang/lld_git.bb        |   5 +
 meta/recipes-devtools/clang/llvm_git.bb       |  18 +-
 meta/recipes-devtools/rust/rust_1.94.1.bb     |   5 +-
 10 files changed, 439 insertions(+), 3 deletions(-)
 create mode 100644 meta-selftest/recipes-devtools/clang/clang_%.bbappend
 create mode 100644 meta-selftest/recipes-devtools/clang/lld_%.bbappend
 create mode 100644 meta-selftest/recipes-devtools/clang/llvm_%.bbappend
 create mode 100644 meta/lib/oeqa/selftest/cases/clang.py
 create mode 100644 meta/recipes-devtools/clang/clang/0042-guard-clang-tools-extra-test.patch
Signature · 1 line
2.44.3
#1 lore raw

PATCH v5 1/5 clang-tools-extra: disable tests

From: Deepesh Varatharajan <[email protected]>

clang-tools-extra tests depend on the llvm-bcanalyzer CMake target, which exists in LLVM's CMake project but is not visible when Clang is built separately. To run clang tests, disable clang-tools-extra tests for now.

---
 .../0042-guard-clang-tools-extra-test.patch   | 74 +++++++++++++++++++
 meta/recipes-devtools/clang/common.inc        |  1 +
 2 files changed, 75 insertions(+)
 create mode 100644 meta/recipes-devtools/clang/clang/0042-guard-clang-tools-extra-test.patch
meta/recipes-devtools/clang/clang/0042-guard-clang-tools-extra-test.patch new file +74 -0
new file mode 100644
index 0000000000..9b4e29ff64
@@ -0,0 +1,74 @@
+clang-tools-extra tests depend on the llvm-bcanalyzer CMake target, which
+exists in LLVM's CMake project but is not visible when Clang is built
+separately. To run clang tests, disable clang-tools-extra tests for now.
+
+Without this patch when CLANG_INCLUDE_TESTS is ON got the following error
+
+--------------------------------------------------------------------------------
+| CMake Error at ../clang/21.1.8/recipe-sysroot/usr/lib/cmake/llvm/AddLLVM.cmake:2113 (add_dependencies):
+|   The dependency target "llvm-bcanalyzer" of target
+|   "check-clang-extra-clang-tidy-infrastructure-header-filter-from-config-file-simple"
+|   does not exist.
+| Call Stack (most recent call first):
+|   ../clang/21.1.8/recipe-sysroot/usr/lib/cmake/llvm/AddLLVM.cmake:2221 (add_lit_target)
+|   tools/extra/test/CMakeLists.txt:87 (add_lit_testsuites)
+|
+| CMake Error at ../clang/21.1.8/recipe-sysroot/usr/lib/cmake/llvm/AddLLVM.cmake:2113 (add_dependencies):
+|   The dependency target "llvm-bcanalyzer" of target
+|   "check-clang-extra-modularize" does not exist.
+| Call Stack (most recent call first):
+|   ../clang/21.1.8/recipe-sysroot/usr/lib/cmake/llvm/AddLLVM.cmake:2221 (add_lit_target)
+|   tools/extra/test/CMakeLists.txt:87 (add_lit_testsuites)
+-------------------------------------------------------------------------------
+
+Upstream-Status: Inappropriate [OE-Specific]
+Signed-off-by: Deepesh Varatharajan <[email protected]>
+
+diff --git a/clang-tools-extra/CMakeLists.txt b/clang-tools-extra/CMakeLists.txt
+index 6b6f2b1..26e4c10 100644
+--- a/clang-tools-extra/CMakeLists.txt
++++ b/clang-tools-extra/CMakeLists.txt
+@@ -8,7 +8,7 @@ include(GNUInstallDirs)
+ option(CLANG_TIDY_ENABLE_QUERY_BASED_CUSTOM_CHECKS
+   "Enable query-based custom checks in clang-tidy" ON)
+
+-if(CLANG_INCLUDE_TESTS)
++if(CLANG_TOOLS_EXTRA_INCLUDE_TESTS)
+   umbrella_lit_testsuite_begin(check-clang-tools)
+
+   option(CLANG_TOOLS_TEST_USE_VG "Run Clang tools' tests under Valgrind" OFF)
+@@ -45,7 +45,7 @@ if (CLANG_ENABLE_CLANGD)
+ endif()
+
+ # Add the common testsuite after all the tools.
+-if(CLANG_INCLUDE_TESTS)
++if(CLANG_TOOLS_EXTRA_INCLUDE_TESTS)
+   add_subdirectory(test)
+   add_subdirectory(unittests)
+   umbrella_lit_testsuite_end(check-clang-tools)
+diff --git a/clang-tools-extra/include-cleaner/CMakeLists.txt b/clang-tools-extra/include-cleaner/CMakeLists.txt
+index dc147f9..4855577 100644
+--- a/clang-tools-extra/include-cleaner/CMakeLists.txt
++++ b/clang-tools-extra/include-cleaner/CMakeLists.txt
+@@ -1,7 +1,7 @@
+ include_directories(include)
+ add_subdirectory(lib)
+ add_subdirectory(tool)
+-if(CLANG_INCLUDE_TESTS)
++if(CLANG_TOOLS_EXTRA_INCLUDE_TESTS)
+   add_subdirectory(test)
+   add_subdirectory(unittests)
+ endif()
+diff --git a/clang-tools-extra/clangd/CMakeLists.txt b/clang-tools-extra/clangd/CMakeLists.txt
+index a1e9da4..94dcb96 100644
+--- a/clang-tools-extra/clangd/CMakeLists.txt
++++ b/clang-tools-extra/clangd/CMakeLists.txt
+@@ -215,7 +215,7 @@ endif()
+ option(CLANGD_BUILD_DEXP "Build the dexp tool as part of Clangd" ON)
+ llvm_canonicalize_cmake_booleans(CLANGD_BUILD_DEXP)
+
+-if(CLANG_INCLUDE_TESTS)
++if(CLANG_TOOLS_EXTRA_INCLUDE_TESTS)
+   add_subdirectory(test)
+   add_subdirectory(unittests)
+ endif()
meta/recipes-devtools/clang/common.inc +1 -0
index 9d45898c68..62ffe78075 100644
@@ -60,6 +60,7 @@ SRC_URI = "\
     file://0039-Rename-UNUSED-and-UNKNOWN-elements-of-OffloadArch-enum.patch \
     file://0040-libcxxabi-declare-__gnu_unwind_frame-in-cxa_personal.patch \
     file://0041-Consolidate-and-fix-sysroot-based-compiler-rt-search.patch \
+    file://0042-guard-clang-tools-extra-test.patch \
 "
 # Fallback to no-PIE if not set
 GCCPIE ??= ""
Signature · 1 line
2.44.3
#2 lore raw

PATCH v5 2/5 clang: Enable cmake flags for llvm, clang, lld tests

In reply to [email protected]

From: Deepesh Varatharajan <[email protected]>

Enable the necessary CMake flags to build and run tests for LLVM, Clang and LLD. Install the LLVM target tools needed to run tests via llvm-lit inside QEMU only when CLANG_ENABLE_TESTSUITE = "1".

---
 meta/recipes-devtools/clang/clang_git.bb |  8 ++++++++
 meta/recipes-devtools/clang/lld_git.bb   |  5 +++++
 meta/recipes-devtools/clang/llvm_git.bb  | 18 +++++++++++++++++-
 3 files changed, 30 insertions(+), 1 deletion(-)
meta/recipes-devtools/clang/clang_git.bb +8 -0
index 662cda1b2e..080feed63a 100644
@@ -77,6 +77,14 @@ EXTRA_OECMAKE += "-DLLVM_ENABLE_ASSERTIONS=OFF \
                   -DCMAKE_STRIP=${STAGING_BINDIR_NATIVE}/llvm-strip \
 "
 
+CLANG_ENABLE_TESTSUITE ??= "0"
+CLANG_TESTSUITE_FLAGS = "\
+                  -DCLANG_INCLUDE_TESTS=ON \
+                  -DLLVM_INCLUDE_TESTS=ON \
+"
+
+EXTRA_OECMAKE:append:class-target = " ${@bb.utils.contains('CLANG_ENABLE_TESTSUITE', '1', d.getVar('CLANG_TESTSUITE_FLAGS'), '', d)}"
+
 DEPENDS = "llvm-tblgen-native llvm-native llvm binutils zlib zstd libffi libxml2 libxml2-native"
 DEPENDS:append:class-target = " ${@bb.utils.contains('TC_CXX_RUNTIME', 'llvm', 'compiler-rt libcxx', '', d)}"
 
meta/recipes-devtools/clang/lld_git.bb +5 -0
index ba36942790..8960cac2d3 100644
@@ -19,4 +19,9 @@ OECMAKE_SOURCEPATH = "${S}/lld"
 EXTRA_OECMAKE += "-DLLVM_INCLUDE_TESTS=OFF -DLLVM_USE_SYMLINKS=ON \
                   -DLLVM_TABLEGEN_EXE=${STAGING_BINDIR_NATIVE}/llvm-tblgen"
 
+CLANG_ENABLE_TESTSUITE ??= "0"
+LLD_TESTSUITE_FLAGS = "-DLLVM_INCLUDE_TESTS=ON"
+
+EXTRA_OECMAKE:append:class-target = " ${@bb.utils.contains('CLANG_ENABLE_TESTSUITE', '1', d.getVar('LLD_TESTSUITE_FLAGS'), '', d)}"
+
 BBCLASSEXTEND = "native nativesdk"
meta/recipes-devtools/clang/llvm_git.bb +17 -1
index 96ea383731..e7823154b9 100644
@@ -80,6 +80,18 @@ PACKAGECONFIG[opt-viewer] = "-DLLVM_TOOL_OPT_VIEWER_BUILD=ON,-DLLVM_TOOL_OPT_VIE
 PACKAGECONFIG[lto] = "-DLLVM_ENABLE_LTO=Full -DLLVM_BINUTILS_INCDIR=${STAGING_INCDIR},,binutils,"
 PACKAGECONFIG[thin-lto] = "-DLLVM_ENABLE_LTO=Thin -DLLVM_BINUTILS_INCDIR=${STAGING_INCDIR},,binutils,"
 
+CLANG_ENABLE_TESTSUITE ??= "0"
+LLVM_TESTSUITE_FLAGS = "\
+                  -DLLVM_BUILD_TESTS=ON \
+                  -DLLVM_INSTALL_GTEST=ON \
+                  -DLLVM_INCLUDE_TESTS=ON \
+                  -DLLVM_TOOL_LLVM_EXEGESIS_BUILD=ON \
+                  -DLLVM_TOOL_OBJ2YAML_BUILD=ON \
+                  -DLLVM_TOOL_YAML2OBJ_BUILD=ON \
+                 "
+
+EXTRA_OECMAKE:append:class-target = " ${@bb.utils.contains('CLANG_ENABLE_TESTSUITE', '1', d.getVar('LLVM_TESTSUITE_FLAGS'), '', d) } "
+
 # LLVM debug symbols are very large (several gigabytes), reduce the debug level
 # so they're just hundreds of megabytes.
 DEBUG_LEVELFLAG = "-g1"
@@ -118,7 +130,7 @@ do_install:append:class-native() {
     rm ${D}${bindir}/*-tblgen
 }
 
-SYSROOT_PREPROCESS_FUNCS:append:class-target = " llvm_sysroot_preprocess"
+SYSROOT_PREPROCESS_FUNCS:append:class-target = " llvm_sysroot_preprocess ${@bb.utils.contains('CLANG_ENABLE_TESTSUITE', '1', 'llvm_sysroot_preprocess_testsuite', '', d) }"
 SYSROOT_PREPROCESS_FUNCS:append:class-nativesdk = " llvm_sysroot_preprocess"
 
 llvm_sysroot_preprocess() {
@@ -126,6 +138,10 @@ llvm_sysroot_preprocess() {
         install -m 0755 ${S}/llvm/tools/llvm-config/llvm-config ${SYSROOT_DESTDIR}${bindir_crossscripts}/
 }
 
+llvm_sysroot_preprocess_testsuite() {
+        install -m 0755 ${B}/bin/* ${SYSROOT_DESTDIR}${bindir}/
+}
+
 FILES:${PN}-dev += "${libdir}/llvm-config"
 
 BBCLASSEXTEND = "native nativesdk"
Signature · 1 line
2.44.3
#3 lore raw

PATCH v5 3/5 clang: Set CLANG_ENABLE_TESTSUITE = "1"

In reply to [email protected]

From: Deepesh Varatharajan <[email protected]>

While running testsuite set CLANG_ENABLE_TESTSUITE = "1"

---
 meta-selftest/recipes-devtools/clang/clang_%.bbappend | 2 ++
 meta-selftest/recipes-devtools/clang/lld_%.bbappend   | 2 ++
 meta-selftest/recipes-devtools/clang/llvm_%.bbappend  | 2 ++
 3 files changed, 6 insertions(+)
 create mode 100644 meta-selftest/recipes-devtools/clang/clang_%.bbappend
 create mode 100644 meta-selftest/recipes-devtools/clang/lld_%.bbappend
 create mode 100644 meta-selftest/recipes-devtools/clang/llvm_%.bbappend
meta-selftest/recipes-devtools/clang/clang_%.bbappend new file +2 -0
new file mode 100644
index 0000000000..32c236b972
@@ -0,0 +1,2 @@
+# Enable CLANG testsuite
+CLANG_ENABLE_TESTSUITE = "1"
meta-selftest/recipes-devtools/clang/lld_%.bbappend new file +2 -0
new file mode 100644
index 0000000000..32c236b972
@@ -0,0 +1,2 @@
+# Enable CLANG testsuite
+CLANG_ENABLE_TESTSUITE = "1"
meta-selftest/recipes-devtools/clang/llvm_%.bbappend new file +2 -0
new file mode 100644
index 0000000000..32c236b972
@@ -0,0 +1,2 @@
+# Enable CLANG testsuite
+CLANG_ENABLE_TESTSUITE = "1"
Signature · 1 line
2.44.3
#4 lore raw

Re: [OE-core] [PATCH 3/5 v5] clang: Set CLANG_ENABLE_TESTSUITE = "1"

Quoted 36 lines · Deepesh via lists.openembedded.org

From: Deepesh Varatharajan <[email protected]>

While running testsuite set CLANG_ENABLE_TESTSUITE = "1"

---
 meta-selftest/recipes-devtools/clang/clang_%.bbappend | 2 ++ meta-selftest/recipes-devtools/clang/lld_%.bbappend   | 2 ++ meta-selftest/recipes-devtools/clang/llvm_%.bbappend  | 2 ++

 3 files changed, 6 insertions(+)

 create mode 100644 meta-selftest/recipes-devtools/clang/clang_%.bbappend create mode 100644 meta-selftest/recipes-devtools/clang/lld_%.bbappend create mode 100644 meta-selftest/recipes-devtools/clang/llvm_%.bbappend

meta-selftest/recipes-devtools/clang/clang_%.bbappend new file +2 -0
new file mode 100644
index 0000000000..32c236b972
@@ -0,0 +1,2 @@
+# Enable CLANG testsuite
+CLANG_ENABLE_TESTSUITE = "1"
meta-selftest/recipes-devtools/clang/lld_%.bbappend new file +2 -0
new file mode 100644
index 0000000000..32c236b972
@@ -0,0 +1,2 @@
+# Enable CLANG testsuite
+CLANG_ENABLE_TESTSUITE = "1"
meta-selftest/recipes-devtools/clang/llvm_%.bbappend new file +0 -0
new file mode 100644
index 0000000000..32c236b972

meta-selftest/recipes-devtools/clang/llvm_%.bbappend line 2

Quoted 2 lines
meta-selftest/recipes-devtools/clang/llvm_%.bbappend new file +2 -0
@@ -0,0 +1,2 @@
+# Enable CLANG testsuite
+CLANG_ENABLE_TESTSUITE = "1"

Having bbappends inside meta-selftest isn't something we've done before and feels a bit odd. I think it will cause yocto-check=layer to fail too.

Why wouldn't we just set this variable inside the tests that need it?

Cheers,

Richard

#5 lore raw

Re: [OE-core] [PATCH 3/5 v5] clang: Set CLANG_ENABLE_TESTSUITE = "1"

Quoted 46 lines · Richard Purdie

CAUTION: This email comes from a non Wind River email account!
Do not click links or open attachments unless you recognize the sender and know the content is safe.

Quoted 36 lines · Deepesh via lists.openembedded.org

From: Deepesh Varatharajan<[email protected]>

While running testsuite set CLANG_ENABLE_TESTSUITE = "1"

---
  meta-selftest/recipes-devtools/clang/clang_%.bbappend | 2 ++
  meta-selftest/recipes-devtools/clang/lld_%.bbappend   | 2 ++
  meta-selftest/recipes-devtools/clang/llvm_%.bbappend  | 2 ++
  3 files changed, 6 insertions(+)

create mode 100644 meta-selftest/recipes-devtools/clang/clang_%.bbappend create mode 100644 meta-selftest/recipes-devtools/clang/lld_%.bbappend create mode 100644 meta-selftest/recipes-devtools/clang/llvm_%.bbappend

meta-selftest/recipes-devtools/clang/clang_%.bbappend new file +2 -0
new file mode 100644
index 0000000000..32c236b972
@@ -0,0 +1,2 @@
+# Enable CLANG testsuite
+CLANG_ENABLE_TESTSUITE = "1"
meta-selftest/recipes-devtools/clang/lld_%.bbappend new file +2 -0
new file mode 100644
index 0000000000..32c236b972
@@ -0,0 +1,2 @@
+# Enable CLANG testsuite
+CLANG_ENABLE_TESTSUITE = "1"
meta-selftest/recipes-devtools/clang/llvm_%.bbappend new file +0 -0
new file mode 100644
index 0000000000..32c236b972

meta-selftest/recipes-devtools/clang/llvm_%.bbappend line 2

Quoted 2 lines
meta-selftest/recipes-devtools/clang/llvm_%.bbappend new file +2 -0
@@ -0,0 +1,2 @@
+# Enable CLANG testsuite
+CLANG_ENABLE_TESTSUITE = "1"

Having bbappends inside meta-selftest isn't something we've done before and feels a bit odd. I think it will cause yocto-check=layer to fail too.

Quoted 1 line

Why wouldn't we just set this variable inside the tests that need it?

As you mentioned, yocto-check-layer is failing due to a signature difference with this change. The reason for placing this in meta-selftest is that we’ve observed intermittent issues when reusing sstate, where the required flags are not always enabled, leading to testsuite failures. To make the behavior more consistent and avoid these sstate-related inconsistencies, we opted to set the variable in meta-selftest, since it is included by default when running the testsuite. That said, I understand the concern with this approach given the layer check failure. Is there a better way you’d recommend handling this kind of sstate-related issue? Regards, Deepesh

Quoted 5 lines

Cheers,

Richard

#6 lore raw

Re: [OE-core] [PATCH 3/5 v5] clang: Set CLANG_ENABLE_TESTSUITE = "1"

Quoted 42 lines · Deepesh via lists.openembedded.org
Quoted 40 lines · Richard Purdie

On Tue, 2026-05-05 at 01:16 -0700, Varatharajan, Deepesh via lists.openembedded.org wrote:

Quoted 38 lines

From: Deepesh Varatharajan <[email protected]>

While running testsuite set CLANG_ENABLE_TESTSUITE = "1"

---

 meta-selftest/recipes-devtools/clang/clang_%.bbappend | 2 ++
 meta-selftest/recipes-devtools/clang/lld_%.bbappend   | 2 ++
 meta-selftest/recipes-devtools/clang/llvm_%.bbappend  | 2 ++
 3 files changed, 6 insertions(+)

 create mode 100644 meta-selftest/recipes-devtools/clang/clang_%.bbappend create mode 100644 meta-selftest/recipes-devtools/clang/lld_%.bbappend create mode 100644 meta-selftest/recipes-devtools/clang/llvm_%.bbappend

meta-selftest/recipes-devtools/clang/clang_%.bbappend new file +2 -0
new file mode 100644
index 0000000000..32c236b972
@@ -0,0 +1,2 @@
+# Enable CLANG testsuite
+CLANG_ENABLE_TESTSUITE = "1"
meta-selftest/recipes-devtools/clang/lld_%.bbappend new file +2 -0
new file mode 100644
index 0000000000..32c236b972
@@ -0,0 +1,2 @@
+# Enable CLANG testsuite
+CLANG_ENABLE_TESTSUITE = "1"
meta-selftest/recipes-devtools/clang/llvm_%.bbappend new file +2 -0
new file mode 100644
index 0000000000..32c236b972
@@ -0,0 +1,2 @@
+# Enable CLANG testsuite
+CLANG_ENABLE_TESTSUITE = "1"
Quoted 8 lines
Quoted 7 lines
Quoted 1 line

Having bbappends inside meta-selftest isn't something we've done before and feels a bit odd. I think it will cause yocto-check=layer to fail too.

Why wouldn't we just set this variable inside the tests that need it?

 As you mentioned, yocto-check-layer is failing due to a signature difference with this change.

That means we can't merge this change.

Quoted 3 lines

The reason for placing this in meta-selftest is that we’ve observed intermittent issues when reusing sstate, where the required flags are not always enabled, leading to testsuite failures.

We need to work those issues out then!

Quoted 6 lines

To make the behavior more consistent and avoid these sstate-related inconsistencies, we opted to set the variable in meta-selftest, since it is included by default when running the testsuite.
That said, I understand the concern with this approach given the layer check failure. Is there a better way you’d recommend handling this kind of sstate-related issue?

We need to understand what this sstate issue is and fix that. There shouldn't be "sstate issues" causing any problem like this.

Cheers,

Richard

#7 lore raw

PATCH v5 4/5 oeqa/selftest/clang: Add oe-seltests for Clang/LLVM/LLD

In reply to [email protected]

From: Deepesh Varatharajan <[email protected]>

Introduce selftests to validate LLVM, Clang, and LLD test suites using llvm-lit for target builds.

The tests cover:
- Target tests execution under QEMU via NFS using llvm-lit
- Architecture and OS-specific test filtering
- Known failing test exclusions
- LLVM testing is skipped for x86

---
 meta/lib/oeqa/selftest/cases/clang.py | 325 ++++++++++++++++++++++++++
 1 file changed, 325 insertions(+)
 create mode 100644 meta/lib/oeqa/selftest/cases/clang.py
meta/lib/oeqa/selftest/cases/clang.py new file +325 -0
new file mode 100644
index 0000000000..c5d2188cff
@@ -0,0 +1,325 @@
+#
+# Copyright (c) 2026 by Wind River Systems, Inc.
+#
+# SPDX-License-Identifier: MIT
+#
+import time
+import contextlib
+import subprocess
+from oeqa.core.decorator import OETestTag
+from oeqa.core.decorator.data import skipIfArch
+from oeqa.selftest.case import OESelftestTestCase
+from oeqa.utils.commands import bitbake, get_bb_var, runqemu
+from oeqa.utils.nfs import unfs_server
+
+class ClangFamilyBase(OESelftestTestCase):
+
+    ALL_ARCHS = [
+        "aarch64", "arm", "i386", "x86_64", "x86",
+        "mips", "riscv", "riscv64", "ppc", "ppc64",
+        "hexagon", "sparc", "sparcv9", "msp430",
+        "loongarch"
+    ]
+
+    EXCLUDE_OS = [
+        "Mac", "macho", "Darwin", "OSX", "wasm",
+        "Windows", "Win", "MinGW", "COFF", "zos",
+        "FreeBSD", "aix", "fuchsia", "ve"
+    ]
+
+    DEFAULT_PACKAGES = [
+        "libgcc",
+        "libstdc++",
+        "llvm",
+        "python3",
+        "python3-core",
+        "python3-modules",
+        "nfs-utils",
+    ]
+
+    def setUp(self):
+        super().setUp()
+        self.target_arch = get_bb_var("TARGET_ARCH")
+        self.tmpdir = get_bb_var("TMPDIR")
+        arches = [a for a in self.ALL_ARCHS if a != self.target_arch]
+        self.filter_out = "|".join(arches + self.EXCLUDE_OS)
+
+    def build_core_image(self):
+        features = [
+            'IMAGE_FEATURES += "ssh-server-openssh"',
+            'CORE_IMAGE_EXTRA_INSTALL += "{}"'.format(" ".join(self.DEFAULT_PACKAGES))
+        ]
+        self.write_config("\n".join(features))
+        bitbake("core-image-minimal")
+
+    def start_qemu_nfs(self):
+        ctx = contextlib.ExitStack()
+        s = ctx.__enter__()
+        nfsport, mountport = s.enter_context(unfs_server(self.tmpdir, udp=False))
+        qemu = s.enter_context(
+            runqemu("core-image-minimal", runqemuparams="nographic", qemuparams="-m 3072")
+        )
+
+        status, _ = qemu.run("uname")
+        if status != 0:
+            raise AssertionError("QEMU SSH check failed")
+
+        status, _ = qemu.run(f"mkdir -p {self.tmpdir}")
+        if status != 0:
+            raise AssertionError("Failed to create TMPDIR on target")
+
+        mountcmd = (
+            f"mount -o noac,nfsvers=3,local_lock=all,port={nfsport},mountport={mountport} "
+            f"\"{qemu.server_ip}:{self.tmpdir}\" \"{self.tmpdir}\""
+        )
+        status, output = qemu.run(mountcmd)
+        if status != 0:
+            raise AssertionError(f"NFS mount failed: {output}")
+        return ctx, qemu
+
+    def run_llvm_lit(self, recipe, extra_filter=None, timeout=None):
+        build_dir = get_bb_var("B", recipe)
+        workdir = get_bb_var("WORKDIR", recipe)
+        lit_bin = f"{build_dir}/bin/llvm-lit"
+        test_dir = f"{build_dir}/test"
+        guest_result = f"/tmp/{recipe}-target-results.json"
+        host_result = f"{workdir}/{recipe}-target-results.log"
+
+        filter_regex = self.filter_out
+        if extra_filter:
+            filter_regex += "|" + "|".join(extra_filter)
+
+        cmd = (
+             f"cd {build_dir}/bin && "
+             f"python3 ./llvm-lit --filter-out '{filter_regex}' ../test -o {guest_result}"
+        )
+
+        return cmd, guest_result, host_result
+
+@OETestTag("toolchain-system")
+@OETestTag("toolchain-user")
+@OETestTag("runqemu")
+class LLVMSelfTestSystemEmulated(ClangFamilyBase):
+
+    LLVM_EXTRA_EXCLUDE = [
+        "BugPoint/compile-custom\\.ll$",
+        "BugPoint/replace-funcs-with-null\\.ll$",
+        "CodeGen/AMDGPU/lds-run-twice-absolute-md\\.ll$",
+        "CodeGen/AMDGPU/lds-run-twice\\.ll$",
+        "CodeGen/Generic/fp128-math-libcalls\\.ll$",
+        "CodeGen/Thumb/2009-08-20-ISelBug\\.ll$",
+        "CodeGen/Thumb/2010-07-15-debugOrdering\\.ll$",
+        "CodeGen/Thumb/2014-06-10-thumb1-ldst-opt-bug\\.ll$",
+        "CodeGen/Thumb/PR17309\\.ll$",
+        "CodeGen/Thumb/dyn-stackalloc\\.ll$",
+        "CodeGen/Thumb/frame-access\\.ll$",
+        "CodeGen/Thumb/frame-chain\\.ll$",
+        "CodeGen/Thumb/ldm-merge-call\\.ll$",
+        "CodeGen/Thumb/ldm-merge-struct\\.ll$",
+        "CodeGen/Thumb/pop\\.ll$",
+        "CodeGen/Thumb/pr35836\\.ll$",
+        "CodeGen/Thumb/pr35836_2\\.ll$",
+        "CodeGen/Thumb/scmp\\.ll$",
+        "CodeGen/Thumb/smul_fix\\.ll$",
+        "CodeGen/Thumb/stack-guard-xo\\.ll$",
+        "CodeGen/Thumb/stm-deprecated\\.ll$",
+        "CodeGen/Thumb/stm-merge\\.ll$",
+        "CodeGen/Thumb/thumb-ldm\\.ll$",
+        "CodeGen/Thumb/ucmp\\.ll$",
+        "CodeGen/Thumb/vargs\\.ll$",
+        "CodeGen/Thumb2/2009-08-21-PostRAKill4\\.ll$",
+        "CodeGen/Thumb2/2009-09-01-PostRAProlog\\.ll$",
+        "CodeGen/Thumb2/constant-islands\\.ll$",
+        "CodeGen/Thumb2/ldr-str-imm12\\.ll$",
+        "CodeGen/Thumb2/pacbti-m-varargs-1\\.ll$",
+        "CodeGen/Thumb2/pacbti-m-varargs-2\\.ll$",
+        "CodeGen/Thumb2/thumb2-ldm\\.ll$",
+        "ExecutionEngine/MCJIT/.*",
+        "Other/spirv-sim/.*",
+        "Transforms/LoopLoadElim/.*",
+        "tools/llvm-cas/validation\\.test$",
+        "tools/llvm-cgdata/merge-combined-funcmap-hashtree\\.test$",
+        "tools/llvm-cgdata/merge-funcmap-concat\\.test$",
+        "tools/llvm-cgdata/merge-funcmap-double\\.test$",
+        "tools/llvm-cgdata/merge-funcmap-single\\.test$",
+        "tools/llvm-cgdata/merge-hashtree-concat\\.test$",
+        "tools/llvm-cgdata/merge-hashtree-double\\.test$",
+        "tools/llvm-cgdata/merge-hashtree-single\\.test$",
+        "tools/llvm-locstats/locstats\\.ll$",
+        "tools/llvm-locstats/no_scope_bytes\\.ll$",
+        "tools/llvm-objcopy/DXContainer/dump-section\\.yaml$",
+        "tools/llvm-objcopy/ELF/basic-binary-copy\\.test$",
+        "tools/llvm-objcopy/ELF/binary-first-seg-offset-zero\\.test$",
+        "tools/llvm-objcopy/ELF/binary-no-paddr\\.test$",
+        "tools/llvm-objcopy/ELF/binary-paddr\\.test$",
+        "tools/llvm-objcopy/ELF/binary-segment-layout\\.test$",
+        "tools/llvm-objcopy/ELF/check-addr-offset-align-binary\\.test$",
+        "tools/llvm-objcopy/ELF/dump-section\\.test$",
+        "tools/llvm-objcopy/ELF/gap-fill\\.test$",
+        "tools/llvm-objcopy/ELF/pad-to\\.test$",
+        "tools/llvm-objcopy/ELF/parent-loop-check\\.test$",
+        "tools/llvm-objcopy/ELF/strip-all-gnu\\.test$",
+        "tools/llvm-objcopy/ELF/strip-sections-keep\\.test$",
+        "tools/llvm-objcopy/ELF/strip-sections-only-section\\.test$",
+        "tools/llvm-objcopy/ELF/strip-sections\\.test$",
+        "tools/llvm-objcopy/ELF/update-section\\.test$",
+        "tools/llvm-original-di-preservation/acceptance-test\\.test$",
+        "tools/llvm-original-di-preservation/basic\\.test$",
+        "tools/llvm-reduce/temporary-files-as-bitcode-split\\.ll$",
+        "tools/not/disable-symbolization\\.test$",
+        "tools/opt-viewer/.*",
+        "tools/UpdateTestChecks/.*",
+        "tools/yaml2obj/ELF/custom-fill\\.yaml$",
+        "tools/yaml2obj/ELF/header-elfdatanone\\.yaml$",
+        "tools/yaml2obj/ELF/header-sh-fields\\.yaml$",
+        "tools/yaml2obj/GOFF/GOFF-header-end\\.yaml$",
+        "tools/yaml2obj/GOFF/GOFF-header-settings\\.yaml$",
+    ]
+
+    #Fixme LLVM module testing is broken for x86
+    @skipIfArch(['i686'])
+    def test_llvm(self):
+        bitbake("llvm -c install")
+        self.build_core_image()
+        ctx, qemu = self.start_qemu_nfs()
+        with ctx:
+            cmd, guest_result, host_result = self.run_llvm_lit(
+                "llvm", extra_filter=self.LLVM_EXTRA_EXCLUDE
+            )
+            status, output = qemu.run(cmd, timeout=7200)
+            if status != 0:
+                raise AssertionError(f"llvm-lit failed for LLVM: {output}")
+            status, _ = qemu.run(f"cp {guest_result} {host_result}")
+            if status != 0:
+                raise AssertionError("Failed to copy LLVM lit results back to host")
+
+@OETestTag("toolchain-system")
+@OETestTag("toolchain-user")
+@OETestTag("runqemu")
+class ClangSelfTestSystemEmulated(ClangFamilyBase):
+
+    CLANG_EXTRA_EXCLUDE = [
+        "APINotes/yaml-roundtrip-2\\.test$",
+        "APINotes/yaml-roundtrip\\.test$",
+        "AST/ByteCode/builtin-bit-cast-long-double\\.cpp$",
+        "AST/ByteCode/builtin-bit-cast\\.cpp$",
+        "AST/ByteCode/builtin-functions\\.cpp$",
+        "AST/ByteCode/builtin-object-size\\.cpp$",
+        "AST/ByteCode/c\\.c$",
+        "AST/ByteCode/codegen\\.cpp$",
+        "AST/ByteCode/complex\\.c$",
+        "AST/ByteCode/complex\\.cpp$",
+        "AST/ByteCode/const-eval\\.c$",
+        "AST/ByteCode/const-fpfeatures\\.cpp$",
+        "AST/ByteCode/constexpr\\.c$",
+        "AST/ByteCode/cxx20\\.cpp$",
+        "AST/ByteCode/fixed-point\\.cpp$",
+        "AST/ByteCode/floats\\.cpp$",
+        "AST/ByteCode/functions\\.cpp$",
+        "AST/ByteCode/hlsl\\.hlsl$",
+        "AST/ByteCode/intap\\.cpp$",
+        "AST/ByteCode/invalid\\.cpp$",
+        "AST/ByteCode/lambda\\.cpp$",
+        "AST/ByteCode/literals\\.cpp$",
+        "AST/ByteCode/memberpointers\\.cpp$",
+        "AST/ByteCode/neon\\.c$",
+        "AST/ByteCode/new-delete\\.cpp$",
+        "AST/ByteCode/placement-new\\.cpp$",
+        "AST/ByteCode/records\\.cpp$",
+        "AST/ByteCode/spaceship\\.cpp$",
+        "AST/ByteCode/unions\\.cpp$",
+        "Analysis/dead-stores\\.c$",
+        "Analysis/exploded-graph-rewriter/.*",
+        "Analysis/scan-build/cxx-name\\.test$",
+        "Analysis/scan-build/deduplication\\.test$",
+        "Analysis/scan-build/exclude_directories\\.test$",
+        "Analysis/scan-build/help\\.test$",
+        "Analysis/scan-build/html_output\\.test$",
+        "Analysis/scan-build/plist_html_output\\.test$",
+        "Analysis/scan-build/plist_output\\.test$",
+        "Analysis/scan-build/rebuild_index/rebuild_index\\.test$",
+        "Analysis/scan-build/silence-core-checkers\\.test$",
+        "Analysis/virtualcall-fixits\\.cpp$",
+        "C/C23/n3018\\.c$",
+        "ClangScanDeps/module.*",
+        "ClangScanDeps/multiple-commands\\.c$",
+        "ClangScanDeps/optimize-vfs-edgecases\\.m$",
+        "ClangScanDeps/optimize-vfs-pch\\.m$",
+        "ClangScanDeps/visible-modules\\.c$",
+        "ClangScanDeps/Wsystem-headers-in-module\\.c$",
+        "CodeGen/builtins\\.c$",
+        "CodeGen/compound-literal\\.c$",
+        "CodeGenCXX/int64_uint64\\.cpp$",
+        "CodeGenCXX/pointers-to-data-members\\.cpp$",
+        "CodeGenOpenCLCXX/constexpr\\.clcpp$",
+        "Format/docs_updated\\.test$",
+        "Frontend/rewrite-includes-bom\\.c$",
+        "Interpreter/cxx20-modules\\.cppm$",
+        "Modules/crash-vfs-umbrella-frameworks\\.m$",
+        "Modules/double-quotes\\.m$",
+        "Modules/framework-public-includes-private\\.m$",
+        "Modules/implicit-module-header-maps\\.cpp$",
+        "Preprocessor/embed_constexpr\\.c$",
+        "Preprocessor/header-search-crash\\.c$",
+        "Preprocessor/headermap-rel\\.c$",
+        "Preprocessor/headermap-rel2\\.c$",
+        "Preprocessor/include-header-missing-in-framework-with-headermap\\.c$",
+        "Preprocessor/search-path-usage\\.m$",
+        "Sema/arithmetic-fence-builtin\\.c$",
+        "Sema/atomic-expr\\.c$",
+        "Sema/auto-type\\.c$",
+        "Sema/builtin-expect-with-probability\\.cpp$",
+        "Sema/constant-builtins-fmax\\.cpp$",
+        "Sema/constant-builtins-fmaximum-num\\.cpp$",
+        "Sema/constant-builtins-fmin\\.cpp$",
+        "Sema/constant-builtins-fminimum-num\\.cpp$",
+        "Sema/constexpr\\.c$",
+        "Sema/c2x-auto\\.c$",
+        "Sema/fp-eval-pragma-with-float-double_t-1\\.c$",
+        "Sema/fp-eval-pragma-with-float-double_t-2\\.c$",
+        "Sema/fp-eval-pragma-with-float-double_t-3\\.c$",
+    ]
+
+    def test_clang(self):
+        bitbake("clang -c install")
+        self.build_core_image()
+        ctx, qemu = self.start_qemu_nfs()
+        with ctx:
+            cmd, guest_result, host_result = self.run_llvm_lit(
+                "clang", extra_filter=self.CLANG_EXTRA_EXCLUDE
+            )
+            status, output = qemu.run(cmd, timeout=3600)
+            if status != 0:
+                raise AssertionError(f"llvm-lit failed for Clang: {output}")
+            status, _ = qemu.run(f"cp {guest_result} {host_result}")
+            if status != 0:
+                raise AssertionError("Failed to copy Clang lit results back to host")
+
+@OETestTag("toolchain-system")
+@OETestTag("toolchain-user")
+@OETestTag("runqemu")
+class LLDSelfTestSystemEmulated(ClangFamilyBase):
+
+    LLD_EXTRA_EXCLUDE = [
+        "ELF/fill-trap\\.s$",
+        "ELF/lto/cache-warnings\\.ll$",
+        "ELF/oformat-binary-ttext\\.s$",
+        "ELF/oformat-binary\\.s$",
+        "ELF/partition-synthetic-sections\\.s$",
+        "ELF/reproduce\\.s$",
+    ]
+
+    def test_lld(self):
+        bitbake("lld -c install")
+        self.build_core_image()
+        ctx, qemu = self.start_qemu_nfs()
+        with ctx:
+            cmd, guest_result, host_result = self.run_llvm_lit(
+                "lld", extra_filter=self.LLD_EXTRA_EXCLUDE
+            )
+            status, output = qemu.run(cmd, timeout=3600)
+            if status != 0:
+                raise AssertionError(f"llvm-lit failed for LLD: {output}")
+            status, _ = qemu.run(f"cp {guest_result} {host_result}")
+            if status != 0:
+                raise AssertionError("Failed to copy LLD lit results back to host")
Signature · 1 line
2.44.3
#8 lore raw

PATCH v5 5/5 rust: Fix rust build failure

In reply to [email protected]

From: Deepesh Varatharajan <[email protected]>

Target LLVM tools are installed in the sysroot because they are needed for llvm-lit to run tests. However, this leads Rust to pick up a target llvm-config that cannot run on the host. Overwrite it with the native llvm-config so Rust can execute it correctly.

---
 meta/recipes-devtools/rust/rust_1.94.1.bb | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
meta/recipes-devtools/rust/rust_1.94.1.bb +3 -2
index 3eb2a36406..e4a9f20e27 100644
@@ -238,9 +238,10 @@ rust_runx () {
 
     # Copy the natively built llvm-config into the target so we can run it. Horrible,
     # but works!
-    if [ ${RUST_ALTERNATE_EXE_PATH_NATIVE} != ${RUST_ALTERNATE_EXE_PATH} -a ! -f ${RUST_ALTERNATE_EXE_PATH} ]; then
+    if [ ${RUST_ALTERNATE_EXE_PATH_NATIVE} != ${RUST_ALTERNATE_EXE_PATH} ]; then
         mkdir -p `dirname ${RUST_ALTERNATE_EXE_PATH}`
-        cp ${RUST_ALTERNATE_EXE_PATH_NATIVE} ${RUST_ALTERNATE_EXE_PATH}
+        rm -f ${RUST_ALTERNATE_EXE_PATH}
+        cp -f ${RUST_ALTERNATE_EXE_PATH_NATIVE} ${RUST_ALTERNATE_EXE_PATH}
         patchelf --remove-rpath ${RUST_ALTERNATE_EXE_PATH}
     fi
 
Signature · 1 line
2.44.3
#9 lore raw

Re: [OE-core] [PATCH 5/5 v5] rust: Fix rust build failure

Quoted 19 lines · Deepesh via lists.openembedded.org

From: Deepesh Varatharajan <[email protected]>

Target LLVM tools are installed in the sysroot because they are needed for llvm-lit to run tests. However, this leads Rust to pick up a target llvm-config that cannot run on the host. Overwrite it with the native llvm-config so Rust can execute it correctly.

---
 meta/recipes-devtools/rust/rust_1.94.1.bb | 5 +++--

 1 file changed, 3 insertions(+), 2 deletions(-)
meta/recipes-devtools/rust/rust_1.94.1.bb +0 -0
index 3eb2a36406..e4a9f20e27 100644
@@ -238,9 +238,10 @@ rust_runx () {


     # Copy the natively built llvm-config into the target so we can run it. Horrible,

Quoted 9 lines
     # but works!
-    if [ ${RUST_ALTERNATE_EXE_PATH_NATIVE} != ${RUST_ALTERNATE_EXE_PATH} -a ! -f ${RUST_ALTERNATE_EXE_PATH} ]; then
+    if [ ${RUST_ALTERNATE_EXE_PATH_NATIVE} != ${RUST_ALTERNATE_EXE_PATH} ]; then
         mkdir -p `dirname ${RUST_ALTERNATE_EXE_PATH}`
-        cp ${RUST_ALTERNATE_EXE_PATH_NATIVE} ${RUST_ALTERNATE_EXE_PATH}
+        rm -f ${RUST_ALTERNATE_EXE_PATH}
+        cp -f ${RUST_ALTERNATE_EXE_PATH_NATIVE} ${RUST_ALTERNATE_EXE_PATH}
         patchelf --remove-rpath ${RUST_ALTERNATE_EXE_PATH}
     fi

This appears to be a consequence of the new install in "clang: Enable cmake flags for llvm, clang, lld tests". Perhaps we should just not install llvm-config there if it is going to cause problems and need to be overwritten?

Cheers,

Richard

#10 lore raw

Re: [OE-core] [PATCH 5/5 v5] rust: Fix rust build failure

Quoted 22 lines · Richard Purdie

CAUTION: This email comes from a non Wind River email account!
Do not click links or open attachments unless you recognize the sender and know the content is safe.

Quoted 18 lines · Deepesh via lists.openembedded.org

From: Deepesh Varatharajan <[email protected]>

Target LLVM tools are installed in the sysroot because they are needed for llvm-lit to run tests. However, this leads Rust to pick up a target llvm-config that cannot run on the host. Overwrite it with the native llvm-config so Rust can execute it correctly.

---
  meta/recipes-devtools/rust/rust_1.94.1.bb | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
meta/recipes-devtools/rust/rust_1.94.1.bb +0 -0
index 3eb2a36406..e4a9f20e27 100644
@@ -238,9 +238,10 @@ rust_runx () {
 
Quoted 14 lines

meta/recipes-devtools/rust/rust_1.94.1.bb rust_runx () { · line 246

Quoted 10 lines
meta/recipes-devtools/rust/rust_1.94.1.bb +3 -2
      # Copy the natively built llvm-config into the target so we can run it. Horrible,
      # but works!
-    if [ ${RUST_ALTERNATE_EXE_PATH_NATIVE} != ${RUST_ALTERNATE_EXE_PATH} -a ! -f ${RUST_ALTERNATE_EXE_PATH} ]; then
+    if [ ${RUST_ALTERNATE_EXE_PATH_NATIVE} != ${RUST_ALTERNATE_EXE_PATH} ]; then
          mkdir -p `dirname ${RUST_ALTERNATE_EXE_PATH}`
-        cp ${RUST_ALTERNATE_EXE_PATH_NATIVE} ${RUST_ALTERNATE_EXE_PATH}
+        rm -f ${RUST_ALTERNATE_EXE_PATH}
+        cp -f ${RUST_ALTERNATE_EXE_PATH_NATIVE} ${RUST_ALTERNATE_EXE_PATH}
          patchelf --remove-rpath ${RUST_ALTERNATE_EXE_PATH}
      fi

This appears to be a consequence of the new install in "clang: Enable cmake flags for llvm, clang, lld tests". Perhaps we should just not install llvm-config there if it is going to cause problems and need to be overwritten?

Yes, this is due to the new installations. We now need the target llvm-config to run the Clang family test suite inside QEMU for the target. Previously, we didn’t install LLVM target tools, but running the Clang test suite for the target requires these tools to be present in bin so that llvm-lit can use them.

Also, the existing check is somewhat odd. Even if llvm-config exists in ${RUST_ALTERNATE_EXE_PATH}, it can’t be used for building Rust because that version is built for the target. Therefore, overriding it with the native llvm-config makes sense.

Regards,
Deepesh

Quoted 4 lines

Cheers,

Richard

#11 lore raw

Re: [OE-core] [PATCH 5/5 v5] rust: Fix rust build failure

Quoted 46 lines · Deepesh via lists.openembedded.org
Quoted 22 lines · Richard Purdie

CAUTION: This email comes from a non Wind River email account!
Do not click links or open attachments unless you recognize the sender and know the content is safe.

Quoted 18 lines · Deepesh via lists.openembedded.org

From: Deepesh Varatharajan <[email protected]>

Target LLVM tools are installed in the sysroot because they are needed for llvm-lit to run tests. However, this leads Rust to pick up a target llvm-config that cannot run on the host. Overwrite it with the native llvm-config so Rust can execute it correctly.

---
  meta/recipes-devtools/rust/rust_1.94.1.bb | 5 +++--

  1 file changed, 3 insertions(+), 2 deletions(-)
meta/recipes-devtools/rust/rust_1.94.1.bb +0 -0
index 3eb2a36406..e4a9f20e27 100644
@@ -238,9 +238,10 @@ rust_runx () {
 
Quoted 14 lines
Quoted 10 lines
meta/recipes-devtools/rust/rust_1.94.1.bb +1 -1
       # Copy the natively built llvm-config into the target so we can run it. Horrible,
       # but works!
-    if [ ${RUST_ALTERNATE_EXE_PATH_NATIVE} != ${RUST_ALTERNATE_EXE_PATH} -a ! -f ${RUST_ALTERNATE_EXE_PATH} ]; then
+    if [ ${RUST_ALTERNATE_EXE_PATH_NATIVE} != ${RUST_ALTERNATE_EXE_PATH} ]; then

          mkdir -p dirname ${RUST_ALTERNATE_EXE_PATH}
-        cp ${RUST_ALTERNATE_EXE_PATH_NATIVE} ${RUST_ALTERNATE_EXE_PATH} +        rm -f ${RUST_ALTERNATE_EXE_PATH}
+        cp -f ${RUST_ALTERNATE_EXE_PATH_NATIVE} ${RUST_ALTERNATE_EXE_PATH} patchelf --remove-rpath ${RUST_ALTERNATE_EXE_PATH}
      fi

This appears to be a consequence of the new install in "clang: Enable cmake flags for llvm, clang, lld tests". Perhaps we should just not install llvm-config there if it is going to cause problems and need to be overwritten?

Yes, this is due to the new installations. We now need the target llvm-config to run the Clang
family test suite inside QEMU for the target. Previously, we didn’t install LLVM target tools,
but running the Clang test suite for the target requires these tools to be present in bin so
that llvm-lit can use them.

Quoted 5 lines

Also, the existing check is somewhat odd. Even if llvm-config exists in ${RUST_ALTERNATE_EXE_PATH},
it can’t be used for building Rust because that version is built for the target. Therefore,
overriding it with the native llvm-config makes sense.

We simply can't mix target and native binaries like this.

Think about what happens if you take target sstate built on x86-64 and reuse it on an aarch64 host system.

Cheers,

Richard

#12 lore raw

Re: [OE-core] [PATCH 5/5 v5] rust: Fix rust build failure

Quoted 54 lines · Richard Purdie

CAUTION: This email comes from a non Wind River email account!
Do not click links or open attachments unless you recognize the sender and know the content is safe.

Quoted 45 lines · Deepesh via lists.openembedded.org
Quoted 22 lines · Richard Purdie

CAUTION: This email comes from a non Wind River email account!
Do not click links or open attachments unless you recognize the sender and know the content is safe.

Quoted 18 lines · Deepesh via lists.openembedded.org

From: Deepesh Varatharajan <[email protected]>

Target LLVM tools are installed in the sysroot because they are needed for llvm-lit to run tests. However, this leads Rust to pick up a target llvm-config that cannot run on the host. Overwrite it with the native llvm-config so Rust can execute it correctly.

---
   meta/recipes-devtools/rust/rust_1.94.1.bb | 5 +++--
   1 file changed, 3 insertions(+), 2 deletions(-)
meta/recipes-devtools/rust/rust_1.94.1.bb +0 -0
index 3eb2a36406..e4a9f20e27 100644
@@ -238,9 +238,10 @@ rust_runx () {
 
Quoted 14 lines

meta/recipes-devtools/rust/rust_1.94.1.bb rust_runx () { · line 246

Quoted 10 lines
meta/recipes-devtools/rust/rust_1.94.1.bb +3 -2
       # Copy the natively built llvm-config into the target so we can run it. Horrible,
       # but works!
-    if [ ${RUST_ALTERNATE_EXE_PATH_NATIVE} != ${RUST_ALTERNATE_EXE_PATH} -a ! -f ${RUST_ALTERNATE_EXE_PATH} ]; then
+    if [ ${RUST_ALTERNATE_EXE_PATH_NATIVE} != ${RUST_ALTERNATE_EXE_PATH} ]; then
           mkdir -p `dirname ${RUST_ALTERNATE_EXE_PATH}`
-        cp ${RUST_ALTERNATE_EXE_PATH_NATIVE} ${RUST_ALTERNATE_EXE_PATH}
+        rm -f ${RUST_ALTERNATE_EXE_PATH}
+        cp -f ${RUST_ALTERNATE_EXE_PATH_NATIVE} ${RUST_ALTERNATE_EXE_PATH}
           patchelf --remove-rpath ${RUST_ALTERNATE_EXE_PATH}
       fi

This appears to be a consequence of the new install in "clang: Enable cmake flags for llvm, clang, lld tests". Perhaps we should just not install llvm-config there if it is going to cause problems and need to be overwritten?

Yes, this is due to the new installations. We now need the target llvm-config to run the Clang
family test suite inside QEMU for the target. Previously, we didn’t install LLVM target tools,
but running the Clang test suite for the target requires these tools to be present in bin so
that llvm-lit can use them.

Quoted 5 lines

Also, the existing check is somewhat odd. Even if llvm-config exists in ${RUST_ALTERNATE_EXE_PATH},
it can’t be used for building Rust because that version is built for the target. Therefore,
overriding it with the native llvm-config makes sense.

Quoted 8 lines

We simply can't mix target and native binaries like this.

Think about what happens if you take target sstate built on x86-64 and reuse it on an aarch64 host system.

Cheers,

Richard

Yes, I see your point about mixing native and target binaries and the potential impact on sstate reuse.

However, this behavior already existed before this change. We were copying the native llvm-config into the target sysroot when the paths differed. The only difference here is that we now always overwrite it instead of skipping when a file already exists.

With the recent Clang changes, a target llvm-config is now installed, which causes the previous conditional check to skip the copy. That leads to Rust picking up a target-built llvm-config, which is not usable for building Rust.

So this change doesn’t introduce new mixing. It ensures we consistently use the native llvm-config, which is what the original logic intended. Did I misunderstood something ?

Regards,
Deepesh

Quoted 2 lines
#13 lore raw

Re: [OE-core] [PATCH 5/5 v5] rust: Fix rust build failure

Quoted 77 lines · Deepesh Varatharajan
Quoted 54 lines · Richard Purdie

CAUTION: This email comes from a non Wind River email account!
Do not click links or open attachments unless you recognize the sender and know the content is safe.

Quoted 45 lines · Deepesh via lists.openembedded.org
Quoted 22 lines · Richard Purdie

CAUTION: This email comes from a non Wind River email account!
Do not click links or open attachments unless you recognize the sender and know the content is safe.

Quoted 18 lines · Deepesh via lists.openembedded.org

From: Deepesh Varatharajan <[email protected]>

Target LLVM tools are installed in the sysroot because they are needed for llvm-lit to run tests. However, this leads Rust to pick up a target llvm-config that cannot run on the host. Overwrite it with the native llvm-config so Rust can execute it correctly.

---
   meta/recipes-devtools/rust/rust_1.94.1.bb | 5 +++--

   1 file changed, 3 insertions(+), 2 deletions(-)
meta/recipes-devtools/rust/rust_1.94.1.bb +0 -0
index 3eb2a36406..e4a9f20e27 100644
@@ -238,9 +238,10 @@ rust_runx () {
 
Quoted 14 lines
Quoted 10 lines
meta/recipes-devtools/rust/rust_1.94.1.bb +1 -1
        # Copy the natively built llvm-config into the target so we can run it. Horrible,
        # but works!
-    if [ ${RUST_ALTERNATE_EXE_PATH_NATIVE} != ${RUST_ALTERNATE_EXE_PATH} -a ! -f ${RUST_ALTERNATE_EXE_PATH} ]; then
+    if [ ${RUST_ALTERNATE_EXE_PATH_NATIVE} != ${RUST_ALTERNATE_EXE_PATH} ]; then

           mkdir -p dirname ${RUST_ALTERNATE_EXE_PATH}
-        cp ${RUST_ALTERNATE_EXE_PATH_NATIVE} ${RUST_ALTERNATE_EXE_PATH} +        rm -f ${RUST_ALTERNATE_EXE_PATH}
+        cp -f ${RUST_ALTERNATE_EXE_PATH_NATIVE} ${RUST_ALTERNATE_EXE_PATH} patchelf --remove-rpath ${RUST_ALTERNATE_EXE_PATH} fi

This appears to be a consequence of the new install in "clang: Enable cmake flags for llvm, clang, lld tests". Perhaps we should just not install llvm-config there if it is going to cause problems and need to be overwritten?

Yes, this is due to the new installations. We now need the target llvm-config to run the Clang
family test suite inside QEMU for the target. Previously, we didn’t install LLVM target tools,
but running the Clang test suite for the target requires these tools to be present in bin so
that llvm-lit can use them.

Quoted 5 lines

Also, the existing check is somewhat odd. Even if llvm-config exists in ${RUST_ALTERNATE_EXE_PATH},
it can’t be used for building Rust because that version is built for the target. Therefore,
overriding it with the native llvm-config makes sense.

Quoted 6 lines

We simply can't mix target and native binaries like this.

Think about what happens if you take target sstate built on x86-64 and reuse it on an aarch64 host system.

Yes, I see your point about mixing native and target binaries and the potential impact on sstate reuse.

However, this behavior already existed before this change. We were copying the native llvm-config into
the target sysroot when the paths differed. The only difference here is that we now always overwrite it
instead of skipping when a file already exists.

With the recent Clang changes, a target llvm-config is now installed, which causes the previous conditional
check to skip the copy. That leads to Rust picking up a target-built llvm-config, which is not usable for
building Rust.

Quoted 3 lines

So this change doesn’t introduce new mixing. It ensures we consistently use the native llvm-config, which
is what the original logic intended. Did I misunderstood something ?

Looking at the code, it is in rust_runx and that code us used during compile/install so it only affects things locally, it doesn't change the sstate objects. I was thinking this was changing installed files, sorry.

The check for files existing is probably there due to the fact the function can be called multiple times and we want to copy the first time only.

I still have to wonder why we are installing something which we then have to overwrite though. If we have to overwrite it, we shouldn't be installing it in the first place?

Does the llvm test suite actually use the llvm-config target binary?

Cheers,

Richard

#14 lore raw

Re: [OE-core] [PATCH 5/5 v5] rust: Fix rust build failure

Quoted 83 lines · Richard Purdie

CAUTION: This email comes from a non Wind River email account!
Do not click links or open attachments unless you recognize the sender and know the content is safe.

Quoted 76 lines · Deepesh Varatharajan
Quoted 54 lines · Richard Purdie

CAUTION: This email comes from a non Wind River email account!
Do not click links or open attachments unless you recognize the sender and know the content is safe.

Quoted 45 lines · Deepesh via lists.openembedded.org
Quoted 22 lines · Richard Purdie

CAUTION: This email comes from a non Wind River email account!
Do not click links or open attachments unless you recognize the sender and know the content is safe.

Quoted 18 lines · Deepesh via lists.openembedded.org

From: Deepesh Varatharajan <[email protected]>

Target LLVM tools are installed in the sysroot because they are needed for llvm-lit to run tests. However, this leads Rust to pick up a target llvm-config that cannot run on the host. Overwrite it with the native llvm-config so Rust can execute it correctly.

---
    meta/recipes-devtools/rust/rust_1.94.1.bb | 5 +++--
    1 file changed, 3 insertions(+), 2 deletions(-)
meta/recipes-devtools/rust/rust_1.94.1.bb +0 -0
index 3eb2a36406..e4a9f20e27 100644
@@ -238,9 +238,10 @@ rust_runx () {
 
Quoted 14 lines

meta/recipes-devtools/rust/rust_1.94.1.bb rust_runx () { · line 246

Quoted 10 lines
meta/recipes-devtools/rust/rust_1.94.1.bb +3 -2
        # Copy the natively built llvm-config into the target so we can run it. Horrible,
        # but works!
-    if [ ${RUST_ALTERNATE_EXE_PATH_NATIVE} != ${RUST_ALTERNATE_EXE_PATH} -a ! -f ${RUST_ALTERNATE_EXE_PATH} ]; then
+    if [ ${RUST_ALTERNATE_EXE_PATH_NATIVE} != ${RUST_ALTERNATE_EXE_PATH} ]; then
            mkdir -p `dirname ${RUST_ALTERNATE_EXE_PATH}`
-        cp ${RUST_ALTERNATE_EXE_PATH_NATIVE} ${RUST_ALTERNATE_EXE_PATH}
+        rm -f ${RUST_ALTERNATE_EXE_PATH}
+        cp -f ${RUST_ALTERNATE_EXE_PATH_NATIVE} ${RUST_ALTERNATE_EXE_PATH}
            patchelf --remove-rpath ${RUST_ALTERNATE_EXE_PATH}
        fi

This appears to be a consequence of the new install in "clang: Enable cmake flags for llvm, clang, lld tests". Perhaps we should just not install llvm-config there if it is going to cause problems and need to be overwritten?

Yes, this is due to the new installations. We now need the target llvm-config to run the Clang
family test suite inside QEMU for the target. Previously, we didn’t install LLVM target tools,
but running the Clang test suite for the target requires these tools to be present in bin so
that llvm-lit can use them.

Quoted 5 lines

Also, the existing check is somewhat odd. Even if llvm-config exists in ${RUST_ALTERNATE_EXE_PATH},
it can’t be used for building Rust because that version is built for the target. Therefore,
overriding it with the native llvm-config makes sense.

Quoted 6 lines

We simply can't mix target and native binaries like this.

Think about what happens if you take target sstate built on x86-64 and reuse it on an aarch64 host system.

Yes, I see your point about mixing native and target binaries and the potential impact on sstate reuse.

However, this behavior already existed before this change. We were copying the native llvm-config into
the target sysroot when the paths differed. The only difference here is that we now always overwrite it
instead of skipping when a file already exists.

With the recent Clang changes, a target llvm-config is now installed, which causes the previous conditional
check to skip the copy. That leads to Rust picking up a target-built llvm-config, which is not usable for
building Rust.

Quoted 3 lines

So this change doesn’t introduce new mixing. It ensures we consistently use the native llvm-config, which
is what the original logic intended. Did I misunderstood something ?

Quoted 8 lines

Looking at the code, it is in rust_runx and that code us used during compile/install so it only affects things locally, it doesn't change the sstate objects. I was thinking this was changing installed files, sorry.

The check for files existing is probably there due to the fact the function can be called multiple times and we want to copy the first time only.

True

Quoted 4 lines

I still have to wonder why we are installing something which we then have to overwrite though. If we have to overwrite it, we shouldn't be installing it in the first place?

The target llvm-config is required for running the Clang test suite, since those tests depend on LLVM and are executed under QEMU, where a target binary is needed.

As part of that, we install the target llvm-config into the sysroot. However, Rust also depends on LLVM, and during its build it picks up llvm-config from that same location. In this case, using the target llvm-config doesn’t work, because Rust needs a native binary for the host build.

So the situation is a bit split:

For Clang tests, we need the target llvm-config available in the sysroot so it can run under QEMU. For building Rust, we need the native llvm-config, not the target one.

The overwrite ensures that Rust consistently uses the native llvm-config, while still allowing the target one to be installed for Clang test purposes. This doesn’t change the intended behavior, but resolves the conflict between the two use cases.

Quoted 2 lines

Does the llvm test suite actually use the llvm-config target binary?

Yes it does.

Quoted 4 lines

Cheers,

Richard