[llvm] cmake: Derive CMake system name from a triple via new mechanism (PR #208773)
Alexis Engelke via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 30 06:30:30 PDT 2026
================
@@ -0,0 +1,155 @@
+#!/usr/bin/env python3
+"""Derive a CMake system name from a target triple.
+
+The recognized OS and environment names are defined in
+llvm/include/llvm/TargetParser/TripleName.def. This script parses that
+file so the CMake runtimes build can map a (possibly unnormalized)
+triple to a CMake system name without running a compiled tool. CMake
+invokes it once per target with --triple and reads the printed name.
+
+Modes:
+ --triple TRIPLE Print the CMake system name for TRIPLE (empty if unknown or
+ the triple has too few components; the caller then falls back
+ to the host system name).
+
+Options:
+ --def-file PATH Path to TripleName.def to parse instead of the copy located
+ relative to this script (in llvm/include/llvm/TargetParser).
+
+"""
+
+import argparse
+import os
+import re
+import sys
+
+_OS_RE = re.compile(r'^\s*TRIPLE_OS\(\s*(\w+)\s*,\s*"([^"]*)"\s*,\s*"([^"]*)"\s*\)')
+_OS_ALIAS_RE = re.compile(r'^\s*TRIPLE_OS_ALIAS\(\s*(\w+)\s*,\s*"([^"]*)"\s*\)')
+_ENV_RE = re.compile(r'^\s*TRIPLE_ENV\(\s*(\w+)\s*,\s*"([^"]*)"\s*,\s*"([^"]*)"\s*\)')
----------------
aengelke wrote:
I don't have a good feeling about this ad-hoc C preprocessor parsing...
https://github.com/llvm/llvm-project/pull/208773
More information about the llvm-commits
mailing list