ld: Run clang tests only if supported

Message ID CAMe9rOo-XXDjJQ1AgyOOLL9APJ8d_A+r2Oy81PT2kZGYwSrKWA@mail.gmail.com
State New
Headers
Series ld: Run clang tests only if supported |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-arm fail Patch failed to apply
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 fail Patch failed to apply

Commit Message

H.J. Lu Aug. 28, 2026, 8:11 a.m. UTC
  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.
  

Comments

H.J. Lu Aug. 28, 2026, 8:27 a.m. UTC | #1
On Fri, Aug 28, 2026 at 4:11 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> 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.

This is the patch I am checking in.
  

Patch

From 384f7c42ecff8acb4fb37bf033d9f8066369094b Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
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 <hjl.tools@gmail.com>
---
 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