mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
Revert "cmake: check llvm-config in separate function"
This reverts commit 55c3efcb58cc153fc3109a61c6949e470b57b81e. This caused a regression when building Zig with Homebrew. Also I don't like that it prints a message on success. Only when there is a problem should an error message be printed. closes #14093
This commit is contained in:
parent
601ab9a251
commit
b1207b3293
@ -8,9 +8,27 @@
|
|||||||
# LLVM_LIBDIRS
|
# LLVM_LIBDIRS
|
||||||
# LLVM_LINK_MODE
|
# LLVM_LINK_MODE
|
||||||
|
|
||||||
function(check_llvm_config LLVM_CONFIG_EXE)
|
|
||||||
# Start with empty message for current llvm-config
|
if(ZIG_USE_LLVM_CONFIG)
|
||||||
set(LLVM_CONFIG_ERROR_MESSAGES "" PARENT_SCOPE)
|
set(LLVM_CONFIG_ERROR_MESSAGES "")
|
||||||
|
while(1)
|
||||||
|
unset(LLVM_CONFIG_EXE CACHE)
|
||||||
|
find_program(LLVM_CONFIG_EXE
|
||||||
|
NAMES llvm-config-15 llvm-config-15.0 llvm-config150 llvm-config15 llvm-config NAMES_PER_DIR
|
||||||
|
PATHS
|
||||||
|
"/mingw64/bin"
|
||||||
|
"/c/msys64/mingw64/bin"
|
||||||
|
"c:/msys64/mingw64/bin"
|
||||||
|
"C:/Libraries/llvm-15.0.0/bin")
|
||||||
|
|
||||||
|
if ("${LLVM_CONFIG_EXE}" STREQUAL "LLVM_CONFIG_EXE-NOTFOUND")
|
||||||
|
if (NOT LLVM_CONFIG_ERROR_MESSAGES STREQUAL "")
|
||||||
|
list(JOIN LLVM_CONFIG_ERROR_MESSAGES "\n" LLVM_CONFIG_ERROR_MESSAGE)
|
||||||
|
message(FATAL_ERROR ${LLVM_CONFIG_ERROR_MESSAGE})
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "unable to find llvm-config")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
# Check that this LLVM is the right version
|
# Check that this LLVM is the right version
|
||||||
execute_process(
|
execute_process(
|
||||||
@ -18,10 +36,14 @@ function(check_llvm_config LLVM_CONFIG_EXE)
|
|||||||
OUTPUT_VARIABLE LLVM_CONFIG_VERSION
|
OUTPUT_VARIABLE LLVM_CONFIG_VERSION
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
|
||||||
if("${LLVM_CONFIG_VERSION}" VERSION_LESS 15 OR "${LLVM_CONFIG_VERSION}" VERSION_GREATER_EQUAL 16)
|
get_filename_component(LLVM_CONFIG_DIR "${LLVM_CONFIG_EXE}" DIRECTORY)
|
||||||
# Save the error message for current llvm-config we find
|
if("${LLVM_CONFIG_VERSION}" VERSION_LESS 15 OR "${LLVM_CONFIG_VERSION}" VERSION_EQUAL 16 OR "${LLVM_CONFIG_VERSION}" VERSION_GREATER 16)
|
||||||
set(LLVM_CONFIG_ERROR_MESSAGES "Expected LLVM 15.x but found ${LLVM_CONFIG_VERSION}" PARENT_SCOPE)
|
# Save the error message, in case this is the last llvm-config we find
|
||||||
return()
|
list(APPEND LLVM_CONFIG_ERROR_MESSAGES "expected LLVM 15.x but found ${LLVM_CONFIG_VERSION} using ${LLVM_CONFIG_EXE}")
|
||||||
|
|
||||||
|
# Ignore this directory and try the search again
|
||||||
|
list(APPEND CMAKE_IGNORE_PATH "${LLVM_CONFIG_DIR}")
|
||||||
|
continue()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Check that this LLVM supports linking as a shared/static library, if requested
|
# Check that this LLVM supports linking as a shared/static library, if requested
|
||||||
@ -39,12 +61,16 @@ function(check_llvm_config LLVM_CONFIG_EXE)
|
|||||||
ERROR_STRIP_TRAILING_WHITESPACE)
|
ERROR_STRIP_TRAILING_WHITESPACE)
|
||||||
|
|
||||||
if (LLVM_CONFIG_ERROR)
|
if (LLVM_CONFIG_ERROR)
|
||||||
|
# Save the error message, in case this is the last llvm-config we find
|
||||||
if (ZIG_SHARED_LLVM)
|
if (ZIG_SHARED_LLVM)
|
||||||
set(LLVM_CONFIG_ERROR_MESSAGES "This LLVM does not support linking as a shared library" PARENT_SCOPE)
|
list(APPEND LLVM_CONFIG_ERROR_MESSAGES "LLVM 15.x found at ${LLVM_CONFIG_EXE} does not support linking as a shared library")
|
||||||
else()
|
else()
|
||||||
set(LLVM_CONFIG_ERROR_MESSAGES "This LLVM does not support linking as a static library" PARENT_SCOPE)
|
list(APPEND LLVM_CONFIG_ERROR_MESSAGES "LLVM 15.x found at ${LLVM_CONFIG_EXE} does not support linking as a static library")
|
||||||
endif()
|
endif()
|
||||||
return()
|
|
||||||
|
# Ignore this directory and try the search again
|
||||||
|
list(APPEND CMAKE_IGNORE_PATH "${LLVM_CONFIG_DIR}")
|
||||||
|
continue()
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -53,15 +79,17 @@ function(check_llvm_config LLVM_CONFIG_EXE)
|
|||||||
OUTPUT_VARIABLE LLVM_TARGETS_BUILT_SPACES
|
OUTPUT_VARIABLE LLVM_TARGETS_BUILT_SPACES
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
string(REPLACE " " ";" LLVM_TARGETS_BUILT "${LLVM_TARGETS_BUILT_SPACES}")
|
string(REPLACE " " ";" LLVM_TARGETS_BUILT "${LLVM_TARGETS_BUILT_SPACES}")
|
||||||
|
function(NEED_TARGET TARGET_NAME)
|
||||||
macro(NEED_TARGET TARGET_NAME)
|
|
||||||
list (FIND LLVM_TARGETS_BUILT "${TARGET_NAME}" _index)
|
list (FIND LLVM_TARGETS_BUILT "${TARGET_NAME}" _index)
|
||||||
if (${_index} EQUAL -1)
|
if (${_index} EQUAL -1)
|
||||||
set(LLVM_CONFIG_ERROR_MESSAGES "This LLVM is missing target ${TARGET_NAME}. Zig requires LLVM to be built with all default targets enabled." PARENT_SCOPE)
|
# Save the error message, in case this is the last llvm-config we find
|
||||||
return()
|
list(APPEND LLVM_CONFIG_ERROR_MESSAGES "LLVM (according to ${LLVM_CONFIG_EXE}) is missing target ${TARGET_NAME}. Zig requires LLVM to be built with all default targets enabled.")
|
||||||
endif()
|
|
||||||
endmacro()
|
|
||||||
|
|
||||||
|
# Ignore this directory and try the search again
|
||||||
|
list(APPEND CMAKE_IGNORE_PATH "${LLVM_CONFIG_DIR}")
|
||||||
|
continue()
|
||||||
|
endif()
|
||||||
|
endfunction(NEED_TARGET)
|
||||||
NEED_TARGET("AArch64")
|
NEED_TARGET("AArch64")
|
||||||
NEED_TARGET("AMDGPU")
|
NEED_TARGET("AMDGPU")
|
||||||
NEED_TARGET("ARM")
|
NEED_TARGET("ARM")
|
||||||
@ -80,39 +108,9 @@ function(check_llvm_config LLVM_CONFIG_EXE)
|
|||||||
NEED_TARGET("WebAssembly")
|
NEED_TARGET("WebAssembly")
|
||||||
NEED_TARGET("X86")
|
NEED_TARGET("X86")
|
||||||
NEED_TARGET("XCore")
|
NEED_TARGET("XCore")
|
||||||
endfunction()
|
|
||||||
|
|
||||||
if(ZIG_USE_LLVM_CONFIG)
|
# Got it!
|
||||||
while(1)
|
|
||||||
unset(LLVM_CONFIG_EXE CACHE)
|
|
||||||
find_program(LLVM_CONFIG_EXE
|
|
||||||
NAMES llvm-config-15 llvm-config-15.0 llvm-config150 llvm-config15 llvm-config NAMES_PER_DIR
|
|
||||||
PATHS
|
|
||||||
"/mingw64/bin"
|
|
||||||
"/c/msys64/mingw64/bin"
|
|
||||||
"c:/msys64/mingw64/bin"
|
|
||||||
"C:/Libraries/llvm-15.0.0/bin")
|
|
||||||
|
|
||||||
if("${LLVM_CONFIG_EXE}" STREQUAL "LLVM_CONFIG_EXE-NOTFOUND")
|
|
||||||
message(FATAL_ERROR "Suitable llvm-config is not found.")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
message("Trying ${LLVM_CONFIG_EXE}...")
|
|
||||||
|
|
||||||
check_llvm_config(${LLVM_CONFIG_EXE})
|
|
||||||
if(LLVM_CONFIG_ERROR_MESSAGES STREQUAL "")
|
|
||||||
message("This llvm-config is suitable for us, continuing...")
|
|
||||||
break()
|
break()
|
||||||
else()
|
|
||||||
|
|
||||||
message("This llvm-config is not suitable for us:")
|
|
||||||
list(JOIN LLVM_CONFIG_ERROR_MESSAGES "\n" LLVM_CONFIG_ERROR_MESSAGE)
|
|
||||||
message(${LLVM_CONFIG_ERROR_MESSAGE})
|
|
||||||
message("Trying another llvm-config...")
|
|
||||||
|
|
||||||
get_filename_component(LLVM_CONFIG_DIR "${LLVM_CONFIG_EXE}" DIRECTORY)
|
|
||||||
list(APPEND CMAKE_IGNORE_PATH "${LLVM_CONFIG_DIR}")
|
|
||||||
endif()
|
|
||||||
endwhile()
|
endwhile()
|
||||||
|
|
||||||
if(ZIG_SHARED_LLVM OR ZIG_STATIC_LLVM)
|
if(ZIG_SHARED_LLVM OR ZIG_STATIC_LLVM)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user