[compiler-rt] Check if LLD is built when checking if lto_supported (PR #92752)

Jan Voung via llvm-commits llvm-commits at lists.llvm.org
Mon May 20 06:54:00 PDT 2024


https://github.com/jvoung updated https://github.com/llvm/llvm-project/pull/92752

>From a59fb1ed877fd628d765381a2806e818d735653f Mon Sep 17 00:00:00 2001
From: Jan Voung <jvoung at gmail.com>
Date: Mon, 20 May 2024 13:46:40 +0000
Subject: [PATCH 1/2] Check if LLD is built when checking if lto_supported

Otherwise, older copies of LLD may not understand the latest bitcode
versions (for example, if we increase `ModuleSummaryIndex::BitCodeSummaryVersion`)
---
 compiler-rt/test/lit.common.cfg.py | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/compiler-rt/test/lit.common.cfg.py b/compiler-rt/test/lit.common.cfg.py
index fae1d1686e569..862f772aaf827 100644
--- a/compiler-rt/test/lit.common.cfg.py
+++ b/compiler-rt/test/lit.common.cfg.py
@@ -744,6 +744,13 @@ def is_binutils_lto_supported():
     return True
 
 
+def is_lld_lto_supported():
+    # We require LLD does support LTO, but we require it to be built with the
+    # latest changes to claim support. Otherwise older copies of LLD may not
+    # understand new bitcode versions.
+    return os.path.exists(os.path.join(config.llvm_tools_dir, "lld"))
+
+
 def is_windows_lto_supported():
     if not target_is_msvc:
         return True
@@ -755,7 +762,7 @@ def is_windows_lto_supported():
     config.lto_flags = ["-Wl,-lto_library," + liblto_path()]
 elif config.host_os in ["Linux", "FreeBSD", "NetBSD"]:
     config.lto_supported = False
-    if config.use_lld:
+    if config.use_lld and is_lld_lto_supported():
         config.lto_supported = True
     if is_binutils_lto_supported():
         config.available_features.add("binutils_lto")

>From f38989543955a3649168da1e0e7a93404d0884ac Mon Sep 17 00:00:00 2001
From: Jan Voung <jvoung at gmail.com>
Date: Mon, 20 May 2024 13:46:40 +0000
Subject: [PATCH 2/2] Check if LLD is built when checking if lto_supported

Otherwise, older copies of LLD may not understand the latest bitcode
versions (for example, if we increase `ModuleSummaryIndex::BitCodeSummaryVersion`)
---
 compiler-rt/test/lit.common.cfg.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/compiler-rt/test/lit.common.cfg.py b/compiler-rt/test/lit.common.cfg.py
index 862f772aaf827..64b9a9d025e7b 100644
--- a/compiler-rt/test/lit.common.cfg.py
+++ b/compiler-rt/test/lit.common.cfg.py
@@ -745,8 +745,8 @@ def is_binutils_lto_supported():
 
 
 def is_lld_lto_supported():
-    # We require LLD does support LTO, but we require it to be built with the
-    # latest changes to claim support. Otherwise older copies of LLD may not
+    # LLD does support LTO, but we require it to be built with the latest
+    # changes to claim support. Otherwise older copies of LLD may not
     # understand new bitcode versions.
     return os.path.exists(os.path.join(config.llvm_tools_dir, "lld"))
 



More information about the llvm-commits mailing list