Skip to content

Commit f1b8d3d

Browse files
authored
Cross compile with rustc instead of cross-rs; drop aarch64-unknown-linux-musl (#715)
1 parent 3029c67 commit f1b8d3d

File tree

2 files changed

+32
-23
lines changed

2 files changed

+32
-23
lines changed

.circleci/config.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ aliases:
2222
machine:
2323
image: ubuntu-2204:2024.01.2
2424
resource_class: large
25-
environment:
26-
COMPILER_ARCHIVE: cross-x86_64-unknown-linux-gnu.tar.gz
2725

2826
executors:
2927
unknown-linux-gnu:
@@ -36,8 +34,6 @@ executors:
3634
macos:
3735
xcode: 15.3.0
3836
resource_class: macos.m1.medium.gen1
39-
environment:
40-
COMPILER_ARCHIVE: cross-x86_64-apple-darwin.tar.gz
4137

4238
# Define a job to be invoked later in a workflow.
4339
# See: https://circleci.com/docs/configuration-reference/#jobs
@@ -176,6 +172,10 @@ workflows:
176172
parameters:
177173
arch: [x86_64, aarch64]
178174
platform: [unknown-linux-gnu, unknown-linux-musl, apple-darwin]
175+
exclude:
176+
# This combination cannot be built
177+
- arch: aarch64
178+
platform: unknown-linux-musl
179179
target_triplet: << matrix.arch >>-<< matrix.platform >>
180180
archive_path: starknet-devnet-<< matrix.arch >>-<< matrix.platform >>.tar.gz
181181
- image-build-amd:

scripts/compile_binary.sh

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,41 @@
22

33
set -euo pipefail
44

5-
CROSS_VERSION="v0.2.5"
6-
7-
if [ $# != 1 ]; then
8-
>&2 echo "Error: $0 <TARGET>"
5+
if [ "$#" -ne 1 ]; then
6+
echo >&2 "Error: $0 <TARGET>"
97
exit 1
108
fi
119
TARGET="$1"
1210

13-
kernel_name=$(uname -s)
14-
case "$kernel_name" in
15-
Darwin*)
16-
# on mac (for apple-darwin targets), rely on host compiler's targets
17-
rustup target add "$TARGET"
18-
compiler_command="cargo"
11+
CARGO_CONFIG=~/.cargo/config.toml
12+
13+
case "$TARGET" in
14+
x86_64-unknown-linux-gnu | x86_64-apple-darwin | aarch64-apple-darwin)
15+
echo "Target requires no extra actions: $TARGET"
1916
;;
20-
Linux*)
21-
# on linux, rely on cross compiler
22-
download_url="https://github.com/cross-rs/cross/releases/download/${CROSS_VERSION}/cross-x86_64-unknown-linux-gnu.tar.gz"
23-
curl -SsL "$download_url" |
24-
tar -xvz -C /tmp
25-
compiler_command="/tmp/cross"
17+
18+
x86_64-unknown-linux-musl)
19+
sudo apt-get update
20+
sudo apt-get install musl-tools
21+
musl-gcc --version && echo "Musl successfully installed"
2622
;;
23+
24+
aarch64-unknown-linux-gnu)
25+
sudo apt-get update
26+
sudo apt-get install gcc-aarch64-linux-gnu
27+
28+
aarch64-linux-gnu-gcc --version
29+
echo "Cross compiler successfully installed"
30+
31+
echo '[target.aarch64-unknown-linux-gnu]' >>"$CARGO_CONFIG"
32+
echo 'linker = "aarch64-linux-gnu-gcc"' >>"$CARGO_CONFIG"
33+
;;
34+
2735
*)
28-
>&2 echo "Unsupported kernel: $kernel_name"
29-
exit 1
36+
echo >&2 "Error: Unsupported compilation target: $TARGET"
37+
exit 2
3038
;;
3139
esac
3240

33-
"$compiler_command" build --release --target="$TARGET"
41+
rustup target add "$TARGET"
42+
cargo build --release --target="$TARGET" --bin starknet-devnet

0 commit comments

Comments
 (0)