Skip to content

Commit 2cbe2ae

Browse files
committed
tc_build: llvm: Handle absence of LLVM_ALL_EXPERIMENTAL_TARGETS
LLVM_ALL_EXPERIMENTAL_TARGETS was introduced in LLVM 17, so we cannot use it for populating experimental targets on versions older than that. Manually populate the experimental targets in that case by using the initial list of experimental targets from the introduction of LLVM_ALL_EXPERIMENTAL_TARGETS and checking that the 'llvm/lib/Target/<target>' folder exists in the provided LLVM source before adding it to the supported targets list. Signed-off-by: Nathan Chancellor <nathan@kernel.org>
1 parent e4a183c commit 2cbe2ae

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

tc_build/llvm.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,22 @@
1616

1717

1818
def get_all_targets(llvm_folder, experimental=False):
19+
contents = Path(llvm_folder, 'llvm/CMakeLists.txt').read_text(encoding='utf-8')
20+
targets = []
21+
1922
variables = ['LLVM_ALL_TARGETS']
2023
if experimental:
21-
variables.append('LLVM_ALL_EXPERIMENTAL_TARGETS')
22-
23-
contents = Path(llvm_folder, 'llvm/CMakeLists.txt').read_text(encoding='utf-8')
24+
# Introduced by https://github.com/llvm/llvm-project/commit/1908820d6de5004964e85608070e7c869fc81eac in LLVM 17
25+
if 'LLVM_ALL_EXPERIMENTAL_TARGETS' in contents:
26+
variables.append('LLVM_ALL_EXPERIMENTAL_TARGETS')
27+
else:
28+
# Manually populate experimental targets based on list above
29+
possible_experimental_targets = ('ARC', 'CSKY', 'DirectX', 'M68k', 'SPIRV', 'Xtensa')
30+
targets += [
31+
target for target in possible_experimental_targets
32+
if Path(llvm_folder, 'llvm/lib/Target', target).exists()
33+
]
2434

25-
targets = []
2635
for variable in variables:
2736
if not (match := re.search(fr"set\({variable}([\w|\s]+)\)", contents)):
2837
raise RuntimeError(f"Could not find {variables}?")

0 commit comments

Comments
 (0)