Skip to content

Commit 069c8d9

Browse files
committed
Let builders target /target
1 parent 9245dcb commit 069c8d9

File tree

7 files changed

+26
-32
lines changed

7 files changed

+26
-32
lines changed

Makefile

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,6 @@ bench:
6868

6969
# Creates a release build in a containerized build environment of the static library for Alpine Linux (.a)
7070
release-build-alpine:
71-
# Builders should not write their target folder into the host file system (https://github.com/CosmWasm/wasmvm/issues/437)
72-
rm -rf libwasmvm/target/aarch64-unknown-linux-musl/release
73-
rm -rf libwasmvm/target/x86_64-unknown-linux-musl/release
7471
# build the muslc *.a file
7572
docker run --rm -u $(USER_ID):$(USER_GROUP) -v $(shell pwd)/libwasmvm:/code $(BUILDERS_PREFIX)-alpine
7673
cp libwasmvm/artifacts/libwasmvm_muslc.x86_64.a internal/api
@@ -79,9 +76,6 @@ release-build-alpine:
7976

8077
# Creates a release build in a containerized build environment of the shared library for glibc Linux (.so)
8178
release-build-linux:
82-
# Builders should not write their target folder into the host file system (https://github.com/CosmWasm/wasmvm/issues/437)
83-
rm -rf libwasmvm/target/x86_64-unknown-linux-gnu/release
84-
rm -rf libwasmvm/target/aarch64-unknown-linux-gnu/release
8579
docker run --rm -u $(USER_ID):$(USER_GROUP) -v $(shell pwd)/libwasmvm:/code $(BUILDERS_PREFIX)-debian build_gnu_x86_64.sh
8680
docker run --rm -u $(USER_ID):$(USER_GROUP) -v $(shell pwd)/libwasmvm:/code $(BUILDERS_PREFIX)-debian build_gnu_aarch64.sh
8781
cp libwasmvm/artifacts/libwasmvm.x86_64.so internal/api
@@ -90,28 +84,20 @@ release-build-linux:
9084

9185
# Creates a release build in a containerized build environment of the shared library for macOS (.dylib)
9286
release-build-macos:
93-
# Builders should not write their target folder into the host file system (https://github.com/CosmWasm/wasmvm/issues/437)
94-
rm -rf libwasmvm/target/x86_64-apple-darwin/release
95-
rm -rf libwasmvm/target/aarch64-apple-darwin/release
9687
docker run --rm -u $(USER_ID):$(USER_GROUP) -v $(shell pwd)/libwasmvm:/code $(BUILDERS_PREFIX)-cross build_macos.sh
9788
cp libwasmvm/artifacts/libwasmvm.dylib internal/api
9889
make update-bindings
9990

10091
# Creates a release build in a containerized build environment of the static library for macOS (.a)
10192
release-build-macos-static:
102-
# Builders should not write their target folder into the host file system (https://github.com/CosmWasm/wasmvm/issues/437)
103-
rm -rf libwasmvm/target/x86_64-apple-darwin/release
104-
rm -rf libwasmvm/target/aarch64-apple-darwin/release
10593
docker run --rm -u $(USER_ID):$(USER_GROUP) -v $(shell pwd)/libwasmvm:/code $(BUILDERS_PREFIX)-cross build_macos_static.sh
10694
cp libwasmvm/artifacts/libwasmvmstatic_darwin.a internal/api/libwasmvmstatic_darwin.a
10795
make update-bindings
10896

10997
# Creates a release build in a containerized build environment of the shared library for Windows (.dll)
11098
release-build-windows:
111-
# Builders should not write their target folder into the host file system (https://github.com/CosmWasm/wasmvm/issues/437)
112-
rm -rf libwasmvm/target/x86_64-pc-windows-gnu/release
11399
docker run --rm -u $(USER_ID):$(USER_GROUP) -v $(shell pwd)/libwasmvm:/code $(BUILDERS_PREFIX)-cross build_windows.sh
114-
cp libwasmvm/target/x86_64-pc-windows-gnu/release/wasmvm.dll internal/api
100+
cp libwasmvm/artifacts/wasmvm.dll internal/api
115101
make update-bindings
116102

117103
update-bindings:

builders/guest/build_gnu_aarch64.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
set -o errexit -o nounset -o pipefail
33

44
export CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse
5+
export TARGET_DIR="/target" # write to /target in the guest's file system to avoid writing to the host
56

67
# No stripping implemented (see https://github.com/CosmWasm/wasmvm/issues/222#issuecomment-2260007943).
78

@@ -14,5 +15,5 @@ export AR_aarch64_unknown_linux_gnu=llvm-ar
1415
export CFLAGS_aarch64_unknown_linux_gnu="--sysroot=/usr/aarch64-linux-gnu"
1516
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
1617
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER="$qemu_aarch64"
17-
cargo build --release --target aarch64-unknown-linux-gnu
18-
cp target/aarch64-unknown-linux-gnu/release/libwasmvm.so artifacts/libwasmvm.aarch64.so
18+
cargo build --release --target-dir="$TARGET_DIR" --target aarch64-unknown-linux-gnu
19+
cp "$TARGET_DIR/aarch64-unknown-linux-gnu/release/libwasmvm.so" artifacts/libwasmvm.aarch64.so

builders/guest/build_gnu_x86_64.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
set -o errexit -o nounset -o pipefail
33

44
export CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse
5+
export TARGET_DIR="/target" # write to /target in the guest's file system to avoid writing to the host
56

67
# No stripping implemented (see https://github.com/CosmWasm/wasmvm/issues/222#issuecomment-2260007943).
78

89
echo "Starting x86_64-unknown-linux-gnu build"
910
export CC=clang
1011
export CXX=clang++
11-
cargo build --release --target x86_64-unknown-linux-gnu
12-
cp target/x86_64-unknown-linux-gnu/release/libwasmvm.so artifacts/libwasmvm.x86_64.so
12+
cargo build --release --target-dir="$TARGET_DIR" --target x86_64-unknown-linux-gnu
13+
cp "$TARGET_DIR/x86_64-unknown-linux-gnu/release/libwasmvm.so" artifacts/libwasmvm.x86_64.so

builders/guest/build_macos.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
set -o errexit -o nounset -o pipefail
33

44
export CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse
5+
export TARGET_DIR="/target" # write to /target in the guest's file system to avoid writing to the host
56

67
# ref: https://wapl.es/rust/2019/02/17/rust-cross-compile-linux-to-macos.html
78
export PATH="/opt/osxcross/target/bin:$PATH"
@@ -12,14 +13,14 @@ export LIBZ_SYS_STATIC=1
1213
echo "Starting aarch64-apple-darwin build"
1314
export CC=aarch64-apple-darwin20.4-clang
1415
export CXX=aarch64-apple-darwin20.4-clang++
15-
cargo build --release --target aarch64-apple-darwin
16+
cargo build --release --target-dir="$TARGET_DIR" --target aarch64-apple-darwin
1617

1718
echo "Starting x86_64-apple-darwin build"
1819
export CC=o64-clang
1920
export CXX=o64-clang++
20-
cargo build --release --target x86_64-apple-darwin
21+
cargo build --release --target-dir="$TARGET_DIR" --target x86_64-apple-darwin
2122

2223
# Create a universal library with both archs
2324
lipo -output artifacts/libwasmvm.dylib -create \
24-
target/x86_64-apple-darwin/release/deps/libwasmvm.dylib \
25-
target/aarch64-apple-darwin/release/deps/libwasmvm.dylib
25+
"$TARGET_DIR/x86_64-apple-darwin/release/deps/libwasmvm.dylib" \
26+
"$TARGET_DIR/aarch64-apple-darwin/release/deps/libwasmvm.dylib"

builders/guest/build_macos_static.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
set -o errexit -o nounset -o pipefail
33

44
export CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse
5+
export TARGET_DIR="/target" # write to /target in the guest's file system to avoid writing to the host
56

67
# ref: https://wapl.es/rust/2019/02/17/rust-cross-compile-linux-to-macos.html
78
export PATH="/opt/osxcross/target/bin:$PATH"
@@ -12,14 +13,14 @@ export LIBZ_SYS_STATIC=1
1213
echo "Starting aarch64-apple-darwin build"
1314
export CC=aarch64-apple-darwin20.4-clang
1415
export CXX=aarch64-apple-darwin20.4-clang++
15-
cargo build --release --target aarch64-apple-darwin --example wasmvmstatic
16+
cargo build --release --target-dir="$TARGET_DIR" --target aarch64-apple-darwin --example wasmvmstatic
1617

1718
echo "Starting x86_64-apple-darwin build"
1819
export CC=o64-clang
1920
export CXX=o64-clang++
20-
cargo build --release --target x86_64-apple-darwin --example wasmvmstatic
21+
cargo build --release --target-dir="$TARGET_DIR" --target x86_64-apple-darwin --example wasmvmstatic
2122

2223
# Create a universal library with both archs
2324
lipo -output artifacts/libwasmvmstatic_darwin.a -create \
24-
target/x86_64-apple-darwin/release/examples/libwasmvmstatic.a \
25-
target/aarch64-apple-darwin/release/examples/libwasmvmstatic.a
25+
"$TARGET_DIR/x86_64-apple-darwin/release/examples/libwasmvmstatic.a" \
26+
"$TARGET_DIR/aarch64-apple-darwin/release/examples/libwasmvmstatic.a"

builders/guest/build_muslc.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@
22
set -e # Note we are not using bash here but the Alpine default shell
33

44
export CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse
5+
export TARGET_DIR="/target" # write to /target in the guest's file system to avoid writing to the host
56

67
# No stripping implemented (see https://github.com/CosmWasm/wasmvm/issues/222#issuecomment-2260007943).
78

89
echo "Starting aarch64-unknown-linux-musl build"
910
export CC=/opt/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc
10-
cargo build --release --target aarch64-unknown-linux-musl --example wasmvmstatic
11+
cargo build --release --target-dir="$TARGET_DIR" --target aarch64-unknown-linux-musl --example wasmvmstatic
1112
unset CC
1213

1314
echo "Starting x86_64-unknown-linux-musl build"
14-
cargo build --release --target x86_64-unknown-linux-musl --example wasmvmstatic
15+
cargo build --release --target-dir="$TARGET_DIR" --target x86_64-unknown-linux-musl --example wasmvmstatic
1516

16-
cp target/aarch64-unknown-linux-musl/release/examples/libwasmvmstatic.a artifacts/libwasmvm_muslc.aarch64.a
17-
cp target/x86_64-unknown-linux-musl/release/examples/libwasmvmstatic.a artifacts/libwasmvm_muslc.x86_64.a
17+
cp "$TARGET_DIR/aarch64-unknown-linux-musl/release/examples/libwasmvmstatic.a" artifacts/libwasmvm_muslc.aarch64.a
18+
cp "$TARGET_DIR/x86_64-unknown-linux-musl/release/examples/libwasmvmstatic.a" artifacts/libwasmvm_muslc.x86_64.a

builders/guest/build_windows.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
set -o errexit -o nounset -o pipefail
33

44
export CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse
5+
export TARGET_DIR="/target" # write to /target in the guest's file system to avoid writing to the host
56

67
# ref: https://www.reddit.com/r/rust/comments/5k8uab/crosscompiling_from_ubuntu_to_windows_with_rustup/
78

8-
cargo build --release --target x86_64-pc-windows-gnu
9+
cargo build --release --target-dir="$TARGET_DIR" --target x86_64-pc-windows-gnu
10+
11+
cp "$TARGET_DIR/x86_64-pc-windows-gnu/release/wasmvm.dll" artifacts/wasmvm.dll

0 commit comments

Comments
 (0)