[clang] [clang][test] Pass -resource-dir in riscv*-toolchain-extra.c tests (PR #226952)

via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 28 03:43:47 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-risc-v

Author: gallopruss-sie

<details>
<summary>Changes</summary>

These tests check that, with no GCC installation, the driver finds the linker, crt0 and sysroot relative to its own bin/ directory. The compiler-rt paths come from the resource directory, which the tests did not specify, so they relied on the build's CLANG_RESOURCE_DIR placing it within the fake toolchain tree.

With a relative CLANG_RESOURCE_DIR containing several "..", e.g. ../../../../lib/clang/24 as used by Gentoo, the resource directory resolves outside of the test tree. This previously passed only because the unnormalized path still contained "riscv64-nogcc/". Since 99988429d395 removed the dots from the path, the checks fail.

Pass an explicit -resource-dir within the test tree so the tests don't depend on the build configuration.

---
Full diff: https://github.com/llvm/llvm-project/pull/226952.diff


2 Files Affected:

- (modified) clang/test/Driver/riscv32-toolchain-extra.c (+2) 
- (modified) clang/test/Driver/riscv64-toolchain-extra.c (+2) 


``````````diff
diff --git a/clang/test/Driver/riscv32-toolchain-extra.c b/clang/test/Driver/riscv32-toolchain-extra.c
index d228a58d23d4e..68ef8d56ef83f 100644
--- a/clang/test/Driver/riscv32-toolchain-extra.c
+++ b/clang/test/Driver/riscv32-toolchain-extra.c
@@ -17,11 +17,13 @@
 // RUN: ln -s %S/Inputs/basic_riscv32_nogcc_tree/riscv32-unknown-elf %t/riscv32-nogcc/riscv32-unknown-elf
 // RUN: %t/riscv32-nogcc/bin/clang %s -### -no-canonical-prefixes \
 // RUN:    --gcc-toolchain=%t/riscv32-nogcc/invalid \
+// RUN:    -resource-dir=%t/riscv32-nogcc/lib/clang \
 // RUN:    --target=riscv32-unknown-elf --rtlib=platform -fuse-ld=ld 2>&1 \
 // RUN:    | FileCheck -check-prefix=C-RV32-BAREMETAL-ILP32-NOGCC %s
 
 // RUN: %t/riscv32-nogcc/bin/clang %s -### -no-canonical-prefixes \
 // RUN:    --sysroot=%t/riscv32-nogcc/bin/../riscv32-unknown-elf \
+// RUN:    -resource-dir=%t/riscv32-nogcc/lib/clang \
 // RUN:    --target=riscv32-unknown-elf --rtlib=platform -fuse-ld=ld 2>&1 \
 // RUN:    | FileCheck -check-prefix=C-RV32-BAREMETAL-ILP32-NOGCC %s
 
diff --git a/clang/test/Driver/riscv64-toolchain-extra.c b/clang/test/Driver/riscv64-toolchain-extra.c
index e1d3a10dd788d..e419df6b035da 100644
--- a/clang/test/Driver/riscv64-toolchain-extra.c
+++ b/clang/test/Driver/riscv64-toolchain-extra.c
@@ -17,11 +17,13 @@
 // RUN: ln -s %S/Inputs/basic_riscv64_nogcc_tree/riscv64-unknown-elf %t/riscv64-nogcc/riscv64-unknown-elf
 // RUN: %t/riscv64-nogcc/bin/clang %s -### -no-canonical-prefixes \
 // RUN:    --gcc-toolchain=%t/riscv64-nogcc/invalid \
+// RUN:    -resource-dir=%t/riscv64-nogcc/lib/clang \
 // RUN:    --target=riscv64-unknown-elf --rtlib=platform -fuse-ld=ld 2>&1 \
 // RUN:    | FileCheck -check-prefix=C-RV64-BAREMETAL-LP64-NOGCC %s
 
 // RUN: %t/riscv64-nogcc/bin/clang %s -### -no-canonical-prefixes \
 // RUN:    --sysroot=%t/riscv64-nogcc/bin/../riscv64-unknown-elf \
+// RUN:    -resource-dir=%t/riscv64-nogcc/lib/clang \
 // RUN:    --target=riscv64-unknown-elf --rtlib=platform -fuse-ld=ld 2>&1 \
 // RUN:    | FileCheck -check-prefix=C-RV64-BAREMETAL-LP64-NOGCC %s
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/226952


More information about the cfe-commits mailing list