diff --git a/ports/llvm-12/0020-fix-FindZ3.cmake.patch b/ports/llvm-12/0020-fix-FindZ3.cmake.patch new file mode 100644 index 00000000..6b894adb --- /dev/null +++ b/ports/llvm-12/0020-fix-FindZ3.cmake.patch @@ -0,0 +1,70 @@ +diff --git a/llvm/cmake/modules/FindZ3.cmake b/llvm/cmake/modules/FindZ3.cmake +index 118b1eac3b32..455bbf28facc 100644 +--- a/llvm/cmake/modules/FindZ3.cmake ++++ b/llvm/cmake/modules/FindZ3.cmake +@@ -1,3 +1,22 @@ ++# Try first to find Z3 using its upstream cmake files (included in newer version) ++# unless the user has provided a hint that would assume skipping the CONFIG ++# option ++if (NOT DEFINED Z3_ROOT AND NOT LLVM_Z3_INSTALL_DIR) ++ find_package(Z3 QUIET CONFIG) ++endif() ++ ++# If we found with CONFIG mode, then set up the compatible variables ++if (Z3_FOUND) ++ set(Z3_VERSION "${Z3_VERSION_STRING}") ++ set(Z3_LIBRARIES z3::libz3) ++ get_property(Z3_INCLUDE_DIR ++ TARGET z3::libz3 PROPERTY ++ INTERFACE_INCLUDE_DIRECTORIES ++ ) ++ find_package_handle_standard_args(Z3 CONFIG_MODE) ++ ++else() ++ + INCLUDE(CheckCXXSourceRuns) + + # Function to check Z3's version +@@ -123,3 +142,5 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(Z3 + VERSION_VAR Z3_VERSION_STRING) + + mark_as_advanced(Z3_INCLUDE_DIR Z3_LIBRARIES) ++ ++endif() +diff --git a/llvm/lib/Support/CMakeLists.txt b/llvm/lib/Support/CMakeLists.txt +index cdee11412eb5..9a229e903ba5 100644 +--- a/llvm/lib/Support/CMakeLists.txt ++++ b/llvm/lib/Support/CMakeLists.txt +@@ -46,7 +46,11 @@ endif() + + # Link Z3 if the user wants to build it. + if(LLVM_WITH_Z3) +- set(system_libs ${system_libs} ${Z3_LIBRARIES}) ++ if(TARGET "${Z3_LIBRARIES}") ++ set(imported_libs ${imported_libs} "${Z3_LIBRARIES}") ++ else() ++ set(system_libs ${system_libs} ${Z3_LIBRARIES}) ++ endif() + endif() + + # Override the C runtime allocator on Windows and embed it into LLVM tools & libraries +@@ -248,6 +252,19 @@ if(LLVM_ENABLE_ZLIB) + set(llvm_system_libs ${llvm_system_libs} "${zlib_library}") + endif() + ++if(LLVM_WITH_Z3 AND TARGET "${Z3_LIBRARIES}") ++ # CMAKE_BUILD_TYPE is only meaningful to single-configuration generators. ++ if(CMAKE_BUILD_TYPE) ++ string(TOUPPER ${CMAKE_BUILD_TYPE} build_type) ++ get_property(z3_library TARGET "${Z3_LIBRARIES}" PROPERTY LOCATION_${build_type}) ++ endif() ++ if(NOT z3_library) ++ get_property(z3_library TARGET "${Z3_LIBRARIES}" PROPERTY LOCATION) ++ endif() ++ get_library_name("${z3_library}" z3_library) ++ set(llvm_system_libs ${llvm_system_libs} "${z3_library}") ++endif() ++ + if(LLVM_ENABLE_TERMINFO) + get_library_name(${TERMINFO_LIB} terminfo_library) + set(llvm_system_libs ${llvm_system_libs} "${terminfo_library}") diff --git a/ports/llvm-12/0020-remove-FindZ3.cmake.patch b/ports/llvm-12/0020-remove-FindZ3.cmake.patch deleted file mode 100644 index 22c3b125..00000000 --- a/ports/llvm-12/0020-remove-FindZ3.cmake.patch +++ /dev/null @@ -1,116 +0,0 @@ -diff --git a/llvm/cmake/modules/FindZ3.cmake b/llvm/cmake/modules/FindZ3.cmake -deleted file mode 100644 -index 95dd37789..000000000 ---- a/llvm/cmake/modules/FindZ3.cmake -+++ /dev/null -@@ -1,110 +0,0 @@ --INCLUDE(CheckCXXSourceRuns) -- --# Function to check Z3's version --function(check_z3_version z3_include z3_lib) -- # The program that will be executed to print Z3's version. -- file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testz3.c -- "#include -- #include -- int main() { -- unsigned int major, minor, build, rev; -- Z3_get_version(&major, &minor, &build, &rev); -- printf(\"%u.%u.%u\", major, minor, build); -- return 0; -- }") -- -- # Get lib path -- get_filename_component(z3_lib_path ${z3_lib} PATH) -- -- try_run( -- Z3_RETURNCODE -- Z3_COMPILED -- ${CMAKE_BINARY_DIR} -- ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testz3.c -- COMPILE_DEFINITIONS -I"${z3_include}" -- LINK_LIBRARIES -L${z3_lib_path} -lz3 -- RUN_OUTPUT_VARIABLE SRC_OUTPUT -- ) -- -- if(Z3_COMPILED) -- string(REGEX REPLACE "([0-9]*\\.[0-9]*\\.[0-9]*)" "\\1" -- z3_version "${SRC_OUTPUT}") -- set(Z3_VERSION_STRING ${z3_version} PARENT_SCOPE) -- endif() --endfunction(check_z3_version) -- --# Looking for Z3 in LLVM_Z3_INSTALL_DIR --find_path(Z3_INCLUDE_DIR NAMES z3.h -- NO_DEFAULT_PATH -- PATHS ${LLVM_Z3_INSTALL_DIR}/include -- PATH_SUFFIXES libz3 z3 -- ) -- --find_library(Z3_LIBRARIES NAMES z3 libz3 -- NO_DEFAULT_PATH -- PATHS ${LLVM_Z3_INSTALL_DIR} -- PATH_SUFFIXES lib bin -- ) -- --# If Z3 has not been found in LLVM_Z3_INSTALL_DIR look in the default directories --find_path(Z3_INCLUDE_DIR NAMES z3.h -- PATH_SUFFIXES libz3 z3 -- ) -- --find_library(Z3_LIBRARIES NAMES z3 libz3 -- PATH_SUFFIXES lib bin -- ) -- --# Searching for the version of the Z3 library is a best-effort task --unset(Z3_VERSION_STRING) -- --# First, try to check it dynamically, by compiling a small program that --# prints Z3's version --if(Z3_INCLUDE_DIR AND Z3_LIBRARIES) -- # We do not have the Z3 binary to query for a version. Try to use -- # a small C++ program to detect it via the Z3_get_version() API call. -- check_z3_version(${Z3_INCLUDE_DIR} ${Z3_LIBRARIES}) --endif() -- --# If the dynamic check fails, we might be cross compiling: if that's the case, --# check the version in the headers, otherwise, fail with a message --if(NOT Z3_VERSION_STRING AND (CMAKE_CROSSCOMPILING AND -- Z3_INCLUDE_DIR AND -- EXISTS "${Z3_INCLUDE_DIR}/z3_version.h")) -- # TODO: print message warning that we couldn't find a compatible lib? -- -- # Z3 4.8.1+ has the version is in a public header. -- file(STRINGS "${Z3_INCLUDE_DIR}/z3_version.h" -- z3_version_str REGEX "^#define[\t ]+Z3_MAJOR_VERSION[\t ]+.*") -- string(REGEX REPLACE "^.*Z3_MAJOR_VERSION[\t ]+([0-9]).*$" "\\1" -- Z3_MAJOR "${z3_version_str}") -- -- file(STRINGS "${Z3_INCLUDE_DIR}/z3_version.h" -- z3_version_str REGEX "^#define[\t ]+Z3_MINOR_VERSION[\t ]+.*") -- string(REGEX REPLACE "^.*Z3_MINOR_VERSION[\t ]+([0-9]).*$" "\\1" -- Z3_MINOR "${z3_version_str}") -- -- file(STRINGS "${Z3_INCLUDE_DIR}/z3_version.h" -- z3_version_str REGEX "^#define[\t ]+Z3_BUILD_NUMBER[\t ]+.*") -- string(REGEX REPLACE "^.*Z3_BUILD_VERSION[\t ]+([0-9]).*$" "\\1" -- Z3_BUILD "${z3_version_str}") -- -- set(Z3_VERSION_STRING ${Z3_MAJOR}.${Z3_MINOR}.${Z3_BUILD}) -- unset(z3_version_str) --endif() -- --if(NOT Z3_VERSION_STRING) -- # Give up: we are unable to obtain a version of the Z3 library. Be -- # conservative and force the found version to 0.0.0 to make version -- # checks always fail. -- set(Z3_VERSION_STRING "0.0.0") --endif() -- --# handle the QUIETLY and REQUIRED arguments and set Z3_FOUND to TRUE if --# all listed variables are TRUE --include(FindPackageHandleStandardArgs) --FIND_PACKAGE_HANDLE_STANDARD_ARGS(Z3 -- REQUIRED_VARS Z3_LIBRARIES Z3_INCLUDE_DIR -- VERSION_VAR Z3_VERSION_STRING) -- --mark_as_advanced(Z3_INCLUDE_DIR Z3_LIBRARIES) diff --git a/ports/llvm-12/0021-fix-FindZ3.cmake.patch b/ports/llvm-12/0021-fix-FindZ3.cmake.patch deleted file mode 100644 index d13e9b2f..00000000 --- a/ports/llvm-12/0021-fix-FindZ3.cmake.patch +++ /dev/null @@ -1,151 +0,0 @@ -diff --git a/llvm/cmake/modules/FindZ3.cmake b/llvm/cmake/modules/FindZ3.cmake -new file mode 100644 -index 000000000..32f6f4160 ---- /dev/null -+++ b/llvm/cmake/modules/FindZ3.cmake -@@ -0,0 +1,127 @@ -+INCLUDE(CheckCXXSourceRuns) -+ -+# Function to check Z3's version -+function(check_z3_version z3_include z3_lib) -+ # The program that will be executed to print Z3's version. -+ file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/testz3.c -+ "#include -+ #include -+ int main() { -+ unsigned int major, minor, build, rev; -+ Z3_get_version(&major, &minor, &build, &rev); -+ printf(\"%u.%u.%u\", major, minor, build); -+ return 0; -+ }") -+ -+ # Try to find a threading module in case Z3 was built with threading support. -+ # Threads are required elsewhere in LLVM, but not marked as required here because -+ # Z3 could have been compiled without threading support. -+ find_package(Threads) -+ set(z3_link_libs ${z3_lib} "${CMAKE_THREAD_LIBS_INIT}") -+ -+ # Get lib path -+ get_filename_component(z3_lib_path ${z3_lib} PATH) -+ -+ try_run( -+ Z3_RETURNCODE -+ Z3_COMPILED -+ ${CMAKE_BINARY_DIR} -+ ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/testz3.c -+ COMPILE_DEFINITIONS -I"${z3_include}" -+ LINK_LIBRARIES -L${z3_lib_path} ${z3_link_libs} -+ RUN_OUTPUT_VARIABLE SRC_OUTPUT -+ ) -+ -+ if(Z3_COMPILED) -+ string(REGEX REPLACE "([0-9]*\\.[0-9]*\\.[0-9]*)" "\\1" -+ z3_version "${SRC_OUTPUT}") -+ set(Z3_VERSION_STRING ${z3_version} PARENT_SCOPE) -+ endif() -+endfunction(check_z3_version) -+ -+# Looking for Z3 in LLVM_Z3_INSTALL_DIR -+find_path(Z3_INCLUDE_DIR NAMES z3.h -+ NO_DEFAULT_PATH -+ PATHS ${LLVM_Z3_INSTALL_DIR}/include -+ PATH_SUFFIXES libz3 z3 -+ ) -+ -+find_library(Z3_LIBS NAMES z3 libz3 -+ NO_DEFAULT_PATH -+ PATHS ${LLVM_Z3_INSTALL_DIR} -+ PATH_SUFFIXES lib bin -+ ) -+ -+# If Z3 has not been found in LLVM_Z3_INSTALL_DIR look in the default directories -+find_path(Z3_INCLUDE_DIR NAMES z3.h -+ PATH_SUFFIXES libz3 z3 -+ ) -+ -+find_library(Z3_LIBS NAMES z3 libz3 -+ PATH_SUFFIXES lib bin -+ ) -+ -+# Searching for the version of the Z3 library is a best-effort task -+unset(Z3_VERSION_STRING) -+ -+# First, try to check it dynamically, by compiling a small program that -+# prints Z3's version -+if(Z3_INCLUDE_DIR AND Z3_LIBS) -+ # We do not have the Z3 binary to query for a version. Try to use -+ # a small C++ program to detect it via the Z3_get_version() API call. -+ check_z3_version(${Z3_INCLUDE_DIR} ${Z3_LIBS}) -+endif() -+ -+# If the dynamic check fails, we might be cross compiling: if that's the case, -+# check the version in the headers, otherwise, fail with a message -+if(EXISTS "${Z3_INCLUDE_DIR}/z3_version.h" AND (NOT Z3_VERSION_STRING OR -+ (CMAKE_CROSSCOMPILING AND -+ Z3_INCLUDE_DIR))) -+ # TODO: print message warning that we couldn't find a compatible lib? -+ -+ # Z3 4.8.1+ has the version is in a public header. -+ file(STRINGS "${Z3_INCLUDE_DIR}/z3_version.h" -+ z3_version_str REGEX "^#define[\t ]+Z3_MAJOR_VERSION[\t ]+.*") -+ string(REGEX REPLACE "^.*Z3_MAJOR_VERSION[\t ]+([0-9]+).*$" "\\1" -+ Z3_MAJOR "${z3_version_str}") -+ -+ file(STRINGS "${Z3_INCLUDE_DIR}/z3_version.h" -+ z3_version_str REGEX "^#define[\t ]+Z3_MINOR_VERSION[\t ]+.*") -+ string(REGEX REPLACE "^.*Z3_MINOR_VERSION[\t ]+([0-9]+).*$" "\\1" -+ Z3_MINOR "${z3_version_str}") -+ -+ file(STRINGS "${Z3_INCLUDE_DIR}/z3_version.h" -+ z3_version_str REGEX "^#define[\t ]+Z3_BUILD_NUMBER[\t ]+.*") -+ string(REGEX REPLACE "^.*Z3_BUILD_NUMBER[\t ]+([0-9]+).*$" "\\1" -+ Z3_BUILD "${z3_version_str}") -+ -+ set(Z3_VERSION_STRING ${Z3_MAJOR}.${Z3_MINOR}.${Z3_BUILD}) -+ unset(z3_version_str) -+endif() -+ -+if(NOT Z3_VERSION_STRING) -+ # Give up: we are unable to obtain a version of the Z3 library. Be -+ # conservative and force the found version to 0.0.0 to make version -+ # checks always fail. -+ set(Z3_VERSION_STRING "0.0.0") -+endif() -+ -+# handle the QUIETLY and REQUIRED arguments and set Z3_FOUND to TRUE if -+# all listed variables are TRUE -+include(FindPackageHandleStandardArgs) -+FIND_PACKAGE_HANDLE_STANDARD_ARGS(Z3 -+ REQUIRED_VARS Z3_LIBS Z3_INCLUDE_DIR -+ VERSION_VAR Z3_VERSION_STRING) -+ -+if(Z3_FOUND AND NOT TARGET Z3) -+ add_library(Z3 UNKNOWN IMPORTED) -+ set_target_properties(Z3 PROPERTIES -+ INTERFACE_INCLUDE_DIRECTORIES "${Z3_INCLUDE_DIR}" -+ IMPORTED_LOCATION "${Z3_LIBS}" -+ ) -+ set(Z3_LIBRARIES "Z3") -+ set(THREADS_PREFER_PTHREAD_FLAG ON) -+ find_package(Threads REQUIRED) -+ target_link_libraries(Z3 INTERFACE Threads::Threads) -+endif() -+mark_as_advanced(Z3_INCLUDE_DIR Z3_LIBS Z3_LIBRARIES) -diff --git a/llvm/cmake/modules/LLVMConfig.cmake.in b/llvm/cmake/modules/LLVMConfig.cmake.in -index ac053141b008..150b748aa491 100644 ---- a/llvm/cmake/modules/LLVMConfig.cmake.in -+++ b/llvm/cmake/modules/LLVMConfig.cmake.in -@@ -65,6 +65,13 @@ if(LLVM_ENABLE_LIBXML2) - endif() - - set(LLVM_WITH_Z3 @LLVM_WITH_Z3@) -+if(LLVM_WITH_Z3) -+ # Need to use our FindModule instead of another one (like the one included -+ # with later versions of Z3 -+ list(PREPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}) -+ find_package(Z3 4.7.1 REQUIRED) -+ list(POP_FRONT CMAKE_MODULE_PATH) -+endif() - - set(LLVM_ENABLE_DIA_SDK @LLVM_ENABLE_DIA_SDK@) - diff --git a/ports/llvm-12/portfile.cmake b/ports/llvm-12/portfile.cmake index c9b79f84..2645efd4 100644 --- a/ports/llvm-12/portfile.cmake +++ b/ports/llvm-12/portfile.cmake @@ -18,8 +18,7 @@ vcpkg_from_github( 0009-fix-tools-install-path.patch 0010-fix-libffi.patch 0011-fix-libxml2.patch - 0020-remove-FindZ3.cmake.patch - 0021-fix-FindZ3.cmake.patch + 0020-fix-FindZ3.cmake.patch 0022-llvm-config-bin-path.patch 0023-clang-sys-include-dir-path.patch ) diff --git a/ports/llvm-13/0020-fix-FindZ3.cmake.patch b/ports/llvm-13/0020-fix-FindZ3.cmake.patch new file mode 100644 index 00000000..91afccaa --- /dev/null +++ b/ports/llvm-13/0020-fix-FindZ3.cmake.patch @@ -0,0 +1,70 @@ +diff --git a/llvm/cmake/modules/FindZ3.cmake b/llvm/cmake/modules/FindZ3.cmake +index 118b1eac3b32..455bbf28facc 100644 +--- a/llvm/cmake/modules/FindZ3.cmake ++++ b/llvm/cmake/modules/FindZ3.cmake +@@ -1,3 +1,22 @@ ++# Try first to find Z3 using its upstream cmake files (included in newer version) ++# unless the user has provided a hint that would assume skipping the CONFIG ++# option ++if (NOT DEFINED Z3_ROOT AND NOT LLVM_Z3_INSTALL_DIR) ++ find_package(Z3 QUIET CONFIG) ++endif() ++ ++# If we found with CONFIG mode, then set up the compatible variables ++if (Z3_FOUND) ++ set(Z3_VERSION "${Z3_VERSION_STRING}") ++ set(Z3_LIBRARIES z3::libz3) ++ get_property(Z3_INCLUDE_DIR ++ TARGET z3::libz3 PROPERTY ++ INTERFACE_INCLUDE_DIRECTORIES ++ ) ++ find_package_handle_standard_args(Z3 CONFIG_MODE) ++ ++else() ++ + INCLUDE(CheckCXXSourceRuns) + + # Function to check Z3's version +@@ -123,3 +142,5 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(Z3 + VERSION_VAR Z3_VERSION_STRING) + + mark_as_advanced(Z3_INCLUDE_DIR Z3_LIBRARIES) ++ ++endif() +diff --git a/llvm/lib/Support/CMakeLists.txt b/llvm/lib/Support/CMakeLists.txt +index 014b4a2caf15..ac121ac0bc14 100644 +--- a/llvm/lib/Support/CMakeLists.txt ++++ b/llvm/lib/Support/CMakeLists.txt +@@ -71,7 +71,11 @@ endif() + + # Link Z3 if the user wants to build it. + if(LLVM_WITH_Z3) +- set(system_libs ${system_libs} ${Z3_LIBRARIES}) ++ if(TARGET "${Z3_LIBRARIES}") ++ set(imported_libs ${imported_libs} "${Z3_LIBRARIES}") ++ else() ++ set(system_libs ${system_libs} ${Z3_LIBRARIES}) ++ endif() + endif() + + # Override the C runtime allocator on Windows and embed it into LLVM tools & libraries +@@ -276,6 +280,19 @@ if(LLVM_ENABLE_ZLIB) + set(llvm_system_libs ${llvm_system_libs} "${zlib_library}") + endif() + ++if(LLVM_WITH_Z3 AND TARGET "${Z3_LIBRARIES}") ++ # CMAKE_BUILD_TYPE is only meaningful to single-configuration generators. ++ if(CMAKE_BUILD_TYPE) ++ string(TOUPPER ${CMAKE_BUILD_TYPE} build_type) ++ get_property(z3_library TARGET "${Z3_LIBRARIES}" PROPERTY LOCATION_${build_type}) ++ endif() ++ if(NOT z3_library) ++ get_property(z3_library TARGET "${Z3_LIBRARIES}" PROPERTY LOCATION) ++ endif() ++ get_library_name("${z3_library}" z3_library) ++ set(llvm_system_libs ${llvm_system_libs} "${z3_library}") ++endif() ++ + if(LLVM_ENABLE_TERMINFO) + get_library_name(${TERMINFO_LIB} terminfo_library) + set(llvm_system_libs ${llvm_system_libs} "${terminfo_library}") diff --git a/ports/llvm-13/0020-remove-FindZ3.cmake.patch b/ports/llvm-13/0020-remove-FindZ3.cmake.patch deleted file mode 100644 index 22c3b125..00000000 --- a/ports/llvm-13/0020-remove-FindZ3.cmake.patch +++ /dev/null @@ -1,116 +0,0 @@ -diff --git a/llvm/cmake/modules/FindZ3.cmake b/llvm/cmake/modules/FindZ3.cmake -deleted file mode 100644 -index 95dd37789..000000000 ---- a/llvm/cmake/modules/FindZ3.cmake -+++ /dev/null -@@ -1,110 +0,0 @@ --INCLUDE(CheckCXXSourceRuns) -- --# Function to check Z3's version --function(check_z3_version z3_include z3_lib) -- # The program that will be executed to print Z3's version. -- file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testz3.c -- "#include -- #include -- int main() { -- unsigned int major, minor, build, rev; -- Z3_get_version(&major, &minor, &build, &rev); -- printf(\"%u.%u.%u\", major, minor, build); -- return 0; -- }") -- -- # Get lib path -- get_filename_component(z3_lib_path ${z3_lib} PATH) -- -- try_run( -- Z3_RETURNCODE -- Z3_COMPILED -- ${CMAKE_BINARY_DIR} -- ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testz3.c -- COMPILE_DEFINITIONS -I"${z3_include}" -- LINK_LIBRARIES -L${z3_lib_path} -lz3 -- RUN_OUTPUT_VARIABLE SRC_OUTPUT -- ) -- -- if(Z3_COMPILED) -- string(REGEX REPLACE "([0-9]*\\.[0-9]*\\.[0-9]*)" "\\1" -- z3_version "${SRC_OUTPUT}") -- set(Z3_VERSION_STRING ${z3_version} PARENT_SCOPE) -- endif() --endfunction(check_z3_version) -- --# Looking for Z3 in LLVM_Z3_INSTALL_DIR --find_path(Z3_INCLUDE_DIR NAMES z3.h -- NO_DEFAULT_PATH -- PATHS ${LLVM_Z3_INSTALL_DIR}/include -- PATH_SUFFIXES libz3 z3 -- ) -- --find_library(Z3_LIBRARIES NAMES z3 libz3 -- NO_DEFAULT_PATH -- PATHS ${LLVM_Z3_INSTALL_DIR} -- PATH_SUFFIXES lib bin -- ) -- --# If Z3 has not been found in LLVM_Z3_INSTALL_DIR look in the default directories --find_path(Z3_INCLUDE_DIR NAMES z3.h -- PATH_SUFFIXES libz3 z3 -- ) -- --find_library(Z3_LIBRARIES NAMES z3 libz3 -- PATH_SUFFIXES lib bin -- ) -- --# Searching for the version of the Z3 library is a best-effort task --unset(Z3_VERSION_STRING) -- --# First, try to check it dynamically, by compiling a small program that --# prints Z3's version --if(Z3_INCLUDE_DIR AND Z3_LIBRARIES) -- # We do not have the Z3 binary to query for a version. Try to use -- # a small C++ program to detect it via the Z3_get_version() API call. -- check_z3_version(${Z3_INCLUDE_DIR} ${Z3_LIBRARIES}) --endif() -- --# If the dynamic check fails, we might be cross compiling: if that's the case, --# check the version in the headers, otherwise, fail with a message --if(NOT Z3_VERSION_STRING AND (CMAKE_CROSSCOMPILING AND -- Z3_INCLUDE_DIR AND -- EXISTS "${Z3_INCLUDE_DIR}/z3_version.h")) -- # TODO: print message warning that we couldn't find a compatible lib? -- -- # Z3 4.8.1+ has the version is in a public header. -- file(STRINGS "${Z3_INCLUDE_DIR}/z3_version.h" -- z3_version_str REGEX "^#define[\t ]+Z3_MAJOR_VERSION[\t ]+.*") -- string(REGEX REPLACE "^.*Z3_MAJOR_VERSION[\t ]+([0-9]).*$" "\\1" -- Z3_MAJOR "${z3_version_str}") -- -- file(STRINGS "${Z3_INCLUDE_DIR}/z3_version.h" -- z3_version_str REGEX "^#define[\t ]+Z3_MINOR_VERSION[\t ]+.*") -- string(REGEX REPLACE "^.*Z3_MINOR_VERSION[\t ]+([0-9]).*$" "\\1" -- Z3_MINOR "${z3_version_str}") -- -- file(STRINGS "${Z3_INCLUDE_DIR}/z3_version.h" -- z3_version_str REGEX "^#define[\t ]+Z3_BUILD_NUMBER[\t ]+.*") -- string(REGEX REPLACE "^.*Z3_BUILD_VERSION[\t ]+([0-9]).*$" "\\1" -- Z3_BUILD "${z3_version_str}") -- -- set(Z3_VERSION_STRING ${Z3_MAJOR}.${Z3_MINOR}.${Z3_BUILD}) -- unset(z3_version_str) --endif() -- --if(NOT Z3_VERSION_STRING) -- # Give up: we are unable to obtain a version of the Z3 library. Be -- # conservative and force the found version to 0.0.0 to make version -- # checks always fail. -- set(Z3_VERSION_STRING "0.0.0") --endif() -- --# handle the QUIETLY and REQUIRED arguments and set Z3_FOUND to TRUE if --# all listed variables are TRUE --include(FindPackageHandleStandardArgs) --FIND_PACKAGE_HANDLE_STANDARD_ARGS(Z3 -- REQUIRED_VARS Z3_LIBRARIES Z3_INCLUDE_DIR -- VERSION_VAR Z3_VERSION_STRING) -- --mark_as_advanced(Z3_INCLUDE_DIR Z3_LIBRARIES) diff --git a/ports/llvm-13/0021-fix-FindZ3.cmake.patch b/ports/llvm-13/0021-fix-FindZ3.cmake.patch deleted file mode 100644 index d13e9b2f..00000000 --- a/ports/llvm-13/0021-fix-FindZ3.cmake.patch +++ /dev/null @@ -1,151 +0,0 @@ -diff --git a/llvm/cmake/modules/FindZ3.cmake b/llvm/cmake/modules/FindZ3.cmake -new file mode 100644 -index 000000000..32f6f4160 ---- /dev/null -+++ b/llvm/cmake/modules/FindZ3.cmake -@@ -0,0 +1,127 @@ -+INCLUDE(CheckCXXSourceRuns) -+ -+# Function to check Z3's version -+function(check_z3_version z3_include z3_lib) -+ # The program that will be executed to print Z3's version. -+ file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/testz3.c -+ "#include -+ #include -+ int main() { -+ unsigned int major, minor, build, rev; -+ Z3_get_version(&major, &minor, &build, &rev); -+ printf(\"%u.%u.%u\", major, minor, build); -+ return 0; -+ }") -+ -+ # Try to find a threading module in case Z3 was built with threading support. -+ # Threads are required elsewhere in LLVM, but not marked as required here because -+ # Z3 could have been compiled without threading support. -+ find_package(Threads) -+ set(z3_link_libs ${z3_lib} "${CMAKE_THREAD_LIBS_INIT}") -+ -+ # Get lib path -+ get_filename_component(z3_lib_path ${z3_lib} PATH) -+ -+ try_run( -+ Z3_RETURNCODE -+ Z3_COMPILED -+ ${CMAKE_BINARY_DIR} -+ ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/testz3.c -+ COMPILE_DEFINITIONS -I"${z3_include}" -+ LINK_LIBRARIES -L${z3_lib_path} ${z3_link_libs} -+ RUN_OUTPUT_VARIABLE SRC_OUTPUT -+ ) -+ -+ if(Z3_COMPILED) -+ string(REGEX REPLACE "([0-9]*\\.[0-9]*\\.[0-9]*)" "\\1" -+ z3_version "${SRC_OUTPUT}") -+ set(Z3_VERSION_STRING ${z3_version} PARENT_SCOPE) -+ endif() -+endfunction(check_z3_version) -+ -+# Looking for Z3 in LLVM_Z3_INSTALL_DIR -+find_path(Z3_INCLUDE_DIR NAMES z3.h -+ NO_DEFAULT_PATH -+ PATHS ${LLVM_Z3_INSTALL_DIR}/include -+ PATH_SUFFIXES libz3 z3 -+ ) -+ -+find_library(Z3_LIBS NAMES z3 libz3 -+ NO_DEFAULT_PATH -+ PATHS ${LLVM_Z3_INSTALL_DIR} -+ PATH_SUFFIXES lib bin -+ ) -+ -+# If Z3 has not been found in LLVM_Z3_INSTALL_DIR look in the default directories -+find_path(Z3_INCLUDE_DIR NAMES z3.h -+ PATH_SUFFIXES libz3 z3 -+ ) -+ -+find_library(Z3_LIBS NAMES z3 libz3 -+ PATH_SUFFIXES lib bin -+ ) -+ -+# Searching for the version of the Z3 library is a best-effort task -+unset(Z3_VERSION_STRING) -+ -+# First, try to check it dynamically, by compiling a small program that -+# prints Z3's version -+if(Z3_INCLUDE_DIR AND Z3_LIBS) -+ # We do not have the Z3 binary to query for a version. Try to use -+ # a small C++ program to detect it via the Z3_get_version() API call. -+ check_z3_version(${Z3_INCLUDE_DIR} ${Z3_LIBS}) -+endif() -+ -+# If the dynamic check fails, we might be cross compiling: if that's the case, -+# check the version in the headers, otherwise, fail with a message -+if(EXISTS "${Z3_INCLUDE_DIR}/z3_version.h" AND (NOT Z3_VERSION_STRING OR -+ (CMAKE_CROSSCOMPILING AND -+ Z3_INCLUDE_DIR))) -+ # TODO: print message warning that we couldn't find a compatible lib? -+ -+ # Z3 4.8.1+ has the version is in a public header. -+ file(STRINGS "${Z3_INCLUDE_DIR}/z3_version.h" -+ z3_version_str REGEX "^#define[\t ]+Z3_MAJOR_VERSION[\t ]+.*") -+ string(REGEX REPLACE "^.*Z3_MAJOR_VERSION[\t ]+([0-9]+).*$" "\\1" -+ Z3_MAJOR "${z3_version_str}") -+ -+ file(STRINGS "${Z3_INCLUDE_DIR}/z3_version.h" -+ z3_version_str REGEX "^#define[\t ]+Z3_MINOR_VERSION[\t ]+.*") -+ string(REGEX REPLACE "^.*Z3_MINOR_VERSION[\t ]+([0-9]+).*$" "\\1" -+ Z3_MINOR "${z3_version_str}") -+ -+ file(STRINGS "${Z3_INCLUDE_DIR}/z3_version.h" -+ z3_version_str REGEX "^#define[\t ]+Z3_BUILD_NUMBER[\t ]+.*") -+ string(REGEX REPLACE "^.*Z3_BUILD_NUMBER[\t ]+([0-9]+).*$" "\\1" -+ Z3_BUILD "${z3_version_str}") -+ -+ set(Z3_VERSION_STRING ${Z3_MAJOR}.${Z3_MINOR}.${Z3_BUILD}) -+ unset(z3_version_str) -+endif() -+ -+if(NOT Z3_VERSION_STRING) -+ # Give up: we are unable to obtain a version of the Z3 library. Be -+ # conservative and force the found version to 0.0.0 to make version -+ # checks always fail. -+ set(Z3_VERSION_STRING "0.0.0") -+endif() -+ -+# handle the QUIETLY and REQUIRED arguments and set Z3_FOUND to TRUE if -+# all listed variables are TRUE -+include(FindPackageHandleStandardArgs) -+FIND_PACKAGE_HANDLE_STANDARD_ARGS(Z3 -+ REQUIRED_VARS Z3_LIBS Z3_INCLUDE_DIR -+ VERSION_VAR Z3_VERSION_STRING) -+ -+if(Z3_FOUND AND NOT TARGET Z3) -+ add_library(Z3 UNKNOWN IMPORTED) -+ set_target_properties(Z3 PROPERTIES -+ INTERFACE_INCLUDE_DIRECTORIES "${Z3_INCLUDE_DIR}" -+ IMPORTED_LOCATION "${Z3_LIBS}" -+ ) -+ set(Z3_LIBRARIES "Z3") -+ set(THREADS_PREFER_PTHREAD_FLAG ON) -+ find_package(Threads REQUIRED) -+ target_link_libraries(Z3 INTERFACE Threads::Threads) -+endif() -+mark_as_advanced(Z3_INCLUDE_DIR Z3_LIBS Z3_LIBRARIES) -diff --git a/llvm/cmake/modules/LLVMConfig.cmake.in b/llvm/cmake/modules/LLVMConfig.cmake.in -index ac053141b008..150b748aa491 100644 ---- a/llvm/cmake/modules/LLVMConfig.cmake.in -+++ b/llvm/cmake/modules/LLVMConfig.cmake.in -@@ -65,6 +65,13 @@ if(LLVM_ENABLE_LIBXML2) - endif() - - set(LLVM_WITH_Z3 @LLVM_WITH_Z3@) -+if(LLVM_WITH_Z3) -+ # Need to use our FindModule instead of another one (like the one included -+ # with later versions of Z3 -+ list(PREPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}) -+ find_package(Z3 4.7.1 REQUIRED) -+ list(POP_FRONT CMAKE_MODULE_PATH) -+endif() - - set(LLVM_ENABLE_DIA_SDK @LLVM_ENABLE_DIA_SDK@) - diff --git a/ports/llvm-13/portfile.cmake b/ports/llvm-13/portfile.cmake index 11ac0544..f73faf7f 100644 --- a/ports/llvm-13/portfile.cmake +++ b/ports/llvm-13/portfile.cmake @@ -17,8 +17,7 @@ vcpkg_from_github( 0009-fix-tools-install-path.patch 0010-fix-libffi.patch 0011-fix-libxml2.patch - 0020-remove-FindZ3.cmake.patch - 0021-fix-FindZ3.cmake.patch + 0020-fix-FindZ3.cmake.patch 0022-llvm-config-bin-path.patch 0023-clang-sys-include-dir-path.patch 0024-remove-elf_relocation-checks.patch