Skip to content

Commit dd73a51

Browse files
committed
[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.
1 parent dda4b96 commit dd73a51

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

llvm/utils/lit/lit/llvm/config.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ def user_is_root():
2424
return False
2525

2626

27+
def remove_triple_vendor(triple):
28+
components = triple.split("-")
29+
30+
# Remove vendor component (e.g. unknown, pc) if present.
31+
if len(components) == 4:
32+
del components[1]
33+
34+
return "-".join(components)
35+
36+
2737
class LLVMConfig(object):
2838
def __init__(self, lit_config, config):
2939
self.lit_config = lit_config
@@ -108,14 +118,14 @@ def __init__(self, lit_config, config):
108118
elif platform.system() == "OS/390":
109119
features.add("system-zos")
110120

111-
# Native compilation: host arch == default triple arch
121+
# Native compilation: host arch == default triple arch (sans vendor)
112122
# Both of these values should probably be in every site config (e.g. as
113123
# part of the standard header. But currently they aren't)
114124
host_triple = getattr(config, "host_triple", None)
115125
target_triple = getattr(config, "target_triple", None)
116126
features.add("host=%s" % host_triple)
117127
features.add("target=%s" % target_triple)
118-
if host_triple and host_triple == target_triple:
128+
if host_triple and remove_triple_vendor(host_triple) == remove_triple_vendor(target_triple):
119129
features.add("native")
120130

121131
# Sanitizers.

0 commit comments

Comments
 (0)