From 255017f400f6dcd146532952e425bdd1a06bd0d7 Mon Sep 17 00:00:00 2001 From: Changming Sun Date: Wed, 11 Jun 2025 10:45:09 -0700 Subject: [PATCH 01/17] update abseil --- cmake/deps.txt | 2 +- cmake/external/abseil-cpp.cmake | 10 +- cmake/external/abseil-cpp.natvis | 10 +- cmake/patches/abseil/absl_windows.patch | 163 -------------------- cmake/vcpkg-ports/abseil/absl_windows.patch | 163 -------------------- cmake/vcpkg-ports/abseil/portfile.cmake | 11 +- cmake/vcpkg-ports/abseil/vcpkg.json | 9 +- 7 files changed, 11 insertions(+), 357 deletions(-) delete mode 100644 cmake/patches/abseil/absl_windows.patch delete mode 100644 cmake/vcpkg-ports/abseil/absl_windows.patch diff --git a/cmake/deps.txt b/cmake/deps.txt index 2df433b0353c6..22d91fe024893 100644 --- a/cmake/deps.txt +++ b/cmake/deps.txt @@ -9,7 +9,7 @@ #since the file contains a version string: "lts_20230802". However, the file is for debugging purposes only and would #not affect built binaries. # -abseil_cpp;https://github.com/abseil/abseil-cpp/archive/refs/tags/20240722.0.zip;36ee53eb1466fb6e593fc5c286680de31f8a494a +abseil_cpp;https://github.com/abseil/abseil-cpp/archive/refs/tags/20250512.0.zip;3d6ff7e7ce144d9a53a53bef1f1bf79e1da4b8e1 coremltools;https://github.com/apple/coremltools/archive/refs/tags/7.1.zip;f1bab0f30966f2e217d8e01207d518f230a1641a cxxopts;https://github.com/jarro2783/cxxopts/archive/3c73d91c0b04e2b59462f0a741be8c07024c1bc0.zip;6c6ca7f8480b26c8d00476e0e24b7184717fe4f0 date;https://github.com/HowardHinnant/date/archive/refs/tags/v3.0.1.zip;2dac0c81dc54ebdd8f8d073a75c053b04b56e159 diff --git a/cmake/external/abseil-cpp.cmake b/cmake/external/abseil-cpp.cmake index 488df5a4e0de8..513b4556f8d6f 100644 --- a/cmake/external/abseil-cpp.cmake +++ b/cmake/external/abseil-cpp.cmake @@ -20,14 +20,9 @@ else() endif() endif() -if(Patch_FOUND AND WIN32) - set(ABSL_PATCH_COMMAND ${Patch_EXECUTABLE} --binary --ignore-whitespace -p1 < ${PROJECT_SOURCE_DIR}/patches/abseil/absl_windows.patch) -else() - set(ABSL_PATCH_COMMAND "") -endif() # NB! Advancing Abseil version changes its internal namespace, -# currently absl::lts_20240116 which affects abseil-cpp.natvis debugger +# currently absl::lts_20250512 which affects abseil-cpp.natvis debugger # visualization file, that must be adjusted accordingly, unless we eliminate # that namespace at build time. onnxruntime_fetchcontent_declare( @@ -35,8 +30,7 @@ onnxruntime_fetchcontent_declare( URL ${DEP_URL_abseil_cpp} URL_HASH SHA1=${DEP_SHA1_abseil_cpp} EXCLUDE_FROM_ALL - PATCH_COMMAND ${ABSL_PATCH_COMMAND} - FIND_PACKAGE_ARGS 20240722 NAMES absl + FIND_PACKAGE_ARGS 20250512 NAMES absl ) onnxruntime_fetchcontent_makeavailable(abseil_cpp) diff --git a/cmake/external/abseil-cpp.natvis b/cmake/external/abseil-cpp.natvis index e995e215432a2..75374e0fa9fba 100644 --- a/cmake/external/abseil-cpp.natvis +++ b/cmake/external/abseil-cpp.natvis @@ -1,6 +1,6 @@ - + @@ -24,7 +24,7 @@ - + @@ -51,7 +51,7 @@ - + *($T1 *){value} (*($T1 *){value}) @@ -60,7 +60,7 @@ - + *($T1 *)this (*($T1 *)this) @@ -68,7 +68,7 @@ - + {value.first}, {value.second} ({value.first}, {value.second}) diff --git a/cmake/patches/abseil/absl_windows.patch b/cmake/patches/abseil/absl_windows.patch deleted file mode 100644 index c50e147aa4a7d..0000000000000 --- a/cmake/patches/abseil/absl_windows.patch +++ /dev/null @@ -1,163 +0,0 @@ -diff --git a/absl/base/attributes.h b/absl/base/attributes.h -index 5ea5ee3e..f4949898 100644 ---- a/absl/base/attributes.h -+++ b/absl/base/attributes.h -@@ -559,7 +559,7 @@ - #undef ABSL_ATTRIBUTE_UNUSED - #define ABSL_ATTRIBUTE_UNUSED __attribute__((__unused__)) - #else --#define ABSL_ATTRIBUTE_UNUSED -+#define ABSL_ATTRIBUTE_UNUSED [[maybe_unused]] - #endif - - // ABSL_ATTRIBUTE_INITIAL_EXEC -diff --git a/absl/container/internal/raw_hash_set.h b/absl/container/internal/raw_hash_set.h -index d4fe8f5c..27418d13 100644 ---- a/absl/container/internal/raw_hash_set.h -+++ b/absl/container/internal/raw_hash_set.h -@@ -1924,7 +1924,7 @@ HashtablezInfoHandle SampleHashtablezInfo(size_t sizeof_slot, size_t sizeof_key, - // In SOO, we sample on the first insertion so if this is an empty SOO case - // (e.g. when reserve is called), then we still need to sample. - if (kSooEnabled && was_soo && c.size() == 0) { -- return Sample(sizeof_slot, sizeof_key, sizeof_value, SooCapacity()); -+ return Sample(sizeof_slot, sizeof_key, sizeof_value, (int16_t)SooCapacity()); - } - // For non-SOO cases, we sample whenever the capacity is increasing from zero - // to non-zero. -@@ -3525,7 +3525,7 @@ class raw_hash_set { - assert(is_soo()); - if (!ShouldSampleHashtablezInfo()) return HashtablezInfoHandle{}; - return Sample(sizeof(slot_type), sizeof(key_type), sizeof(value_type), -- SooCapacity()); -+ (int16_t)SooCapacity()); - } - - inline void destroy_slots() { -diff --git a/absl/copts/GENERATED_AbseilCopts.cmake b/absl/copts/GENERATED_AbseilCopts.cmake -index da2282fe..4c7fc26f 100644 ---- a/absl/copts/GENERATED_AbseilCopts.cmake -+++ b/absl/copts/GENERATED_AbseilCopts.cmake -@@ -181,8 +181,6 @@ list(APPEND ABSL_MSVC_FLAGS - "/wd4005" - "/wd4068" - "/wd4180" -- "/wd4244" -- "/wd4267" - "/wd4503" - "/wd4800" - "/DNOMINMAX" -diff --git a/absl/copts/GENERATED_copts.bzl b/absl/copts/GENERATED_copts.bzl -index b9e0071e..dd8410ec 100644 ---- a/absl/copts/GENERATED_copts.bzl -+++ b/absl/copts/GENERATED_copts.bzl -@@ -182,8 +182,6 @@ ABSL_MSVC_FLAGS = [ - "/wd4005", - "/wd4068", - "/wd4180", -- "/wd4244", -- "/wd4267", - "/wd4503", - "/wd4800", - "/DNOMINMAX", -diff --git a/absl/copts/copts.py b/absl/copts/copts.py -index 2d85ac74..4875d668 100644 ---- a/absl/copts/copts.py -+++ b/absl/copts/copts.py -@@ -118,10 +118,6 @@ MSVC_WARNING_FLAGS = [ - "/wd4068", # unknown pragma - # qualifier applied to function type has no meaning; ignored - "/wd4180", -- # conversion from 'type1' to 'type2', possible loss of data -- "/wd4244", -- # conversion from 'size_t' to 'type', possible loss of data -- "/wd4267", - # The decorated name was longer than the compiler limit - "/wd4503", - # forcing value to bool 'true' or 'false' (performance warning) -diff --git a/absl/debugging/symbolize.cc b/absl/debugging/symbolize.cc -index 638d3954..6b817075 100644 ---- a/absl/debugging/symbolize.cc -+++ b/absl/debugging/symbolize.cc -@@ -14,7 +14,7 @@ - - #include "absl/debugging/symbolize.h" - --#ifdef _WIN32 -+#if defined(_WIN32) && !defined(NDEBUG) - #include - #if !(WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)) || \ - WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) -diff --git a/absl/debugging/symbolize_win32.inc b/absl/debugging/symbolize_win32.inc -index 53a099a1..34d210d6 100644 ---- a/absl/debugging/symbolize_win32.inc -+++ b/absl/debugging/symbolize_win32.inc -@@ -35,15 +35,15 @@ ABSL_NAMESPACE_BEGIN - - static HANDLE process = NULL; - --void InitializeSymbolizer(const char*) { -- if (process != nullptr) { -- return; -- } -+namespace { -+void InitializeSymbolizerImpl() { -+ - process = GetCurrentProcess(); - - // Symbols are not loaded until a reference is made requiring the - // symbols be loaded. This is the fastest, most efficient way to use - // the symbol handler. -+ - SymSetOptions(SYMOPT_DEFERRED_LOADS | SYMOPT_UNDNAME); - if (!SymInitialize(process, nullptr, true)) { - // GetLastError() returns a Win32 DWORD, but we assign to -@@ -54,6 +54,36 @@ void InitializeSymbolizer(const char*) { - } - } - -+bool LookupAndInitialize(const void* pc, SYMBOL_INFO* symbol) { -+ auto hProcess = (process != NULL) ? process : GetCurrentProcess(); -+ if (SymFromAddr(hProcess, reinterpret_cast(pc), nullptr, symbol) != TRUE) { -+ if (GetLastError() == ERROR_INVALID_HANDLE && process == NULL) { -+ InitializeSymbolizerImpl(); -+ if (SymFromAddr(process, reinterpret_cast(pc), nullptr, symbol) != TRUE) { -+ return false; -+ } -+ } else { -+ return false; -+ } -+ return false; -+ } -+ return true; -+} -+} -+ -+void InitializeSymbolizer(const char*) { -+ if (process != nullptr) { -+ return; -+ } -+ -+ alignas(SYMBOL_INFO) char buf[sizeof(SYMBOL_INFO) + MAX_SYM_NAME]; -+ SYMBOL_INFO* symbol = reinterpret_cast(buf); -+ symbol->SizeOfStruct = sizeof(SYMBOL_INFO); -+ symbol->MaxNameLen = MAX_SYM_NAME; -+ -+ static_cast(LookupAndInitialize(reinterpret_cast(&InitializeSymbolizer), symbol)); -+} -+ - bool Symbolize(const void* pc, char* out, int out_size) { - if (out_size <= 0) { - return false; -@@ -62,9 +92,11 @@ bool Symbolize(const void* pc, char* out, int out_size) { - SYMBOL_INFO* symbol = reinterpret_cast(buf); - symbol->SizeOfStruct = sizeof(SYMBOL_INFO); - symbol->MaxNameLen = MAX_SYM_NAME; -- if (!SymFromAddr(process, reinterpret_cast(pc), nullptr, symbol)) { -+ -+ if(!LookupAndInitialize(pc, symbol)) { - return false; - } -+ - const size_t out_size_t = static_cast(out_size); - strncpy(out, symbol->Name, out_size_t); - if (out[out_size_t - 1] != '\0') { diff --git a/cmake/vcpkg-ports/abseil/absl_windows.patch b/cmake/vcpkg-ports/abseil/absl_windows.patch deleted file mode 100644 index c50e147aa4a7d..0000000000000 --- a/cmake/vcpkg-ports/abseil/absl_windows.patch +++ /dev/null @@ -1,163 +0,0 @@ -diff --git a/absl/base/attributes.h b/absl/base/attributes.h -index 5ea5ee3e..f4949898 100644 ---- a/absl/base/attributes.h -+++ b/absl/base/attributes.h -@@ -559,7 +559,7 @@ - #undef ABSL_ATTRIBUTE_UNUSED - #define ABSL_ATTRIBUTE_UNUSED __attribute__((__unused__)) - #else --#define ABSL_ATTRIBUTE_UNUSED -+#define ABSL_ATTRIBUTE_UNUSED [[maybe_unused]] - #endif - - // ABSL_ATTRIBUTE_INITIAL_EXEC -diff --git a/absl/container/internal/raw_hash_set.h b/absl/container/internal/raw_hash_set.h -index d4fe8f5c..27418d13 100644 ---- a/absl/container/internal/raw_hash_set.h -+++ b/absl/container/internal/raw_hash_set.h -@@ -1924,7 +1924,7 @@ HashtablezInfoHandle SampleHashtablezInfo(size_t sizeof_slot, size_t sizeof_key, - // In SOO, we sample on the first insertion so if this is an empty SOO case - // (e.g. when reserve is called), then we still need to sample. - if (kSooEnabled && was_soo && c.size() == 0) { -- return Sample(sizeof_slot, sizeof_key, sizeof_value, SooCapacity()); -+ return Sample(sizeof_slot, sizeof_key, sizeof_value, (int16_t)SooCapacity()); - } - // For non-SOO cases, we sample whenever the capacity is increasing from zero - // to non-zero. -@@ -3525,7 +3525,7 @@ class raw_hash_set { - assert(is_soo()); - if (!ShouldSampleHashtablezInfo()) return HashtablezInfoHandle{}; - return Sample(sizeof(slot_type), sizeof(key_type), sizeof(value_type), -- SooCapacity()); -+ (int16_t)SooCapacity()); - } - - inline void destroy_slots() { -diff --git a/absl/copts/GENERATED_AbseilCopts.cmake b/absl/copts/GENERATED_AbseilCopts.cmake -index da2282fe..4c7fc26f 100644 ---- a/absl/copts/GENERATED_AbseilCopts.cmake -+++ b/absl/copts/GENERATED_AbseilCopts.cmake -@@ -181,8 +181,6 @@ list(APPEND ABSL_MSVC_FLAGS - "/wd4005" - "/wd4068" - "/wd4180" -- "/wd4244" -- "/wd4267" - "/wd4503" - "/wd4800" - "/DNOMINMAX" -diff --git a/absl/copts/GENERATED_copts.bzl b/absl/copts/GENERATED_copts.bzl -index b9e0071e..dd8410ec 100644 ---- a/absl/copts/GENERATED_copts.bzl -+++ b/absl/copts/GENERATED_copts.bzl -@@ -182,8 +182,6 @@ ABSL_MSVC_FLAGS = [ - "/wd4005", - "/wd4068", - "/wd4180", -- "/wd4244", -- "/wd4267", - "/wd4503", - "/wd4800", - "/DNOMINMAX", -diff --git a/absl/copts/copts.py b/absl/copts/copts.py -index 2d85ac74..4875d668 100644 ---- a/absl/copts/copts.py -+++ b/absl/copts/copts.py -@@ -118,10 +118,6 @@ MSVC_WARNING_FLAGS = [ - "/wd4068", # unknown pragma - # qualifier applied to function type has no meaning; ignored - "/wd4180", -- # conversion from 'type1' to 'type2', possible loss of data -- "/wd4244", -- # conversion from 'size_t' to 'type', possible loss of data -- "/wd4267", - # The decorated name was longer than the compiler limit - "/wd4503", - # forcing value to bool 'true' or 'false' (performance warning) -diff --git a/absl/debugging/symbolize.cc b/absl/debugging/symbolize.cc -index 638d3954..6b817075 100644 ---- a/absl/debugging/symbolize.cc -+++ b/absl/debugging/symbolize.cc -@@ -14,7 +14,7 @@ - - #include "absl/debugging/symbolize.h" - --#ifdef _WIN32 -+#if defined(_WIN32) && !defined(NDEBUG) - #include - #if !(WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)) || \ - WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) -diff --git a/absl/debugging/symbolize_win32.inc b/absl/debugging/symbolize_win32.inc -index 53a099a1..34d210d6 100644 ---- a/absl/debugging/symbolize_win32.inc -+++ b/absl/debugging/symbolize_win32.inc -@@ -35,15 +35,15 @@ ABSL_NAMESPACE_BEGIN - - static HANDLE process = NULL; - --void InitializeSymbolizer(const char*) { -- if (process != nullptr) { -- return; -- } -+namespace { -+void InitializeSymbolizerImpl() { -+ - process = GetCurrentProcess(); - - // Symbols are not loaded until a reference is made requiring the - // symbols be loaded. This is the fastest, most efficient way to use - // the symbol handler. -+ - SymSetOptions(SYMOPT_DEFERRED_LOADS | SYMOPT_UNDNAME); - if (!SymInitialize(process, nullptr, true)) { - // GetLastError() returns a Win32 DWORD, but we assign to -@@ -54,6 +54,36 @@ void InitializeSymbolizer(const char*) { - } - } - -+bool LookupAndInitialize(const void* pc, SYMBOL_INFO* symbol) { -+ auto hProcess = (process != NULL) ? process : GetCurrentProcess(); -+ if (SymFromAddr(hProcess, reinterpret_cast(pc), nullptr, symbol) != TRUE) { -+ if (GetLastError() == ERROR_INVALID_HANDLE && process == NULL) { -+ InitializeSymbolizerImpl(); -+ if (SymFromAddr(process, reinterpret_cast(pc), nullptr, symbol) != TRUE) { -+ return false; -+ } -+ } else { -+ return false; -+ } -+ return false; -+ } -+ return true; -+} -+} -+ -+void InitializeSymbolizer(const char*) { -+ if (process != nullptr) { -+ return; -+ } -+ -+ alignas(SYMBOL_INFO) char buf[sizeof(SYMBOL_INFO) + MAX_SYM_NAME]; -+ SYMBOL_INFO* symbol = reinterpret_cast(buf); -+ symbol->SizeOfStruct = sizeof(SYMBOL_INFO); -+ symbol->MaxNameLen = MAX_SYM_NAME; -+ -+ static_cast(LookupAndInitialize(reinterpret_cast(&InitializeSymbolizer), symbol)); -+} -+ - bool Symbolize(const void* pc, char* out, int out_size) { - if (out_size <= 0) { - return false; -@@ -62,9 +92,11 @@ bool Symbolize(const void* pc, char* out, int out_size) { - SYMBOL_INFO* symbol = reinterpret_cast(buf); - symbol->SizeOfStruct = sizeof(SYMBOL_INFO); - symbol->MaxNameLen = MAX_SYM_NAME; -- if (!SymFromAddr(process, reinterpret_cast(pc), nullptr, symbol)) { -+ -+ if(!LookupAndInitialize(pc, symbol)) { - return false; - } -+ - const size_t out_size_t = static_cast(out_size); - strncpy(out, symbol->Name, out_size_t); - if (out[out_size_t - 1] != '\0') { diff --git a/cmake/vcpkg-ports/abseil/portfile.cmake b/cmake/vcpkg-ports/abseil/portfile.cmake index 16a9bd86b06a5..812d395620bce 100644 --- a/cmake/vcpkg-ports/abseil/portfile.cmake +++ b/cmake/vcpkg-ports/abseil/portfile.cmake @@ -6,19 +6,10 @@ vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO abseil/abseil-cpp REF "${VERSION}" - SHA512 bd2cca8f007f2eee66f51c95a979371622b850ceb2ce3608d00ba826f7c494a1da0fba3c1427728f2c173fe50d59b701da35c2c9fdad2752a5a49746b1c8ef31 + SHA512 92542db666e0c628cf56bf8ad09412af9c8b622e4f26e72d1e1b092ceec430a5c105f6561e2d9983af565f55da07f67e770cafe373b20cc4cb29a893a6a236fc HEAD_REF master - PATCHES absl_windows.patch ) -# With ABSL_PROPAGATE_CXX_STD=ON abseil automatically detect if it is being -# compiled with C++14 or C++17, and modifies the installed `absl/base/options.h` -# header accordingly. This works even if CMAKE_CXX_STANDARD is not set. Abseil -# uses the compiler default behavior to update `absl/base/options.h` as needed. -set(ABSL_USE_CXX17_OPTION "") -if("cxx17" IN_LIST FEATURES) - set(ABSL_USE_CXX17_OPTION "-DCMAKE_CXX_STANDARD=17") -endif() set(ABSL_STATIC_RUNTIME_OPTION "") if(VCPKG_TARGET_IS_WINDOWS AND VCPKG_CRT_LINKAGE STREQUAL "static") diff --git a/cmake/vcpkg-ports/abseil/vcpkg.json b/cmake/vcpkg-ports/abseil/vcpkg.json index 1b8bccfbae03b..ca184edf2cdb7 100644 --- a/cmake/vcpkg-ports/abseil/vcpkg.json +++ b/cmake/vcpkg-ports/abseil/vcpkg.json @@ -1,6 +1,6 @@ { "name": "abseil", - "version": "20240722.0", + "version": "20250512.0", "description": [ "Abseil is an open-source collection of C++ library code designed to augment the C++ standard library. The Abseil library code is collected from Google's own C++ code base, has been extensively tested and used in production, and is the same code we depend on in our daily coding lives.", "In some cases, Abseil provides pieces missing from the C++ standard; in others, Abseil provides alternatives to the standard for special needs we've found through usage in the Google code base. We denote those cases clearly within the library code we provide you.", @@ -17,10 +17,5 @@ "name": "vcpkg-cmake-config", "host": true } - ], - "features": { - "cxx17": { - "description": "Enable compiler C++17." - } - } + ] } From 98f1ce4dd9f68e64b470200c45e5c40e6ead6b1e Mon Sep 17 00:00:00 2001 From: Changming Sun Date: Wed, 11 Jun 2025 11:04:36 -0700 Subject: [PATCH 02/17] update --- cmake/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 47bfa3f312eec..000a73a3ec517 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -1336,7 +1336,7 @@ function(onnxruntime_configure_target target_name) if(WIN32 AND onnxruntime_ENABLE_STATIC_ANALYSIS AND onnxruntime_USE_CUSTOM_STATIC_ANALYSIS_RULES) set_target_properties(${target_name} PROPERTIES VS_USER_PROPS ${PROJECT_SOURCE_DIR}/EnableVisualStudioCodeAnalysis.props) endif() - target_include_directories(${target_name} PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${ONNXRUNTIME_ROOT} ${abseil_cpp_SOURCE_DIR}) + target_include_directories(${target_name} PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${ONNXRUNTIME_ROOT}) if (onnxruntime_ENABLE_TRAINING_OPS) target_include_directories(${target_name} PRIVATE ${ORTTRAINING_ROOT}) endif() From 418e17b3e20eacc84ec736edc4cc8610d152bc22 Mon Sep 17 00:00:00 2001 From: Changming Sun Date: Wed, 11 Jun 2025 11:20:01 -0700 Subject: [PATCH 03/17] update --- .github/workflows/windows_openvino.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/windows_openvino.yml b/.github/workflows/windows_openvino.yml index f38fcdae57a35..56897b756a6e1 100644 --- a/.github/workflows/windows_openvino.yml +++ b/.github/workflows/windows_openvino.yml @@ -149,13 +149,13 @@ jobs: shell: pwsh working-directory: ${{ runner.temp }} run: | - python.exe ${{ github.workspace }}\tools\ci_build\build.py --config ${{ env.BuildConfig }} --build_dir build --cmake_generator "Visual Studio 17 2022" --build_shared_lib --use_openvino CPU --use_binskim_compliant_compile_flags --update --parallel + python.exe ${{ github.workspace }}\tools\ci_build\build.py --config ${{ env.BuildConfig }} --build_dir build --cmake_generator "Visual Studio 17 2022" --build_shared_lib --use_openvino CPU --use_binskim_compliant_compile_flags --update --parallel --use_vcpkg - name: Build shell: pwsh working-directory: ${{ runner.temp }} run: | - python.exe ${{ github.workspace }}\tools\ci_build\build.py --config ${{ env.BuildConfig }} --build_dir build --cmake_generator "Visual Studio 17 2022" --build_shared_lib --use_openvino CPU --use_binskim_compliant_compile_flags --build --parallel + python.exe ${{ github.workspace }}\tools\ci_build\build.py --config ${{ env.BuildConfig }} --build_dir build --cmake_generator "Visual Studio 17 2022" --build_shared_lib --use_openvino CPU --use_binskim_compliant_compile_flags --build --parallel --use_vcpkg - name: Run unit tests @@ -169,4 +169,4 @@ jobs: --build_shared_lib ` --use_openvino CPU ` --use_binskim_compliant_compile_flags ` - --test --enable_onnx_tests + --test --enable_onnx_tests --use_vcpkg From aef241063fb430cb5b77cc41a3f99d1ac242cc02 Mon Sep 17 00:00:00 2001 From: Changming Sun Date: Thu, 12 Jun 2025 15:59:00 -0700 Subject: [PATCH 04/17] update --- cmake/external/abseil-cpp.cmake | 5 +++++ cmake/vcpkg-ports/abseil/portfile.cmake | 1 + 2 files changed, 6 insertions(+) diff --git a/cmake/external/abseil-cpp.cmake b/cmake/external/abseil-cpp.cmake index 513b4556f8d6f..84091ed63c6f1 100644 --- a/cmake/external/abseil-cpp.cmake +++ b/cmake/external/abseil-cpp.cmake @@ -20,6 +20,11 @@ else() endif() endif() +if(Patch_FOUND AND WIN32) + set(ABSL_PATCH_COMMAND ${Patch_EXECUTABLE} --binary --ignore-whitespace -p1 < ${PROJECT_SOURCE_DIR}/patches/abseil/absl_windows.patch) +else() + set(ABSL_PATCH_COMMAND "") +endif() # NB! Advancing Abseil version changes its internal namespace, # currently absl::lts_20250512 which affects abseil-cpp.natvis debugger diff --git a/cmake/vcpkg-ports/abseil/portfile.cmake b/cmake/vcpkg-ports/abseil/portfile.cmake index 812d395620bce..0017b8ef74b40 100644 --- a/cmake/vcpkg-ports/abseil/portfile.cmake +++ b/cmake/vcpkg-ports/abseil/portfile.cmake @@ -8,6 +8,7 @@ vcpkg_from_github( REF "${VERSION}" SHA512 92542db666e0c628cf56bf8ad09412af9c8b622e4f26e72d1e1b092ceec430a5c105f6561e2d9983af565f55da07f67e770cafe373b20cc4cb29a893a6a236fc HEAD_REF master + PATCHES absl_windows.patch ) From 4700e01e41a48ad9abae94274ba02057a9bc734c Mon Sep 17 00:00:00 2001 From: Changming Sun Date: Thu, 12 Jun 2025 16:03:24 -0700 Subject: [PATCH 05/17] update --- cmake/patches/abseil/absl_windows.patch | 35 +++++++++++++++++++++ cmake/vcpkg-ports/abseil/absl_windows.patch | 35 +++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 cmake/patches/abseil/absl_windows.patch create mode 100644 cmake/vcpkg-ports/abseil/absl_windows.patch diff --git a/cmake/patches/abseil/absl_windows.patch b/cmake/patches/abseil/absl_windows.patch new file mode 100644 index 0000000000000..d6591d8e2be0a --- /dev/null +++ b/cmake/patches/abseil/absl_windows.patch @@ -0,0 +1,35 @@ +diff --git a/absl/container/internal/raw_hash_set.h b/absl/container/internal/raw_hash_set.h +index 3effc441..565a5260 100644 +--- a/absl/container/internal/raw_hash_set.h ++++ b/absl/container/internal/raw_hash_set.h +@@ -1121,11 +1121,12 @@ class CommonFields : public CommonFieldsGenerationInfo { + #ifdef NDEBUG + f(); + return; +-#endif ++#else + const size_t cap = capacity(); + set_capacity(InvalidCapacity::kReentrance); + f(); + set_capacity(cap); ++#endif + } + + private: +@@ -3348,7 +3349,7 @@ class raw_hash_set { + void AssertHashEqConsistent(const K& key) { + #ifdef NDEBUG + return; +-#endif ++#else + // If the hash/eq functors are known to be consistent, then skip validation. + if (std::is_same::value && + std::is_same::value) { +@@ -3385,6 +3386,7 @@ class raw_hash_set { + // We only do validation for small tables so that it's constant time. + if (capacity() > 16) return; + IterateOverFullSlots(common(), sizeof(slot_type), assert_consistent); ++#endif + } + + // Attempts to find `key` in the table; if it isn't found, returns an iterator diff --git a/cmake/vcpkg-ports/abseil/absl_windows.patch b/cmake/vcpkg-ports/abseil/absl_windows.patch new file mode 100644 index 0000000000000..d6591d8e2be0a --- /dev/null +++ b/cmake/vcpkg-ports/abseil/absl_windows.patch @@ -0,0 +1,35 @@ +diff --git a/absl/container/internal/raw_hash_set.h b/absl/container/internal/raw_hash_set.h +index 3effc441..565a5260 100644 +--- a/absl/container/internal/raw_hash_set.h ++++ b/absl/container/internal/raw_hash_set.h +@@ -1121,11 +1121,12 @@ class CommonFields : public CommonFieldsGenerationInfo { + #ifdef NDEBUG + f(); + return; +-#endif ++#else + const size_t cap = capacity(); + set_capacity(InvalidCapacity::kReentrance); + f(); + set_capacity(cap); ++#endif + } + + private: +@@ -3348,7 +3349,7 @@ class raw_hash_set { + void AssertHashEqConsistent(const K& key) { + #ifdef NDEBUG + return; +-#endif ++#else + // If the hash/eq functors are known to be consistent, then skip validation. + if (std::is_same::value && + std::is_same::value) { +@@ -3385,6 +3386,7 @@ class raw_hash_set { + // We only do validation for small tables so that it's constant time. + if (capacity() > 16) return; + IterateOverFullSlots(common(), sizeof(slot_type), assert_consistent); ++#endif + } + + // Attempts to find `key` in the table; if it isn't found, returns an iterator From 8ea7663aaae3032046ae6e42118133269578fc81 Mon Sep 17 00:00:00 2001 From: Changming Sun Date: Thu, 12 Jun 2025 16:25:19 -0700 Subject: [PATCH 06/17] update --- cmake/patches/abseil/absl_windows.patch | 21 +++++++++++++++------ cmake/vcpkg-ports/abseil/absl_windows.patch | 21 +++++++++++++++------ 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/cmake/patches/abseil/absl_windows.patch b/cmake/patches/abseil/absl_windows.patch index d6591d8e2be0a..036ead7b88e46 100644 --- a/cmake/patches/abseil/absl_windows.patch +++ b/cmake/patches/abseil/absl_windows.patch @@ -1,5 +1,5 @@ diff --git a/absl/container/internal/raw_hash_set.h b/absl/container/internal/raw_hash_set.h -index 3effc441..565a5260 100644 +index 3effc441..c339e269 100644 --- a/absl/container/internal/raw_hash_set.h +++ b/absl/container/internal/raw_hash_set.h @@ -1121,11 +1121,12 @@ class CommonFields : public CommonFieldsGenerationInfo { @@ -16,20 +16,29 @@ index 3effc441..565a5260 100644 } private: -@@ -3348,7 +3349,7 @@ class raw_hash_set { - void AssertHashEqConsistent(const K& key) { +@@ -3344,11 +3345,14 @@ class raw_hash_set { + + // Asserts that hash and equal functors provided by the user are consistent, + // meaning that `eq(k1, k2)` implies `hash(k1)==hash(k2)`. +- template +- void AssertHashEqConsistent(const K& key) { #ifdef NDEBUG ++ template ++ void AssertHashEqConsistent(const K&) { return; -#endif ++ } +#else ++ template ++ void AssertHashEqConsistent(const K& key) { // If the hash/eq functors are known to be consistent, then skip validation. if (std::is_same::value && std::is_same::value) { -@@ -3385,6 +3386,7 @@ class raw_hash_set { - // We only do validation for small tables so that it's constant time. +@@ -3386,6 +3390,7 @@ class raw_hash_set { if (capacity() > 16) return; IterateOverFullSlots(common(), sizeof(slot_type), assert_consistent); -+#endif } ++#endif // Attempts to find `key` in the table; if it isn't found, returns an iterator + // where the value can be inserted into, with the control byte already set to diff --git a/cmake/vcpkg-ports/abseil/absl_windows.patch b/cmake/vcpkg-ports/abseil/absl_windows.patch index d6591d8e2be0a..036ead7b88e46 100644 --- a/cmake/vcpkg-ports/abseil/absl_windows.patch +++ b/cmake/vcpkg-ports/abseil/absl_windows.patch @@ -1,5 +1,5 @@ diff --git a/absl/container/internal/raw_hash_set.h b/absl/container/internal/raw_hash_set.h -index 3effc441..565a5260 100644 +index 3effc441..c339e269 100644 --- a/absl/container/internal/raw_hash_set.h +++ b/absl/container/internal/raw_hash_set.h @@ -1121,11 +1121,12 @@ class CommonFields : public CommonFieldsGenerationInfo { @@ -16,20 +16,29 @@ index 3effc441..565a5260 100644 } private: -@@ -3348,7 +3349,7 @@ class raw_hash_set { - void AssertHashEqConsistent(const K& key) { +@@ -3344,11 +3345,14 @@ class raw_hash_set { + + // Asserts that hash and equal functors provided by the user are consistent, + // meaning that `eq(k1, k2)` implies `hash(k1)==hash(k2)`. +- template +- void AssertHashEqConsistent(const K& key) { #ifdef NDEBUG ++ template ++ void AssertHashEqConsistent(const K&) { return; -#endif ++ } +#else ++ template ++ void AssertHashEqConsistent(const K& key) { // If the hash/eq functors are known to be consistent, then skip validation. if (std::is_same::value && std::is_same::value) { -@@ -3385,6 +3386,7 @@ class raw_hash_set { - // We only do validation for small tables so that it's constant time. +@@ -3386,6 +3390,7 @@ class raw_hash_set { if (capacity() > 16) return; IterateOverFullSlots(common(), sizeof(slot_type), assert_consistent); -+#endif } ++#endif // Attempts to find `key` in the table; if it isn't found, returns an iterator + // where the value can be inserted into, with the control byte already set to From 685026bdcaa41a7c3bd2bb6b80cc90fbe5cbfece Mon Sep 17 00:00:00 2001 From: Changming Sun Date: Thu, 12 Jun 2025 17:56:11 -0700 Subject: [PATCH 07/17] Update op_builder_helpers.cc --- .../providers/nnapi/nnapi_builtin/builders/op_builder_helpers.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/onnxruntime/core/providers/nnapi/nnapi_builtin/builders/op_builder_helpers.cc b/onnxruntime/core/providers/nnapi/nnapi_builtin/builders/op_builder_helpers.cc index 1c82d5e7452fd..c64a2df1ee8ce 100644 --- a/onnxruntime/core/providers/nnapi/nnapi_builtin/builders/op_builder_helpers.cc +++ b/onnxruntime/core/providers/nnapi/nnapi_builtin/builders/op_builder_helpers.cc @@ -1060,7 +1060,6 @@ Status AddReshapeOperator(ModelBuilder& model_builder, const auto& operand_types(model_builder.GetOperandTypes()); const auto& output = node_unit.Outputs()[0].node_arg.Name(); - const auto input_shape = shaper[input]; const auto output_shape = shaper[output]; // For reshape, the output type should be the same as the input type except the shape is different From 6f6409b7f72bb24be5548c94b461f552bc56b752 Mon Sep 17 00:00:00 2001 From: Changming Sun Date: Tue, 17 Jun 2025 12:07:55 -0700 Subject: [PATCH 08/17] update --- .../build_check_binsize_config/android_minimal_baseline.config | 2 ++ .../nnapi_minimal_build_minimal_ort_and_run_tests.sh | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/ci_build/github/linux/ort_minimal/build_check_binsize_config/android_minimal_baseline.config b/tools/ci_build/github/linux/ort_minimal/build_check_binsize_config/android_minimal_baseline.config index 3f1691f47e706..4cee9879babbc 100644 --- a/tools/ci_build/github/linux/ort_minimal/build_check_binsize_config/android_minimal_baseline.config +++ b/tools/ci_build/github/linux/ort_minimal/build_check_binsize_config/android_minimal_baseline.config @@ -3,6 +3,8 @@ "os": "android", "arch": "arm64-v8a", "build_params": [ + "--use_vcpkg", + "--use_vcpkg_ms_internal_asset_cache", "--enable_lto", "--android", "--android_sdk_path=/android_home", diff --git a/tools/ci_build/github/linux/ort_minimal/nnapi_minimal_build_minimal_ort_and_run_tests.sh b/tools/ci_build/github/linux/ort_minimal/nnapi_minimal_build_minimal_ort_and_run_tests.sh index 02f89f4e91e5c..1d9d7f43fd10d 100755 --- a/tools/ci_build/github/linux/ort_minimal/nnapi_minimal_build_minimal_ort_and_run_tests.sh +++ b/tools/ci_build/github/linux/ort_minimal/nnapi_minimal_build_minimal_ort_and_run_tests.sh @@ -34,7 +34,7 @@ python3 $ORT_ROOT/tools/ci_build/build.py \ --disable_ml_ops \ --disable_exceptions \ --include_ops_by_config $ORT_ROOT/onnxruntime/test/testdata/required_ops_and_types.config \ - --skip_tests + --skip_tests --use_vcpkg --use_vcpkg_ms_internal_asset_cache # Push onnxruntime_test_all and testdata to emulator adb push $MIN_BUILD_DIR/Debug/onnxruntime_test_all /data/local/tmp/ From fcace951200d03714e9722f2046a8d6c7f43938e Mon Sep 17 00:00:00 2001 From: Changming Sun Date: Tue, 17 Jun 2025 17:38:32 -0700 Subject: [PATCH 09/17] Update resize.h --- onnxruntime/core/providers/js/operators/resize.h | 1 - 1 file changed, 1 deletion(-) diff --git a/onnxruntime/core/providers/js/operators/resize.h b/onnxruntime/core/providers/js/operators/resize.h index 3e8ccf40753c8..bf04bbd3825c3 100644 --- a/onnxruntime/core/providers/js/operators/resize.h +++ b/onnxruntime/core/providers/js/operators/resize.h @@ -107,7 +107,6 @@ class Resize : public JsKernel, public UpsampleBase { } virtual Status SerializeCustomData(OpKernelContext* context, AllocatorPtr alloc, void** ptr, size_t* size) const { - TensorShapeVector output_dims; std::vector roi_array; std::vector scales_array; From 7638f251f437d7d771ca8b283584e96b47f40483 Mon Sep 17 00:00:00 2001 From: Changming Sun Date: Tue, 17 Jun 2025 17:40:38 -0700 Subject: [PATCH 10/17] delete windows_x86.yml --- .github/workflows/windows_x86.yml | 128 ------------------------------ 1 file changed, 128 deletions(-) delete mode 100644 .github/workflows/windows_x86.yml diff --git a/.github/workflows/windows_x86.yml b/.github/workflows/windows_x86.yml deleted file mode 100644 index 507eacf21cc5a..0000000000000 --- a/.github/workflows/windows_x86.yml +++ /dev/null @@ -1,128 +0,0 @@ -name: Windows CPU CI Pipeline - -on: - push: - branches: [main, 'rel-*'] - pull_request: - branches: [main] - workflow_dispatch: - -concurrency: - group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.ref || github.sha }} - cancel-in-progress: true - -jobs: - build_x86_release: - runs-on: ["self-hosted", "1ES.Pool=onnxruntime-github-vs2022-mms"] - timeout-minutes: 300 - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - submodules: false - - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: '3.12' - architecture: x86 # x86 Python - - - name: Locate vcvarsall and Setup Env - uses: ./.github/actions/locate-vcvarsall-and-setup-env - with: - architecture: x86 # x86 architecture for vcvarsall - - - name: Install python modules - shell: cmd - run: python -m pip install -r "${{ github.workspace }}\tools\ci_build\github\windows\python\requirements.txt" - - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: '20.x' - architecture: x86 #Add architecture - - - name: Setup Java - uses: actions/setup-java@v4 - with: - distribution: 'temurin' - java-version: '17' - architecture: x86 # x86 Java - - - name: API Documentation Check and generate - shell: cmd - run: | - set ORT_DOXY_SRC=${{ github.workspace }} - set ORT_DOXY_OUT=${{ github.workspace }}\build\RelWithDebInfo\RelWithDebInfo - mkdir %ORT_DOXY_SRC% - mkdir %ORT_DOXY_OUT% - "C:\Program Files\doxygen\bin\doxygen.exe" ${{ github.workspace }}\tools\ci_build\github\Doxyfile_csharp.cfg - working-directory: ${{ github.workspace }} - - - name: Use .NET 8.x - uses: actions/setup-dotnet@v4 - with: - dotnet-version: '8.x' - env: - PROCESSOR_ARCHITECTURE: x86 # x86 .NET - - - name: Use Nuget 6.x - uses: nuget/setup-nuget@v2 - with: - nuget-version: '6.x' - - - name: NuGet restore - shell: cmd - run: | - nuget restore ${{ github.workspace }}\packages.config -PackagesDirectory ${{ github.workspace }}\build\RelWithDebInfo -ConfigFile ${{ github.workspace }}\NuGet.config - - - name: Export GitHub Actions cache environment variables - uses: actions/github-script@v7 - with: - script: | - core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); - core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); - - - name: Build and Test - shell: pwsh - run: | - python.exe "${{ github.workspace }}\tools\ci_build\build.py" --config RelWithDebInfo --build_dir "${{ github.workspace }}\build" --skip_submodule_sync --build_csharp --parallel --use_binskim_compliant_compile_flags --cmake_generator "Visual Studio 17 2022" --build_shared_lib --enable_onnx_tests --build_wheel --msbuild_extra_options "IncludeMobileTargets=false" --build_nuget --use_vcpkg --use_vcpkg_ms_internal_asset_cache - if ($LASTEXITCODE -ne 0) { - exit $LASTEXITCODE - } - Remove-Item "${{ github.workspace }}\build\RelWithDebInfo" -Include "*.obj" -Recurse - env: - ALLOW_RELEASED_ONNX_OPSET_ONLY: '0' - DocUpdateNeeded: 'false' - - - name: Validate C# native delegates - shell: cmd - run: python tools\ValidateNativeDelegateAttributes.py - working-directory: ${{ github.workspace }}\\csharp - - - name: Install onnxruntime wheel - shell: pwsh - run: | - python -m pip uninstall -y onnxruntime onnxruntime-gpu onnxruntime-training onnxruntime-directml -qq - Get-ChildItem -Path dist/*.whl | foreach {pip --disable-pip-version-check install --upgrade $_.fullname} - working-directory: "${{ github.workspace }}\\build\\RelWithDebInfo\\RelWithDebInfo" - - - name: Publish OperatorKernels.md (Conditional) - uses: actions/upload-artifact@v4 - if: failure() && env.DocUpdateNeeded == 'true' - with: - name: OperatorKernels.md - path: ${{ github.workspace }}/docs/OperatorKernels.md - - - name: Publish ContribOperators.md (Conditional) - uses: actions/upload-artifact@v4 - if: failure() && env.DocUpdateNeeded == 'true' - with: - name: ContribOperators.md - path: ${{ github.workspace }}/docs/ContribOperators.md - - env: - OrtPackageId: Microsoft.ML.OnnxRuntime - OnnxRuntimeBuildDirectory: ${{ github.workspace }}\build - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 'true' From 8cf7692dd210dad48d5e4f1d69476e6456696a0a Mon Sep 17 00:00:00 2001 From: Changming Sun Date: Wed, 18 Jun 2025 17:23:01 +0000 Subject: [PATCH 11/17] update --- cmake/onnxruntime_common.cmake | 14 ++++++-------- cmake/onnxruntime_lora.cmake | 3 +-- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/cmake/onnxruntime_common.cmake b/cmake/onnxruntime_common.cmake index 1e26eede8a66f..5dcc2b2628bf4 100644 --- a/cmake/onnxruntime_common.cmake +++ b/cmake/onnxruntime_common.cmake @@ -120,16 +120,14 @@ if (onnxruntime_USE_MIMALLOC) target_link_libraries(onnxruntime_common PRIVATE onnxruntime_mimalloc_shim) endif() -if(NOT onnxruntime_DISABLE_ABSEIL) - target_include_directories(onnxruntime_common PRIVATE ${ABSEIL_SOURCE_DIR}) - if (MSVC) - set(ABSEIL_NATVIS_FILE "abseil-cpp.natvis") - target_sources( - onnxruntime_common - INTERFACE $) - endif() +if (MSVC) + set(ABSEIL_NATVIS_FILE "abseil-cpp.natvis") + target_sources( + onnxruntime_common + INTERFACE $) endif() + if (MSVC) set(EIGEN_NATVIS_FILE ${eigen_SOURCE_DIR}/debug/msvc/eigen.natvis) if (EXISTS ${EIGEN_NATVIS_FILE}) diff --git a/cmake/onnxruntime_lora.cmake b/cmake/onnxruntime_lora.cmake index 26ee21c645584..e0579f571e1e0 100644 --- a/cmake/onnxruntime_lora.cmake +++ b/cmake/onnxruntime_lora.cmake @@ -10,8 +10,7 @@ file(GLOB onnxruntime_lora_srcs CONFIGURE_DEPENDS source_group(TREE ${REPO_ROOT} FILES ${onnxruntime_lora_srcs}) onnxruntime_add_static_library(onnxruntime_lora ${onnxruntime_lora_srcs}) -onnxruntime_add_include_to_target(onnxruntime_lora onnx flatbuffers::flatbuffers Boost::mp11 ${GSL_TARGET}) -target_link_libraries(onnxruntime_lora onnxruntime_framework) +onnxruntime_add_include_to_target(onnxruntime_lora onnxruntime_framework onnxruntime_common onnx flatbuffers::flatbuffers Boost::mp11 ${GSL_TARGET}) if(onnxruntime_ENABLE_INSTRUMENT) target_compile_definitions(onnxruntime_lora PUBLIC ONNXRUNTIME_ENABLE_INSTRUMENT) From 7a39f639cc77ae40251752dad0cc8bfa807eb02f Mon Sep 17 00:00:00 2001 From: Changming Sun Date: Wed, 18 Jun 2025 17:29:03 +0000 Subject: [PATCH 12/17] update --- .../build_check_binsize_config/android_minimal_baseline.config | 2 -- 1 file changed, 2 deletions(-) diff --git a/tools/ci_build/github/linux/ort_minimal/build_check_binsize_config/android_minimal_baseline.config b/tools/ci_build/github/linux/ort_minimal/build_check_binsize_config/android_minimal_baseline.config index 4cee9879babbc..3f1691f47e706 100644 --- a/tools/ci_build/github/linux/ort_minimal/build_check_binsize_config/android_minimal_baseline.config +++ b/tools/ci_build/github/linux/ort_minimal/build_check_binsize_config/android_minimal_baseline.config @@ -3,8 +3,6 @@ "os": "android", "arch": "arm64-v8a", "build_params": [ - "--use_vcpkg", - "--use_vcpkg_ms_internal_asset_cache", "--enable_lto", "--android", "--android_sdk_path=/android_home", From 2233d4a0be397f9fdbf0451b39d24225ae9b784e Mon Sep 17 00:00:00 2001 From: Changming Sun Date: Wed, 18 Jun 2025 17:29:06 +0000 Subject: [PATCH 13/17] update --- tools/ci_build/build.py | 10 +--------- tools/ci_build/build_args.py | 5 ----- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/tools/ci_build/build.py b/tools/ci_build/build.py index 4c1ddd94fda5a..2e51b5067a975 100644 --- a/tools/ci_build/build.py +++ b/tools/ci_build/build.py @@ -670,12 +670,8 @@ def generate_build_tree( target_arch = "ARM64" elif args.arm64ec: target_arch = "ARM64EC" - cpu_arch = platform.architecture()[0] if target_arch == "AMD64": - if cpu_arch == "32bit" or args.x86: - triplet = "x86-windows-static" if args.enable_msvc_static_runtime else "x86-windows-static-md" - else: - triplet = "x64-windows-static" if args.enable_msvc_static_runtime else "x64-windows-static-md" + triplet = "x64-windows-static" if args.enable_msvc_static_runtime else "x64-windows-static-md" elif target_arch == "ARM64": triplet = "arm64-windows-static" if args.enable_msvc_static_runtime else "arm64-windows-static-md" elif target_arch == "ARM64EC": @@ -2433,10 +2429,6 @@ def main(): else: target_arch = platform.machine() if target_arch == "AMD64": - if cpu_arch == "32bit" or args.x86: - target_arch = "Win32" - else: - target_arch = "x64" host_arch = "x64" elif target_arch == "ARM64": host_arch = "ARM64" diff --git a/tools/ci_build/build_args.py b/tools/ci_build/build_args.py index 561eab7f2d61d..685154bb2e091 100644 --- a/tools/ci_build/build_args.py +++ b/tools/ci_build/build_args.py @@ -400,11 +400,6 @@ def add_windows_specific_args(parser: argparse.ArgumentParser) -> None: parser.add_argument("--caller_framework", type=str, help="Name of the framework calling ONNX Runtime.") # Cross-compilation targets hosted on Windows - parser.add_argument( - "--x86", - action="store_true", - help="[Windows cross-compiling] Target Windows x86.", - ) parser.add_argument( "--arm", action="store_true", From 41321d154fce361e7d2ad0fb268947fa8f727e7f Mon Sep 17 00:00:00 2001 From: Changming Sun Date: Wed, 18 Jun 2025 16:53:17 -0700 Subject: [PATCH 14/17] udpate --- tools/ci_build/build.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/ci_build/build.py b/tools/ci_build/build.py index 2e51b5067a975..e654b3ac6d106 100644 --- a/tools/ci_build/build.py +++ b/tools/ci_build/build.py @@ -2429,6 +2429,7 @@ def main(): else: target_arch = platform.machine() if target_arch == "AMD64": + target_arch = "x64" host_arch = "x64" elif target_arch == "ARM64": host_arch = "ARM64" From 9edb6ce47c51ee917686fd5c01b2c524bf926909 Mon Sep 17 00:00:00 2001 From: Changming Sun Date: Wed, 18 Jun 2025 18:24:12 -0700 Subject: [PATCH 15/17] revert --- cmake/external/abseil-cpp.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/external/abseil-cpp.cmake b/cmake/external/abseil-cpp.cmake index 84091ed63c6f1..eede60a4a977a 100644 --- a/cmake/external/abseil-cpp.cmake +++ b/cmake/external/abseil-cpp.cmake @@ -35,6 +35,7 @@ onnxruntime_fetchcontent_declare( URL ${DEP_URL_abseil_cpp} URL_HASH SHA1=${DEP_SHA1_abseil_cpp} EXCLUDE_FROM_ALL + PATCH_COMMAND ${ABSL_PATCH_COMMAND} FIND_PACKAGE_ARGS 20250512 NAMES absl ) From fc9fcb20b5d1161fc2482707b3f46675b39fa40c Mon Sep 17 00:00:00 2001 From: Changming Sun Date: Thu, 19 Jun 2025 13:32:25 -0700 Subject: [PATCH 16/17] revert --- .github/workflows/windows_openvino.yml | 6 +- .github/workflows/windows_x86.yml | 128 +++++++++++++++++++++++++ tools/ci_build/build.py | 11 ++- tools/ci_build/build_args.py | 5 + 4 files changed, 145 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/windows_x86.yml diff --git a/.github/workflows/windows_openvino.yml b/.github/workflows/windows_openvino.yml index 56897b756a6e1..f38fcdae57a35 100644 --- a/.github/workflows/windows_openvino.yml +++ b/.github/workflows/windows_openvino.yml @@ -149,13 +149,13 @@ jobs: shell: pwsh working-directory: ${{ runner.temp }} run: | - python.exe ${{ github.workspace }}\tools\ci_build\build.py --config ${{ env.BuildConfig }} --build_dir build --cmake_generator "Visual Studio 17 2022" --build_shared_lib --use_openvino CPU --use_binskim_compliant_compile_flags --update --parallel --use_vcpkg + python.exe ${{ github.workspace }}\tools\ci_build\build.py --config ${{ env.BuildConfig }} --build_dir build --cmake_generator "Visual Studio 17 2022" --build_shared_lib --use_openvino CPU --use_binskim_compliant_compile_flags --update --parallel - name: Build shell: pwsh working-directory: ${{ runner.temp }} run: | - python.exe ${{ github.workspace }}\tools\ci_build\build.py --config ${{ env.BuildConfig }} --build_dir build --cmake_generator "Visual Studio 17 2022" --build_shared_lib --use_openvino CPU --use_binskim_compliant_compile_flags --build --parallel --use_vcpkg + python.exe ${{ github.workspace }}\tools\ci_build\build.py --config ${{ env.BuildConfig }} --build_dir build --cmake_generator "Visual Studio 17 2022" --build_shared_lib --use_openvino CPU --use_binskim_compliant_compile_flags --build --parallel - name: Run unit tests @@ -169,4 +169,4 @@ jobs: --build_shared_lib ` --use_openvino CPU ` --use_binskim_compliant_compile_flags ` - --test --enable_onnx_tests --use_vcpkg + --test --enable_onnx_tests diff --git a/.github/workflows/windows_x86.yml b/.github/workflows/windows_x86.yml new file mode 100644 index 0000000000000..507eacf21cc5a --- /dev/null +++ b/.github/workflows/windows_x86.yml @@ -0,0 +1,128 @@ +name: Windows CPU CI Pipeline + +on: + push: + branches: [main, 'rel-*'] + pull_request: + branches: [main] + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.ref || github.sha }} + cancel-in-progress: true + +jobs: + build_x86_release: + runs-on: ["self-hosted", "1ES.Pool=onnxruntime-github-vs2022-mms"] + timeout-minutes: 300 + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: false + + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + architecture: x86 # x86 Python + + - name: Locate vcvarsall and Setup Env + uses: ./.github/actions/locate-vcvarsall-and-setup-env + with: + architecture: x86 # x86 architecture for vcvarsall + + - name: Install python modules + shell: cmd + run: python -m pip install -r "${{ github.workspace }}\tools\ci_build\github\windows\python\requirements.txt" + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20.x' + architecture: x86 #Add architecture + + - name: Setup Java + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '17' + architecture: x86 # x86 Java + + - name: API Documentation Check and generate + shell: cmd + run: | + set ORT_DOXY_SRC=${{ github.workspace }} + set ORT_DOXY_OUT=${{ github.workspace }}\build\RelWithDebInfo\RelWithDebInfo + mkdir %ORT_DOXY_SRC% + mkdir %ORT_DOXY_OUT% + "C:\Program Files\doxygen\bin\doxygen.exe" ${{ github.workspace }}\tools\ci_build\github\Doxyfile_csharp.cfg + working-directory: ${{ github.workspace }} + + - name: Use .NET 8.x + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '8.x' + env: + PROCESSOR_ARCHITECTURE: x86 # x86 .NET + + - name: Use Nuget 6.x + uses: nuget/setup-nuget@v2 + with: + nuget-version: '6.x' + + - name: NuGet restore + shell: cmd + run: | + nuget restore ${{ github.workspace }}\packages.config -PackagesDirectory ${{ github.workspace }}\build\RelWithDebInfo -ConfigFile ${{ github.workspace }}\NuGet.config + + - name: Export GitHub Actions cache environment variables + uses: actions/github-script@v7 + with: + script: | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); + + - name: Build and Test + shell: pwsh + run: | + python.exe "${{ github.workspace }}\tools\ci_build\build.py" --config RelWithDebInfo --build_dir "${{ github.workspace }}\build" --skip_submodule_sync --build_csharp --parallel --use_binskim_compliant_compile_flags --cmake_generator "Visual Studio 17 2022" --build_shared_lib --enable_onnx_tests --build_wheel --msbuild_extra_options "IncludeMobileTargets=false" --build_nuget --use_vcpkg --use_vcpkg_ms_internal_asset_cache + if ($LASTEXITCODE -ne 0) { + exit $LASTEXITCODE + } + Remove-Item "${{ github.workspace }}\build\RelWithDebInfo" -Include "*.obj" -Recurse + env: + ALLOW_RELEASED_ONNX_OPSET_ONLY: '0' + DocUpdateNeeded: 'false' + + - name: Validate C# native delegates + shell: cmd + run: python tools\ValidateNativeDelegateAttributes.py + working-directory: ${{ github.workspace }}\\csharp + + - name: Install onnxruntime wheel + shell: pwsh + run: | + python -m pip uninstall -y onnxruntime onnxruntime-gpu onnxruntime-training onnxruntime-directml -qq + Get-ChildItem -Path dist/*.whl | foreach {pip --disable-pip-version-check install --upgrade $_.fullname} + working-directory: "${{ github.workspace }}\\build\\RelWithDebInfo\\RelWithDebInfo" + + - name: Publish OperatorKernels.md (Conditional) + uses: actions/upload-artifact@v4 + if: failure() && env.DocUpdateNeeded == 'true' + with: + name: OperatorKernels.md + path: ${{ github.workspace }}/docs/OperatorKernels.md + + - name: Publish ContribOperators.md (Conditional) + uses: actions/upload-artifact@v4 + if: failure() && env.DocUpdateNeeded == 'true' + with: + name: ContribOperators.md + path: ${{ github.workspace }}/docs/ContribOperators.md + + env: + OrtPackageId: Microsoft.ML.OnnxRuntime + OnnxRuntimeBuildDirectory: ${{ github.workspace }}\build + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 'true' diff --git a/tools/ci_build/build.py b/tools/ci_build/build.py index e654b3ac6d106..4c1ddd94fda5a 100644 --- a/tools/ci_build/build.py +++ b/tools/ci_build/build.py @@ -670,8 +670,12 @@ def generate_build_tree( target_arch = "ARM64" elif args.arm64ec: target_arch = "ARM64EC" + cpu_arch = platform.architecture()[0] if target_arch == "AMD64": - triplet = "x64-windows-static" if args.enable_msvc_static_runtime else "x64-windows-static-md" + if cpu_arch == "32bit" or args.x86: + triplet = "x86-windows-static" if args.enable_msvc_static_runtime else "x86-windows-static-md" + else: + triplet = "x64-windows-static" if args.enable_msvc_static_runtime else "x64-windows-static-md" elif target_arch == "ARM64": triplet = "arm64-windows-static" if args.enable_msvc_static_runtime else "arm64-windows-static-md" elif target_arch == "ARM64EC": @@ -2429,7 +2433,10 @@ def main(): else: target_arch = platform.machine() if target_arch == "AMD64": - target_arch = "x64" + if cpu_arch == "32bit" or args.x86: + target_arch = "Win32" + else: + target_arch = "x64" host_arch = "x64" elif target_arch == "ARM64": host_arch = "ARM64" diff --git a/tools/ci_build/build_args.py b/tools/ci_build/build_args.py index 685154bb2e091..561eab7f2d61d 100644 --- a/tools/ci_build/build_args.py +++ b/tools/ci_build/build_args.py @@ -400,6 +400,11 @@ def add_windows_specific_args(parser: argparse.ArgumentParser) -> None: parser.add_argument("--caller_framework", type=str, help="Name of the framework calling ONNX Runtime.") # Cross-compilation targets hosted on Windows + parser.add_argument( + "--x86", + action="store_true", + help="[Windows cross-compiling] Target Windows x86.", + ) parser.add_argument( "--arm", action="store_true", From b97051b55770ba133aa02277a4d3ef3ae93078ce Mon Sep 17 00:00:00 2001 From: Changming Sun Date: Thu, 19 Jun 2025 15:38:02 -0700 Subject: [PATCH 17/17] update --- .github/workflows/windows_x86.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/windows_x86.yml b/.github/workflows/windows_x86.yml index 507eacf21cc5a..4652757c1d292 100644 --- a/.github/workflows/windows_x86.yml +++ b/.github/workflows/windows_x86.yml @@ -87,7 +87,7 @@ jobs: - name: Build and Test shell: pwsh run: | - python.exe "${{ github.workspace }}\tools\ci_build\build.py" --config RelWithDebInfo --build_dir "${{ github.workspace }}\build" --skip_submodule_sync --build_csharp --parallel --use_binskim_compliant_compile_flags --cmake_generator "Visual Studio 17 2022" --build_shared_lib --enable_onnx_tests --build_wheel --msbuild_extra_options "IncludeMobileTargets=false" --build_nuget --use_vcpkg --use_vcpkg_ms_internal_asset_cache + python.exe "${{ github.workspace }}\tools\ci_build\build.py" --config RelWithDebInfo --build_dir "${{ github.workspace }}\build" --skip_submodule_sync --build_csharp --parallel --use_binskim_compliant_compile_flags --cmake_generator "Visual Studio 17 2022" --build_shared_lib --enable_onnx_tests --build_wheel --msbuild_extra_options "IncludeMobileTargets=false" --build_nuget --compile_no_warning_as_error --use_vcpkg --use_vcpkg_ms_internal_asset_cache if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }