From 535456ae344027b8822df1e184d434cd6e00e395 Mon Sep 17 00:00:00 2001 From: Park DongHa Date: Fri, 5 Mar 2021 21:05:40 +0900 Subject: [PATCH 1/4] [metrohash] exclude CRC for x86 * the change will allow x86 triplets * update port SHA --- ports/metrohash/CMakeLists.txt | 11 +++++------ ports/metrohash/portfile.cmake | 23 ++++++++++++----------- ports/metrohash/vcpkg.json | 4 ++-- versions/baseline.json | 2 +- versions/m-/metrohash.json | 5 +++++ 5 files changed, 25 insertions(+), 20 deletions(-) diff --git a/ports/metrohash/CMakeLists.txt b/ports/metrohash/CMakeLists.txt index 3d6c3d59dccf9b..ac9e10e74d7c4a 100644 --- a/ports/metrohash/CMakeLists.txt +++ b/ports/metrohash/CMakeLists.txt @@ -1,14 +1,13 @@ -cmake_minimum_required(VERSION 3.14) +cmake_minimum_required(VERSION 3.1) project(metrohash LANGUAGES CXX) -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 11) add_library(metrohash - src/metrohash64.cpp - src/metrohash128.cpp - ) + src/metrohash64.cpp + src/metrohash128.cpp) list(APPEND metro_headers src/metrohash.h src/metrohash64.h src/metrohash128.h) -if(NOT ANDROID AND NOT IOS) +if(NOT ANDROID AND NOT IOS AND VCPKG_TARGET_ARCHITECTURE MATCHES x64) list(APPEND metro_headers src/metrohash128crc.h) target_sources(metrohash PRIVATE src/metrohash128crc.cpp) if(CMAKE_CXX_COMPILER_ID MATCHES Clang) diff --git a/ports/metrohash/portfile.cmake b/ports/metrohash/portfile.cmake index 66f7c957f6a270..2f7e52556b9233 100644 --- a/ports/metrohash/portfile.cmake +++ b/ports/metrohash/portfile.cmake @@ -1,24 +1,25 @@ -vcpkg_fail_port_install(ON_TARGET "UWP" ON_TARGET "x86" "arm" "aarch64") +vcpkg_fail_port_install(ON_TARGET "UWP" ON_TARGET "arm" "aarch64") vcpkg_check_linkage(ONLY_STATIC_LIBRARY) vcpkg_from_github( - OUT_SOURCE_PATH SOURCE_PATH - REPO jandrewrogers/MetroHash - REF v1.1.3 - SHA512 02b6316e5ebf3d81465eea8a068565452be642394ddf5a53350affbbc9b9bfe1c3d182f7e8f7d49895351c48e11929e465777535e4354e01b6d0ba459e583ac5 - HEAD_REF master + OUT_SOURCE_PATH SOURCE_PATH + REPO jandrewrogers/MetroHash + REF v1.1.3 + SHA512 02b6316e5ebf3d81465eea8a068565452be642394ddf5a53350affbbc9b9bfe1c3d182f7e8f7d49895351c48e11929e465777535e4354e01b6d0ba459e583ac5 + HEAD_REF master ) -if(VCPKG_TARGET_IS_ANDROID) + +if(VCPKG_TARGET_ARCHITECTURE MATCHES arm OR VCPKG_TARGET_ARCHITECTURE STREQUAL x86) vcpkg_replace_string(${SOURCE_PATH}/src/metrohash.h "#include \"metrohash128crc.h\"" - "//#include \"metrohash128crc.h\" // It can't be supported for Android") + "//#include \"metrohash128crc.h\" // It can't be supported for ARM or x86") endif() -configure_file(${CURRENT_PORT_DIR}/CMakeLists.txt ${SOURCE_PATH}/CMakeLists.txt COPYONLY) +file(COPY ${CURRENT_PORT_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH}) configure_file(${CURRENT_PORT_DIR}/Config.cmake.in ${SOURCE_PATH}/cmake/Config.cmake.in COPYONLY) vcpkg_configure_cmake( - SOURCE_PATH ${SOURCE_PATH} - PREFER_NINJA + SOURCE_PATH ${SOURCE_PATH} + PREFER_NINJA ) vcpkg_install_cmake() diff --git a/ports/metrohash/vcpkg.json b/ports/metrohash/vcpkg.json index a439e2c6a53b20..90f5866d8dfa43 100644 --- a/ports/metrohash/vcpkg.json +++ b/ports/metrohash/vcpkg.json @@ -1,8 +1,8 @@ { "name": "metrohash", "version-string": "1.1.3", - "port-version": 3, + "port-version": 4, "description": "MetroHash is a set of state-of-the-art hash functions for non-cryptographic use cases", "homepage": "https://github.com/jandrewrogers/MetroHash", - "supports": "!(uwp | arm | x86)" + "supports": "!(uwp | arm)" } diff --git a/versions/baseline.json b/versions/baseline.json index 7136d913d4ad2d..b4626ab546918b 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -3742,7 +3742,7 @@ }, "metrohash": { "baseline": "1.1.3", - "port-version": 3 + "port-version": 4 }, "mgnlibs": { "baseline": "2019-09-29", diff --git a/versions/m-/metrohash.json b/versions/m-/metrohash.json index f062696f40ca02..1be9aeae4d3af5 100644 --- a/versions/m-/metrohash.json +++ b/versions/m-/metrohash.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "25e4e57cfb9fa17bb4e815affa0ae0b307013119", + "version-string": "1.1.3", + "port-version": 4 + }, { "git-tree": "33078163f0311cfecce47b42c304650b602c9ddf", "version-string": "1.1.3", From a18e6f85d89846458a76328a0957d791882cbf5d Mon Sep 17 00:00:00 2001 From: Park DongHa Date: Fri, 5 Mar 2021 23:50:48 +0900 Subject: [PATCH 2/4] [metrohash] remove fail_port_install * update ci.baseline.txt --- ports/metrohash/portfile.cmake | 1 - ports/metrohash/vcpkg.json | 3 +-- scripts/ci.baseline.txt | 4 ---- versions/m-/metrohash.json | 2 +- 4 files changed, 2 insertions(+), 8 deletions(-) diff --git a/ports/metrohash/portfile.cmake b/ports/metrohash/portfile.cmake index 2f7e52556b9233..fb027f99109da4 100644 --- a/ports/metrohash/portfile.cmake +++ b/ports/metrohash/portfile.cmake @@ -1,4 +1,3 @@ -vcpkg_fail_port_install(ON_TARGET "UWP" ON_TARGET "arm" "aarch64") vcpkg_check_linkage(ONLY_STATIC_LIBRARY) vcpkg_from_github( diff --git a/ports/metrohash/vcpkg.json b/ports/metrohash/vcpkg.json index 90f5866d8dfa43..df5ea78629a947 100644 --- a/ports/metrohash/vcpkg.json +++ b/ports/metrohash/vcpkg.json @@ -3,6 +3,5 @@ "version-string": "1.1.3", "port-version": 4, "description": "MetroHash is a set of state-of-the-art hash functions for non-cryptographic use cases", - "homepage": "https://github.com/jandrewrogers/MetroHash", - "supports": "!(uwp | arm)" + "homepage": "https://github.com/jandrewrogers/MetroHash" } diff --git a/scripts/ci.baseline.txt b/scripts/ci.baseline.txt index aaa4411bf76714..13eb040236debb 100644 --- a/scripts/ci.baseline.txt +++ b/scripts/ci.baseline.txt @@ -880,10 +880,6 @@ meschach:x64-osx=fail meschach:x64-uwp=fail metis:arm-uwp=fail metis:x64-uwp=fail -metrohash:arm-uwp=fail -metrohash:x64-uwp=fail -metrohash:x86-windows=fail -metrohash:arm64-windows=fail mhook:arm64-windows=fail mhook:arm-uwp=fail mhook:x64-linux=fail diff --git a/versions/m-/metrohash.json b/versions/m-/metrohash.json index 1be9aeae4d3af5..ae30beda233ebe 100644 --- a/versions/m-/metrohash.json +++ b/versions/m-/metrohash.json @@ -1,7 +1,7 @@ { "versions": [ { - "git-tree": "25e4e57cfb9fa17bb4e815affa0ae0b307013119", + "git-tree": "19053e184a37875624640bdd196f6177b3d06e6f", "version-string": "1.1.3", "port-version": 4 }, From 5bd6ba0226d6a37e4245b0f63824baf41d0619e7 Mon Sep 17 00:00:00 2001 From: Park DongHa Date: Fri, 5 Mar 2021 23:55:27 +0900 Subject: [PATCH 3/4] [metrohash] sync portfile and CMakeLists.txt * make both file use 'VCPKG_TARGET_TRIPLET' to make ease of comparison --- ports/metrohash/CMakeLists.txt | 4 +++- versions/m-/metrohash.json | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ports/metrohash/CMakeLists.txt b/ports/metrohash/CMakeLists.txt index ac9e10e74d7c4a..8ec90daa6c0c04 100644 --- a/ports/metrohash/CMakeLists.txt +++ b/ports/metrohash/CMakeLists.txt @@ -7,7 +7,9 @@ add_library(metrohash src/metrohash128.cpp) list(APPEND metro_headers src/metrohash.h src/metrohash64.h src/metrohash128.h) -if(NOT ANDROID AND NOT IOS AND VCPKG_TARGET_ARCHITECTURE MATCHES x64) +if(VCPKG_TARGET_ARCHITECTURE MATCHES arm OR VCPKG_TARGET_ARCHITECTURE STREQUAL x86) + message(WARNING "MetroHash's 128 CRC requires SSE 4.2 intrinsic. The functions will be excluded.") +else() list(APPEND metro_headers src/metrohash128crc.h) target_sources(metrohash PRIVATE src/metrohash128crc.cpp) if(CMAKE_CXX_COMPILER_ID MATCHES Clang) diff --git a/versions/m-/metrohash.json b/versions/m-/metrohash.json index ae30beda233ebe..b8a352b4d5c809 100644 --- a/versions/m-/metrohash.json +++ b/versions/m-/metrohash.json @@ -1,7 +1,7 @@ { "versions": [ { - "git-tree": "19053e184a37875624640bdd196f6177b3d06e6f", + "git-tree": "9b4c8680069f3dcab66bbce4c70a5530b2f303b5", "version-string": "1.1.3", "port-version": 4 }, From 1c8c75082276c5d3066f686a732f5b8856bf3a90 Mon Sep 17 00:00:00 2001 From: Robert Schumacher Date: Tue, 16 Mar 2021 12:33:36 -0700 Subject: [PATCH 4/4] [metrohash] Use try_compile helpers --- ports/metrohash/CMakeLists.txt | 33 ++++++++++++++++++++++++--------- ports/metrohash/portfile.cmake | 11 ++++++----- ports/metrohash/vcpkg.json | 2 +- versions/m-/metrohash.json | 4 ++-- 4 files changed, 33 insertions(+), 17 deletions(-) diff --git a/ports/metrohash/CMakeLists.txt b/ports/metrohash/CMakeLists.txt index 8ec90daa6c0c04..d63a71345a943e 100644 --- a/ports/metrohash/CMakeLists.txt +++ b/ports/metrohash/CMakeLists.txt @@ -1,21 +1,36 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.5) project(metrohash LANGUAGES CXX) set(CMAKE_CXX_STANDARD 11) add_library(metrohash - src/metrohash64.cpp - src/metrohash128.cpp) + src/metrohash64.cpp + src/metrohash128.cpp + ) list(APPEND metro_headers src/metrohash.h src/metrohash64.h src/metrohash128.h) -if(VCPKG_TARGET_ARCHITECTURE MATCHES arm OR VCPKG_TARGET_ARCHITECTURE STREQUAL x86) - message(WARNING "MetroHash's 128 CRC requires SSE 4.2 intrinsic. The functions will be excluded.") -else() - list(APPEND metro_headers src/metrohash128crc.h) - target_sources(metrohash PRIVATE src/metrohash128crc.cpp) - if(CMAKE_CXX_COMPILER_ID MATCHES Clang) +include(CheckCXXSourceCompiles) +include(CheckCXXCompilerFlag) + +if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + check_cxx_compiler_flag("-msse4.2" HAS_MSSE42) + if(HAS_MSSE42) target_compile_options(metrohash PRIVATE -msse4.2) + string(APPEND CMAKE_REQUIRED_FLAGS " -msse4.2") endif() endif() + +check_cxx_source_compiles( +"#include +int main() { + _mm_crc32_u64(0, 0); + return 0; +}" +HAS_mm_crc32_u64) + +if(HAS_mm_crc32_u64) + list(APPEND metro_headers src/metrohash128crc.h) + target_sources(metrohash PRIVATE src/metrohash128crc.cpp) +endif() if(CMAKE_CXX_COMPILER_ID MATCHES GNU) target_compile_options(metrohash PRIVATE -march=native) endif() diff --git a/ports/metrohash/portfile.cmake b/ports/metrohash/portfile.cmake index fb027f99109da4..d62741a2adf597 100644 --- a/ports/metrohash/portfile.cmake +++ b/ports/metrohash/portfile.cmake @@ -8,11 +8,6 @@ vcpkg_from_github( HEAD_REF master ) -if(VCPKG_TARGET_ARCHITECTURE MATCHES arm OR VCPKG_TARGET_ARCHITECTURE STREQUAL x86) - vcpkg_replace_string(${SOURCE_PATH}/src/metrohash.h - "#include \"metrohash128crc.h\"" - "//#include \"metrohash128crc.h\" // It can't be supported for ARM or x86") -endif() file(COPY ${CURRENT_PORT_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH}) configure_file(${CURRENT_PORT_DIR}/Config.cmake.in ${SOURCE_PATH}/cmake/Config.cmake.in COPYONLY) @@ -25,5 +20,11 @@ vcpkg_install_cmake() vcpkg_fixup_cmake_targets(CONFIG_PATH lib/cmake/${PORT}) vcpkg_copy_pdbs() +if(NOT EXISTS "${CURRENT_PACKAGES_DIR}/include/metrohash128crc.h") + vcpkg_replace_string(${CURRENT_PACKAGES_DIR}/include/metrohash.h + "#include \"metrohash128crc.h\"" + "//#include \"metrohash128crc.h\" // The target platform does not support _mm_crc32_u64") +endif() + file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright) diff --git a/ports/metrohash/vcpkg.json b/ports/metrohash/vcpkg.json index df5ea78629a947..2f61a8670c6bf2 100644 --- a/ports/metrohash/vcpkg.json +++ b/ports/metrohash/vcpkg.json @@ -1,6 +1,6 @@ { "name": "metrohash", - "version-string": "1.1.3", + "version": "1.1.3", "port-version": 4, "description": "MetroHash is a set of state-of-the-art hash functions for non-cryptographic use cases", "homepage": "https://github.com/jandrewrogers/MetroHash" diff --git a/versions/m-/metrohash.json b/versions/m-/metrohash.json index b8a352b4d5c809..56847f9fbc4e2d 100644 --- a/versions/m-/metrohash.json +++ b/versions/m-/metrohash.json @@ -1,8 +1,8 @@ { "versions": [ { - "git-tree": "9b4c8680069f3dcab66bbce4c70a5530b2f303b5", - "version-string": "1.1.3", + "git-tree": "777a0ee61fdc53dcad0971184232d29b58e52f63", + "version": "1.1.3", "port-version": 4 }, {