[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:42:45 PDT 2026


https://github.com/gallopruss-sie created https://github.com/llvm/llvm-project/pull/226952

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.

>From d2d15246248ee0c8c48869f24f8e99fceb1563b3 Mon Sep 17 00:00:00 2001
From: Russell Gallop <russell.gallop at sony.com>
Date: Mon, 28 Sep 2026 11:33:24 +0100
Subject: [PATCH] [clang][test] Pass -resource-dir in riscv*-toolchain-extra.c
 tests

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.
---
 clang/test/Driver/riscv32-toolchain-extra.c | 2 ++
 clang/test/Driver/riscv64-toolchain-extra.c | 2 ++
 2 files changed, 4 insertions(+)

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
 



More information about the cfe-commits mailing list