Deps: Build cpuinfo

This commit is contained in:
Stenzek 2024-07-02 17:34:12 +10:00
parent 31c3af4866
commit 31aa040758
No known key found for this signature in database
7 changed files with 320 additions and 3 deletions

View file

@ -27,6 +27,7 @@ SHADERC_GLSLANG=142052fa30f9eca191aa9dcf65359fcaed09eeec
SHADERC_SPIRVHEADERS=5e3ad389ee56fca27c9705d093ae5387ce404df4
SHADERC_SPIRVTOOLS=dd4b663e13c07fea4fbb3f70c1c91c86731099f7
SPIRV_CROSS=vulkan-sdk-1.3.283.0
CPUINFO=05332fd802d9109a2a151ec32154b107c1e5caf9
mkdir -p deps-build
cd deps-build
@ -49,6 +50,7 @@ aa27e4454ce631c5a17924ce0624eac736da19fc6f5a2ab15a6c58da7b36950f shaderc-glslan
5d866ce34a4b6908e262e5ebfffc0a5e11dd411640b5f24c85a80ad44c0d4697 shaderc-spirv-headers-$SHADERC_SPIRVHEADERS.tar.gz
03ee1a2c06f3b61008478f4abe9423454e53e580b9488b47c8071547c6a9db47 shaderc-spirv-tools-$SHADERC_SPIRVTOOLS.tar.gz
3376a58abe186a695a50ff12697d210ce27673cea5de1a5090cb2b092b261414 SPIRV-Cross-$SPIRV_CROSS.tar.gz
74a8d9ae0b8b45b39d35708c873320de227bbfe01a46e4d2a91818b8877f4137 cpuinfo-$CPUINFO.tar.gz
EOF
curl -C - -L \
@ -68,7 +70,8 @@ curl -C - -L \
-o "shaderc-glslang-$SHADERC_GLSLANG.tar.gz" "https://github.com/KhronosGroup/glslang/archive/$SHADERC_GLSLANG.tar.gz" \
-o "shaderc-spirv-headers-$SHADERC_SPIRVHEADERS.tar.gz" "https://github.com/KhronosGroup/SPIRV-Headers/archive/$SHADERC_SPIRVHEADERS.tar.gz" \
-o "shaderc-spirv-tools-$SHADERC_SPIRVTOOLS.tar.gz" "https://github.com/KhronosGroup/SPIRV-Tools/archive/$SHADERC_SPIRVTOOLS.tar.gz" \
-o "SPIRV-Cross-$SPIRV_CROSS.tar.gz" "https://github.com/KhronosGroup/SPIRV-Cross/archive/refs/tags/$SPIRV_CROSS.tar.gz"
-o "SPIRV-Cross-$SPIRV_CROSS.tar.gz" "https://github.com/KhronosGroup/SPIRV-Cross/archive/refs/tags/$SPIRV_CROSS.tar.gz" \
-o "cpuinfo-$CPUINFO.tar.gz" "https://github.com/pytorch/cpuinfo/archive/$CPUINFO.tar.gz"
shasum -a 256 --check SHASUMS
@ -253,6 +256,16 @@ cmake --build build --parallel
ninja -C build install
cd ..
echo "Building cpuinfo"
rm -fr "cpuinfo-$CPUINFO"
tar xf "cpuinfo-$CPUINFO.tar.gz"
cd "cpuinfo-$CPUINFO"
patch -p1 < "$SCRIPTDIR/cpuinfo-changes.patch"
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$INSTALLDIR" -DCMAKE_INSTALL_PREFIX="$INSTALLDIR" -DCPUINFO_LIBRARY_TYPE=shared -DCPUINFO_RUNTIME_TYPE=shared -DCPUINFO_LOG_LEVEL=error -DCPUINFO_LOG_TO_STDIO=ON -DCPUINFO_BUILD_TOOLS=OFF -DCPUINFO_BUILD_UNIT_TESTS=OFF -DCPUINFO_BUILD_MOCK_TESTS=OFF -DCPUINFO_BUILD_BENCHMARKS=OFF -DUSE_SYSTEM_LIBS=ON -B build -G Ninja
cmake --build build --parallel
ninja -C build install
cd ..
echo "Cleaning up..."
cd ..
rm -r deps-build

View file

@ -49,6 +49,7 @@ SHADERC_GLSLANG=142052fa30f9eca191aa9dcf65359fcaed09eeec
SHADERC_SPIRVHEADERS=5e3ad389ee56fca27c9705d093ae5387ce404df4
SHADERC_SPIRVTOOLS=dd4b663e13c07fea4fbb3f70c1c91c86731099f7
SPIRV_CROSS=vulkan-sdk-1.3.283.0
CPUINFO=05332fd802d9109a2a151ec32154b107c1e5caf9
mkdir -p deps-build
cd deps-build
@ -87,6 +88,7 @@ aa27e4454ce631c5a17924ce0624eac736da19fc6f5a2ab15a6c58da7b36950f shaderc-glslan
5d866ce34a4b6908e262e5ebfffc0a5e11dd411640b5f24c85a80ad44c0d4697 shaderc-spirv-headers-$SHADERC_SPIRVHEADERS.tar.gz
03ee1a2c06f3b61008478f4abe9423454e53e580b9488b47c8071547c6a9db47 shaderc-spirv-tools-$SHADERC_SPIRVTOOLS.tar.gz
3376a58abe186a695a50ff12697d210ce27673cea5de1a5090cb2b092b261414 SPIRV-Cross-$SPIRV_CROSS.tar.gz
74a8d9ae0b8b45b39d35708c873320de227bbfe01a46e4d2a91818b8877f4137 cpuinfo-$CPUINFO.tar.gz
EOF
curl -L \
@ -106,8 +108,9 @@ curl -L \
-o "shaderc-$SHADERC.tar.gz" "https://github.com/google/shaderc/archive/refs/tags/v$SHADERC.tar.gz" \
-o "shaderc-glslang-$SHADERC_GLSLANG.tar.gz" "https://github.com/KhronosGroup/glslang/archive/$SHADERC_GLSLANG.tar.gz" \
-o "shaderc-spirv-headers-$SHADERC_SPIRVHEADERS.tar.gz" "https://github.com/KhronosGroup/SPIRV-Headers/archive/$SHADERC_SPIRVHEADERS.tar.gz" \
-o "shaderc-spirv-tools-$SHADERC_SPIRVTOOLS.tar.gz" "https://github.com/KhronosGroup/SPIRV-Tools/archive/$SHADERC_SPIRVTOOLS.tar.gz"\
-o "SPIRV-Cross-$SPIRV_CROSS.tar.gz" "https://github.com/KhronosGroup/SPIRV-Cross/archive/refs/tags/$SPIRV_CROSS.tar.gz"
-o "shaderc-spirv-tools-$SHADERC_SPIRVTOOLS.tar.gz" "https://github.com/KhronosGroup/SPIRV-Tools/archive/$SHADERC_SPIRVTOOLS.tar.gz" \
-o "SPIRV-Cross-$SPIRV_CROSS.tar.gz" "https://github.com/KhronosGroup/SPIRV-Cross/archive/refs/tags/$SPIRV_CROSS.tar.gz" \
-o "cpuinfo-$CPUINFO.tar.gz" "https://github.com/pytorch/cpuinfo/archive/$CPUINFO.tar.gz"
shasum -a 256 --check SHASUMS
@ -320,6 +323,19 @@ cmake --build build --parallel
cmake --install build
cd ..
echo "Building cpuinfo"
rm -fr "cpuinfo-$CPUINFO"
tar xf "cpuinfo-$CPUINFO.tar.gz"
cd "cpuinfo-$CPUINFO"
patch -p1 < "$SCRIPTDIR/cpuinfo-changes.patch"
cmake "${CMAKE_COMMON[@]}" "$CMAKE_ARCH_X64" -DCPUINFO_LIBRARY_TYPE=shared -DCPUINFO_RUNTIME_TYPE=shared -DCPUINFO_LOG_LEVEL=error -DCPUINFO_LOG_TO_STDIO=ON -DCPUINFO_BUILD_TOOLS=OFF -DCPUINFO_BUILD_UNIT_TESTS=OFF -DCPUINFO_BUILD_MOCK_TESTS=OFF -DCPUINFO_BUILD_BENCHMARKS=OFF -DUSE_SYSTEM_LIBS=ON -B build
make -C build "-j$NPROCS"
cmake "${CMAKE_COMMON[@]}" "$CMAKE_ARCH_ARM64" -DCPUINFO_LIBRARY_TYPE=shared -DCPUINFO_RUNTIME_TYPE=shared -DCPUINFO_LOG_LEVEL=error -DCPUINFO_LOG_TO_STDIO=ON -DCPUINFO_BUILD_TOOLS=OFF -DCPUINFO_BUILD_UNIT_TESTS=OFF -DCPUINFO_BUILD_MOCK_TESTS=OFF -DCPUINFO_BUILD_BENCHMARKS=OFF -DUSE_SYSTEM_LIBS=ON -B build-arm64
make -C build-arm64 "-j$NPROCS"
merge_binaries $(realpath build) $(realpath build-arm64)
make -C build install
cd ..
echo "Cleaning up..."
cd ..
rm -rf deps-build

View file

@ -59,6 +59,7 @@ set SHADERC_GLSLANG=142052fa30f9eca191aa9dcf65359fcaed09eeec
set SHADERC_SPIRVHEADERS=5e3ad389ee56fca27c9705d093ae5387ce404df4
set SHADERC_SPIRVTOOLS=dd4b663e13c07fea4fbb3f70c1c91c86731099f7
set SPIRV_CROSS=vulkan-sdk-1.3.283.0
set CPUINFO=05332fd802d9109a2a151ec32154b107c1e5caf9
call :downloadfile "freetype-%FREETYPE%.tar.gz" https://download.savannah.gnu.org/releases/freetype/freetype-%FREETYPE%.tar.gz 1ac27e16c134a7f2ccea177faba19801131116fd682efc1f5737037c5db224b5 || goto error
call :downloadfile "harfbuzz-%HARFBUZZ%.zip" https://github.com/harfbuzz/harfbuzz/archive/refs/tags/%HARFBUZZ%.zip b2bc56184ae37324bc4829fde7d3f9e6916866ad711ee85792e457547c9fd127 || goto error
@ -75,6 +76,7 @@ call :downloadfile "zlib%ZLIBSHORT%.zip" "https://zlib.net/zlib%ZLIBSHORT%.zip"
call :downloadfile "zstd-%ZSTD%.zip" "https://github.com/facebook/zstd/archive/refs/tags/v%ZSTD%.zip" 3b1c3b46e416d36931efd34663122d7f51b550c87f74de2d38249516fe7d8be5 || goto error
call :downloadfile "zstd-fd5f8106a58601a963ee816e6a57aa7c61fafc53.patch" https://github.com/facebook/zstd/commit/fd5f8106a58601a963ee816e6a57aa7c61fafc53.patch 675f144b11f8ab2424b64bed8ccdca5d3f35b9326046fa7a883925dd180f0651 || goto error
call :downloadfile "cpuinfo-%CPUINFO%.zip" "https://github.com/pytorch/cpuinfo/archive/%CPUINFO%.zip" d4a3e252d04b55b1a3bec800fcf2eee36746a2f54405280a9c8355306e09ebe4 || goto error
call :downloadfile "shaderc-%SHADERC%.zip" "https://github.com/google/shaderc/archive/refs/tags/v%SHADERC%.zip" 6c9f42ed6bf42750f5369b089909abfdcf0101488b4a1f41116d5159d00af8e7 || goto error
call :downloadfile "shaderc-glslang-%SHADERC_GLSLANG%.zip" "https://github.com/KhronosGroup/glslang/archive/%SHADERC_GLSLANG%.zip" 03ad8a6fa987af4653d0cfe6bdaed41bcf617f1366a151fb1574da75950cd3e8 || goto error
call :downloadfile "shaderc-spirv-headers-%SHADERC_SPIRVHEADERS%.zip" "https://github.com/KhronosGroup/SPIRV-Headers/archive/%SHADERC_SPIRVHEADERS%.zip" fa59a54334feaba5702b9c25724c3f4746123865769b36dd5a28d9ef5e9d39ab || goto error
@ -264,6 +266,16 @@ cmake --build build --parallel || goto error
ninja -C build install || goto error
cd .. || goto error
echo Building cpuinfo...
rmdir /S /Q "cpuinfo-%CPUINFO%"
%SEVENZIP% x "cpuinfo-%CPUINFO%.zip" || goto error
cd "cpuinfo-%CPUINFO%" || goto error
%PATCH% -p1 < "%SCRIPTDIR%\cpuinfo-changes.patch" || goto error
cmake %ARM64TOOLCHAIN% -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="%INSTALLDIR%" -DCMAKE_INSTALL_PREFIX="%INSTALLDIR%" -DCPUINFO_LIBRARY_TYPE=shared -DCPUINFO_RUNTIME_TYPE=shared -DCPUINFO_LOG_LEVEL=error -DCPUINFO_LOG_TO_STDIO=ON -DCPUINFO_BUILD_TOOLS=OFF -DCPUINFO_BUILD_UNIT_TESTS=OFF -DCPUINFO_BUILD_MOCK_TESTS=OFF -DCPUINFO_BUILD_BENCHMARKS=OFF -DUSE_SYSTEM_LIBS=ON -B build -G Ninja
cmake --build build --parallel || goto error
ninja -C build install || goto error
cd .. || goto error
echo Cleaning up...
cd ..
rd /S /Q deps-build

View file

@ -57,6 +57,7 @@ set SHADERC_GLSLANG=142052fa30f9eca191aa9dcf65359fcaed09eeec
set SHADERC_SPIRVHEADERS=5e3ad389ee56fca27c9705d093ae5387ce404df4
set SHADERC_SPIRVTOOLS=dd4b663e13c07fea4fbb3f70c1c91c86731099f7
set SPIRV_CROSS=vulkan-sdk-1.3.283.0
set CPUINFO=05332fd802d9109a2a151ec32154b107c1e5caf9
call :downloadfile "freetype-%FREETYPE%.tar.gz" https://download.savannah.gnu.org/releases/freetype/freetype-%FREETYPE%.tar.gz 1ac27e16c134a7f2ccea177faba19801131116fd682efc1f5737037c5db224b5 || goto error
call :downloadfile "harfbuzz-%HARFBUZZ%.zip" https://github.com/harfbuzz/harfbuzz/archive/refs/tags/%HARFBUZZ%.zip b2bc56184ae37324bc4829fde7d3f9e6916866ad711ee85792e457547c9fd127 || goto error
@ -73,6 +74,7 @@ call :downloadfile "zlib%ZLIBSHORT%.zip" "https://zlib.net/zlib%ZLIBSHORT%.zip"
call :downloadfile "zstd-%ZSTD%.zip" "https://github.com/facebook/zstd/archive/refs/tags/v%ZSTD%.zip" 3b1c3b46e416d36931efd34663122d7f51b550c87f74de2d38249516fe7d8be5 || goto error
call :downloadfile "zstd-fd5f8106a58601a963ee816e6a57aa7c61fafc53.patch" https://github.com/facebook/zstd/commit/fd5f8106a58601a963ee816e6a57aa7c61fafc53.patch 675f144b11f8ab2424b64bed8ccdca5d3f35b9326046fa7a883925dd180f0651 || goto error
call :downloadfile "cpuinfo-%CPUINFO%.zip" "https://github.com/pytorch/cpuinfo/archive/%CPUINFO%.zip" d4a3e252d04b55b1a3bec800fcf2eee36746a2f54405280a9c8355306e09ebe4 || goto error
call :downloadfile "shaderc-%SHADERC%.zip" "https://github.com/google/shaderc/archive/refs/tags/v%SHADERC%.zip" 6c9f42ed6bf42750f5369b089909abfdcf0101488b4a1f41116d5159d00af8e7 || goto error
call :downloadfile "shaderc-glslang-%SHADERC_GLSLANG%.zip" "https://github.com/KhronosGroup/glslang/archive/%SHADERC_GLSLANG%.zip" 03ad8a6fa987af4653d0cfe6bdaed41bcf617f1366a151fb1574da75950cd3e8 || goto error
call :downloadfile "shaderc-spirv-headers-%SHADERC_SPIRVHEADERS%.zip" "https://github.com/KhronosGroup/SPIRV-Headers/archive/%SHADERC_SPIRVHEADERS%.zip" fa59a54334feaba5702b9c25724c3f4746123865769b36dd5a28d9ef5e9d39ab || goto error
@ -261,6 +263,16 @@ cmake --build build --parallel || goto error
ninja -C build install || goto error
cd .. || goto error
echo Building cpuinfo...
rmdir /S /Q "cpuinfo-%CPUINFO%"
%SEVENZIP% x "cpuinfo-%CPUINFO%.zip" || goto error
cd "cpuinfo-%CPUINFO%" || goto error
%PATCH% -p1 < "%SCRIPTDIR%\cpuinfo-changes.patch" || goto error
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="%INSTALLDIR%" -DCMAKE_INSTALL_PREFIX="%INSTALLDIR%" -DCPUINFO_LIBRARY_TYPE=shared -DCPUINFO_RUNTIME_TYPE=shared -DCPUINFO_LOG_LEVEL=error -DCPUINFO_LOG_TO_STDIO=ON -DCPUINFO_BUILD_TOOLS=OFF -DCPUINFO_BUILD_UNIT_TESTS=OFF -DCPUINFO_BUILD_MOCK_TESTS=OFF -DCPUINFO_BUILD_BENCHMARKS=OFF -DUSE_SYSTEM_LIBS=ON -B build -G Ninja
cmake --build build --parallel || goto error
ninja -C build install || goto error
cd .. || goto error
echo Cleaning up...
cd ..
rd /S /Q deps-build

View file

@ -0,0 +1,223 @@
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -253,6 +253,8 @@
IF(CPUINFO_LIBRARY_TYPE STREQUAL "default")
ADD_LIBRARY(cpuinfo ${CPUINFO_SRCS})
ELSEIF(CPUINFO_LIBRARY_TYPE STREQUAL "shared")
+ SET(CMAKE_C_VISIBILITY_PRESET hidden)
+ SET(CMAKE_CXX_VISIBILITY_PRESET hidden)
ADD_LIBRARY(cpuinfo SHARED ${CPUINFO_SRCS})
ELSEIF(CPUINFO_LIBRARY_TYPE STREQUAL "static")
ADD_LIBRARY(cpuinfo STATIC ${CPUINFO_SRCS})
@@ -301,8 +303,14 @@
TARGET_COMPILE_DEFINITIONS(cpuinfo_internals PRIVATE "CPUINFO_LOG_LEVEL=0")
TARGET_COMPILE_DEFINITIONS(cpuinfo_internals PRIVATE "CPUINFO_LOG_TO_STDIO=1")
+IF(CPUINFO_LIBRARY_TYPE STREQUAL "shared")
+ TARGET_COMPILE_DEFINITIONS(cpuinfo PUBLIC CPUINFO_SHARED)
+ TARGET_COMPILE_DEFINITIONS(cpuinfo PRIVATE CPUINFO_BUILD)
+ TARGET_COMPILE_DEFINITIONS(cpuinfo_internals PRIVATE CPUINFO_SHARED CPUINFO_BUILD)
+ENDIF()
+
IF(CPUINFO_SUPPORTED_PLATFORM)
- TARGET_COMPILE_DEFINITIONS(cpuinfo INTERFACE CPUINFO_SUPPORTED_PLATFORM=1)
+ TARGET_COMPILE_DEFINITIONS(cpuinfo PRIVATE CPUINFO_SUPPORTED_PLATFORM=1)
IF(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Android")
TARGET_LINK_LIBRARIES(cpuinfo PUBLIC ${CMAKE_THREAD_LIBS_INIT})
TARGET_LINK_LIBRARIES(cpuinfo_internals PUBLIC ${CMAKE_THREAD_LIBS_INIT})
@@ -313,7 +321,7 @@
TARGET_LINK_LIBRARIES(cpuinfo_internals PUBLIC ${CMAKE_THREAD_LIBS_INIT})
ENDIF()
ELSE()
- TARGET_COMPILE_DEFINITIONS(cpuinfo INTERFACE CPUINFO_SUPPORTED_PLATFORM=0)
+ TARGET_COMPILE_DEFINITIONS(cpuinfo PRIVATE CPUINFO_SUPPORTED_PLATFORM=0)
ENDIF()
ADD_LIBRARY(${PROJECT_NAME}::cpuinfo ALIAS cpuinfo)
@@ -329,6 +337,7 @@
INSTALL(TARGETS cpuinfo
EXPORT cpuinfo-targets
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
--- a/include/cpuinfo.h
+++ b/include/cpuinfo.h
@@ -96,6 +96,24 @@
#define CPUINFO_ARCH_RISCV64 0
#endif
+#ifdef CPUINFO_SHARED
+#ifdef _WIN32
+#ifdef CPUINFO_BUILD
+#define CPUINFO_EXPORT __declspec(dllexport)
+#else
+#define CPUINFO_EXPORT __declspec(dllimport)
+#endif
+#else
+#ifdef CPUINFO_BUILD
+#define CPUINFO_EXPORT __attribute__((visibility("default")))
+#else
+#define CPUINFO_EXPORT
+#endif
+#endif
+#else
+#define CPUINFO_EXPORT
+#endif
+
#if CPUINFO_ARCH_X86 && defined(_MSC_VER)
#define CPUINFO_ABI __cdecl
#elif CPUINFO_ARCH_X86 && defined(__GNUC__)
@@ -735,9 +753,9 @@
extern "C" {
#endif
-bool CPUINFO_ABI cpuinfo_initialize(void);
+CPUINFO_EXPORT bool CPUINFO_ABI cpuinfo_initialize(void);
-void CPUINFO_ABI cpuinfo_deinitialize(void);
+CPUINFO_EXPORT void CPUINFO_ABI cpuinfo_deinitialize(void);
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
/* This structure is not a part of stable API. Use cpuinfo_has_x86_* functions
@@ -856,7 +874,7 @@
bool lwp;
};
-extern struct cpuinfo_x86_isa cpuinfo_isa;
+extern CPUINFO_EXPORT struct cpuinfo_x86_isa cpuinfo_isa;
#endif
static inline bool cpuinfo_has_x86_rdtsc(void) {
@@ -1679,7 +1697,7 @@
bool crc32;
};
-extern struct cpuinfo_arm_isa cpuinfo_isa;
+extern CPUINFO_EXPORT struct cpuinfo_arm_isa cpuinfo_isa;
#endif
static inline bool cpuinfo_has_arm_thumb(void) {
@@ -2064,7 +2082,7 @@
bool v;
};
-extern struct cpuinfo_riscv_isa cpuinfo_isa;
+extern CPUINFO_EXPORT struct cpuinfo_riscv_isa cpuinfo_isa;
#endif
static inline bool cpuinfo_has_riscv_i(void) {
@@ -2137,43 +2155,43 @@
#endif
}
-const struct cpuinfo_processor* CPUINFO_ABI cpuinfo_get_processors(void);
-const struct cpuinfo_core* CPUINFO_ABI cpuinfo_get_cores(void);
-const struct cpuinfo_cluster* CPUINFO_ABI cpuinfo_get_clusters(void);
-const struct cpuinfo_package* CPUINFO_ABI cpuinfo_get_packages(void);
-const struct cpuinfo_uarch_info* CPUINFO_ABI cpuinfo_get_uarchs(void);
-const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l1i_caches(void);
-const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l1d_caches(void);
-const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l2_caches(void);
-const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l3_caches(void);
-const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l4_caches(void);
-
-const struct cpuinfo_processor* CPUINFO_ABI cpuinfo_get_processor(uint32_t index);
-const struct cpuinfo_core* CPUINFO_ABI cpuinfo_get_core(uint32_t index);
-const struct cpuinfo_cluster* CPUINFO_ABI cpuinfo_get_cluster(uint32_t index);
-const struct cpuinfo_package* CPUINFO_ABI cpuinfo_get_package(uint32_t index);
-const struct cpuinfo_uarch_info* CPUINFO_ABI cpuinfo_get_uarch(uint32_t index);
-const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l1i_cache(uint32_t index);
-const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l1d_cache(uint32_t index);
-const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l2_cache(uint32_t index);
-const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l3_cache(uint32_t index);
-const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l4_cache(uint32_t index);
-
-uint32_t CPUINFO_ABI cpuinfo_get_processors_count(void);
-uint32_t CPUINFO_ABI cpuinfo_get_cores_count(void);
-uint32_t CPUINFO_ABI cpuinfo_get_clusters_count(void);
-uint32_t CPUINFO_ABI cpuinfo_get_packages_count(void);
-uint32_t CPUINFO_ABI cpuinfo_get_uarchs_count(void);
-uint32_t CPUINFO_ABI cpuinfo_get_l1i_caches_count(void);
-uint32_t CPUINFO_ABI cpuinfo_get_l1d_caches_count(void);
-uint32_t CPUINFO_ABI cpuinfo_get_l2_caches_count(void);
-uint32_t CPUINFO_ABI cpuinfo_get_l3_caches_count(void);
-uint32_t CPUINFO_ABI cpuinfo_get_l4_caches_count(void);
+CPUINFO_EXPORT const struct cpuinfo_processor* CPUINFO_ABI cpuinfo_get_processors(void);
+CPUINFO_EXPORT const struct cpuinfo_core* CPUINFO_ABI cpuinfo_get_cores(void);
+CPUINFO_EXPORT const struct cpuinfo_cluster* CPUINFO_ABI cpuinfo_get_clusters(void);
+CPUINFO_EXPORT const struct cpuinfo_package* CPUINFO_ABI cpuinfo_get_packages(void);
+CPUINFO_EXPORT const struct cpuinfo_uarch_info* CPUINFO_ABI cpuinfo_get_uarchs(void);
+CPUINFO_EXPORT const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l1i_caches(void);
+CPUINFO_EXPORT const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l1d_caches(void);
+CPUINFO_EXPORT const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l2_caches(void);
+CPUINFO_EXPORT const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l3_caches(void);
+CPUINFO_EXPORT const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l4_caches(void);
+
+CPUINFO_EXPORT const struct cpuinfo_processor* CPUINFO_ABI cpuinfo_get_processor(uint32_t index);
+CPUINFO_EXPORT const struct cpuinfo_core* CPUINFO_ABI cpuinfo_get_core(uint32_t index);
+CPUINFO_EXPORT const struct cpuinfo_cluster* CPUINFO_ABI cpuinfo_get_cluster(uint32_t index);
+CPUINFO_EXPORT const struct cpuinfo_package* CPUINFO_ABI cpuinfo_get_package(uint32_t index);
+CPUINFO_EXPORT const struct cpuinfo_uarch_info* CPUINFO_ABI cpuinfo_get_uarch(uint32_t index);
+CPUINFO_EXPORT const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l1i_cache(uint32_t index);
+CPUINFO_EXPORT const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l1d_cache(uint32_t index);
+CPUINFO_EXPORT const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l2_cache(uint32_t index);
+CPUINFO_EXPORT const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l3_cache(uint32_t index);
+CPUINFO_EXPORT const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l4_cache(uint32_t index);
+
+CPUINFO_EXPORT uint32_t CPUINFO_ABI cpuinfo_get_processors_count(void);
+CPUINFO_EXPORT uint32_t CPUINFO_ABI cpuinfo_get_cores_count(void);
+CPUINFO_EXPORT uint32_t CPUINFO_ABI cpuinfo_get_clusters_count(void);
+CPUINFO_EXPORT uint32_t CPUINFO_ABI cpuinfo_get_packages_count(void);
+CPUINFO_EXPORT uint32_t CPUINFO_ABI cpuinfo_get_uarchs_count(void);
+CPUINFO_EXPORT uint32_t CPUINFO_ABI cpuinfo_get_l1i_caches_count(void);
+CPUINFO_EXPORT uint32_t CPUINFO_ABI cpuinfo_get_l1d_caches_count(void);
+CPUINFO_EXPORT uint32_t CPUINFO_ABI cpuinfo_get_l2_caches_count(void);
+CPUINFO_EXPORT uint32_t CPUINFO_ABI cpuinfo_get_l3_caches_count(void);
+CPUINFO_EXPORT uint32_t CPUINFO_ABI cpuinfo_get_l4_caches_count(void);
/**
* Returns upper bound on cache size.
*/
-uint32_t CPUINFO_ABI cpuinfo_get_max_cache_size(void);
+CPUINFO_EXPORT uint32_t CPUINFO_ABI cpuinfo_get_max_cache_size(void);
/**
* Identify the logical processor that executes the current thread.
@@ -2182,7 +2200,7 @@
* for any time. Callers should treat the result as only a hint, and be prepared
* to handle NULL return value.
*/
-const struct cpuinfo_processor* CPUINFO_ABI cpuinfo_get_current_processor(void);
+CPUINFO_EXPORT const struct cpuinfo_processor* CPUINFO_ABI cpuinfo_get_current_processor(void);
/**
* Identify the core that executes the current thread.
@@ -2191,7 +2209,7 @@
* time. Callers should treat the result as only a hint, and be prepared to
* handle NULL return value.
*/
-const struct cpuinfo_core* CPUINFO_ABI cpuinfo_get_current_core(void);
+CPUINFO_EXPORT const struct cpuinfo_core* CPUINFO_ABI cpuinfo_get_current_core(void);
/**
* Identify the microarchitecture index of the core that executes the current
@@ -2201,7 +2219,7 @@
* There is no guarantee that the thread will stay on the same type of core for
* any time. Callers should treat the result as only a hint.
*/
-uint32_t CPUINFO_ABI cpuinfo_get_current_uarch_index(void);
+CPUINFO_EXPORT uint32_t CPUINFO_ABI cpuinfo_get_current_uarch_index(void);
/**
* Identify the microarchitecture index of the core that executes the current
@@ -2211,7 +2229,7 @@
* There is no guarantee that the thread will stay on the same type of core for
* any time. Callers should treat the result as only a hint.
*/
-uint32_t CPUINFO_ABI cpuinfo_get_current_uarch_index_with_default(uint32_t default_uarch_index);
+CPUINFO_EXPORT uint32_t CPUINFO_ABI cpuinfo_get_current_uarch_index_with_default(uint32_t default_uarch_index);
#ifdef __cplusplus
} /* extern "C" */

View file

@ -0,0 +1,40 @@
{
"name": "cpuinfo",
"buildsystem": "cmake-ninja",
"builddir": true,
"config-opts": [
"-DCMAKE_BUILD_TYPE=Release",
"-DCPUINFO_LIBRARY_TYPE=shared",
"-DCPUINFO_RUNTIME_TYPE=shared",
"-DCPUINFO_LOG_LEVEL=error",
"-DCPUINFO_LOG_TO_STDIO=ON",
"-DCPUINFO_BUILD_TOOLS=OFF",
"-DCPUINFO_BUILD_UNIT_TESTS=OFF",
"-DCPUINFO_BUILD_MOCK_TESTS=OFF",
"-DCPUINFO_BUILD_BENCHMARKS=OFF",
"-DUSE_SYSTEM_LIBS=ON"
],
"build-options": {
"strip": true
},
"sources": [
{
"type": "git",
"url": "https://github.com/pytorch/cpuinfo.git",
"commit": "05332fd802d9109a2a151ec32154b107c1e5caf9"
},
{
"type": "patch",
"path": "../../cpuinfo-changes.patch"
}
],
"cleanup": [
"/bin",
"/include",
"/lib/*.a",
"/lib/*.la",
"/lib/cmake",
"/lib/pkgconfig",
"/share"
]
}

View file

@ -22,6 +22,7 @@
"modules/21-libbacktrace.json",
"modules/22-shaderc.json",
"modules/23-spirv-cross.json",
"modules/24-cpuinfo.json",
{
"name": "duckstation",
"buildsystem": "cmake-ninja",