@@ -687,7 +687,9 @@ Rust compiler locally. See "[Targeting Fuchsia with a compiler built from source
687
687
for the steps to build locally.
688
688
689
689
You'll also need to download a copy of the Fuchsia SDK. The current minimum
690
- supported SDK version is [ 9.20220726.1.1] ( https://chrome-infra-packages.appspot.com/p/fuchsia/sdk/core/linux-amd64/+/version:9.20220726.1.1 ) .
690
+ supported SDK version is [ 10.20221207.2.89] [ minimum_supported_sdk_version ] .
691
+
692
+ [ minimum_supported_sdk_version ] : https://chrome-infra-packages.appspot.com/p/fuchsia/sdk/core/linux-amd64/+/version:10.20221207.2.89
691
693
692
694
Fuchsia's test runner interacts with the Fuchsia emulator and is located at
693
695
` src/ci/docker/scripts/fuchsia-test-runner.py ` . We can use it to start our
@@ -697,7 +699,7 @@ test environment with:
697
699
src/ci/docker/scripts/fuchsia-test-runner.py start
698
700
--rust ${RUST_SRC_PATH} /install
699
701
--sdk ${SDK_PATH}
700
- --target-triple {x86_64-unknown-fuchsia| aarch64-unknown-fuchsia}
702
+ --target {x86_64-unknown-fuchsia| aarch64-unknown-fuchsia}
701
703
```
702
704
703
705
Where ` ${RUST_SRC_PATH}/install ` is the ` prefix ` set in ` config.toml ` and
@@ -717,17 +719,11 @@ run the full `tests/ui` test suite:
717
719
--target x86_64-unknown-fuchsia \
718
720
--run=always --jobs 1 \
719
721
--test-args --target-rustcflags \
720
- --test-args -L \
721
- --test-args --target-rustcflags \
722
- --test-args ${SDK_PATH} /arch/{x64| arm64}/sysroot/lib \
723
- --test-args --target-rustcflags \
724
- --test-args -L \
722
+ --test-args -Lnative=${SDK_PATH} /arch/{x64| arm64}/sysroot/lib \
725
723
--test-args --target-rustcflags \
726
- --test-args ${SDK_PATH} /arch/{x64| arm64}/lib \
724
+ --test-args -Lnative= ${SDK_PATH} /arch/{x64| arm64}/lib \
727
725
--test-args --target-rustcflags \
728
- --test-args -Cpanic=abort \
729
- --test-args --target-rustcflags \
730
- --test-args -Zpanic_abort_tests \
726
+ --test-args -Clink-arg=--undefined-version \
731
727
--test-args --remote-test-client \
732
728
--test-args src/ci/docker/scripts/fuchsia-test-runner.py \
733
729
)
@@ -736,7 +732,18 @@ run the full `tests/ui` test suite:
736
732
* Note: The test suite cannot be run in parallel at the moment, so ` x.py `
737
733
must be run with ` --jobs 1 ` to ensure only one test runs at a time.*
738
734
739
- When finished, the test runner can be used to stop the test environment:
735
+ By default, ` x.py ` compiles test binaries with ` panic=unwind ` . If you built your
736
+ Rust toolchain with ` -Cpanic=abort ` , you need to tell ` x.py ` to compile test
737
+ binaries with ` panic=abort ` as well:
738
+
739
+ ``` sh
740
+ --test-args --target-rustcflags \
741
+ --test-args -Cpanic=abort \
742
+ --test-args --target-rustcflags \
743
+ --test-args -Zpanic_abort_tests \
744
+ ```
745
+
746
+ When finished testing, the test runner can be used to stop the test environment:
740
747
741
748
``` sh
742
749
src/ci/docker/scripts/fuchsia-test-runner.py stop
@@ -764,8 +771,9 @@ ${SDK_PATH}/tools/${ARCH}/ffx debug connect -- \
764
771
* ` --symbol-path ` gets required symbol paths, which are
765
772
necessary for stepping through your program.
766
773
767
- The "[ displaying source code in ` zxdb ` ] ( #displaying-source-code-in-zxdb ) " section describes how you can
768
- display Rust and/or Fuchsia source code in your debugging session.
774
+ The "[ displaying source code in ` zxdb ` ] ( #displaying-source-code-in-zxdb ) "
775
+ section describes how you can display Rust and/or Fuchsia source code in your
776
+ debugging session.
769
777
770
778
### Using ` zxdb `
771
779
@@ -866,6 +874,64 @@ ${SDK_PATH}/tools/${ARCH}/ffx debug connect -- \
866
874
Linking to a Fuchsia checkout can help with debugging Fuchsia libraries,
867
875
such as [ fdio] .
868
876
877
+ ### Debugging the compiler test suite
878
+
879
+ Debugging the compiler test suite requires some special configuration:
880
+
881
+ First, we have to properly configure zxdb so it will be able to find debug
882
+ symbols and source information for our test. The test runner can do this for us
883
+ with:
884
+
885
+ ``` sh
886
+ src/ci/docker/scripts/fuchsia-test-runner.py debug \
887
+ --rust-src ${RUST_SRC_PATH} \
888
+ --fuchsia-src ${FUCHSIA_SRC_PATH} \
889
+ --test ${TEST}
890
+ ```
891
+
892
+ where ` ${TEST} ` is relative to Rust's ` tests ` directory (e.g. ` ui/abi/... ` ).
893
+
894
+ This will start a zxdb session that is properly configured for the specific test
895
+ being run. All three arguments are optional, so you can omit ` --fuchsia-src ` if
896
+ you don't have it downloaded. Now is a good time to set any desired breakpoints,
897
+ like ` b main ` .
898
+
899
+ Next, we have to tell ` x.py ` not to optimize or strip debug symbols from our
900
+ test suite binaries. We can do this by passing some new arguments to ` rustc `
901
+ through our ` x.py ` invocation. The full invocation is:
902
+
903
+ ``` sh
904
+ ( \
905
+ source config-env.sh && \
906
+ ./x.py \
907
+ --config config.toml \
908
+ --stage=2 \
909
+ test tests/${TEST} \
910
+ --target x86_64-unknown-fuchsia \
911
+ --run=always --jobs 1 \
912
+ --test-args --target-rustcflags \
913
+ --test-args -Lnative=${SDK_PATH} /arch/{x64| arm64}/sysroot/lib \
914
+ --test-args --target-rustcflags \
915
+ --test-args -Lnative=${SDK_PATH} /arch/{x64| arm64}/lib \
916
+ --test-args --target-rustcflags \
917
+ --test-args -Clink-arg=--undefined-version \
918
+ --test-args --target-rustcflags \
919
+ --test-args -Cdebuginfo=2 \
920
+ --test-args --target-rustcflags \
921
+ --test-args -Copt-level=0 \
922
+ --test-args --target-rustcflags \
923
+ --test-args -Cstrip=none \
924
+ --test-args --remote-test-client \
925
+ --test-args src/ci/docker/scripts/fuchsia-test-runner.py \
926
+ )
927
+ ```
928
+
929
+ * If you built your Rust toolchain with ` panic=abort ` , make sure to include the
930
+ previous flags so your test binaries are also compiled with ` panic=abort ` .*
931
+
932
+ Upon running this command, the test suite binary will be run and zxdb will
933
+ attach and load any relevant debug symbols.
934
+
869
935
[ Fuchsia team ] : https://team-api.infra.rust-lang.org/v1/teams/fuchsia.json
870
936
[ Fuchsia ] : https://fuchsia.dev/
871
937
[ source tree ] : https://fuchsia.dev/fuchsia-src/get-started/learn/build
0 commit comments