Skip to content

Commit 58f365b

Browse files
committed
Bug 2011393 - Fix build issue on Solaris/gcc. r=TYLin
Solaris is that `char` and `int8_t` are the same type, so diplomat's helper function causes redefinition errors. So we need to add a special guard for Solaris to avoid the redefinition. Differential Revision: https://phabricator.services.mozilla.com/D279979
1 parent 0305418 commit 58f365b

File tree

4 files changed

+46
-11
lines changed

4 files changed

+46
-11
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
diff --git a/intl/icu_capi/bindings/cpp/icu4x/diplomat_runtime.hpp b/intl/icu_capi/bindings/cpp/icu4x/diplomat_runtime.hpp
2+
index 2ef428fe024b..2d036b1d4ea5 100644
3+
--- a/intl/icu_capi/bindings/cpp/icu4x/diplomat_runtime.hpp
4+
+++ b/intl/icu_capi/bindings/cpp/icu4x/diplomat_runtime.hpp
5+
@@ -372,17 +372,21 @@ struct diplomat_c_span_convert {
6+
struct diplomat_c_span_convert<T, std::enable_if_t<std::is_same_v<T, span<const c_ty>>>> { \
7+
using type = diplomat::capi::Diplomat##name##View; \
8+
}; \
9+
template<typename T> \
10+
struct diplomat_c_span_convert<T, std::enable_if_t<std::is_same_v<T, span<c_ty>>>> { \
11+
using type = diplomat::capi::Diplomat##name##ViewMut; \
12+
}; \
13+
14+
+#if !defined(__sun) || !defined(_CHAR_IS_SIGNED)
15+
+// int8_t and char are the same type on Solaris. Guard this definition to avoid
16+
+// conflicts. https://github.com/rust-diplomat/diplomat/issues/1015
17+
MAKE_SLICE_CONVERTERS(I8, int8_t)
18+
+#endif
19+
MAKE_SLICE_CONVERTERS(U8, uint8_t)
20+
MAKE_SLICE_CONVERTERS(I16, int16_t)
21+
MAKE_SLICE_CONVERTERS(U16, uint16_t)
22+
MAKE_SLICE_CONVERTERS(I32, int32_t)
23+
MAKE_SLICE_CONVERTERS(U32, uint32_t)
24+
MAKE_SLICE_CONVERTERS(I64, int64_t)
25+
MAKE_SLICE_CONVERTERS(U64, uint64_t)
26+
MAKE_SLICE_CONVERTERS(F32, float)
27+
@@ -559,9 +563,9 @@ struct next_to_iter_helper {
28+
}
29+
30+
std::shared_ptr<T> _ptr; // shared to satisfy the copyable requirement
31+
next_type _curr;
32+
};
33+
34+
} // namespace diplomat
35+
} // namespace icu4x
36+
-#endif
37+
\ No newline at end of file
38+
+#endif

intl/icu4x-patches/README

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,9 @@
22

33
A patch for Cargo.toml of icu_capi. Remove weak dependencies of unnecessary crates.
44

5-
### 002-GH4109.patch
5+
### 002-bug2011393.patch
66

7-
A patch for icu_capi for clang and static analysis.
8-
9-
### 003-explicit.patch
10-
11-
A patch for icu_capi to add explicit keyword
12-
13-
### 004-dead-code.patch
14-
15-
A patch for icu_capi to mark the ICU4XDataStruct as dead code as it's never read from Rust.
7+
A patch for Solaris support. int8_t and char are the same type on Solaris. Guard this definition to avoid conflicts. https://github.com/rust-diplomat/diplomat/issues/1015
168

179
### empty.toml
1810

intl/icu_capi/bindings/cpp/icu4x/diplomat_runtime.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,11 @@ struct diplomat_c_span_convert {
377377
using type = diplomat::capi::Diplomat##name##ViewMut; \
378378
}; \
379379

380+
#if !defined(__sun) || !defined(_CHAR_IS_SIGNED)
381+
// int8_t and char are the same type on Solaris. Guard this definition to avoid
382+
// conflicts. https://github.com/rust-diplomat/diplomat/issues/1015
380383
MAKE_SLICE_CONVERTERS(I8, int8_t)
384+
#endif
381385
MAKE_SLICE_CONVERTERS(U8, uint8_t)
382386
MAKE_SLICE_CONVERTERS(I16, int16_t)
383387
MAKE_SLICE_CONVERTERS(U16, uint16_t)
@@ -564,4 +568,4 @@ struct next_to_iter_helper {
564568

565569
} // namespace diplomat
566570
} // namespace icu4x
567-
#endif
571+
#endif

intl/update-icu4x.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ rm -rf icu_capi_tar.gz
8181
log "Patching icu_capi"
8282
for patch in \
8383
001-Cargo.toml.patch \
84+
002-bug2011393.patch \
8485
; do
8586
patch -d ${top_src_dir} -p1 --no-backup-if-mismatch < ${top_src_dir}/intl/icu4x-patches/$patch
8687
done

0 commit comments

Comments
 (0)