This is an automated email from the ASF dual-hosted git repository.
jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git
The following commit(s) were added to refs/heads/master by this push:
new 233f99ff fixes for gcc on arm64
new 2f31176f Merge branch 'master' of github.com:apache/incubator-brpc
233f99ff is described below
commit 233f99ff5ed130479800dbd5821487571064be55
Author: gejun.0 <[email protected]>
AuthorDate: Sat Aug 27 12:05:31 2022 +0800
fixes for gcc on arm64
---
config_brpc.sh | 9 +++++++++
src/butil/containers/case_ignored_flat_map.h | 7 ++++---
src/butil/iobuf.cpp | 9 ++++-----
test/Makefile | 2 +-
test/bthread_execution_queue_unittest.cpp | 16 ++++++----------
test/bthread_key_unittest.cpp | 9 ++++-----
test/cacheline_unittest.cpp | 2 +-
test/flat_map_unittest.cpp | 1 +
8 files changed, 30 insertions(+), 25 deletions(-)
diff --git a/config_brpc.sh b/config_brpc.sh
index cf04b726..d0de0fdb 100755
--- a/config_brpc.sh
+++ b/config_brpc.sh
@@ -318,6 +318,8 @@ append_to_output "CXX=$CXX"
append_to_output "GCC_VERSION=$GCC_VERSION"
append_to_output "STATIC_LINKINGS=$STATIC_LINKINGS"
append_to_output "DYNAMIC_LINKINGS=$DYNAMIC_LINKINGS"
+
+# CPP means C PreProcessing, not C PlusPlus
CPPFLAGS="-DBRPC_WITH_GLOG=$WITH_GLOG -DGFLAGS_NS=$GFLAGS_NS"
# Avoid over-optimizations of TLS variables by GCC>=4.8
@@ -355,6 +357,13 @@ if [ $WITH_MESALINK != 0 ]; then
fi
append_to_output "CPPFLAGS=${CPPFLAGS}"
+append_to_output "# without the flag, linux+arm64 may crash due to folding on
TLS.
+ifeq (\$(CC),gcc)
+ ifeq (\$(shell uname -p),aarch64)
+ CPPFLAGS+=-fno-gcse
+ endif
+endif
+"
append_to_output "ifeq (\$(NEED_LIBPROTOC), 1)"
PROTOC_LIB=$(find $PROTOBUF_LIB -name "libprotoc.*" | head -n1)
diff --git a/src/butil/containers/case_ignored_flat_map.h
b/src/butil/containers/case_ignored_flat_map.h
index 6bc1a9af..30cfdda6 100644
--- a/src/butil/containers/case_ignored_flat_map.h
+++ b/src/butil/containers/case_ignored_flat_map.h
@@ -24,11 +24,12 @@
namespace butil {
-// NOTE: Using ascii_tolower instead of ::tolower shortens 150ns in
+// Using ascii_tolower instead of ::tolower shortens 150ns in
// FlatMapTest.perf_small_string_map (with -O2 added, -O0 by default)
-inline char ascii_tolower(char c) {
+// note: using char caused crashes on ubuntu 20.04 aarch64 (VM on apple M1)
+inline char ascii_tolower(int/*note*/ c) {
extern const signed char* const g_tolower_map;
- return g_tolower_map[(int)c];
+ return g_tolower_map[c];
}
struct CaseIgnoredHasher {
diff --git a/src/butil/iobuf.cpp b/src/butil/iobuf.cpp
index 515f7021..214c7663 100644
--- a/src/butil/iobuf.cpp
+++ b/src/butil/iobuf.cpp
@@ -100,14 +100,14 @@ static ssize_t sys_pwritev(int fd, const struct iovec
*vector,
}
inline iov_function get_preadv_func() {
+#if defined(OS_MACOSX)
+ return user_preadv;
+#endif
butil::fd_guard fd(open("/dev/zero", O_RDONLY));
if (fd < 0) {
PLOG(WARNING) << "Fail to open /dev/zero";
return user_preadv;
}
-#if defined(OS_MACOSX)
- return user_preadv;
-#endif
char dummy[1];
iovec vec = { dummy, sizeof(dummy) };
const int rc = syscall(SYS_preadv, (int)fd, &vec, 1, 0);
@@ -141,8 +141,7 @@ inline iov_function get_pwritev_func() {
#else // ARCH_CPU_X86_64
-#warning "We don't check whether the kernel supports SYS_preadv or SYS_pwritev
" \
- "when the arch is not X86_64, use user space preadv/pwritev directly"
+#warning "We don't check if the kernel supports SYS_preadv or SYS_pwritev on
non-X86_64, use impl. on pread/pwrite directly"
inline iov_function get_preadv_func() {
return user_preadv;
diff --git a/test/Makefile b/test/Makefile
index 5aa90e8b..871a99ed 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -27,8 +27,8 @@ ifeq ($(shell test $(GCC_VERSION) -ge 40400; echo $$?),0)
CXXFLAGS+=-msse4 -msse4.2
endif
endif
-#not solved yet
ifeq ($(CC),gcc)
+ # FIXME(jge): not solved yet
ifeq ($(shell test $(GCC_VERSION) -ge 70000; echo $$?),0)
CXXFLAGS+=-Wno-aligned-new
endif
diff --git a/test/bthread_execution_queue_unittest.cpp
b/test/bthread_execution_queue_unittest.cpp
index 8c70cbe4..8fb810d9 100644
--- a/test/bthread_execution_queue_unittest.cpp
+++ b/test/bthread_execution_queue_unittest.cpp
@@ -76,16 +76,12 @@ TEST_F(ExecutionQueueTest, single_thread) {
}
struct PushArg {
- bthread::ExecutionQueueId<LongIntTask> id;
- butil::atomic<int64_t> total_num;
- butil::atomic<int64_t> total_time;
- butil::atomic<int64_t> expected_value;
- volatile bool stopped;
- bool wait_task_completed;
-
- PushArg() {
- memset(this, 0, sizeof(*this));
- }
+ bthread::ExecutionQueueId<LongIntTask> id {0};
+ butil::atomic<int64_t> total_num {0};
+ butil::atomic<int64_t> total_time {0};
+ butil::atomic<int64_t> expected_value {0};
+ volatile bool stopped {false};
+ bool wait_task_completed {false};
};
void* push_thread(void *arg) {
diff --git a/test/bthread_key_unittest.cpp b/test/bthread_key_unittest.cpp
index 1ccf9e6b..4b05d33d 100644
--- a/test/bthread_key_unittest.cpp
+++ b/test/bthread_key_unittest.cpp
@@ -39,10 +39,10 @@ namespace {
// Count tls usages.
struct Counters {
- butil::atomic<size_t> ncreate;
- butil::atomic<size_t> ndestroy;
- butil::atomic<size_t> nenterthread;
- butil::atomic<size_t> nleavethread;
+ butil::atomic<size_t> ncreate {0};
+ butil::atomic<size_t> ndestroy {0};
+ butil::atomic<size_t> nenterthread {0};
+ butil::atomic<size_t> nleavethread {0};
};
// Wrap same counters into different objects to make sure that different key
@@ -103,7 +103,6 @@ static void* worker1(void* arg) {
TEST(KeyTest, creating_key_in_parallel) {
Counters args;
- memset(&args, 0, sizeof(args));
pthread_t th[8];
bthread_t bth[8];
for (size_t i = 0; i < arraysize(th); ++i) {
diff --git a/test/cacheline_unittest.cpp b/test/cacheline_unittest.cpp
index 4d1372e6..efcb8841 100644
--- a/test/cacheline_unittest.cpp
+++ b/test/cacheline_unittest.cpp
@@ -34,7 +34,7 @@ struct BAIDU_CACHELINE_ALIGNMENT Bar {
struct Foo {
char dummy1[0];
int z;
- int BAIDU_CACHELINE_ALIGNMENT x[0];
+ BAIDU_CACHELINE_ALIGNMENT int x[0];
int y;
int m;
Bar bar;
diff --git a/test/flat_map_unittest.cpp b/test/flat_map_unittest.cpp
index 99f30e41..b8f0372d 100644
--- a/test/flat_map_unittest.cpp
+++ b/test/flat_map_unittest.cpp
@@ -836,6 +836,7 @@ struct Key {
Key() : x_(0) { ++n_con_key; }
Key(int x) : x_(x) { ++ n_con_key; }
Key(const Key& rhs) : x_(rhs.x_) { ++ n_cp_con_key; }
+ void operator=(const Key& rhs) { x_ = rhs.x_; }
~Key() { ++ n_des_key; }
int x_;
};
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]