Skip to content

Commit bc95e99

Browse files
authored
Update abseil (microsoft#25033)
1. Updated abseil to the latest version, which fixed all BinSkim warnings so that we no longer need to patch it. 2. However, the new abseil itself has some extra warnings, so I have to patch it. 3. Added "--compile_no_warning_as_error" to windows 32-bit build. I will fix the warnings later.
1 parent 2c041e0 commit bc95e99

File tree

14 files changed

+95
-351
lines changed

14 files changed

+95
-351
lines changed

.github/workflows/windows_x86.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ jobs:
8787
- name: Build and Test
8888
shell: pwsh
8989
run: |
90-
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
90+
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
9191
if ($LASTEXITCODE -ne 0) {
9292
exit $LASTEXITCODE
9393
}

cmake/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1336,7 +1336,7 @@ function(onnxruntime_configure_target target_name)
13361336
if(WIN32 AND onnxruntime_ENABLE_STATIC_ANALYSIS AND onnxruntime_USE_CUSTOM_STATIC_ANALYSIS_RULES)
13371337
set_target_properties(${target_name} PROPERTIES VS_USER_PROPS ${PROJECT_SOURCE_DIR}/EnableVisualStudioCodeAnalysis.props)
13381338
endif()
1339-
target_include_directories(${target_name} PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${ONNXRUNTIME_ROOT} ${abseil_cpp_SOURCE_DIR})
1339+
target_include_directories(${target_name} PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${ONNXRUNTIME_ROOT})
13401340
if (onnxruntime_ENABLE_TRAINING_OPS)
13411341
target_include_directories(${target_name} PRIVATE ${ORTTRAINING_ROOT})
13421342
endif()

cmake/deps.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#since the file contains a version string: "lts_20230802". However, the file is for debugging purposes only and would
1010
#not affect built binaries.
1111
#
12-
abseil_cpp;https://github.com/abseil/abseil-cpp/archive/refs/tags/20240722.0.zip;36ee53eb1466fb6e593fc5c286680de31f8a494a
12+
abseil_cpp;https://github.com/abseil/abseil-cpp/archive/refs/tags/20250512.0.zip;3d6ff7e7ce144d9a53a53bef1f1bf79e1da4b8e1
1313
coremltools;https://github.com/apple/coremltools/archive/refs/tags/7.1.zip;f1bab0f30966f2e217d8e01207d518f230a1641a
1414
cxxopts;https://github.com/jarro2783/cxxopts/archive/3c73d91c0b04e2b59462f0a741be8c07024c1bc0.zip;6c6ca7f8480b26c8d00476e0e24b7184717fe4f0
1515
date;https://github.com/HowardHinnant/date/archive/refs/tags/v3.0.1.zip;2dac0c81dc54ebdd8f8d073a75c053b04b56e159

cmake/external/abseil-cpp.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ else()
2727
endif()
2828

2929
# NB! Advancing Abseil version changes its internal namespace,
30-
# currently absl::lts_20240116 which affects abseil-cpp.natvis debugger
30+
# currently absl::lts_20250512 which affects abseil-cpp.natvis debugger
3131
# visualization file, that must be adjusted accordingly, unless we eliminate
3232
# that namespace at build time.
3333
onnxruntime_fetchcontent_declare(
@@ -36,7 +36,7 @@ onnxruntime_fetchcontent_declare(
3636
URL_HASH SHA1=${DEP_SHA1_abseil_cpp}
3737
EXCLUDE_FROM_ALL
3838
PATCH_COMMAND ${ABSL_PATCH_COMMAND}
39-
FIND_PACKAGE_ARGS 20240722 NAMES absl
39+
FIND_PACKAGE_ARGS 20250512 NAMES absl
4040
)
4141

4242
onnxruntime_fetchcontent_makeavailable(abseil_cpp)

cmake/external/abseil-cpp.natvis

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
3-
<Type Name="absl::lts_20240722::InlinedVector&lt;*&gt;">
3+
<Type Name="absl::lts_20250512::InlinedVector&lt;*&gt;">
44
<Intrinsic Name="_size" Expression="storage_.metadata_.value >> 1"/>
55
<Intrinsic Name="_is_allocated" Expression="(storage_.metadata_.value &amp; 1) == 1"/>
66
<Intrinsic Name="_inlined_data" Expression="($T1*)storage_.data_.inlined.inlined_data"/>
@@ -24,7 +24,7 @@
2424
</Expand>
2525
</Type>
2626
<!-- Should handle both flat hash_set and hash_map -->
27-
<Type Name="absl::lts_20240116::container_internal::raw_hash_set&lt;*&gt;">
27+
<Type Name="absl::lts_20250512::container_internal::raw_hash_set&lt;*&gt;">
2828
<Intrinsic Name="_commonfields" Expression="settings_.value"/>
2929
<Intrinsic Name="_size" Expression="settings_.value.compressed_tuple_.value"/>
3030
<Intrinsic Name="_capacity" Expression="_commonfields().capacity_"/>
@@ -51,7 +51,7 @@
5151
</Type>
5252

5353
<!-- Primitive types stored as a value -->
54-
<Type Name="absl::lts_20240116::container_internal::Storage&lt;*,*,0&gt;">
54+
<Type Name="absl::lts_20250512::container_internal::Storage&lt;*,*,0&gt;">
5555
<DisplayString IncludeView="noparens">*($T1 *){value}</DisplayString>
5656
<DisplayString ExcludeView="noparens">(*($T1 *){value})</DisplayString>
5757
<Expand>
@@ -60,15 +60,15 @@
6060
</Type>
6161

6262
<!-- For storage inherited from the type -->
63-
<Type Name="absl::lts_20240116::container_internal::Storage&lt;*,*,1&gt;">
63+
<Type Name="absl::lts_20250512::container_internal::Storage&lt;*,*,1&gt;">
6464
<DisplayString IncludeView="noparens">*($T1 *)this</DisplayString>
6565
<DisplayString ExcludeView="noparens">(*($T1 *)this)</DisplayString>
6666
<Expand>
6767
<ExpandedItem>*($T1 *)this</ExpandedItem>
6868
</Expand>
6969
</Type>
7070

71-
<Type Name="absl::lts_20240116::container_internal::map_slot_type&lt;*&gt;">
71+
<Type Name="absl::lts_20250512::container_internal::map_slot_type&lt;*&gt;">
7272
<DisplayString IncludeView="noparens">{value.first}, {value.second}</DisplayString>
7373
<DisplayString ExcludeView="noparens">({value.first}, {value.second})</DisplayString>
7474
<Expand>

cmake/onnxruntime_common.cmake

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,16 +120,14 @@ if (onnxruntime_USE_MIMALLOC)
120120
target_link_libraries(onnxruntime_common PRIVATE onnxruntime_mimalloc_shim)
121121
endif()
122122

123-
if(NOT onnxruntime_DISABLE_ABSEIL)
124-
target_include_directories(onnxruntime_common PRIVATE ${ABSEIL_SOURCE_DIR})
125-
if (MSVC)
126-
set(ABSEIL_NATVIS_FILE "abseil-cpp.natvis")
127-
target_sources(
128-
onnxruntime_common
129-
INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/external/${ABSEIL_NATVIS_FILE}>)
130-
endif()
123+
if (MSVC)
124+
set(ABSEIL_NATVIS_FILE "abseil-cpp.natvis")
125+
target_sources(
126+
onnxruntime_common
127+
INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/external/${ABSEIL_NATVIS_FILE}>)
131128
endif()
132129

130+
133131
if (MSVC)
134132
set(EIGEN_NATVIS_FILE ${eigen_SOURCE_DIR}/debug/msvc/eigen.natvis)
135133
if (EXISTS ${EIGEN_NATVIS_FILE})

cmake/onnxruntime_lora.cmake

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ file(GLOB onnxruntime_lora_srcs CONFIGURE_DEPENDS
1010
source_group(TREE ${REPO_ROOT} FILES ${onnxruntime_lora_srcs})
1111

1212
onnxruntime_add_static_library(onnxruntime_lora ${onnxruntime_lora_srcs})
13-
onnxruntime_add_include_to_target(onnxruntime_lora onnx flatbuffers::flatbuffers Boost::mp11 ${GSL_TARGET})
14-
target_link_libraries(onnxruntime_lora onnxruntime_framework)
13+
onnxruntime_add_include_to_target(onnxruntime_lora onnxruntime_framework onnxruntime_common onnx flatbuffers::flatbuffers Boost::mp11 ${GSL_TARGET})
1514

1615
if(onnxruntime_ENABLE_INSTRUMENT)
1716
target_compile_definitions(onnxruntime_lora PUBLIC ONNXRUNTIME_ENABLE_INSTRUMENT)
Lines changed: 37 additions & 156 deletions
Original file line numberDiff line numberDiff line change
@@ -1,163 +1,44 @@
1-
diff --git a/absl/base/attributes.h b/absl/base/attributes.h
2-
index 5ea5ee3e..f4949898 100644
3-
--- a/absl/base/attributes.h
4-
+++ b/absl/base/attributes.h
5-
@@ -559,7 +559,7 @@
6-
#undef ABSL_ATTRIBUTE_UNUSED
7-
#define ABSL_ATTRIBUTE_UNUSED __attribute__((__unused__))
8-
#else
9-
-#define ABSL_ATTRIBUTE_UNUSED
10-
+#define ABSL_ATTRIBUTE_UNUSED [[maybe_unused]]
11-
#endif
12-
13-
// ABSL_ATTRIBUTE_INITIAL_EXEC
141
diff --git a/absl/container/internal/raw_hash_set.h b/absl/container/internal/raw_hash_set.h
15-
index d4fe8f5c..27418d13 100644
2+
index 3effc441..c339e269 100644
163
--- a/absl/container/internal/raw_hash_set.h
174
+++ b/absl/container/internal/raw_hash_set.h
18-
@@ -1924,7 +1924,7 @@ HashtablezInfoHandle SampleHashtablezInfo(size_t sizeof_slot, size_t sizeof_key,
19-
// In SOO, we sample on the first insertion so if this is an empty SOO case
20-
// (e.g. when reserve is called), then we still need to sample.
21-
if (kSooEnabled && was_soo && c.size() == 0) {
22-
- return Sample(sizeof_slot, sizeof_key, sizeof_value, SooCapacity());
23-
+ return Sample(sizeof_slot, sizeof_key, sizeof_value, (int16_t)SooCapacity());
24-
}
25-
// For non-SOO cases, we sample whenever the capacity is increasing from zero
26-
// to non-zero.
27-
@@ -3525,7 +3525,7 @@ class raw_hash_set {
28-
assert(is_soo());
29-
if (!ShouldSampleHashtablezInfo<CharAlloc>()) return HashtablezInfoHandle{};
30-
return Sample(sizeof(slot_type), sizeof(key_type), sizeof(value_type),
31-
- SooCapacity());
32-
+ (int16_t)SooCapacity());
5+
@@ -1121,11 +1121,12 @@ class CommonFields : public CommonFieldsGenerationInfo {
6+
#ifdef NDEBUG
7+
f();
8+
return;
9+
-#endif
10+
+#else
11+
const size_t cap = capacity();
12+
set_capacity(InvalidCapacity::kReentrance);
13+
f();
14+
set_capacity(cap);
15+
+#endif
3316
}
3417

35-
inline void destroy_slots() {
36-
diff --git a/absl/copts/GENERATED_AbseilCopts.cmake b/absl/copts/GENERATED_AbseilCopts.cmake
37-
index da2282fe..4c7fc26f 100644
38-
--- a/absl/copts/GENERATED_AbseilCopts.cmake
39-
+++ b/absl/copts/GENERATED_AbseilCopts.cmake
40-
@@ -181,8 +181,6 @@ list(APPEND ABSL_MSVC_FLAGS
41-
"/wd4005"
42-
"/wd4068"
43-
"/wd4180"
44-
- "/wd4244"
45-
- "/wd4267"
46-
"/wd4503"
47-
"/wd4800"
48-
"/DNOMINMAX"
49-
diff --git a/absl/copts/GENERATED_copts.bzl b/absl/copts/GENERATED_copts.bzl
50-
index b9e0071e..dd8410ec 100644
51-
--- a/absl/copts/GENERATED_copts.bzl
52-
+++ b/absl/copts/GENERATED_copts.bzl
53-
@@ -182,8 +182,6 @@ ABSL_MSVC_FLAGS = [
54-
"/wd4005",
55-
"/wd4068",
56-
"/wd4180",
57-
- "/wd4244",
58-
- "/wd4267",
59-
"/wd4503",
60-
"/wd4800",
61-
"/DNOMINMAX",
62-
diff --git a/absl/copts/copts.py b/absl/copts/copts.py
63-
index 2d85ac74..4875d668 100644
64-
--- a/absl/copts/copts.py
65-
+++ b/absl/copts/copts.py
66-
@@ -118,10 +118,6 @@ MSVC_WARNING_FLAGS = [
67-
"/wd4068", # unknown pragma
68-
# qualifier applied to function type has no meaning; ignored
69-
"/wd4180",
70-
- # conversion from 'type1' to 'type2', possible loss of data
71-
- "/wd4244",
72-
- # conversion from 'size_t' to 'type', possible loss of data
73-
- "/wd4267",
74-
# The decorated name was longer than the compiler limit
75-
"/wd4503",
76-
# forcing value to bool 'true' or 'false' (performance warning)
77-
diff --git a/absl/debugging/symbolize.cc b/absl/debugging/symbolize.cc
78-
index 638d3954..6b817075 100644
79-
--- a/absl/debugging/symbolize.cc
80-
+++ b/absl/debugging/symbolize.cc
81-
@@ -14,7 +14,7 @@
82-
83-
#include "absl/debugging/symbolize.h"
84-
85-
-#ifdef _WIN32
86-
+#if defined(_WIN32) && !defined(NDEBUG)
87-
#include <winapifamily.h>
88-
#if !(WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)) || \
89-
WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
90-
diff --git a/absl/debugging/symbolize_win32.inc b/absl/debugging/symbolize_win32.inc
91-
index 53a099a1..34d210d6 100644
92-
--- a/absl/debugging/symbolize_win32.inc
93-
+++ b/absl/debugging/symbolize_win32.inc
94-
@@ -35,15 +35,15 @@ ABSL_NAMESPACE_BEGIN
95-
96-
static HANDLE process = NULL;
97-
98-
-void InitializeSymbolizer(const char*) {
99-
- if (process != nullptr) {
100-
- return;
101-
- }
102-
+namespace {
103-
+void InitializeSymbolizerImpl() {
104-
+
105-
process = GetCurrentProcess();
106-
107-
// Symbols are not loaded until a reference is made requiring the
108-
// symbols be loaded. This is the fastest, most efficient way to use
109-
// the symbol handler.
110-
+
111-
SymSetOptions(SYMOPT_DEFERRED_LOADS | SYMOPT_UNDNAME);
112-
if (!SymInitialize(process, nullptr, true)) {
113-
// GetLastError() returns a Win32 DWORD, but we assign to
114-
@@ -54,6 +54,36 @@ void InitializeSymbolizer(const char*) {
115-
}
116-
}
117-
118-
+bool LookupAndInitialize(const void* pc, SYMBOL_INFO* symbol) {
119-
+ auto hProcess = (process != NULL) ? process : GetCurrentProcess();
120-
+ if (SymFromAddr(hProcess, reinterpret_cast<DWORD64>(pc), nullptr, symbol) != TRUE) {
121-
+ if (GetLastError() == ERROR_INVALID_HANDLE && process == NULL) {
122-
+ InitializeSymbolizerImpl();
123-
+ if (SymFromAddr(process, reinterpret_cast<DWORD64>(pc), nullptr, symbol) != TRUE) {
124-
+ return false;
125-
+ }
126-
+ } else {
127-
+ return false;
128-
+ }
129-
+ return false;
18+
private:
19+
@@ -3344,11 +3345,14 @@ class raw_hash_set {
20+
21+
// Asserts that hash and equal functors provided by the user are consistent,
22+
// meaning that `eq(k1, k2)` implies `hash(k1)==hash(k2)`.
23+
- template <class K>
24+
- void AssertHashEqConsistent(const K& key) {
25+
#ifdef NDEBUG
26+
+ template <class K>
27+
+ void AssertHashEqConsistent(const K&) {
28+
return;
29+
-#endif
13030
+ }
131-
+ return true;
132-
+}
133-
+}
134-
+
135-
+void InitializeSymbolizer(const char*) {
136-
+ if (process != nullptr) {
137-
+ return;
138-
+ }
139-
+
140-
+ alignas(SYMBOL_INFO) char buf[sizeof(SYMBOL_INFO) + MAX_SYM_NAME];
141-
+ SYMBOL_INFO* symbol = reinterpret_cast<SYMBOL_INFO*>(buf);
142-
+ symbol->SizeOfStruct = sizeof(SYMBOL_INFO);
143-
+ symbol->MaxNameLen = MAX_SYM_NAME;
144-
+
145-
+ static_cast<void>(LookupAndInitialize(reinterpret_cast<const void*>(&InitializeSymbolizer), symbol));
146-
+}
147-
+
148-
bool Symbolize(const void* pc, char* out, int out_size) {
149-
if (out_size <= 0) {
150-
return false;
151-
@@ -62,9 +92,11 @@ bool Symbolize(const void* pc, char* out, int out_size) {
152-
SYMBOL_INFO* symbol = reinterpret_cast<SYMBOL_INFO*>(buf);
153-
symbol->SizeOfStruct = sizeof(SYMBOL_INFO);
154-
symbol->MaxNameLen = MAX_SYM_NAME;
155-
- if (!SymFromAddr(process, reinterpret_cast<DWORD64>(pc), nullptr, symbol)) {
156-
+
157-
+ if(!LookupAndInitialize(pc, symbol)) {
158-
return false;
31+
+#else
32+
+ template <class K>
33+
+ void AssertHashEqConsistent(const K& key) {
34+
// If the hash/eq functors are known to be consistent, then skip validation.
35+
if (std::is_same<hasher, absl::container_internal::StringHash>::value &&
36+
std::is_same<key_equal, absl::container_internal::StringEq>::value) {
37+
@@ -3386,6 +3390,7 @@ class raw_hash_set {
38+
if (capacity() > 16) return;
39+
IterateOverFullSlots(common(), sizeof(slot_type), assert_consistent);
15940
}
160-
+
161-
const size_t out_size_t = static_cast<size_t>(out_size);
162-
strncpy(out, symbol->Name, out_size_t);
163-
if (out[out_size_t - 1] != '\0') {
41+
+#endif
42+
43+
// Attempts to find `key` in the table; if it isn't found, returns an iterator
44+
// where the value can be inserted into, with the control byte already set to

0 commit comments

Comments
 (0)