From 2d376135960ac355353dda4c6998b160e32cc1e5 Mon Sep 17 00:00:00 2001 From: Billy Robert O'Neal III Date: Wed, 15 Jun 2022 14:07:23 -0700 Subject: [PATCH] [cpuinfo] Always check for x86-ish with the same regex. Submitted upstream as https://github.com/pytorch/cpuinfo/pull/93 Resolves https://github.com/microsoft/vcpkg/issues/24713 Competing resolution of https://github.com/microsoft/vcpkg/pull/24726 --- ports/cpuinfo/check-for-x86-correctly.patch | 48 +++++++++++++++++++++ ports/cpuinfo/portfile.cmake | 23 ++-------- ports/cpuinfo/vcpkg.json | 1 + versions/baseline.json | 2 +- versions/c-/cpuinfo.json | 5 +++ 5 files changed, 59 insertions(+), 20 deletions(-) create mode 100644 ports/cpuinfo/check-for-x86-correctly.patch diff --git a/ports/cpuinfo/check-for-x86-correctly.patch b/ports/cpuinfo/check-for-x86-correctly.patch new file mode 100644 index 00000000000000..7acb388cdf7ae0 --- /dev/null +++ b/ports/cpuinfo/check-for-x86-correctly.patch @@ -0,0 +1,48 @@ +From 99486c3d72cc0aec72992eb95bd46a27f09ff41e Mon Sep 17 00:00:00 2001 +From: Billy Robert O'Neal III +Date: Wed, 15 Jun 2022 13:59:23 -0700 +Subject: [PATCH] Always check for x86-ish with the same regex. + +On line 68, and in most places, "intel-like" is checked with `i[3-6]86|AMD64|x86(_64)?`, but in these 3 places the (_x64)? was missing. + +First reported as https://github.com/microsoft/vcpkg/issues/24713 +--- + CMakeLists.txt | 7 +++---- + 1 file changed, 3 insertions(+), 4 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 74364e8..1cdada0 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -319,7 +319,7 @@ ENDIF() + # ---[ cpuinfo mock library and mock tests + IF(CPUINFO_SUPPORTED_PLATFORM AND CPUINFO_BUILD_MOCK_TESTS) + SET(CPUINFO_MOCK_SRCS "${CPUINFO_SRCS}") +- IF(CPUINFO_TARGET_PROCESSOR MATCHES "^(i[3-6]86|AMD64|x86_64)$") ++ IF(CPUINFO_TARGET_PROCESSOR MATCHES "^(i[3-6]86|AMD64|x86(_64)?)$") + LIST(APPEND CPUINFO_MOCK_SRCS src/x86/mockcpuid.c) + ENDIF() + IF(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Android") +@@ -763,7 +763,7 @@ IF(CPUINFO_SUPPORTED_PLATFORM AND CPUINFO_BUILD_UNIT_TESTS) + ADD_TEST(get-current-test get-current-test) + ENDIF() + +- IF(CPUINFO_TARGET_PROCESSOR MATCHES "^(i[3-6]86|AMD64|x86_64)$") ++ IF(CPUINFO_TARGET_PROCESSOR MATCHES "^(i[3-6]86|AMD64|x86(_64)?)$") + ADD_EXECUTABLE(brand-string-test test/name/brand-string.cc) + CPUINFO_TARGET_ENABLE_CXX11(brand-string-test) + CPUINFO_TARGET_RUNTIME_LIBRARY(brand-string-test) +@@ -830,7 +830,7 @@ IF(CPUINFO_SUPPORTED_PLATFORM AND CPUINFO_BUILD_TOOLS) + CPUINFO_TARGET_RUNTIME_LIBRARY(cpuinfo-dump) + ENDIF() + +- IF(CPUINFO_TARGET_PROCESSOR MATCHES "^(i[3-6]86|AMD64|x86_64)$") ++ IF(CPUINFO_TARGET_PROCESSOR MATCHES "^(i[3-6]86|AMD64|x86(_64)?)$") + ADD_EXECUTABLE(cpuid-dump tools/cpuid-dump.c) + CPUINFO_TARGET_ENABLE_C99(cpuid-dump) + CPUINFO_TARGET_RUNTIME_LIBRARY(cpuid-dump) +@@ -869,4 +869,3 @@ IF(CPUINFO_BUILD_PKG_CONFIG) + DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") + + ENDIF() +- diff --git a/ports/cpuinfo/portfile.cmake b/ports/cpuinfo/portfile.cmake index aa964e6e17d08b..d992673358b266 100644 --- a/ports/cpuinfo/portfile.cmake +++ b/ports/cpuinfo/portfile.cmake @@ -9,6 +9,8 @@ vcpkg_from_github( REF b40bae27785787b6dd70788986fd96434cf90ae2 SHA512 dbbe4f3e1d5ae74ffc8ba2cba0ab745a23f4993788f4947825ef5125dd1cbed3e13e0c98e020e6fcfa9879f54f06d7cba4de73ec29f77649b6a27b4ab82c8f1c HEAD_REF master + PATCHES + check-for-x86-correctly.patch # https://github.com/pytorch/cpuinfo/pull/93 ) vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS @@ -16,6 +18,7 @@ vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS tools CPUINFO_BUILD_TOOLS ) +set(LINK_OPTIONS "") if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic") list(APPEND LINK_OPTIONS -DCPUINFO_LIBRARY_TYPE=shared) else() @@ -28,29 +31,11 @@ else() list(APPEND LINK_OPTIONS -DCPUINFO_RUNTIME_TYPE=static) endif() -# hack to get around that toolchains/windows.cmake doesn't set CMAKE_SYSTEM_ARCHITECTURE -set(CPUINFO_TARGET_PROCESSOR_param "") -if(VCPKG_TARGET_IS_WINDOWS) - # NOTE: arm64-windows is unsupported for now; - # see https://github.com/pytorch/cpuinfo/pull/82 for updates - # NOTE: arm-windows is unsupported - if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86") - set(CPUINFO_TARGET_PROCESSOR_param "-DCPUINFO_TARGET_PROCESSOR=x86") - elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64") - set(CPUINFO_TARGET_PROCESSOR_param "-DCPUINFO_TARGET_PROCESSOR=AMD64") - elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm") - set(CPUINFO_TARGET_PROCESSOR_param "-DCPUINFO_TARGET_PROCESSOR=ARM") - elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64") - set(CPUINFO_TARGET_PROCESSOR_param "-DCPUINFO_TARGET_PROCESSOR=ARM64") - endif() -endif() - vcpkg_cmake_configure( SOURCE_PATH "${SOURCE_PATH}" OPTIONS ${FEATURE_OPTIONS} ${LINK_OPTIONS} - ${CPUINFO_TARGET_PROCESSOR_param} -DCPUINFO_BUILD_UNIT_TESTS=OFF -DCPUINFO_BUILD_MOCK_TESTS=OFF -DCPUINFO_BUILD_BENCHMARKS=OFF @@ -64,7 +49,7 @@ vcpkg_cmake_config_fixup() vcpkg_copy_pdbs() vcpkg_fixup_pkgconfig() # pkg_check_modules(libcpuinfo) -file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") if("tools" IN_LIST FEATURES) vcpkg_copy_tools( diff --git a/ports/cpuinfo/vcpkg.json b/ports/cpuinfo/vcpkg.json index d718f9393058a2..cc1c3159cb23f4 100644 --- a/ports/cpuinfo/vcpkg.json +++ b/ports/cpuinfo/vcpkg.json @@ -1,6 +1,7 @@ { "name": "cpuinfo", "version-date": "2022-04-02", + "port-version": 1, "description": "CPU INFOrmation library (x86/x86-64/ARM/ARM64, Linux/Windows/Android/macOS/iOS)", "homepage": "https://github.com/pytorch/cpuinfo", "license": "BSD-2-Clause", diff --git a/versions/baseline.json b/versions/baseline.json index e7de1400fc69ce..c82856c090aca2 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -1682,7 +1682,7 @@ }, "cpuinfo": { "baseline": "2022-04-02", - "port-version": 0 + "port-version": 1 }, "cr": { "baseline": "2020-04-26", diff --git a/versions/c-/cpuinfo.json b/versions/c-/cpuinfo.json index fef8a68d0b663f..485dd2a03d0651 100644 --- a/versions/c-/cpuinfo.json +++ b/versions/c-/cpuinfo.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "11ac581a5c1307b2039cf9db3933c2aeffb7a923", + "version-date": "2022-04-02", + "port-version": 1 + }, { "git-tree": "69febccb10ae5b789dd6c5af2b85740617fc34f4", "version-date": "2022-04-02",