Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[llvm][lit] Handle case when there is no llvm default target triple #76934

Merged
merged 1 commit into from
Jan 5, 2024

Conversation

DavidSpickett
Copy link
Collaborator

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 checks 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.

@llvmbot
Copy link
Collaborator

llvmbot commented Jan 4, 2024

@llvm/pr-subscribers-testing-tools

Author: David Spickett (DavidSpickett)

Changes

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 checks 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.


Full diff: https://github.com/llvm/llvm-project/pull/76934.diff

1 Files Affected:

  • (modified) llvm/utils/lit/lit/llvm/config.py (+21-8)
diff --git a/llvm/utils/lit/lit/llvm/config.py b/llvm/utils/lit/lit/llvm/config.py
index 79094b839e772e..c39c4c7da8397a 100644
--- a/llvm/utils/lit/lit/llvm/config.py
+++ b/llvm/utils/lit/lit/llvm/config.py
@@ -632,15 +632,28 @@ def use_clang(
             self.add_tool_substitutions(tool_substitutions)
             self.config.substitutions.append(("%resource_dir", builtin_include_dir))
 
-        self.config.substitutions.append(
-            (
-                "%itanium_abi_triple",
-                self.make_itanium_abi_triple(self.config.target_triple),
+        # There will be no default target triple if one was not specifically
+        # set, and the host's architecture is not an enabled target.
+        if (
+            self.config.target_triple
+            and self.config.target_triple != "@LLVM_TARGET_TRIPLE@"
+        ):
+            self.config.substitutions.append(
+                (
+                    "%itanium_abi_triple",
+                    self.make_itanium_abi_triple(self.config.target_triple),
+                )
             )
-        )
-        self.config.substitutions.append(
-            ("%ms_abi_triple", self.make_msabi_triple(self.config.target_triple))
-        )
+            self.config.substitutions.append(
+                ("%ms_abi_triple", self.make_msabi_triple(self.config.target_triple))
+            )
+        else:
+            if not self.lit_config.quiet:
+                self.lit_config.note(
+                    "No default target triple was found, some tests may fail as a result."
+                )
+            self.config.substitutions.append(("%itanium_abi_triple", ""))
+            self.config.substitutions.append(("%ms_abi_triple", ""))
 
         # The host triple might not be set, at least if we're compiling clang
         # from an already installed llvm.

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 checks 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.
Copy link
Contributor

@RoboTux RoboTux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@DavidSpickett DavidSpickett merged commit 2a1e390 into llvm:main Jan 5, 2024
4 checks passed
@DavidSpickett DavidSpickett deleted the lit-target branch January 5, 2024 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants