Skip to content

Commit 00e74ec

Browse files
pepicrftclaude
andcommitted
fix(ci): Install clang-14 for cross-compilation
The default cross Docker images use Ubuntu 20.04 with clang-10, but bindgen 0.72+ requires clang 11+ (uses clang_Type_getValueType which was added in clang 11). Install clang-14 from LLVM apt repository and set LIBCLANG_PATH and LLVM_CONFIG_PATH environment variables for all Linux targets. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 4e7afb7 commit 00e74ec

File tree

1 file changed

+41
-22
lines changed

1 file changed

+41
-22
lines changed

Cross.toml

Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,65 +4,84 @@
44
# IMPORTANT: Cross-compilation runs ON x86_64 hosts, so protoc must be x86_64
55
# even when cross-compiling FOR ARM targets. Protoc runs during build.rs,
66
# which executes on the host, not the target architecture.
7+
#
8+
# NOTE: We install clang-14 because bindgen 0.72+ requires clang 11+
9+
# (uses clang_Type_getValueType which was added in clang 11).
10+
# The default cross images have clang 10 which is too old.
711

812
[build.env]
9-
passthrough = ["PROTOC"]
13+
passthrough = ["PROTOC", "LIBCLANG_PATH", "LLVM_CONFIG_PATH"]
1014

1115
# All targets use x86_64 protoc because cross builds run on x86_64 hosts
1216
[target.x86_64-unknown-linux-gnu]
1317
pre-build = [
14-
"apt-get update && apt-get install -y curl unzip",
18+
"apt-get update && apt-get install -y curl unzip wget gnupg software-properties-common",
19+
"wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -",
20+
"add-apt-repository 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main'",
21+
"apt-get update && apt-get install -y clang-14 libclang-14-dev",
22+
"ln -sf /usr/bin/clang-14 /usr/bin/clang",
1523
"curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v28.3/protoc-28.3-linux-x86_64.zip",
1624
"unzip protoc-28.3-linux-x86_64.zip -d /usr/local",
1725
"chmod +x /usr/local/bin/protoc",
1826
"rm protoc-28.3-linux-x86_64.zip",
1927
]
2028

29+
[target.x86_64-unknown-linux-gnu.env]
30+
LIBCLANG_PATH = "/usr/lib/llvm-14/lib"
31+
LLVM_CONFIG_PATH = "/usr/bin/llvm-config-14"
32+
2133
[target.x86_64-unknown-linux-musl]
22-
# libclang-dev is required for librocksdb-sys build script
2334
pre-build = [
24-
"apt-get update && apt-get install -y curl unzip libclang-dev",
35+
"apt-get update && apt-get install -y curl unzip wget gnupg software-properties-common",
36+
"wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -",
37+
"add-apt-repository 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main'",
38+
"apt-get update && apt-get install -y clang-14 libclang-14-dev",
39+
"ln -sf /usr/bin/clang-14 /usr/bin/clang",
2540
"curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v28.3/protoc-28.3-linux-x86_64.zip",
2641
"unzip protoc-28.3-linux-x86_64.zip -d /usr/local",
2742
"chmod +x /usr/local/bin/protoc",
2843
"rm protoc-28.3-linux-x86_64.zip",
2944
]
3045

46+
[target.x86_64-unknown-linux-musl.env]
47+
LIBCLANG_PATH = "/usr/lib/llvm-14/lib"
48+
LLVM_CONFIG_PATH = "/usr/bin/llvm-config-14"
49+
3150
[target.aarch64-unknown-linux-gnu]
3251
pre-build = [
33-
"apt-get update && apt-get install -y curl unzip",
52+
"apt-get update && apt-get install -y curl unzip wget gnupg software-properties-common",
53+
"wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -",
54+
"add-apt-repository 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main'",
55+
"apt-get update && apt-get install -y clang-14 libclang-14-dev",
56+
"ln -sf /usr/bin/clang-14 /usr/bin/clang",
3457
"curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v28.3/protoc-28.3-linux-x86_64.zip",
3558
"unzip protoc-28.3-linux-x86_64.zip -d /usr/local",
3659
"chmod +x /usr/local/bin/protoc",
3760
"rm protoc-28.3-linux-x86_64.zip",
3861
]
3962

63+
[target.aarch64-unknown-linux-gnu.env]
64+
LIBCLANG_PATH = "/usr/lib/llvm-14/lib"
65+
LLVM_CONFIG_PATH = "/usr/bin/llvm-config-14"
66+
4067
[target.aarch64-unknown-linux-musl]
41-
# libclang-dev is required for librocksdb-sys build script
4268
pre-build = [
43-
"apt-get update && apt-get install -y curl unzip libclang-dev",
69+
"apt-get update && apt-get install -y curl unzip wget gnupg software-properties-common",
70+
"wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -",
71+
"add-apt-repository 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main'",
72+
"apt-get update && apt-get install -y clang-14 libclang-14-dev",
73+
"ln -sf /usr/bin/clang-14 /usr/bin/clang",
4474
"curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v28.3/protoc-28.3-linux-x86_64.zip",
4575
"unzip protoc-28.3-linux-x86_64.zip -d /usr/local",
4676
"chmod +x /usr/local/bin/protoc",
4777
"rm protoc-28.3-linux-x86_64.zip",
4878
]
4979

80+
[target.aarch64-unknown-linux-musl.env]
81+
LIBCLANG_PATH = "/usr/lib/llvm-14/lib"
82+
LLVM_CONFIG_PATH = "/usr/bin/llvm-config-14"
83+
5084
# ARMv7 targets are disabled because rquickjs doesn't have pre-built bindings for them
5185
# Uncomment when/if rquickjs adds armv7 support
5286
# [target.armv7-unknown-linux-gnueabihf]
53-
# pre-build = [
54-
# "apt-get update && apt-get install -y curl unzip libclang-dev",
55-
# "curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v28.3/protoc-28.3-linux-x86_64.zip",
56-
# "unzip protoc-28.3-linux-x86_64.zip -d /usr/local",
57-
# "chmod +x /usr/local/bin/protoc",
58-
# "rm protoc-28.3-linux-x86_64.zip",
59-
# ]
60-
6187
# [target.armv7-unknown-linux-musleabihf]
62-
# pre-build = [
63-
# "apt-get update && apt-get install -y curl unzip libclang-dev",
64-
# "curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v28.3/protoc-28.3-linux-x86_64.zip",
65-
# "unzip protoc-28.3-linux-x86_64.zip -d /usr/local",
66-
# "chmod +x /usr/local/bin/protoc",
67-
# "rm protoc-28.3-linux-x86_64.zip",
68-
# ]

0 commit comments

Comments
 (0)