Skip to content

Commit 2a1e390

Browse files
[llvm][lit] Handle case when there is no llvm default target triple (#76934)
This can happen when you do not choose a specific target triple, and do not enable the host architecture when building (if you do enable it, it would become the default target). Such as only enabling RISC-V, when building on an AArch64 machine. Originally reported https://discourse.llvm.org/t/llvm-test-error-could-not-turn-into-itanium-abi-triple/76013. When attempting to run a single test via lit you get: `Could not turn '' into Itanium ABI triple` Setting a default triple with `LLVM_DEFAULT_TARGET_TRIPLE` works around the issue. This change copies the existing host triple check to target triple, and adds a note to highlight the potential issue. As `check-clang` on my AArch64 machine failed 32% of tests in this configuration. Which is to be expected and is ok if you only want to run specific tests, but for anyone unintentionally building this way the note is a clue to the cause.
1 parent 71f56e4 commit 2a1e390

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

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

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -646,15 +646,25 @@ def use_clang(
646646
self.add_tool_substitutions(tool_substitutions)
647647
self.config.substitutions.append(("%resource_dir", builtin_include_dir))
648648

649-
self.config.substitutions.append(
650-
(
651-
"%itanium_abi_triple",
652-
self.make_itanium_abi_triple(self.config.target_triple),
649+
# There will be no default target triple if one was not specifically
650+
# set, and the host's architecture is not an enabled target.
651+
if self.config.target_triple:
652+
self.config.substitutions.append(
653+
(
654+
"%itanium_abi_triple",
655+
self.make_itanium_abi_triple(self.config.target_triple),
656+
)
653657
)
654-
)
655-
self.config.substitutions.append(
656-
("%ms_abi_triple", self.make_msabi_triple(self.config.target_triple))
657-
)
658+
self.config.substitutions.append(
659+
("%ms_abi_triple", self.make_msabi_triple(self.config.target_triple))
660+
)
661+
else:
662+
if not self.lit_config.quiet:
663+
self.lit_config.note(
664+
"No default target triple was found, some tests may fail as a result."
665+
)
666+
self.config.substitutions.append(("%itanium_abi_triple", ""))
667+
self.config.substitutions.append(("%ms_abi_triple", ""))
658668

659669
# The host triple might not be set, at least if we're compiling clang
660670
# from an already installed llvm.

0 commit comments

Comments
 (0)