[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 06:01:01 PDT 2026


gallopruss-sie wrote:

> I don't really know what the test was supposed to test, so I don't know if it's right or not. However, I don't really see the difference between not testing for the path prefix being there and overriding `-clang-resource-dir`, so it will always be there and nothing is really tested.

Yes, interesting point. The test was originally added in de61aa3118b9bac85c468ea7ec40604a086744f5 which is about sysroot computation so originally didn't care about this. I think it was later changed to check resource paths in e0f22fe04a5c, so I think it does still need to test resource paths.

An alternative would be to make the test less sensitive to the path (continuing the direction from 1ab13f8cc3f7) (something like):

```
diff --git a/clang/test/Driver/riscv64-toolchain-extra.c b/clang/test/Driver/riscv64-toolchain-extra.c
--- a/clang/test/Driver/riscv64-toolchain-extra.c
+++ b/clang/test/Driver/riscv64-toolchain-extra.c
@@ -28,7 +28,7 @@
 // C-RV64-BAREMETAL-LP64-NOGCC: "-internal-isystem" "{{.*}}/riscv64-nogcc/bin/../riscv64-unknown-elf/include"
 // C-RV64-BAREMETAL-LP64-NOGCC: "{{.*}}/riscv64-nogcc/bin/riscv64-unknown-elf-ld"
 // C-RV64-BAREMETAL-LP64-NOGCC: "{{.*}}/riscv64-nogcc/bin/../riscv64-unknown-elf/lib/crt0.o"
-// C-RV64-BAREMETAL-LP64-NOGCC: "{{.*}}/riscv64-nogcc/{{.*}}/riscv64-unknown-unknown-elf/clang_rt.crtbegin.o"
+// C-RV64-BAREMETAL-LP64-NOGCC: "{{.*}}/riscv64-unknown-unknown-elf/clang_rt.crtbegin.o"
 // C-RV64-BAREMETAL-LP64-NOGCC: "{{.*}}/riscv64-nogcc/bin/../riscv64-unknown-elf/lib"
-// C-RV64-BAREMETAL-LP64-NOGCC: "--start-group" "{{.*}}/riscv64-nogcc/{{.*}}/riscv64-unknown-unknown-elf/libclang_rt.builtins.a" "-lc" "-lgloss" "--end-group"
-// C-RV64-BAREMETAL-LP64-NOGCC: "{{.*}}/riscv64-nogcc/{{.*}}/riscv64-unknown-unknown-elf/clang_rt.crtend.o"
+// C-RV64-BAREMETAL-LP64-NOGCC: "--start-group" "{{.*}}/riscv64-unknown-unknown-elf/libclang_rt.builtins.a" "-lc" "-lgloss" "--end-group"
+// C-RV64-BAREMETAL-LP64-NOGCC: "{{.*}}/riscv64-unknown-unknown-elf/clang_rt.crtend.o"
```

Do you think that would be a better approach?

Thanks
Russ

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


More information about the cfe-commits mailing list