[PATCH] ld: Run clang tests only if supported
"H.J. Lu" <[email protected]>
| Newsgroups | gmane.comp.gnu.binutils |
|---|---|
| Message-ID | <CAMe9rOo-XXDjJQ1AgyOOLL9APJ8d_A+r2Oy81PT2kZGYwSrKWA@mail.gmail.com> |
Since Clang doesn't support all GCC options, PR ld/34570 tests fail to compile if GCC specific options are used to build binutils. Add llvm_lto_tests to lto.exp and don't run PR ld/34576 tests if Clang fails to compile them. PR ld/34576 * testsuite/ld-plugin/lto.exp (llvm_lto_tests): New. Use it. -- H.J.
0001-ld-Run-clang-tests-only-if-supported.patch
(text/x-patch, 2.2 KB)
From 384f7c42ecff8acb4fb37bf033d9f8066369094b Mon Sep 17 00:00:00 2001 From: "H.J. Lu" <[email protected]> Date: Fri, 28 Aug 2026 16:02:11 +0800 Subject: [PATCH] ld: Run clang tests only if supported Since Clang doesn't support all GCC options, PR ld/34570 tests fail to compile if GCC specific options are used to build binutils. Add llvm_lto_tests to lto.exp and don't run PR ld/34576 tests if Clang fails to compile them. PR ld/34576 * testsuite/ld-plugin/lto.exp (llvm_lto_tests): New. Use it. Signed-off-by: H.J. Lu <[email protected]> --- ld/testsuite/ld-plugin/lto.exp | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/ld/testsuite/ld-plugin/lto.exp b/ld/testsuite/ld-plugin/lto.exp index 8ad341293b5..0144ae8f70a 100644 --- a/ld/testsuite/ld-plugin/lto.exp +++ b/ld/testsuite/ld-plugin/lto.exp @@ -1452,12 +1452,20 @@ if { [check_lto_fat_available] } { } } -# Skip native x32 and i?86 targets since system LLVMgold.so may not be -# compatible with native x32 and i?86 targets binutils. -if { ![istarget "x86_64-*-linux*-gnux32"] - && ![istarget "i?86-*-*"] - && [info exists CLANG_FOR_TARGET] - && ![string match "" $llvm_plug_opt] } { +proc llvm_lto_tests {} { + global CC_FOR_TARGET + global CLANG_FOR_TARGET + global llvm_plug_opt + + # Skip native x32 and i?86 targets since system LLVMgold.so may not + # be compatible with native x32 and i?86 targets binutils. + if {[istarget "x86_64-*-linux*-gnux32"] + || [istarget "i?86-*-*"] + || ![info exists CLANG_FOR_TARGET] + || [string match "" $llvm_plug_opt] } { + return + } + set CC_FOR_TARGET_saved "$CC_FOR_TARGET" set CC_FOR_TARGET "$CLANG_FOR_TARGET" run_cc_link_tests [list \ @@ -1473,6 +1481,14 @@ if { ![istarget "x86_64-*-linux*-gnux32"] "-flto" \ {pr34572b.c} \ ] \ + ] + + if {![file exists tmpdir/pr34572a.o] + || ![file exists tmpdir/pr34572b.o]} { + return + } + + run_cc_link_tests [list \ [list \ "Build pr34572a.exe" \ "-flto -Wl,--start-lib tmpdir/pr34572a.o -Wl,--end-lib" \ @@ -1509,4 +1525,6 @@ if { ![istarget "x86_64-*-linux*-gnux32"] set CC_FOR_TARGET "$CC_FOR_TARGET_saved" } +llvm_lto_tests + restore_notify -- 2.55.0