Skip to content

Commit f55f0c8

Browse files
committed
[build](be) make master compile on aarch64 Ubuntu 22.04 (clang 19)
- bitmap_value.h: suppress -Wshadow for BitmapDataType enum constants (they collide with protobuf-exported doris::BITMAP; clang >= 17 turns it into an -Werror failure) - be/CMakeLists.txt: keep -Wshadow non-fatal on clang, and -Wno-deprecated-declarations for BE_TEST (libstdc++ >= 12 marks std::get_temporary_buffer deprecated, tripping existing tests) - parquet_column_convert.h: std::powf -> std::pow (libstdc++ <cmath> does not declare powf in namespace std) - function_string_misc.cpp: std::format -> fmt::format (libstdc++ 12 has no <format>; fmt is the project convention) - be_thread_stack_action.cpp: append_frame is only used on the x86_64 unwind path; mark [[maybe_unused]] so aarch64 -Werror builds pass - glibc-compatibility: add resolv_shim.c forwarding __res_nsearch to res_nsearch — glibc >= 2.34 exports the former only as a non-default compat version, breaking the link against the prebuilt krb5 archive
1 parent 5a13768 commit f55f0c8

7 files changed

Lines changed: 58 additions & 6 deletions

File tree

be/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,10 @@ if (COMPILER_CLANG)
407407
-Wunused-macros
408408
-Wconversion
409409
-Wthread-safety)
410+
# Clang >= 17 flags namespace-scope shadowing (e.g. enum constants vs
411+
# protobuf-generated enums) that older toolchains accepted; keep the
412+
# warnings visible but non-fatal so newer compilers can build.
413+
add_compile_options(-Wno-error=shadow)
410414
add_compile_options(-Wno-gnu-statement-expression
411415
-Wno-implicit-float-conversion
412416
-Wno-sign-conversion
@@ -900,6 +904,9 @@ if (MAKE_TEST)
900904
add_compile_options(
901905
-Wno-implicit-int-conversion
902906
-Wno-shorten-64-to-32
907+
# Newer libstdc++ (>= 12) marks std::get_temporary_buffer deprecated;
908+
# test code using std::stable_sort trips over it under -Werror.
909+
-Wno-deprecated-declarations
903910
)
904911
endif()
905912
endif ()

be/src/core/value/bitmap_value.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2971,12 +2971,23 @@ class BitmapValue {
29712971
_set.clear();
29722972
}
29732973

2974+
// NOTE: the enumerators (EMPTY/SINGLE/BITMAP/SET) collide with protobuf
2975+
// enum values exported at namespace scope by olap_file.pb.h (e.g.
2976+
// doris::BITMAP); clang >= 17 -Wshadow flags the shadowing as an error
2977+
// under -Werror, so suppress it just for this declaration.
2978+
#if defined(__clang__)
2979+
#pragma clang diagnostic push
2980+
#pragma clang diagnostic ignored "-Wshadow"
2981+
#endif
29742982
enum BitmapDataType {
29752983
EMPTY = 0,
29762984
SINGLE = 1, // single element
29772985
BITMAP = 2, // more than one elements
29782986
SET = 3 // elements count less or equal than 32
29792987
};
2988+
#if defined(__clang__)
2989+
#pragma clang diagnostic pop
2990+
#endif
29802991
uint64_t _sv = 0; // store the single value when _type == SINGLE
29812992
// !FIXME: We should rethink the logic about _bitmap and _is_shared
29822993
mutable std::shared_ptr<detail::Roaring64Map> _bitmap; // used when _type == BITMAP

be/src/exprs/function/function_string_misc.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
#include <cstdint>
3131
#include <cstdlib>
3232
#include <cstring>
33-
#include <format>
3433
#include <iomanip>
3534
#include <memory>
3635
#include <random>
@@ -226,7 +225,7 @@ class FunctionAutoPartitionName : public IFunction {
226225
// check the name of length
227226
int len = res_p.size();
228227
if (len > 50) {
229-
res_p = std::format("{}_{:08x}", res_p.substr(0, 50), to_hash_code(res_p));
228+
res_p = fmt::format("{}_{:08x}", res_p.substr(0, 50), to_hash_code(res_p));
230229
len = res_p.size();
231230
}
232231
curr_len += len;

be/src/format/parquet/parquet_column_convert.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <libdivide.h>
2323

2424
#include <chrono>
25+
#include <cmath> // std::pow (used by the half-float decoding path)
2526
#include <limits>
2627

2728
#include "common/cast_set.h"
@@ -593,7 +594,7 @@ class Float16PhysicalConverter : public PhysicalToLogicalConverter {
593594
// half subnormal:
594595
// value = (-1)^sign * (mant / 2^10) * 2^(1 - bias)
595596
// half bias = 15 → exponent = 1 - 15 = -14
596-
float f = (static_cast<float>(mant) / 1024.0F) * std::powf(2.0F, -14.0F);
597+
float f = (static_cast<float>(mant) / 1024.0F) * std::pow(2.0F, -14.0F);
597598
return sign ? -f : f;
598599
}
599600
} else if (exp == 0x1F) {

be/src/glibc-compatibility/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ if (GLIBC_COMPATIBILITY)
6565
# before ASAN shadow memory is initialized, causing SIGSEGV. Skip custom memcpy in
6666
# this case and fall back to glibc's memcpy.
6767
if (ARCH_ARM AND (CMAKE_BUILD_TYPE STREQUAL "ASAN_UT" OR CMAKE_BUILD_TYPE STREQUAL "ASAN"))
68-
add_library(glibc-compatibility-explicit OBJECT musl/getrandom.c)
68+
add_library(glibc-compatibility-explicit OBJECT musl/getrandom.c resolv_shim.c)
6969
else()
70-
add_library(glibc-compatibility-explicit OBJECT musl/getrandom.c ${MEMCPY_SOURCE})
70+
add_library(glibc-compatibility-explicit OBJECT musl/getrandom.c resolv_shim.c ${MEMCPY_SOURCE})
7171
endif()
7272
target_compile_options(glibc-compatibility-explicit PRIVATE -fPIC)
7373
add_library(glibc-compatibility STATIC ${glibc_compatibility_sources})
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
// glibc >= 2.34 demoted the double-underscore resolver entry points
19+
// (__res_nsearch & friends) to non-default compat versions, so newly linked
20+
// binaries cannot bind them anymore. The prebuilt thirdparty krb5 archive
21+
// (dnsglue.o) still references __res_nsearch, which breaks the doris_be link
22+
// on Ubuntu 22.04 (glibc 2.35). Provide a thin forwarder to the public
23+
// res_nsearch entry point, which is the identical implementation (same
24+
// symbol address in libc).
25+
26+
#include <resolv.h>
27+
#include <sys/types.h>
28+
29+
int __res_nsearch(res_state statp, const char* dname, int class_, int type,
30+
unsigned char* answer, int anslen) {
31+
return res_nsearch(statp, dname, class_, type, answer, anslen);
32+
}

be/src/service/http/action/be_thread_stack_action.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,9 @@ pid_t get_current_tid() {
133133
return static_cast<pid_t>(syscall(SYS_gettid));
134134
}
135135

136-
void append_frame(SignalContextCapture* capture, uintptr_t pc) {
136+
// Only called from the x86_64 libunwind path below; on aarch64 it is
137+
// intentionally unused, so keep -Wunused-function quiet.
138+
[[maybe_unused]] void append_frame(SignalContextCapture* capture, uintptr_t pc) {
137139
if (pc == 0 || capture->size >= capture->frame_pointers.size()) {
138140
return;
139141
}

0 commit comments

Comments
 (0)