Skip to content

Commit 8891afb

Browse files
chengyi01Cyber-SiKu
chengyi01
authored andcommitted
upgrade bazel
1. upgrade bazel to 4.2.2 2. support clang-7.0.1 3. support gcc-8.3.0 4. test in debian10 5. dockerfile can be used to make an image of the build environment add patch: 1. apache/brpc@6efb0cf 2. apache/brpc@3a928dd
1 parent fccfc6c commit 8891afb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+1109
-66
lines changed

.bazelrc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
build --define=with_glog=true --define=libunwind=true
2+
build --copt -DHAVE_ZLIB=1 --copt -DGFLAGS_NS=google --copt -DUSE_BTHREAD_MUTEX
3+
build --cxxopt -Wno-error=format-security
4+
build:gcc7-later --cxxopt -faligned-new
5+
build --incompatible_blacklisted_protos_requires_proto_info=false

.bazelversion

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.17.2
1+
4.2.2

Makefile

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@ release?= 0
77
only?= "*"
88
tag?= "curvebs:unknown"
99
case?= "*"
10+
os?= "debian9"
1011

1112
list:
1213
@bash util/build.sh --list
1314

1415
build:
15-
@bash util/build.sh --only=$(only) --release=$(release)
16+
@bash util/build.sh --only=$(only) --release=$(release) --os=$(os)
1617

1718
install:
1819
@bash util/install.sh --prefix=$(prefix) --only=$(only)
1920

2021
image:
21-
@bash util/image.sh $(tag)
22+
@bash util/image.sh $(tag) $(os)

WORKSPACE

+55-31
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,20 @@
1717
workspace(name = "curve")
1818

1919
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
20+
load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository")
21+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
22+
23+
# skylib
24+
http_archive(
25+
name = "bazel_skylib",
26+
urls = [
27+
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.2.0/bazel-skylib-1.2.0.tar.gz",
28+
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.2.0/bazel-skylib-1.2.0.tar.gz",
29+
],
30+
sha256 = "af87959afe497dc8dfd4c6cb66e1279cb98ccc84284619ebfec27d9c09a903de",
31+
)
32+
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
33+
bazel_skylib_workspace()
2034

2135
git_repository(
2236
name = "com_github_baidu_braft",
@@ -32,13 +46,30 @@ bind(
3246
# proto_library, cc_proto_library, and java_proto_library rules implicitly
3347
# depend on @com_google_protobuf for protoc and proto runtimes.
3448
# This statement defines the @com_google_protobuf repo.
49+
50+
# zlib
3551
http_archive(
36-
name = "com_google_protobuf",
37-
sha256 = "cef7f1b5a7c5fba672bec2a319246e8feba471f04dcebfe362d55930ee7c1c30",
38-
strip_prefix = "protobuf-3.5.0",
39-
urls = ["https://github.com/google/protobuf/archive/v3.5.0.zip"],
52+
name = "net_zlib",
53+
build_file = "@com_google_protobuf//:third_party/zlib.BUILD",
54+
sha256 = "c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1",
55+
strip_prefix = "zlib-1.2.11",
56+
urls = ["https://zlib.net/zlib-1.2.11.tar.gz"],
57+
)
58+
59+
bind(
60+
name = "zlib",
61+
actual = "@net_zlib//:zlib",
4062
)
4163

64+
http_archive(
65+
name = "com_google_protobuf",
66+
strip_prefix = "protobuf-3.6.1.3",
67+
patch_args = ["-p1"],
68+
patches = ["//:thirdparties/protobuf/protobuf.patch"],
69+
sha256 = "9510dd2afc29e7245e9e884336f848c8a6600a14ae726adb6befdb4f786f0be2",
70+
urls = ["https://github.com/google/protobuf/archive/v3.6.1.3.zip"],
71+
)
72+
4273
bind(
4374
name = "protobuf",
4475
actual = "@com_google_protobuf//:protobuf",
@@ -76,22 +107,19 @@ bind(
76107
http_archive(
77108
name = "com_github_gflags_gflags",
78109
strip_prefix = "gflags-2.2.2",
79-
urls = [
80-
"https://mirror.bazel.build/github.com/gflags/gflags/archive/v2.2.2.tar.gz",
81-
"https://github.com/gflags/gflags/archive/v2.2.2.tar.gz",
82-
],
110+
urls = ["https://github.com/gflags/gflags/archive/v2.2.2.tar.gz"],
83111
)
84112

85113
bind(
86114
name = "gflags",
87115
actual = "@com_github_gflags_gflags//:gflags",
88116
)
89117

90-
new_http_archive(
118+
http_archive(
91119
name = "com_github_google_leveldb",
92120
build_file = "bazel/leveldb.BUILD",
93121
strip_prefix = "leveldb-a53934a3ae1244679f812d998a4f16f2c7f309a6",
94-
url = "https://github.com/google/leveldb/archive/a53934a3ae1244679f812d998a4f16f2c7f309a6.tar.gz",
122+
urls = ["https://github.com/google/leveldb/archive/a53934a3ae1244679f812d998a4f16f2c7f309a6.tar.gz"],
95123
)
96124

97125
bind(
@@ -142,49 +170,37 @@ bind(
142170

143171
new_local_repository(
144172
name = "etcdclient",
145-
build_file = "bazel/etcdclient.BUILD",
173+
build_file = "external/bazel/etcdclient.BUILD",
146174
path = "thirdparties/etcdclient",
147175
)
148176

149-
new_http_archive(
177+
http_archive(
150178
name = "aws",
151-
urls = [
152-
"https://github.com/aws/aws-sdk-cpp/archive/1.7.340.tar.gz",
153-
"https://mirror.bazel.build/github.com/aws/aws-sdk-cpp/archive/1.7.340.tar.gz",
154-
],
179+
urls = ["https://github.com/aws/aws-sdk-cpp/archive/1.7.340.tar.gz"],
155180
sha256 = "2e82517045efb55409cff1408c12829d9e8aea22c1e2888529cb769b7473b0bf",
156181
strip_prefix = "aws-sdk-cpp-1.7.340",
157182
build_file = "//:thirdparties/aws/aws.BUILD",
158183
)
159184

160-
new_http_archive(
185+
http_archive(
161186
name = "aws_c_common",
162-
urls = [
163-
"https://github.com/awslabs/aws-c-common/archive/v0.4.29.tar.gz",
164-
"https://mirror.tensorflow.org/github.com/awslabs/aws-c-common/archive/v0.4.29.tar.gz",
165-
],
187+
urls = ["https://github.com/awslabs/aws-c-common/archive/v0.4.29.tar.gz"],
166188
sha256 = "01c2a58553a37b3aa5914d9e0bf7bf14507ff4937bc5872a678892ca20fcae1f",
167189
strip_prefix = "aws-c-common-0.4.29",
168190
build_file = "//:thirdparties/aws/aws-c-common.BUILD",
169191
)
170192

171-
new_http_archive(
193+
http_archive(
172194
name = "aws_c_event_stream",
173-
urls = [
174-
"https://github.com/awslabs/aws-c-event-stream/archive/v0.1.4.tar.gz",
175-
"https://mirror.tensorflow.org/github.com/awslabs/aws-c-event-stream/archive/v0.1.4.tar.gz",
176-
],
195+
urls = ["https://github.com/awslabs/aws-c-event-stream/archive/v0.1.4.tar.gz"],
177196
sha256 = "31d880d1c868d3f3df1e1f4b45e56ac73724a4dc3449d04d47fc0746f6f077b6",
178197
strip_prefix = "aws-c-event-stream-0.1.4",
179198
build_file = "//:thirdparties/aws/aws-c-event-stream.BUILD",
180199
)
181200

182-
new_http_archive(
201+
http_archive(
183202
name = "aws_checksums",
184-
urls = [
185-
"https://github.com/awslabs/aws-checksums/archive/v0.1.5.tar.gz",
186-
"https://mirror.tensorflow.org/github.com/awslabs/aws-checksums/archive/v0.1.5.tar.gz",
187-
],
203+
urls = ["https://github.com/awslabs/aws-checksums/archive/v0.1.5.tar.gz"],
188204
sha256 = "6e6bed6f75cf54006b6bafb01b3b96df19605572131a2260fddaf0e87949ced0",
189205
strip_prefix = "aws-checksums-0.1.5",
190206
build_file = "//:thirdparties/aws/aws-checksums.BUILD",
@@ -205,3 +221,11 @@ http_archive(
205221
strip_prefix = "abseil-cpp-20210324.2",
206222
sha256 = "59b862f50e710277f8ede96f083a5bb8d7c9595376146838b9580be90374ee1f",
207223
)
224+
225+
# Bazel platform rules.
226+
http_archive(
227+
name = "platforms",
228+
sha256 = "b601beaf841244de5c5a50d2b2eddd34839788000fa1be4260ce6603ca0d8eb7",
229+
strip_prefix = "platforms-98939346da932eef0b54cf808622f5bb0928f00b",
230+
urls = ["https://github.com/bazelbuild/platforms/archive/98939346da932eef0b54cf808622f5bb0928f00b.zip"],
231+
)

build.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,16 @@ curve_version=${tag_version}+${commit_id}${debug}
5151

5252

5353
#step3 执行编译
54-
# check bazel verion, bazel vesion must = 0.17.2
54+
# check bazel verion, bazel vesion must = 4.2.2
5555
bazel_version=`bazel version | grep "Build label" | awk '{print $3}'`
5656
if [ -z ${bazel_version} ]
5757
then
58-
echo "please install bazel 0.17.2 first"
58+
echo "please install bazel 4.2.2 first"
5959
exit
6060
fi
61-
if [ ${bazel_version} != "0.17.2" ]
61+
if [ ${bazel_version} != "4.2.2" ]
6262
then
63-
echo "bazel version must 0.17.2"
63+
echo "bazel version must 4.2.2"
6464
echo "now version is ${bazel_version}"
6565
exit
6666
fi

copts.bzl

+9-4
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,8 @@ CURVE_LLVM_FLAGS = [
120120
"-Wvla",
121121
"-Wwrite-strings",
122122
"-Wno-float-conversion",
123-
"-Wno-implicit-float-conversion",
124-
"-Wno-implicit-int-float-conversion",
125-
"-Wno-implicit-int-conversion",
123+
"-Wno-float-conversion",
124+
"-Wno-float-overflow-conversion",
126125
"-Wno-shorten-64-to-32",
127126
"-Wno-sign-conversion",
128127
"-DNOMINMAX",
@@ -146,10 +145,16 @@ CURVE_LLVM_TEST_FLAGS = [
146145
"-Wno-used-but-marked-unused",
147146
"-Wno-zero-as-null-pointer-constant",
148147
"-Wno-gnu-zero-variadic-macro-arguments",
148+
"-Wbraced-scalar-init",
149+
]
150+
151+
# FIXME: temporary disabled because triggered in many places
152+
CURVE_LLVM_DISABLED_FLGAS = [
153+
"-Wno-c++11-narrowing",
149154
]
150155

151156
CURVE_DEFAULT_COPTS = select({
152-
"//:clang_compiler": CURVE_LLVM_FLAGS + CXX_FLAGS + BASE_FLAGS,
157+
"//:clang_compiler": CURVE_LLVM_FLAGS + CXX_FLAGS + BASE_FLAGS + CURVE_LLVM_DISABLED_FLGAS,
153158
"//conditions:default": CURVE_GCC_FLAGS + CXX_FLAGS + BASE_FLAGS + CURVE_GCC_DISABLED_FLGAS,
154159
})
155160

curvefs/Makefile

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ release?= 0
77
only?= "*"
88
hosts?= "*"
99
tag?= "curvefs:unknown"
10+
os?= "debian9"
1011

1112
define deploy_begin
1213
@bash util/deploy.sh begin
@@ -31,13 +32,13 @@ define only_specify
3132
endef
3233

3334
build:
34-
@bash util/build.sh --only=$(only) --release=$(release)
35+
@bash util/build.sh --only=$(only) --release=$(release) --os=$(os)
3536

3637
install:
3738
@bash util/install.sh --prefix=$(prefix) --only=$(only)
3839

3940
image:
40-
@bash util/image.sh $(tag)
41+
@bash util/image.sh $(tag) $(os)
4142

4243
deploy:
4344
$(call deploy_begin)

curvefs/docker/debian10/Dockerfile

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM opencurvedocker/curve-base:debian10
2+
ENV TZ=Asia/Shanghai
3+
RUN mkdir -p /curvefs /etc/curvefs /core
4+
COPY curvefs /curvefs
5+
COPY entrypoint.sh /
6+
COPY curvefs/tools/sbin/curvefs_tool /usr/bin
7+
RUN chmod a+x /entrypoint.sh
8+
ENTRYPOINT ["/entrypoint.sh"]
+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
FROM debian:10
2+
3+
RUN echo "deb http://mirrors.163.com/debian/ buster main non-free contrib\n" \
4+
"deb http://mirrors.163.com/debian/ buster-updates main non-free contrib\n" \
5+
"deb http://mirrors.163.com/debian/ buster-backports main non-free contrib\n" \
6+
"deb http://mirrors.163.com/debian-security/ buster/updates main non-free contrib\n" \
7+
"deb-src http://mirrors.163.com/debian/ buster main non-free contrib\n" \
8+
"deb-src http://mirrors.163.com/debian/ buster-updates main non-free contrib\n" \
9+
"deb-src http://mirrors.163.com/debian/ buster-backports main non-free contrib\n" \
10+
"deb-src http://mirrors.163.com/debian-security/ buster/updates main non-free contrib\n" \
11+
> /etc/apt/sources.list \
12+
&& apt-get clean \
13+
&& apt-get -y update \
14+
&& apt-get -y install \
15+
gcc \
16+
gdb \
17+
make \
18+
openssl \
19+
net-tools \
20+
libcurl3-gnutls \
21+
perl \
22+
linux-perf \
23+
vim \
24+
curl \
25+
cron \
26+
procps \
27+
lsof \
28+
nginx \
29+
less \
30+
fuse3 \
31+
libnl-3-200 \
32+
libnl-genl-3-200 \
33+
libjemalloc2 \
34+
&& ln -s /usr/lib/x86_64-linux-gnu/libjemalloc.so.2 /usr/local/lib/libjemalloc.so
35+
36+
COPY libetcdclient.so /usr/lib/

curvefs/docker/debian10/base/Makefile

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.PHONY: build
2+
3+
build:
4+
docker build -t opencurvedocker/curve-base:debian10 .
+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
FROM debian:10
2+
3+
RUN echo "deb http://mirrors.163.com/debian/ buster main non-free contrib\n" \
4+
"deb http://mirrors.163.com/debian/ buster-updates main non-free contrib\n" \
5+
"deb http://mirrors.163.com/debian/ buster-backports main non-free contrib\n" \
6+
"deb http://mirrors.163.com/debian-security/ buster/updates main non-free contrib\n" \
7+
"deb-src http://mirrors.163.com/debian/ buster main non-free contrib\n" \
8+
"deb-src http://mirrors.163.com/debian/ buster-updates main non-free contrib\n" \
9+
"deb-src http://mirrors.163.com/debian/ buster-backports main non-free contrib\n" \
10+
"deb-src http://mirrors.163.com/debian-security/ buster/updates main non-free contrib\n" \
11+
> /etc/apt/sources.list \
12+
&& apt-get clean \
13+
&& apt-get -y update \
14+
&& apt-get -y install \
15+
wget \
16+
git \
17+
gcc \
18+
g++ \
19+
clang \
20+
libssl-dev \
21+
libnl-genl-3-dev \
22+
libcurl4-gnutls-dev \
23+
uuid-dev \
24+
libfiu-dev \
25+
libfuse3-dev \
26+
zlib1g-dev \
27+
make \
28+
openjdk-11-jdk \
29+
sudo \
30+
&& wget https://github.com/bazelbuild/bazelisk/releases/download/v1.11.0/bazelisk-linux-amd64 \
31+
&& mv bazelisk-linux-amd64 /usr/bin/bazelisk \
32+
&& ln -s /usr/bin/bazelisk /usr/bin/bazel \
33+
&& wget https://github.com/bazelbuild/bazel/releases/download/4.2.2/bazel-4.2.2-linux-x86_64 \
34+
&& mkdir -p /root/.cache/bazelisk/downloads/bazelbuild/bazel-4.2.2-linux-x86_64/bin \
35+
&& mv bazel-4.2.2-linux-x86_64 /root/.cache/bazelisk/downloads/bazelbuild/bazel-4.2.2-linux-x86_64/bin/bazel \
36+
&& chmod +x /root/.cache/bazelisk/downloads/bazelbuild/bazel-4.2.2-linux-x86_64/bin/bazel /usr/bin/bazel /usr/bin/bazelisk
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.PHONY: build
2+
3+
build:
4+
docker build -t opencurvedocker/curve-base:build-debian10 .
File renamed without changes.

curvefs/docker/debian11/Dockerfile

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM opencurvedocker/curve-base:debian11
2+
ENV TZ=Asia/Shanghai
3+
RUN mkdir -p /curvefs /etc/curvefs /core
4+
COPY curvefs /curvefs
5+
COPY entrypoint.sh /
6+
COPY curvefs/tools/sbin/curvefs_tool /usr/bin
7+
RUN chmod a+x /entrypoint.sh
8+
ENTRYPOINT ["/entrypoint.sh"]
+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
FROM debian:11
2+
3+
RUN echo "deb http://mirrors.163.com/debian/ bullseye main non-free contrib\n" \
4+
"deb http://mirrors.163.com/debian/ bullseye-updates main non-free contrib\n" \
5+
"deb http://mirrors.163.com/debian/ bullseye-backports main non-free contrib\n" \
6+
"deb http://mirrors.163.com/debian-security/ stable-security main non-free contrib\n" \
7+
"deb-src http://mirrors.163.com/debian/ bullseye main non-free contrib\n" \
8+
"deb-src http://mirrors.163.com/debian/ bullseye-updates main non-free contrib\n" \
9+
"deb-src http://mirrors.163.com/debian/ bullseye-backports main non-free contrib\n" \
10+
"deb-src http://mirrors.163.com/debian-security/ stable-security main non-free contrib\n" \
11+
> /etc/apt/sources.list \
12+
&& apt-get clean \
13+
&& apt-get -y update \
14+
&& apt-get -y install \
15+
gcc \
16+
gdb \
17+
make \
18+
openssl \
19+
net-tools \
20+
libcurl3-gnutls \
21+
perl \
22+
linux-perf \
23+
vim \
24+
curl \
25+
cron \
26+
procps \
27+
lsof \
28+
nginx \
29+
less \
30+
fuse3 \
31+
libnl-3-200 \
32+
libnl-genl-3-200 \
33+
libjemalloc2 \
34+
&& ln -s /usr/lib/x86_64-linux-gnu/libjemalloc.so.2 /usr/local/lib/libjemalloc.so
35+
36+
COPY libetcdclient.so /usr/lib/

0 commit comments

Comments
 (0)