You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+59-12Lines changed: 59 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,32 +26,79 @@ This is a __Linux Docker image__ based on [ekidd/rust-musl-builder](https://hub.
26
26
27
27
It contains essential tools for cross-compile [Rust](https://www.rust-lang.org/) projects such as __Linux__ static binaries via [musl-libc / musl-gcc](https://doc.rust-lang.org/edition-guide/rust-2018/platform-and-target-support/musl-support-for-fully-static-binaries.html) (`x86_64-unknown-linux-musl`) and __macOS__ binaries (`x86_64-apple-darwin`) via [osxcross](https://github.com/tpoechtrager/osxcross) just using the same Linux image.
28
28
29
+
The Docker image is [multi-arch](https://www.docker.com/blog/multi-arch-build-and-images-the-simple-way/) (`amd64` and `arm64`) so you can use them in native environments.
30
+
Also, it is possible to cross-compile Linux or Darwin apps to `arm64` from the `x86_64` Docker image variant.
31
+
29
32
## Usage
30
33
31
34
### Compiling an application inside a Docker container
32
35
33
36
By default, the working directory is `/root/src`.
34
37
38
+
### x86_64 (amd64)
39
+
40
+
Below are the default toolchains included in the Docker image.
41
+
35
42
#### x86_64-unknown-linux-musl
36
43
37
44
```sh
38
45
docker run --rm \
39
46
--volume "${PWD}/sample":/root/src \
40
47
--workdir /root/src \
41
-
joseluisq/rust-linux-darwin-builder:1.64.0 \
42
-
sh -c "cargo build --release"
48
+
joseluisq/rust-linux-darwin-builder:1.65.0 \
49
+
sh -c "cargo build --release --target x86_64-unknown-linux-musl"
43
50
```
44
51
45
-
*Note that `x86_64-unknown-linux-gnu` is also available.*
52
+
#### x86_64-unknown-linux-gnu
53
+
54
+
```sh
55
+
docker run --rm \
56
+
--volume "${PWD}/sample":/root/src \
57
+
--workdir /root/src \
58
+
joseluisq/rust-linux-darwin-builder:1.65.0 \
59
+
sh -c "cargo build --release --target x86_64-unknown-linux-gnu"
60
+
```
46
61
47
62
#### x86_64-apple-darwin
48
63
49
64
```sh
50
65
docker run --rm \
51
66
--volume "${PWD}/sample":/root/src \
52
67
--workdir /root/src \
53
-
joseluisq/rust-linux-darwin-builder:1.64.0 \
54
-
sh -c "cargo build --release --target x86_64-apple-darwin"
68
+
joseluisq/rust-linux-darwin-builder:1.65.0 \
69
+
sh -c "cargo build --release --target x86_64-apple-darwin"
70
+
```
71
+
72
+
### aarch64 (arm64)
73
+
74
+
#### aarch64-unknown-linux-gnu
75
+
76
+
```sh
77
+
docker run --rm \
78
+
--volume "${PWD}/sample":/root/src \
79
+
--workdir /root/src \
80
+
joseluisq/rust-linux-darwin-builder:1.65.0 \
81
+
sh -c "cargo build --release --target aarch64-unknown-linux-gnu"
82
+
```
83
+
84
+
#### aarch64-unknown-linux-musl
85
+
86
+
```sh
87
+
docker run --rm \
88
+
--volume "${PWD}/sample":/root/src \
89
+
--workdir /root/src \
90
+
joseluisq/rust-linux-darwin-builder:1.65.0 \
91
+
sh -c "cargo build --release --target aarch64-unknown-linux-musl"
92
+
```
93
+
94
+
#### aarch64-apple-darwin
95
+
96
+
```sh
97
+
docker run --rm \
98
+
--volume "${PWD}/sample":/root/src \
99
+
--workdir /root/src \
100
+
joseluisq/rust-linux-darwin-builder:1.65.0 \
101
+
sh -c "cargo build --release --target aarch64-apple-darwin"
55
102
```
56
103
57
104
### Cargo Home advice
@@ -63,7 +110,7 @@ It's known that the [`CARGO_HOME`](https://doc.rust-lang.org/cargo/guide/cargo-h
63
110
You can also use the image as a base for your Dockerfile:
64
111
65
112
```Dockerfile
66
-
FROM joseluisq/rust-linux-darwin-builder:1.64.0
113
+
FROM joseluisq/rust-linux-darwin-builder:1.65.0
67
114
```
68
115
69
116
### OSXCross
@@ -106,7 +153,7 @@ compile:
106
153
@docker run --rm -it \
107
154
-v $(PWD):/drone/src \
108
155
-w /drone/src \
109
-
joseluisq/rust-linux-darwin-builder:1.64.0 \
156
+
joseluisq/rust-linux-darwin-builder:1.65.0 \
110
157
make cross-compile
111
158
.PHONY: compile
112
159
@@ -131,13 +178,13 @@ Just run the makefile `compile` target, then you will see two release binaries `
0 commit comments