Skip to content

Commit 9c525ea

Browse files
authored
Merge pull request #315 from nathanchance/fix-experimental-targets-llvm-older-than-17
tc_build: llvm: Handle absence of LLVM_ALL_EXPERIMENTAL_TARGETS
2 parents e4a183c + 2cbe2ae commit 9c525ea

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)