Skip to content

Commit f0936e1

Browse files
authored
Ensure llvm-ar is used as the archiver (#13)
* Setup CI to test arm64 docker image * Use llvm-ar as the archiver in build process * Ensure llvm package is install so llvm-ar will be present
1 parent b719fb0 commit f0936e1

File tree

5 files changed

+40
-6
lines changed

5 files changed

+40
-6
lines changed

.github/workflows/rust.yml

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,36 @@ jobs:
4646
- name: Reproducible build runs
4747
run: cd test-contract && ./scripts/reproducible_build_docker --update && ./scripts/reproducible_build_docker --no-clean
4848

49+
ubuntu-arm64-docker-build:
50+
51+
runs-on: ubuntu-latest
52+
53+
steps:
54+
- uses: actions/checkout@v3
55+
- name: Setup qemu binfmt
56+
run: docker run --privileged --rm tonistiigi/binfmt --install all
57+
- name: Install cargo generate
58+
run: cargo install cargo-generate
59+
- name: Generate workspace
60+
run: cargo generate --path . workspace --name test-workspace
61+
- name: Generate crates && contracts
62+
run: cd test-workspace &&
63+
make generate CRATE=clib TEMPLATE=c-wrapper-crate DESTINATION=crates TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
64+
make generate CRATE=rlib TEMPLATE=x64-simulator-crate DESTINATION=crates TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
65+
make generate CRATE=c1 TEMPLATE=contract TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
66+
make generate CRATE=c2 TEMPLATE=atomics-contract TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
67+
make generate CRATE=c3 TEMPLATE=stack-reorder-contract TEMPLATE_TYPE=--path TEMPLATE_REPO=..
68+
- name: Submodules
69+
run: cd test-workspace &&
70+
git submodule add https://github.com/nervosnetwork/ckb-c-stdlib deps/ckb-c-stdlib &&
71+
git submodule add https://github.com/xxuejie/lib-dummy-atomics deps/lib-dummy-atomics
72+
- name: Reproducible build runs
73+
run: cd test-workspace && export DOCKER_RUN_ARGS="--platform linux/arm64" && ./scripts/reproducible_build_docker --update && ./scripts/reproducible_build_docker --no-clean
74+
- name: Generate standalone contract
75+
run: cargo generate --path . standalone-contract --name test-contract
76+
- name: Reproducible build runs
77+
run: cd test-contract && export DOCKER_RUN_ARGS="--platform linux/arm64" && ./scripts/reproducible_build_docker --update && ./scripts/reproducible_build_docker --no-clean
78+
4979
debian-build:
5080

5181
runs-on: ubuntu-latest
@@ -98,7 +128,7 @@ jobs:
98128

99129
steps:
100130
- name: Install dependencies
101-
run: sudo dnf -y install clang git make openssl-devel
131+
run: sudo dnf -y install clang llvm git make openssl-devel
102132
- uses: actions-rust-lang/setup-rust-toolchain@v1
103133
with:
104134
components: clippy
@@ -138,7 +168,7 @@ jobs:
138168

139169
steps:
140170
- name: Install dependencies
141-
run: pacman --noconfirm -Syu clang git make openssl pkgconf
171+
run: pacman --noconfirm -Syu clang llvm git make openssl pkgconf
142172
- uses: actions-rust-lang/setup-rust-toolchain@v1
143173
with:
144174
components: clippy

atomics-contract/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ MODE := release
1818
# Tweak this to change the clang version to use for building C code. By default
1919
# we use a bash script with somes heuristics to find clang in current system.
2020
CLANG := $(shell $(TOP)/scripts/find_clang)
21+
AR := $(subst clang,llvm-ar,$(CLANG))
2122
# When this is set to some value, the generated binaries will be copied over
2223
BUILD_DIR :=
2324
# Generated binaries to copy. By convention, a Rust crate's directory name will
@@ -33,7 +34,7 @@ endif
3334
default: build test
3435

3536
build:
36-
RUSTFLAGS="$(FULL_RUSTFLAGS)" TARGET_CC="$(CLANG)" \
37+
RUSTFLAGS="$(FULL_RUSTFLAGS)" TARGET_CC="$(CLANG)" TARGET_AR="$(AR)" \
3738
cargo build --target=riscv64imac-unknown-none-elf $(MODE_ARGS) $(CARGO_ARGS)
3839
@set -eu; \
3940
if [ "x$(BUILD_DIR)" != "x" ]; then \

contract/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ MODE := release
1818
# Tweak this to change the clang version to use for building C code. By default
1919
# we use a bash script with somes heuristics to find clang in current system.
2020
CLANG := $(shell $(TOP)/scripts/find_clang)
21+
AR := $(subst clang,llvm-ar,$(CLANG))
2122
# When this is set to some value, the generated binaries will be copied over
2223
BUILD_DIR :=
2324
# Generated binaries to copy. By convention, a Rust crate's directory name will
@@ -33,7 +34,7 @@ endif
3334
default: build test
3435

3536
build:
36-
RUSTFLAGS="$(FULL_RUSTFLAGS)" TARGET_CC="$(CLANG)" \
37+
RUSTFLAGS="$(FULL_RUSTFLAGS)" TARGET_CC="$(CLANG)" TARGET_AR="$(AR)" \
3738
cargo build --target=riscv64imac-unknown-none-elf $(MODE_ARGS) $(CARGO_ARGS)
3839
@set -eu; \
3940
if [ "x$(BUILD_DIR)" != "x" ]; then \

stack-reorder-contract/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ MODE := release
1919
# Tweak this to change the clang version to use for building C code. By default
2020
# we use a bash script with somes heuristics to find clang in current system.
2121
CLANG := $(shell $(TOP)/scripts/find_clang)
22+
AR := $(subst clang,llvm-ar,$(CLANG))
2223
# When this is set to some value, the generated binaries will be copied over
2324
BUILD_DIR :=
2425
# Generated binaries to copy. By convention, a Rust crate's directory name will
@@ -34,7 +35,7 @@ endif
3435
default: build test
3536

3637
build:
37-
RUSTFLAGS="$(FULL_RUSTFLAGS)" TARGET_CC="$(CLANG)" \
38+
RUSTFLAGS="$(FULL_RUSTFLAGS)" TARGET_CC="$(CLANG)" TARGET_AR="$(AR)" \
3839
cargo build --target=riscv64imac-unknown-none-elf $(MODE_ARGS) $(CARGO_ARGS)
3940
@set -eu; \
4041
if [ "x$(BUILD_DIR)" != "x" ]; then \

standalone-contract/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ MODE := release
1818
# Tweak this to change the clang version to use for building C code. By default
1919
# we use a bash script with somes heuristics to find clang in current system.
2020
CLANG := $(shell $(TOP)/scripts/find_clang)
21+
AR := $(subst clang,llvm-ar,$(CLANG))
2122
# When this is set to some value, the generated binaries will be copied over
2223
BUILD_DIR := build/$(MODE)
2324
# Generated binaries to copy. By convention, a Rust crate's directory name will
@@ -33,7 +34,7 @@ endif
3334
default: build test
3435

3536
build:
36-
RUSTFLAGS="$(FULL_RUSTFLAGS)" TARGET_CC="$(CLANG)" \
37+
RUSTFLAGS="$(FULL_RUSTFLAGS)" TARGET_CC="$(CLANG)" TARGET_AR="$(AR)" \
3738
cargo build --target=riscv64imac-unknown-none-elf $(MODE_ARGS) $(CARGO_ARGS)
3839
mkdir -p $(BUILD_DIR)
3940
@set -eu; \

0 commit comments

Comments
 (0)