[llvm] [llvm][lit] Omit vendor in triples for "native" feature (PR #136325)
Raul Tambre via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 18 09:49:56 PDT 2025
https://github.com/tambry created https://github.com/llvm/llvm-project/pull/136325
The vendor component may be different, e.g. x86_64-linux-gnu vs x86_64-pc-linux-gnu, but it's still native.
>From dd73a513206a08f1c7b65edc42bea122c70b7ee9 Mon Sep 17 00:00:00 2001
From: Raul Tambre <raul at tambre.ee>
Date: Fri, 18 Apr 2025 19:36:26 +0300
Subject: [PATCH] [llvm][lit] Omit vendor in triples for "native" feature
The vendor component may be different, e.g. x86_64-linux-gnu vs x86_64-pc-linux-gnu, but it's still native.
---
llvm/utils/lit/lit/llvm/config.py | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/llvm/utils/lit/lit/llvm/config.py b/llvm/utils/lit/lit/llvm/config.py
index c134cda90e2ee..0b40a407f8f69 100644
--- a/llvm/utils/lit/lit/llvm/config.py
+++ b/llvm/utils/lit/lit/llvm/config.py
@@ -24,6 +24,16 @@ def user_is_root():
return False
+def remove_triple_vendor(triple):
+ components = triple.split("-")
+
+ # Remove vendor component (e.g. unknown, pc) if present.
+ if len(components) == 4:
+ del components[1]
+
+ return "-".join(components)
+
+
class LLVMConfig(object):
def __init__(self, lit_config, config):
self.lit_config = lit_config
@@ -108,14 +118,14 @@ def __init__(self, lit_config, config):
elif platform.system() == "OS/390":
features.add("system-zos")
- # Native compilation: host arch == default triple arch
+ # Native compilation: host arch == default triple arch (sans vendor)
# Both of these values should probably be in every site config (e.g. as
# part of the standard header. But currently they aren't)
host_triple = getattr(config, "host_triple", None)
target_triple = getattr(config, "target_triple", None)
features.add("host=%s" % host_triple)
features.add("target=%s" % target_triple)
- if host_triple and host_triple == target_triple:
+ if host_triple and remove_triple_vendor(host_triple) == remove_triple_vendor(target_triple):
features.add("native")
# Sanitizers.
More information about the llvm-commits
mailing list