This is an automated email from the ASF dual-hosted git repository.
dataroaring pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-3.0 by this push:
new abc190ae1c3 branch-3.0: [Fix](compile) Fix arm compile failure caused
by undefined symbol #51715 (#51926)
abc190ae1c3 is described below
commit abc190ae1c3a7b022a0d79d67136dfcbfddee106
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Thu Jun 19 20:04:55 2025 +0800
branch-3.0: [Fix](compile) Fix arm compile failure caused by undefined
symbol #51715 (#51926)
Cherry-picked from #51715
Co-authored-by: zclllyybb <[email protected]>
---
be/src/vec/common/arithmetic_overflow.h | 42 ++++++++++++++++++++++++++++++++-
1 file changed, 41 insertions(+), 1 deletion(-)
diff --git a/be/src/vec/common/arithmetic_overflow.h
b/be/src/vec/common/arithmetic_overflow.h
index e030957c600..1a86af01b05 100644
--- a/be/src/vec/common/arithmetic_overflow.h
+++ b/be/src/vec/common/arithmetic_overflow.h
@@ -115,9 +115,49 @@ inline bool mul_overflow(long long x, long long y, long
long& res) {
return __builtin_smulll_overflow(x, y, &res);
}
+// from __muloXi4 in llvm's compiler-rt
+static inline __int128 int128_overflow_mul(__int128 a, __int128 b, int*
overflow) {
+ const int N = (int)(sizeof(__int128) * CHAR_BIT);
+ const auto MIN = (__int128)((__uint128_t)1 << (N - 1));
+ const __int128 MAX = ~MIN;
+ *overflow = 0;
+ __int128 result = (__uint128_t)a * b;
+ if (a == MIN) {
+ if (b != 0 && b != 1) {
+ *overflow = 1;
+ }
+ return result;
+ }
+ if (b == MIN) {
+ if (a != 0 && a != 1) {
+ *overflow = 1;
+ }
+ return result;
+ }
+ __int128 sa = a >> (N - 1);
+ __int128 abs_a = (a ^ sa) - sa;
+ __int128 sb = b >> (N - 1);
+ __int128 abs_b = (b ^ sb) - sb;
+ if (abs_a < 2 || abs_b < 2) {
+ return result;
+ }
+ if (sa == sb) {
+ if (abs_a > MAX / abs_b) {
+ *overflow = 1;
+ }
+ } else {
+ if (abs_a > MIN / -abs_b) {
+ *overflow = 1;
+ }
+ }
+ return result;
+}
+
template <>
inline bool mul_overflow(__int128 x, __int128 y, __int128& res) {
- return __builtin_mul_overflow(x, y, &res);
+ int overflow = 0;
+ res = int128_overflow_mul(x, y, &overflow);
+ return overflow != 0;
}
template <>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]