Skip to content

Commit

Permalink
[cpuinfo] Always check for x86-ish with the same regex. (microsoft#25258
Browse files Browse the repository at this point in the history
)

Submitted upstream as pytorch/cpuinfo#93

Resolves microsoft#24713

Competing resolution of microsoft#24726
  • Loading branch information
BillyONeal authored Jun 16, 2022
1 parent 3d8f781 commit 0af508e
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 20 deletions.
48 changes: 48 additions & 0 deletions ports/cpuinfo/check-for-x86-correctly.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
From 99486c3d72cc0aec72992eb95bd46a27f09ff41e Mon Sep 17 00:00:00 2001
From: Billy Robert O'Neal III <[email protected]>
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()
-
23 changes: 4 additions & 19 deletions ports/cpuinfo/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ 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
FEATURES
tools CPUINFO_BUILD_TOOLS
)

set(LINK_OPTIONS "")
if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
list(APPEND LINK_OPTIONS -DCPUINFO_LIBRARY_TYPE=shared)
else()
Expand All @@ -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
Expand All @@ -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(
Expand Down
1 change: 1 addition & 0 deletions ports/cpuinfo/vcpkg.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -1682,7 +1682,7 @@
},
"cpuinfo": {
"baseline": "2022-04-02",
"port-version": 0
"port-version": 1
},
"cr": {
"baseline": "2020-04-26",
Expand Down
5 changes: 5 additions & 0 deletions versions/c-/cpuinfo.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "11ac581a5c1307b2039cf9db3933c2aeffb7a923",
"version-date": "2022-04-02",
"port-version": 1
},
{
"git-tree": "69febccb10ae5b789dd6c5af2b85740617fc34f4",
"version-date": "2022-04-02",
Expand Down

0 comments on commit 0af508e

Please sign in to comment.