1
- # `aarch64-fuchsia` and `x86_64-fuchsia`
1
+ # `aarch64-unknown- fuchsia` and `x86_64-unknown -fuchsia`
2
2
3
3
**Tier: 2**
4
4
@@ -67,7 +67,7 @@ This walkthrough will cover:
67
67
1. Building a Fuchsia package.
68
68
1. Publishing and running a Fuchsia package to a Fuchsia emulator.
69
69
70
- For the purposes of this walkthrough, we will only target `x86_64-fuchsia`.
70
+ For the purposes of this walkthrough, we will only target `x86_64-unknown- fuchsia`.
71
71
72
72
## Compiling a Rust binary targeting Fuchsia
73
73
@@ -83,8 +83,8 @@ to handle the installation of Fuchsia targets for you. This can be done by issui
83
83
the following commands:
84
84
85
85
```sh
86
- rustup target add x86_64-fuchsia
87
- rustup target add aarch64-fuchsia
86
+ rustup target add x86_64-unknown- fuchsia
87
+ rustup target add aarch64-unknown- fuchsia
88
88
```
89
89
90
90
After installing our Fuchsia targets, we can now compile a Rust binary that targets
@@ -127,7 +127,7 @@ during compilation:
127
127
128
128
**`.cargo/config.toml`**
129
129
```txt
130
- [target.x86_64-fuchsia]
130
+ [target.x86_64-unknown- fuchsia]
131
131
132
132
rustflags = [
133
133
"-Lnative=<SDK_PATH>/arch/x64/lib",
@@ -159,10 +159,10 @@ hello_fuchsia/
159
159
Finally, we can build our rust binary as:
160
160
161
161
```sh
162
- cargo build --target x86_64-fuchsia
162
+ cargo build --target x86_64-unknown- fuchsia
163
163
```
164
164
165
- Now we have a Rust binary at `target/x86_64-fuchsia/debug/hello_fuchsia`,
165
+ Now we have a Rust binary at `target/x86_64-unknown- fuchsia/debug/hello_fuchsia`,
166
166
targeting our desired Fuchsia target.
167
167
168
168
**Current directory structure**
@@ -171,7 +171,7 @@ hello_fuchsia/
171
171
┣━ src/
172
172
┃ ┗━ main.rs
173
173
┣━ target/
174
- ┃ ┗━ x86_64-fuchsia/
174
+ ┃ ┗━ x86_64-unknown- fuchsia/
175
175
┃ ┗━ debug/
176
176
┃ ┗━ hello_fuchsia
177
177
┣━ Cargo.toml
@@ -193,19 +193,19 @@ configuration in `config.toml`:
193
193
194
194
```toml
195
195
[build]
196
- target = ["<host_platform>", "aarch64-fuchsia", "x86_64-fuchsia"]
196
+ target = ["<host_platform>", "aarch64-unknown- fuchsia", "x86_64-unknown -fuchsia"]
197
197
198
198
[rust]
199
199
lld = true
200
200
201
201
[llvm]
202
202
download-ci-llvm = false
203
203
204
- [target.x86_64-fuchsia]
204
+ [target.x86_64-unknown- fuchsia]
205
205
cc = "clang"
206
206
cxx = "clang++"
207
207
208
- [target.aarch64-fuchsia]
208
+ [target.aarch64-unknown- fuchsia]
209
209
cc = "clang"
210
210
cxx = "clang++"
211
211
```
@@ -236,14 +236,14 @@ a script we name `config-env.sh`:
236
236
# Configure this environment variable to be the path to the downloaded SDK
237
237
export SDK_PATH="<SDK path goes here>"
238
238
239
- export CFLAGS_aarch64_fuchsia ="--target=aarch64-fuchsia --sysroot=${SDK_PATH}/arch/arm64/sysroot -I${SDK_PATH}/pkg/fdio/include"
240
- export CXXFLAGS_aarch64_fuchsia ="--target=aarch64-fuchsia --sysroot=${SDK_PATH}/arch/arm64/sysroot -I${SDK_PATH}/pkg/fdio/include"
241
- export LDFLAGS_aarch64_fuchsia ="--target=aarch64-fuchsia --sysroot=${SDK_PATH}/arch/arm64/sysroot -L${SDK_PATH}/arch/arm64/lib"
242
- export CARGO_TARGET_AARCH64_FUCHSIA_RUSTFLAGS ="-C link-arg=--sysroot=${SDK_PATH}/arch/arm64/sysroot -Lnative=${SDK_PATH}/arch/arm64/sysroot/lib -Lnative=${SDK_PATH}/arch/arm64/lib"
243
- export CFLAGS_x86_64_fuchsia ="--target=x86_64-fuchsia --sysroot=${SDK_PATH}/arch/x64/sysroot -I${SDK_PATH}/pkg/fdio/include"
244
- export CXXFLAGS_x86_64_fuchsia ="--target=x86_64-fuchsia --sysroot=${SDK_PATH}/arch/x64/sysroot -I${SDK_PATH}/pkg/fdio/include"
245
- export LDFLAGS_x86_64_fuchsia ="--target=x86_64-fuchsia --sysroot=${SDK_PATH}/arch/x64/sysroot -L${SDK_PATH}/arch/x64/lib"
246
- export CARGO_TARGET_X86_64_FUCHSIA_RUSTFLAGS ="-C link-arg=--sysroot=${SDK_PATH}/arch/x64/sysroot -Lnative=${SDK_PATH}/arch/x64/sysroot/lib -Lnative=${SDK_PATH}/arch/x64/lib"
239
+ export CFLAGS_aarch64_unknown_fuchsia ="--target=aarch64-unknown -fuchsia --sysroot=${SDK_PATH}/arch/arm64/sysroot -I${SDK_PATH}/pkg/fdio/include"
240
+ export CXXFLAGS_aarch64_unknown_fuchsia ="--target=aarch64-unknown -fuchsia --sysroot=${SDK_PATH}/arch/arm64/sysroot -I${SDK_PATH}/pkg/fdio/include"
241
+ export LDFLAGS_aarch64_unknown_fuchsia ="--target=aarch64-unknown -fuchsia --sysroot=${SDK_PATH}/arch/arm64/sysroot -L${SDK_PATH}/arch/arm64/lib"
242
+ export CARGO_TARGET_AARCH64_UNKNOWN_FUCHSIA_RUSTFLAGS ="-C link-arg=--sysroot=${SDK_PATH}/arch/arm64/sysroot -Lnative=${SDK_PATH}/arch/arm64/sysroot/lib -Lnative=${SDK_PATH}/arch/arm64/lib"
243
+ export CFLAGS_x86_64_unknown_fuchsia ="--target=x86_64-unknown -fuchsia --sysroot=${SDK_PATH}/arch/x64/sysroot -I${SDK_PATH}/pkg/fdio/include"
244
+ export CXXFLAGS_x86_64_unknown_fuchsia ="--target=x86_64-unknown -fuchsia --sysroot=${SDK_PATH}/arch/x64/sysroot -I${SDK_PATH}/pkg/fdio/include"
245
+ export LDFLAGS_x86_64_unknown_fuchsia ="--target=x86_64-unknown -fuchsia --sysroot=${SDK_PATH}/arch/x64/sysroot -L${SDK_PATH}/arch/x64/lib"
246
+ export CARGO_TARGET_X86_64_UNKNOWN_FUCHSIA_RUSTFLAGS ="-C link-arg=--sysroot=${SDK_PATH}/arch/x64/sysroot -Lnative=${SDK_PATH}/arch/x64/sysroot/lib -Lnative=${SDK_PATH}/arch/x64/lib"
247
247
```
248
248
249
249
Finally, the Rust compiler can be built and installed:
@@ -288,7 +288,7 @@ hello_fuchsia/
288
288
Using your freshly installed `rustc`, you can compile a binary for Fuchsia using
289
289
the following options:
290
290
291
- * `--target x86_64-fuchsia`/`--target aarch64-fuchsia`: Targets the Fuchsia
291
+ * `--target x86_64-unknown- fuchsia`/`--target aarch64-unknown -fuchsia`: Targets the Fuchsia
292
292
platform of your choice
293
293
* `-Lnative ${SDK_PATH}/arch/${ARCH}/lib`: Link against Fuchsia libraries from
294
294
the SDK
@@ -299,7 +299,7 @@ Putting it all together:
299
299
300
300
```sh
301
301
# Configure these for the Fuchsia target of your choice
302
- TARGET_ARCH="<x86_64-fuchsia|aarch64-fuchsia>"
302
+ TARGET_ARCH="<x86_64-unknown- fuchsia|aarch64-unknown -fuchsia>"
303
303
ARCH="<x64|aarch64>"
304
304
305
305
rustc \
@@ -325,16 +325,16 @@ Before moving on, double check your directory structure:
325
325
**Current directory structure**
326
326
```txt
327
327
hello_fuchsia/
328
- ┣━ src/ (if using rustc)
329
- ┃ ┗━ hello_fuchsia.rs ...
330
- ┣━ bin/ ...
331
- ┃ ┗━ hello_fuchsia ...
332
- ┣━ src/ (if using cargo)
333
- ┃ ┗━ main.rs ...
334
- ┗━ target/ ...
335
- ┗━ x86_64-fuchsia/ ...
336
- ┗━ debug/ ...
337
- ┗━ hello_fuchsia ...
328
+ ┣━ src/ (if using rustc)
329
+ ┃ ┗━ hello_fuchsia.rs ...
330
+ ┣━ bin/ ...
331
+ ┃ ┗━ hello_fuchsia ...
332
+ ┣━ src/ (if using cargo)
333
+ ┃ ┗━ main.rs ...
334
+ ┗━ target/ ...
335
+ ┗━ x86_64-unknown- fuchsia/ ...
336
+ ┗━ debug/ ...
337
+ ┗━ hello_fuchsia ...
338
338
```
339
339
340
340
With our Rust binary built, we can move to creating a Fuchsia package.
@@ -371,7 +371,7 @@ package must contain one.
371
371
372
372
**`pkg/hello_fuchsia.manifest` if using cargo**
373
373
```txt
374
- bin/hello_fuchsia=target/x86_64-fuchsia/debug/hello_fuchsia
374
+ bin/hello_fuchsia=target/x86_64-unknown- fuchsia/debug/hello_fuchsia
375
375
lib/ld.so.1=<SDK_PATH>/arch/x64/sysroot/dist/lib/ld.so.1
376
376
lib/libfdio.so=<SDK_PATH>/arch/x64/dist/libfdio.so
377
377
meta/package=pkg/meta/package
@@ -546,16 +546,16 @@ structure will look like:
546
546
**Final directory structure**
547
547
```txt
548
548
hello_fuchsia/
549
- ┣━ src/ (if using rustc)
550
- ┃ ┗━ hello_fuchsia.rs ...
551
- ┣━ bin/ ...
552
- ┃ ┗━ hello_fuchsia ...
553
- ┣━ src/ (if using cargo)
554
- ┃ ┗━ main.rs ...
555
- ┣━ target/ ...
556
- ┃ ┗━ x86_64-fuchsia/ ...
557
- ┃ ┗━ debug/ ...
558
- ┃ ┗━ hello_fuchsia ...
549
+ ┣━ src/ (if using rustc)
550
+ ┃ ┗━ hello_fuchsia.rs ...
551
+ ┣━ bin/ ...
552
+ ┃ ┗━ hello_fuchsia ...
553
+ ┣━ src/ (if using cargo)
554
+ ┃ ┗━ main.rs ...
555
+ ┣━ target/ ...
556
+ ┃ ┗━ x86_64-unknown- fuchsia/ ...
557
+ ┃ ┗━ debug/ ...
558
+ ┃ ┗━ hello_fuchsia ...
559
559
┗━ pkg/
560
560
┣━ meta/
561
561
┃ ┣━ package
@@ -644,8 +644,8 @@ Tests can be run in the same way as a regular binary.
644
644
645
645
* If using `cargo`, you can simply pass `test --no-run`
646
646
to the `cargo` invocation and then repackage and rerun the Fuchsia package. From our previous example,
647
- this would look like `cargo test --target x86_64-fuchsia --no-run`, and moving the executable
648
- binary path found from the line `Executable unittests src/main.rs (target/x86_64-fuchsia/debug/deps/hello_fuchsia-<HASH>)`
647
+ this would look like `cargo test --target x86_64-unknown- fuchsia --no-run`, and moving the executable
648
+ binary path found from the line `Executable unittests src/main.rs (target/x86_64-unknown- fuchsia/debug/deps/hello_fuchsia-<HASH>)`
649
649
into `pkg/hello_fuchsia.manifest`.
650
650
651
651
* If using the compiled `rustc`, you can simply pass `--test`
@@ -714,7 +714,7 @@ run the full `src/test/ui` test suite:
714
714
--config config.toml \
715
715
--stage=2 \
716
716
test src/test/ui \
717
- --target x86_64-fuchsia \
717
+ --target x86_64-unknown- fuchsia \
718
718
--run=always --jobs 1 \
719
719
--test-args --target-rustcflags \
720
720
--test-args -L \
@@ -758,7 +758,7 @@ directory to launch `zxdb`:
758
758
**In separate terminal**
759
759
```sh
760
760
${SDK_PATH}/tools/${ARCH}/ffx debug connect -- \
761
- --symbol-path target/x86_64-fuchsia/debug
761
+ --symbol-path target/x86_64-unknown- fuchsia/debug
762
762
```
763
763
764
764
* `--symbol-path` gets required symbol paths, which are
@@ -854,7 +854,7 @@ source code:
854
854
855
855
```sh
856
856
${SDK_PATH}/tools/${ARCH}/ffx debug connect -- \
857
- --symbol-path target/x86_64-fuchsia/debug \
857
+ --symbol-path target/x86_64-unknown- fuchsia/debug \
858
858
--build-dir ${RUST_SRC_PATH}/rust \
859
859
--build-dir ${FUCHSIA_SRC_PATH}/fuchsia/out/default
860
860
```
0 commit comments