Skip to content

Commit 8882662

Browse files
committed
update cross-compile cc toolchain to latest
1 parent afeb4a0 commit 8882662

File tree

6 files changed

+76
-50
lines changed

6 files changed

+76
-50
lines changed

.bazelrc

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,30 @@ build --copt=-O3
1212
build:release --copt=-w
1313
build:release --output_filter=DONT_MATCH_ANYTHING
1414

15+
# build with shared gnu libstdc++ instead of static libc++
16+
build:gnulibcpp --@com_github_emacski_bazeltools//toolchain/cpp/clang:use_libcpp="libstdc++"
17+
build:gnulibcpp --cxxopt=-D_GLIBCXX_USE_CXX11_ABI=0
18+
1519
# protobuf / grpc build options
1620
build --define=use_fast_cpp_protos=true
1721
build --define=allow_oversize_protos=true
1822
build --define=grpc_no_ares=true
1923

2024
# platform config groups
2125

22-
build:linux_amd64 --platforms=@com_github_emacski_bazeltools//platform:linux_amd64
26+
build:linux_amd64 --platforms=@com_github_emacski_bazeltools//toolchain:linux_amd64
2327
# boringssl requires legacy toolchain resolution
24-
build:linux_amd64 --crosstool_top=@com_github_emacski_bazeltools//toolchain/cpp/clang:toolchain
28+
build:linux_amd64 --crosstool_top=@com_github_emacski_bazeltools//toolchain/cpp/clang:clang11_crosstool
2529
build:linux_amd64 --cpu=k8
2630

27-
build:linux_arm64 --platforms=@com_github_emacski_bazeltools//platform:linux_arm64
31+
build:linux_arm64 --platforms=@com_github_emacski_bazeltools//toolchain:linux_arm64
2832
# boringssl requires legacy toolchain resolution
29-
build:linux_arm64 --crosstool_top=@com_github_emacski_bazeltools//toolchain/cpp/clang:toolchain
33+
build:linux_arm64 --crosstool_top=@com_github_emacski_bazeltools//toolchain/cpp/clang:clang11_crosstool
3034
build:linux_arm64 --cpu=aarch64
3135

32-
build:linux_arm --platforms=@com_github_emacski_bazeltools//platform:linux_arm
36+
build:linux_arm --platforms=@com_github_emacski_bazeltools//toolchain:linux_arm
3337
# boringssl requires legacy toolchain resolution
34-
build:linux_arm --crosstool_top=@com_github_emacski_bazeltools//toolchain/cpp/clang:toolchain
35-
build:linux_arm --cpu=arm
38+
build:linux_arm --crosstool_top=@com_github_emacski_bazeltools//toolchain/cpp/clang:clang11_crosstool
39+
build:linux_arm --cpu=armhf
3640

3741
try-import %workspace%/.bazelrc.user

WORKSPACE

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,17 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
1818

1919
http_archive(
2020
name = "com_github_emacski_bazeltools",
21-
sha256 = "ef868ef493a8fc9609a32093a90b57f320646fa5af3b3eb49bb7380f5e0580c6",
22-
strip_prefix = "bazel-tools-9cbf59fc288489ab3c7e42ed124507e1b1adba3a",
23-
urls = ["https://github.com/emacski/bazel-tools/archive/9cbf59fc288489ab3c7e42ed124507e1b1adba3a.tar.gz"],
21+
sha256 = "dba9e8f0613401ed3c052d6fe79b3517197a7747046659845309fb17e9b3038d",
22+
strip_prefix = "bazel-tools-17a0d8b9ae66bc542853a72365ef1aeb85086827",
23+
urls = ["https://github.com/emacski/bazel-tools/archive/17a0d8b9ae66bc542853a72365ef1aeb85086827.tar.gz"],
2424
)
2525

26-
register_toolchains("@com_github_emacski_bazeltools//toolchain/cpp/clang:all")
26+
load(
27+
"@com_github_emacski_bazeltools//toolchain/cpp/clang:defs.bzl",
28+
"register_clang_cross_toolchains",
29+
)
30+
31+
register_clang_cross_toolchains(clang_version = "11")
2732

2833
# python client deps
2934

@@ -94,14 +99,29 @@ go_repository(
9499

95100
# protobuf / grpc deps
96101

102+
http_archive(
103+
name = "com_google_protobuf",
104+
sha256 = "0cbdc9adda01f6d2facc65a22a2be5cecefbefe5a09e5382ee8879b522c04441",
105+
strip_prefix = "protobuf-3.15.8",
106+
urls = [
107+
"https://github.com/protocolbuffers/protobuf/archive/v3.15.8.tar.gz",
108+
],
109+
)
110+
111+
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
112+
113+
protobuf_deps()
114+
97115
http_archive(
98116
name = "com_github_grpc_grpc",
99117
patches = [
100-
"@com_github_emacski_tensorflowservingarmclient//third_party/grpc:cython_library.patch",
118+
"@//third_party/grpc:cython_library.patch",
101119
],
102120
sha256 = "bb6de0544adddd54662ba1c314eff974e84c955c39204a4a2b733ccd990354b7",
103121
strip_prefix = "grpc-1.36.3",
104-
urls = ["https://github.com/grpc/grpc/archive/v1.36.3.tar.gz"],
122+
urls = [
123+
"https://github.com/grpc/grpc/archive/v1.36.3.tar.gz"
124+
],
105125
)
106126

107127
load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")

cc/README.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,17 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
99

1010
http_archive(
1111
name = "com_github_emacski_bazeltools",
12-
sha256 = "ef868ef493a8fc9609a32093a90b57f320646fa5af3b3eb49bb7380f5e0580c6",
13-
strip_prefix = "bazel-tools-9cbf59fc288489ab3c7e42ed124507e1b1adba3a",
14-
urls = ["https://github.com/emacski/bazel-tools/archive/9cbf59fc288489ab3c7e42ed124507e1b1adba3a.tar.gz"],
12+
sha256 = "dba9e8f0613401ed3c052d6fe79b3517197a7747046659845309fb17e9b3038d",
13+
strip_prefix = "bazel-tools-17a0d8b9ae66bc542853a72365ef1aeb85086827",
14+
urls = ["https://github.com/emacski/bazel-tools/archive/17a0d8b9ae66bc542853a72365ef1aeb85086827.tar.gz"],
1515
)
1616

17+
load(
18+
"@com_github_emacski_bazeltools//toolchain/cpp/clang:defs.bzl",
19+
"register_clang_cross_toolchains",
20+
)
1721
# OPTIONAL: only required if using the cross-build cc toolchain
18-
register_toolchains("@com_github_emacski_bazeltools//toolchain/cpp/clang:all")
22+
register_clang_cross_toolchains(clang_version = "11")
1923

2024
http_archive(
2125
name = "com_github_emacski_tensorflowservingarmclient",
@@ -54,19 +58,16 @@ Optional Bazel Build Options
5458

5559
# amd64 (x86_64)
5660
--platforms=@com_github_emacski_bazeltools//platform:linux_amd64
57-
# some deps still require legacy toolchain resolution
58-
--crosstool_top=@com_github_emacski_bazeltools//toolchain/cpp/clang:toolchain
59-
--cpu=k8
6061

6162
# arm64 (aarch64)
6263
--platforms=@com_github_emacski_bazeltools//platform:linux_arm64
63-
# some deps still require legacy toolchain resolution
64-
--crosstool_top=@com_github_emacski_bazeltools//toolchain/cpp/clang:toolchain
64+
# some deps may still require legacy toolchain resolution
65+
--crosstool_top=@com_github_emacski_bazeltools//toolchain/cpp/clang:clang11_crosstool
6566
--cpu=aarch64
6667

6768
# arm (armhf)
6869
--platforms=@com_github_emacski_bazeltools//platform:linux_arm
6970
# some deps still require legacy toolchain resolution
70-
--crosstool_top=@com_github_emacski_bazeltools//toolchain/cpp/clang:toolchain
71-
--cpu=arm
71+
--crosstool_top=@com_github_emacski_bazeltools//toolchain/cpp/clang:clang11_crosstool
72+
--cpu=armhf
7273
```

go/README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,17 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
99

1010
http_archive(
1111
name = "com_github_emacski_bazeltools",
12-
sha256 = "ef868ef493a8fc9609a32093a90b57f320646fa5af3b3eb49bb7380f5e0580c6",
13-
strip_prefix = "bazel-tools-9cbf59fc288489ab3c7e42ed124507e1b1adba3a",
14-
urls = ["https://github.com/emacski/bazel-tools/archive/9cbf59fc288489ab3c7e42ed124507e1b1adba3a.tar.gz"],
12+
sha256 = "dba9e8f0613401ed3c052d6fe79b3517197a7747046659845309fb17e9b3038d",
13+
strip_prefix = "bazel-tools-17a0d8b9ae66bc542853a72365ef1aeb85086827",
14+
urls = ["https://github.com/emacski/bazel-tools/archive/17a0d8b9ae66bc542853a72365ef1aeb85086827.tar.gz"],
1515
)
1616

17+
load(
18+
"@com_github_emacski_bazeltools//toolchain/cpp/clang:defs.bzl",
19+
"register_clang_cross_toolchains",
20+
)
1721
# OPTIONAL: only required if using the cross-build cc toolchain
18-
register_toolchains("@com_github_emacski_bazeltools//toolchain/cpp/clang:all")
22+
register_clang_cross_toolchains(clang_version = "11")
1923

2024
http_archive(
2125
name = "io_bazel_rules_go",

py/README.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,17 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
99

1010
http_archive(
1111
name = "com_github_emacski_bazeltools",
12-
sha256 = "ef868ef493a8fc9609a32093a90b57f320646fa5af3b3eb49bb7380f5e0580c6",
13-
strip_prefix = "bazel-tools-9cbf59fc288489ab3c7e42ed124507e1b1adba3a",
14-
urls = ["https://github.com/emacski/bazel-tools/archive/9cbf59fc288489ab3c7e42ed124507e1b1adba3a.tar.gz"],
12+
sha256 = "dba9e8f0613401ed3c052d6fe79b3517197a7747046659845309fb17e9b3038d",
13+
strip_prefix = "bazel-tools-17a0d8b9ae66bc542853a72365ef1aeb85086827",
14+
urls = ["https://github.com/emacski/bazel-tools/archive/17a0d8b9ae66bc542853a72365ef1aeb85086827.tar.gz"],
1515
)
1616

17+
load(
18+
"@com_github_emacski_bazeltools//toolchain/cpp/clang:defs.bzl",
19+
"register_clang_cross_toolchains",
20+
)
1721
# OPTIONAL: only required if using the cross-build cc toolchain
18-
register_toolchains("@com_github_emacski_bazeltools//toolchain/cpp/clang:all")
22+
register_clang_cross_toolchains(clang_version = "11")
1923

2024
http_archive(
2125
name = "rules_python",
@@ -64,19 +68,16 @@ Optional Bazel Build Options
6468

6569
# amd64 (x86_64)
6670
--platforms=@com_github_emacski_bazeltools//platform:linux_amd64
67-
# some deps still require legacy toolchain resolution
68-
--crosstool_top=@com_github_emacski_bazeltools//toolchain/cpp/clang:toolchain
69-
--cpu=k8
7071

7172
# arm64 (aarch64)
7273
--platforms=@com_github_emacski_bazeltools//platform:linux_arm64
73-
# some deps still require legacy toolchain resolution
74-
--crosstool_top=@com_github_emacski_bazeltools//toolchain/cpp/clang:toolchain
74+
# some deps may still require legacy toolchain resolution
75+
--crosstool_top=@com_github_emacski_bazeltools//toolchain/cpp/clang:clang11_crosstool
7576
--cpu=aarch64
7677

7778
# arm (armhf)
7879
--platforms=@com_github_emacski_bazeltools//platform:linux_arm
7980
# some deps still require legacy toolchain resolution
80-
--crosstool_top=@com_github_emacski_bazeltools//toolchain/cpp/clang:toolchain
81-
--cpu=arm
81+
--crosstool_top=@com_github_emacski_bazeltools//toolchain/cpp/clang:clang11_crosstool
82+
--cpu=armhf
8283
```

tools/docker/Dockerfile

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@
1414
FROM debian:buster
1515
RUN apt-get update && \
1616
apt-get install -y --no-install-recommends \
17+
curl ca-certificates \
1718
gcc g++ \
1819
gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf \
19-
gcc-aarch64-linux-gnu g++-aarch64-linux-gnu \
20-
libtinfo5 \
21-
curl xz-utils ca-certificates && \
20+
gcc-aarch64-linux-gnu g++-aarch64-linux-gnu && \
2221
apt-get clean && \
2322
rm -rf /var/lib/apt/lists/*
24-
ENV INSTALL_LLVM_VERSION=10.0.0
25-
RUN curl https://raw.githubusercontent.com/emacski/bazel-tools/master/toolchain/cpp/clang/install_clang_cross.sh -o install_clang_cross.sh && \
26-
sh install_clang_cross.sh && rm -f install_clang_cross.sh
23+
# clang cross-compile toolchain
24+
RUN curl -L https://raw.githubusercontent.com/emacski/bazel-tools/master/toolchain/cpp/clang/install_clang11_debian10.sh \
25+
-o install_clang11_debian10.sh && \
26+
sh install_clang11_debian10.sh && rm -f install_clang11_debian10.sh
2727
# python toolchain
2828
RUN apt-get update && \
2929
apt-get install -y --no-install-recommends \
@@ -43,11 +43,7 @@ RUN dpkg --add-architecture arm64 && \
4343
libpython3.7-dev:arm64 \
4444
libpython3.7-dev:armhf && \
4545
apt-get clean && \
46-
rm -rf /var/lib/apt/lists/* && \
47-
mkdir /usr/aarch64-linux-gnu/include/aarch64-linux-gnu && \
48-
mkdir /usr/arm-linux-gnueabihf/include/arm-linux-gnueabihf && \
49-
mv /usr/include/aarch64-linux-gnu/python3.7m /usr/aarch64-linux-gnu/include/aarch64-linux-gnu/ && \
50-
mv /usr/include/arm-linux-gnueabihf/python3.7m /usr/arm-linux-gnueabihf/include/arm-linux-gnueabihf/
46+
rm -rf /var/lib/apt/lists/*
5147
# install bazel
5248
RUN apt-get update && \
5349
apt-get install -y \

0 commit comments

Comments
 (0)