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

David Spickett via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 4 05:44:59 PST 2024


================
@@ -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@"
----------------
DavidSpickett wrote:

My understanding is that `LLVM_TARGET_TRIPLE` is the default target.

First reference to it is `<build dir>/lib/cmake/llvm/LLVMConfig.cmake`:
```
set(LLVM_TARGET_TRIPLE "")

set(LLVM_HOST_TRIPLE "aarch64-unknown-linux-gnu")
```
For a clang that reports:
```
$ ./bin/clang --version
clang version 18.0.0git (https://github.com/llvm/llvm-project.git dd71751f6e0e0ece16184a7428ecd160ef320bc6)
Target: unknown
Thread model: posix
InstalledDir: /home/david.spickett/build-llvm-no-host/./bin
```
And the majority of lit configs are using:
```
config.target_triple = "@LLVM_TARGET_TRIPLE@"
```
So if you have a default target, "@LLVM_TARGET_TRIPLE@" expands to that triple, and `config.target_triple` will have that same value.

The `self.config.target_triple != "@LLVM_TARGET_TRIPLE@"` is I think to catch when the `@...@` isn't expanded at all. Not sure how that would happen, just following the `host_triple` logic there.

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


More information about the llvm-commits mailing list