authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-02-07 12:18:01-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-02-07 12:22:04-05:00
logf8ba50f5ed2f0d3ee3b0042d2f4057c50e68f63b
tree1e513f45bbefe70016ed36145eabc923eeb4246e
parenta94304d3e4b9220d2b22501eb2666e5aa89df236
signature Commit is signed but in an unrecognized format.

build: make sure LLVM is exactly correct

* check the version to be the correct major version * ensure that it has all the default targets enabled

1 files changed, 38 insertions(+), 2 deletions(-)

cmake/Findllvm.cmake+38-2
......@@ -15,15 +15,51 @@ find_program(LLVM_CONFIG_EXE
1515 "c:/msys64/mingw64/bin"
1616 "C:/Libraries/llvm-8.0.0/bin")
1717
18if ("${LLVM_CONFIG_EXE}" STREQUAL "LLVM_CONFIG_EXE-NOTFOUND")
19 message(FATAL_ERROR "unable to find llvm-config")
20endif()
21
1822execute_process(
1923 COMMAND ${LLVM_CONFIG_EXE} --version
2024 OUTPUT_VARIABLE LLVM_CONFIG_VERSION
2125 OUTPUT_STRIP_TRAILING_WHITESPACE)
2226
23if(LLVM_CONFIG_VERSION VERSION_LESS 7)
24 message(FATAL_ERROR "expected LLVM version >=7 but found ${LLVM_CONFIG_VERSION}")
27if("${LLVM_CONFIG_VERSION}" VERSION_LESS 7)
28 message(FATAL_ERROR "expected LLVM 7.x but found ${LLVM_CONFIG_VERSION}")
29endif()
30if("${LLVM_CONFIG_VERSION}" VERSION_EQUAL 8)
31 message(FATAL_ERROR "expected LLVM 7.x but found ${LLVM_CONFIG_VERSION}")
32endif()
33if("${LLVM_CONFIG_VERSION}" VERSION_GREATER 8)
34 message(FATAL_ERROR "expected LLVM 7.x but found ${LLVM_CONFIG_VERSION}")
2535endif()
2636
37execute_process(
38 COMMAND ${LLVM_CONFIG_EXE} --targets-built
39 OUTPUT_VARIABLE LLVM_TARGETS_BUILT_SPACES
40 OUTPUT_STRIP_TRAILING_WHITESPACE)
41string(REPLACE " " ";" LLVM_TARGETS_BUILT "${LLVM_TARGETS_BUILT_SPACES}")
42function(NEED_TARGET TARGET_NAME)
43 list (FIND LLVM_TARGETS_BUILT "${TARGET_NAME}" _index)
44 if (${_index} EQUAL -1)
45 message(FATAL_ERROR "LLVM is missing target ${TARGET_NAME}. Zig requires LLVM to be built with all default targets enabled.")
46 endif()
47endfunction(NEED_TARGET)
48NEED_TARGET("AArch64")
49NEED_TARGET("AMDGPU")
50NEED_TARGET("ARM")
51NEED_TARGET("BPF")
52NEED_TARGET("Hexagon")
53NEED_TARGET("Lanai")
54NEED_TARGET("Mips")
55NEED_TARGET("MSP430")
56NEED_TARGET("NVPTX")
57NEED_TARGET("PowerPC")
58NEED_TARGET("Sparc")
59NEED_TARGET("SystemZ")
60NEED_TARGET("X86")
61NEED_TARGET("XCore")
62
2763if(NOT(CMAKE_BUILD_TYPE STREQUAL "Debug") OR ZIG_STATIC)
2864 execute_process(
2965 COMMAND ${LLVM_CONFIG_EXE} --libfiles --link-static