1- # ` aarch64-fuchsia ` and ` x86_64-fuchsia `
1+ # ` aarch64-unknown- fuchsia ` and ` x86_64-unknown -fuchsia `
22
33** Tier: 2**
44
@@ -67,7 +67,7 @@ This walkthrough will cover:
67671 . Building a Fuchsia package.
68681 . Publishing and running a Fuchsia package to a Fuchsia emulator.
6969
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 ` .
7171
7272## Compiling a Rust binary targeting Fuchsia
7373
@@ -83,8 +83,8 @@ to handle the installation of Fuchsia targets for you. This can be done by issui
8383the following commands:
8484
8585``` 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
8888```
8989
9090After installing our Fuchsia targets, we can now compile a Rust binary that targets
@@ -127,7 +127,7 @@ during compilation:
127127
128128** ` .cargo/config.toml ` **
129129``` txt
130- [target.x86_64-fuchsia]
130+ [target.x86_64-unknown- fuchsia]
131131
132132rustflags = [
133133 "-Lnative=<SDK_PATH>/arch/x64/lib",
@@ -159,10 +159,10 @@ hello_fuchsia/
159159Finally, we can build our rust binary as:
160160
161161``` sh
162- cargo build --target x86_64-fuchsia
162+ cargo build --target x86_64-unknown- fuchsia
163163```
164164
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 ` ,
166166targeting our desired Fuchsia target.
167167
168168** Current directory structure**
@@ -171,7 +171,7 @@ hello_fuchsia/
171171┣━ src/
172172┃ ┗━ main.rs
173173┣━ target/
174- ┃ ┗━ x86_64-fuchsia/
174+ ┃ ┗━ x86_64-unknown- fuchsia/
175175┃ ┗━ debug/
176176┃ ┗━ hello_fuchsia
177177┣━ Cargo.toml
@@ -193,19 +193,19 @@ configuration in `config.toml`:
193193
194194``` toml
195195[build ]
196- target = [" <host_platform>" , " aarch64-fuchsia" , " x86_64-fuchsia" ]
196+ target = [" <host_platform>" , " aarch64-unknown- fuchsia" , " x86_64-unknown -fuchsia" ]
197197
198198[rust ]
199199lld = true
200200
201201[llvm ]
202202download-ci-llvm = false
203203
204- [target .x86_64-fuchsia ]
204+ [target .x86_64-unknown- fuchsia ]
205205cc = " clang"
206206cxx = " clang++"
207207
208- [target .aarch64-fuchsia ]
208+ [target .aarch64-unknown- fuchsia ]
209209cc = " clang"
210210cxx = " clang++"
211211```
@@ -236,14 +236,14 @@ a script we name `config-env.sh`:
236236# Configure this environment variable to be the path to the downloaded SDK
237237export SDK_PATH=" <SDK path goes here>"
238238
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"
247247```
248248
249249Finally, the Rust compiler can be built and installed:
@@ -288,7 +288,7 @@ hello_fuchsia/
288288Using your freshly installed ` rustc ` , you can compile a binary for Fuchsia using
289289the following options:
290290
291- * ` --target x86_64-fuchsia ` /` --target aarch64-fuchsia ` : Targets the Fuchsia
291+ * ` --target x86_64-unknown- fuchsia ` /` --target aarch64-unknown -fuchsia ` : Targets the Fuchsia
292292 platform of your choice
293293* ` -Lnative ${SDK_PATH}/arch/${ARCH}/lib ` : Link against Fuchsia libraries from
294294 the SDK
@@ -299,7 +299,7 @@ Putting it all together:
299299
300300``` sh
301301# 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>"
303303ARCH=" <x64|aarch64>"
304304
305305rustc \
@@ -325,16 +325,16 @@ Before moving on, double check your directory structure:
325325** Current directory structure**
326326``` txt
327327hello_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 ...
338338```
339339
340340With our Rust binary built, we can move to creating a Fuchsia package.
@@ -371,7 +371,7 @@ package must contain one.
371371
372372** ` pkg/hello_fuchsia.manifest ` if using cargo**
373373``` txt
374- bin/hello_fuchsia=target/x86_64-fuchsia/debug/hello_fuchsia
374+ bin/hello_fuchsia=target/x86_64-unknown- fuchsia/debug/hello_fuchsia
375375lib/ld.so.1=<SDK_PATH>/arch/x64/sysroot/dist/lib/ld.so.1
376376lib/libfdio.so=<SDK_PATH>/arch/x64/dist/libfdio.so
377377meta/package=pkg/meta/package
@@ -546,16 +546,16 @@ structure will look like:
546546** Final directory structure**
547547``` txt
548548hello_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 ...
559559┗━ pkg/
560560 ┣━ meta/
561561 ┃ ┣━ package
@@ -644,8 +644,8 @@ Tests can be run in the same way as a regular binary.
644644
645645* If using ` cargo ` , you can simply pass ` test --no-run `
646646to 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>) `
649649into ` pkg/hello_fuchsia.manifest ` .
650650
651651* If using the compiled ` rustc ` , you can simply pass ` --test `
@@ -714,7 +714,7 @@ run the full `src/test/ui` test suite:
714714 --config config.toml \
715715 --stage=2 \
716716 test src/test/ui \
717- --target x86_64-fuchsia \
717+ --target x86_64-unknown- fuchsia \
718718 --run=always --jobs 1 \
719719 --test-args --target-rustcflags \
720720 --test-args -L \
@@ -758,7 +758,7 @@ directory to launch `zxdb`:
758758** In separate terminal**
759759``` sh
760760${SDK_PATH} /tools/${ARCH} /ffx debug connect -- \
761- --symbol-path target/x86_64-fuchsia/debug
761+ --symbol-path target/x86_64-unknown- fuchsia/debug
762762```
763763
764764* ` --symbol-path ` gets required symbol paths, which are
@@ -854,7 +854,7 @@ source code:
854854
855855``` sh
856856${SDK_PATH} /tools/${ARCH} /ffx debug connect -- \
857- --symbol-path target/x86_64-fuchsia/debug \
857+ --symbol-path target/x86_64-unknown- fuchsia/debug \
858858 --build-dir ${RUST_SRC_PATH} /rust \
859859 --build-dir ${FUCHSIA_SRC_PATH} /fuchsia/out/default
860860```
0 commit comments