From 49516b3f5705c201a915c1b0c690d0f112da6c6a Mon Sep 17 00:00:00 2001 From: ozkanonur Date: Thu, 23 Feb 2023 21:35:41 +0300 Subject: [PATCH 1/8] support `x fmt` for sub and outside of rust directories Signed-off-by: ozkanonur --- src/bootstrap/format.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bootstrap/format.rs b/src/bootstrap/format.rs index 615794958d0..ae72a42973c 100644 --- a/src/bootstrap/format.rs +++ b/src/bootstrap/format.rs @@ -218,7 +218,7 @@ pub fn format(build: &Builder<'_>, check: bool, paths: &[PathBuf]) { WalkBuilder::new(first) } } else { - WalkBuilder::new(first) + WalkBuilder::new(src.join(first)) }; for path in &paths[1..] { @@ -229,7 +229,7 @@ pub fn format(build: &Builder<'_>, check: bool, paths: &[PathBuf]) { walker.add(path); } } else { - walker.add(path); + walker.add(src.join(path)); } } From a402cb0f9b47d4518a75fc0f202c2837d627e793 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Thu, 23 Feb 2023 12:26:14 -0700 Subject: [PATCH 2/8] docs: use intra-doc links for `Vec::get(_mut)` Now that #63351 is fixed, there's no reason not to. --- library/alloc/src/vec/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs index a07f3da78d3..b279f21b524 100644 --- a/library/alloc/src/vec/mod.rs +++ b/library/alloc/src/vec/mod.rs @@ -378,8 +378,8 @@ mod spec_extend; /// Currently, `Vec` does not guarantee the order in which elements are dropped. /// The order has changed in the past and may change again. /// -/// [`get`]: ../../std/vec/struct.Vec.html#method.get -/// [`get_mut`]: ../../std/vec/struct.Vec.html#method.get_mut +/// [`get`]: slice::get +/// [`get_mut`]: slice::get_mut /// [`String`]: crate::string::String /// [`&str`]: type@str /// [`shrink_to_fit`]: Vec::shrink_to_fit From 5a9a3df3125b13de25ba7d0c91efebf82e94c3f9 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Thu, 23 Feb 2023 13:26:00 -0700 Subject: [PATCH 3/8] rustdoc: avoid including `
  • ` tags in item table short desc Fixes a bug seen at https://docs.rs/gl_constants/0.1.1/gl_constants/index.html --- src/librustdoc/html/markdown.rs | 5 +---- tests/rustdoc/item-desc-list-at-start.item-table.html | 1 + tests/rustdoc/item-desc-list-at-start.rs | 9 +++++++++ 3 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 tests/rustdoc/item-desc-list-at-start.item-table.html create mode 100644 tests/rustdoc/item-desc-list-at-start.rs diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index 9ef0b501c08..89f1ad71134 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -552,10 +552,7 @@ impl<'a, I: Iterator>> SummaryLine<'a, I> { } fn check_if_allowed_tag(t: &Tag<'_>) -> bool { - matches!( - t, - Tag::Paragraph | Tag::Item | Tag::Emphasis | Tag::Strong | Tag::Link(..) | Tag::BlockQuote - ) + matches!(t, Tag::Paragraph | Tag::Emphasis | Tag::Strong | Tag::Link(..) | Tag::BlockQuote) } fn is_forbidden_tag(t: &Tag<'_>) -> bool { diff --git a/tests/rustdoc/item-desc-list-at-start.item-table.html b/tests/rustdoc/item-desc-list-at-start.item-table.html new file mode 100644 index 00000000000..72bde573cea --- /dev/null +++ b/tests/rustdoc/item-desc-list-at-start.item-table.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/tests/rustdoc/item-desc-list-at-start.rs b/tests/rustdoc/item-desc-list-at-start.rs new file mode 100644 index 00000000000..d88c61d333e --- /dev/null +++ b/tests/rustdoc/item-desc-list-at-start.rs @@ -0,0 +1,9 @@ +// @has item_desc_list_at_start/index.html +// @count - '//ul[@class="item-table"]/li/div/li' 0 +// @count - '//ul[@class="item-table"]/li' 1 +// @snapshot item-table - '//ul[@class="item-table"]' + +// based on https://docs.rs/gl_constants/0.1.1/src/gl_constants/lib.rs.html#16 + +/// * Groups: `SamplePatternSGIS`, `SamplePatternEXT` +pub const MY_CONSTANT: usize = 0; From b6e0efe6559f75cc58256814d59a6d8131e884ec Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 23 Feb 2023 22:04:19 +0100 Subject: [PATCH 4/8] Update browser-ui-test version --- .../docker/host-x86_64/x86_64-gnu-tools/browser-ui-test.version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ci/docker/host-x86_64/x86_64-gnu-tools/browser-ui-test.version b/src/ci/docker/host-x86_64/x86_64-gnu-tools/browser-ui-test.version index 94ec2401292..9c550b2d728 100644 --- a/src/ci/docker/host-x86_64/x86_64-gnu-tools/browser-ui-test.version +++ b/src/ci/docker/host-x86_64/x86_64-gnu-tools/browser-ui-test.version @@ -1 +1 @@ -0.14.3 \ No newline at end of file +0.14.4 \ No newline at end of file From 4ff1c4d3e72c7b1f9a4d5cb9ff6a832e8dfc5a7f Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 23 Feb 2023 22:04:38 +0100 Subject: [PATCH 5/8] No need for the wait-for anymore to go around browser navigation bug --- tests/rustdoc-gui/help-page.goml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/rustdoc-gui/help-page.goml b/tests/rustdoc-gui/help-page.goml index 5f4c1ba2f85..6e2321a6963 100644 --- a/tests/rustdoc-gui/help-page.goml +++ b/tests/rustdoc-gui/help-page.goml @@ -68,5 +68,4 @@ size: (1000, 1000) // Popover only appears when the screen width is >700px. assert-false: "#help" click: "#help-button > a" click: ".popover a[href='https://doc.rust-lang.org/rustdoc/']" -wait-for: 2000 -assert-document-property: {"URL": "https://doc.rust-lang.org/rustdoc/"} +wait-for-document-property: {"URL": "https://doc.rust-lang.org/rustdoc/"} From a861b192da5426d20cfecf35f898aa642f87f9e6 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Fri, 24 Feb 2023 18:46:24 +0000 Subject: [PATCH 6/8] Wrap missing provider message correctly --- compiler/rustc_middle/src/ty/query.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_middle/src/ty/query.rs b/compiler/rustc_middle/src/ty/query.rs index 5b3f3870429..3d9a5075d4a 100644 --- a/compiler/rustc_middle/src/ty/query.rs +++ b/compiler/rustc_middle/src/ty/query.rs @@ -328,8 +328,9 @@ macro_rules! define_callbacks { Providers { $($name: |_, key| bug!( - "`tcx.{}({:?})` is not supported for {} crate;\n - hint: Queries can be either made to the local crate, or the external crate. This error means you tried to use it for one that's not supported.\n + "`tcx.{}({:?})` is not supported for {} crate;\n\ + hint: Queries can be either made to the local crate, or the external crate. \ + This error means you tried to use it for one that's not supported.\n\ If that's not the case, {} was likely never assigned to a provider function.\n", stringify!($name), key, From 34966aab55e0a86be6a6dbe57596151ee8c74263 Mon Sep 17 00:00:00 2001 From: Obei Sideg Date: Fri, 24 Feb 2023 23:23:30 +0300 Subject: [PATCH 7/8] Migrate `rustc_hir_analysis` to session diagnostic Part one, lib.rs file --- compiler/rustc_hir_analysis/locales/en-US.ftl | 23 ++++++ compiler/rustc_hir_analysis/src/errors.rs | 67 ++++++++++++++++ compiler/rustc_hir_analysis/src/lib.rs | 80 ++++--------------- 3 files changed, 107 insertions(+), 63 deletions(-) diff --git a/compiler/rustc_hir_analysis/locales/en-US.ftl b/compiler/rustc_hir_analysis/locales/en-US.ftl index 7e3a31f3355..e87731160d9 100644 --- a/compiler/rustc_hir_analysis/locales/en-US.ftl +++ b/compiler/rustc_hir_analysis/locales/en-US.ftl @@ -132,3 +132,26 @@ hir_analysis_where_clause_on_main = `main` function is not allowed to have a `wh hir_analysis_track_caller_on_main = `main` function is not allowed to be `#[track_caller]` .label = `main` function is not allowed to be `#[track_caller]` + +hir_analysis_start_not_track_caller = `start` is not allowed to be `#[track_caller]` + .label = `start` is not allowed to be `#[track_caller]` + +hir_analysis_start_not_async = `start` is not allowed to be `async` + .label = `start` is not allowed to be `async` + +hir_analysis_start_function_where = start function is not allowed to have a `where` clause + .label = start function cannot have a `where` clause + +hir_analysis_start_function_parameters = start function is not allowed to have type parameters + .label = start function cannot have type parameters + +hir_analysis_main_function_return_type_generic = `main` function return type is not allowed to have generic parameters + +hir_analysis_main_function_async = `main` function is not allowed to be `async` + .label = `main` function is not allowed to be `async` + +hir_analysis_main_function_generic_parameters = `main` function is not allowed to have generic parameters + .label = `main` cannot have generic parameters + +hir_analysis_variadic_function_compatible_convention = C-variadic function must have a compatible calling convention, like {$conventions} + .label = C-variadic function must have a compatible calling convention diff --git a/compiler/rustc_hir_analysis/src/errors.rs b/compiler/rustc_hir_analysis/src/errors.rs index d0fb7aff30e..309d02052b7 100644 --- a/compiler/rustc_hir_analysis/src/errors.rs +++ b/compiler/rustc_hir_analysis/src/errors.rs @@ -333,3 +333,70 @@ pub(crate) struct TrackCallerOnMain { #[label] pub annotated: Span, } + +#[derive(Diagnostic)] +#[diag(hir_analysis_start_not_track_caller)] +pub(crate) struct StartTrackCaller { + #[primary_span] + pub span: Span, + #[label] + pub start: Span, +} + +#[derive(Diagnostic)] +#[diag(hir_analysis_start_not_async, code = "E0752")] +pub(crate) struct StartAsync { + #[primary_span] + #[label] + pub span: Span, +} + +#[derive(Diagnostic)] +#[diag(hir_analysis_start_function_where, code = "E0647")] +pub(crate) struct StartFunctionWhere { + #[primary_span] + #[label] + pub span: Span, +} + +#[derive(Diagnostic)] +#[diag(hir_analysis_start_function_parameters, code = "E0132")] +pub(crate) struct StartFunctionParameters { + #[primary_span] + #[label] + pub span: Span, +} + +#[derive(Diagnostic)] +#[diag(hir_analysis_main_function_return_type_generic, code = "E0131")] +pub(crate) struct MainFunctionReturnTypeGeneric { + #[primary_span] + pub span: Span, +} + +#[derive(Diagnostic)] +#[diag(hir_analysis_main_function_async, code = "E0752")] +pub(crate) struct MainFunctionAsync { + #[primary_span] + pub span: Span, + #[label] + pub asyncness: Option, +} + +#[derive(Diagnostic)] +#[diag(hir_analysis_main_function_generic_parameters, code = "E0131")] +pub(crate) struct MainFunctionGenericParameters { + #[primary_span] + pub span: Span, + #[label] + pub label_span: Option, +} + +#[derive(Diagnostic)] +#[diag(hir_analysis_variadic_function_compatible_convention, code = "E0045")] +pub(crate) struct VariadicFunctionCompatibleConvention<'a> { + #[primary_span] + #[label] + pub span: Span, + pub conventions: &'a str, +} diff --git a/compiler/rustc_hir_analysis/src/lib.rs b/compiler/rustc_hir_analysis/src/lib.rs index 9a43ca685e3..33c132fd534 100644 --- a/compiler/rustc_hir_analysis/src/lib.rs +++ b/compiler/rustc_hir_analysis/src/lib.rs @@ -98,7 +98,7 @@ mod outlives; pub mod structured_errors; mod variance; -use rustc_errors::{struct_span_err, ErrorGuaranteed}; +use rustc_errors::ErrorGuaranteed; use rustc_errors::{DiagnosticMessage, SubdiagnosticMessage}; use rustc_hir as hir; use rustc_hir::Node; @@ -123,7 +123,6 @@ use bounds::Bounds; fluent_messages! { "../locales/en-US.ftl" } fn require_c_abi_if_c_variadic(tcx: TyCtxt<'_>, decl: &hir::FnDecl<'_>, abi: Abi, span: Span) { - const ERROR_HEAD: &str = "C-variadic function must have a compatible calling convention"; const CONVENTIONS_UNSTABLE: &str = "`C`, `cdecl`, `win64`, `sysv64` or `efiapi`"; const CONVENTIONS_STABLE: &str = "`C` or `cdecl`"; const UNSTABLE_EXPLAIN: &str = @@ -155,8 +154,7 @@ fn require_c_abi_if_c_variadic(tcx: TyCtxt<'_>, decl: &hir::FnDecl<'_>, abi: Abi (true, false) => CONVENTIONS_UNSTABLE, }; - let mut err = struct_span_err!(tcx.sess, span, E0045, "{}, like {}", ERROR_HEAD, conventions); - err.span_label(span, ERROR_HEAD).emit(); + tcx.sess.emit_err(errors::VariadicFunctionCompatibleConvention { span, conventions }); } fn require_same_types<'tcx>( @@ -258,15 +256,10 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) { let main_fn_predicates = tcx.predicates_of(main_def_id); if main_fn_generics.count() != 0 || !main_fnsig.bound_vars().is_empty() { let generics_param_span = main_fn_generics_params_span(tcx, main_def_id); - let msg = "`main` function is not allowed to have generic \ - parameters"; - let mut diag = - struct_span_err!(tcx.sess, generics_param_span.unwrap_or(main_span), E0131, "{}", msg); - if let Some(generics_param_span) = generics_param_span { - let label = "`main` cannot have generic parameters"; - diag.span_label(generics_param_span, label); - } - diag.emit(); + tcx.sess.emit_err(errors::MainFunctionGenericParameters { + span: generics_param_span.unwrap_or(main_span), + label_span: generics_param_span, + }); error = true; } else if !main_fn_predicates.predicates.is_empty() { // generics may bring in implicit predicates, so we skip this check if generics is present. @@ -280,17 +273,8 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) { let main_asyncness = tcx.asyncness(main_def_id); if let hir::IsAsync::Async = main_asyncness { - let mut diag = struct_span_err!( - tcx.sess, - main_span, - E0752, - "`main` function is not allowed to be `async`" - ); let asyncness_span = main_fn_asyncness_span(tcx, main_def_id); - if let Some(asyncness_span) = asyncness_span { - diag.span_label(asyncness_span, "`main` function is not allowed to be `async`"); - } - diag.emit(); + tcx.sess.emit_err(errors::MainFunctionAsync { span: main_span, asyncness: asyncness_span }); error = true; } @@ -308,9 +292,7 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) { let return_ty = main_fnsig.output(); let return_ty_span = main_fn_return_type_span(tcx, main_def_id).unwrap_or(main_span); if !return_ty.bound_vars().is_empty() { - let msg = "`main` function return type is not allowed to have generic \ - parameters"; - struct_span_err!(tcx.sess, return_ty_span, E0131, "{}", msg).emit(); + tcx.sess.emit_err(errors::MainFunctionReturnTypeGeneric { span: return_ty_span }); error = true; } let return_ty = return_ty.skip_binder(); @@ -367,56 +349,28 @@ fn check_start_fn_ty(tcx: TyCtxt<'_>, start_def_id: DefId) { if let hir::ItemKind::Fn(sig, generics, _) = &it.kind { let mut error = false; if !generics.params.is_empty() { - struct_span_err!( - tcx.sess, - generics.span, - E0132, - "start function is not allowed to have type parameters" - ) - .span_label(generics.span, "start function cannot have type parameters") - .emit(); + tcx.sess.emit_err(errors::StartFunctionParameters { span: generics.span }); error = true; } if generics.has_where_clause_predicates { - struct_span_err!( - tcx.sess, - generics.where_clause_span, - E0647, - "start function is not allowed to have a `where` clause" - ) - .span_label( - generics.where_clause_span, - "start function cannot have a `where` clause", - ) - .emit(); + tcx.sess.emit_err(errors::StartFunctionWhere { + span: generics.where_clause_span, + }); error = true; } if let hir::IsAsync::Async = sig.header.asyncness { let span = tcx.def_span(it.owner_id); - struct_span_err!( - tcx.sess, - span, - E0752, - "`start` is not allowed to be `async`" - ) - .span_label(span, "`start` is not allowed to be `async`") - .emit(); + tcx.sess.emit_err(errors::StartAsync { span: span }); error = true; } let attrs = tcx.hir().attrs(start_id); for attr in attrs { if attr.has_name(sym::track_caller) { - tcx.sess - .struct_span_err( - attr.span, - "`start` is not allowed to be `#[track_caller]`", - ) - .span_label( - start_span, - "`start` is not allowed to be `#[track_caller]`", - ) - .emit(); + tcx.sess.emit_err(errors::StartTrackCaller { + span: attr.span, + start: start_span, + }); error = true; } } From 6e7902bc3d97b5c7e7f2e000a8e0d61d55a4c3f8 Mon Sep 17 00:00:00 2001 From: David Koloski Date: Wed, 22 Feb 2023 12:40:22 -0500 Subject: [PATCH 8/8] Update `fuchsia-test-runner.py` and docs This updates the test runner to the latest version of the SDK and fixes debugging support for Rust source code. --- src/ci/docker/scripts/fuchsia-test-runner.py | 82 +++++++++++++--- src/doc/rustc/src/platform-support/fuchsia.md | 94 ++++++++++++++++--- 2 files changed, 149 insertions(+), 27 deletions(-) diff --git a/src/ci/docker/scripts/fuchsia-test-runner.py b/src/ci/docker/scripts/fuchsia-test-runner.py index a6d84a3c18a..c3d532c4b27 100755 --- a/src/ci/docker/scripts/fuchsia-test-runner.py +++ b/src/ci/docker/scripts/fuchsia-test-runner.py @@ -507,9 +507,8 @@ class TestEnvironment: bin/{exe_name}={bin_path} lib/{libstd_name}={rust_dir}/lib/rustlib/{rustlib_dir}/lib/{libstd_name} lib/{libtest_name}={rust_dir}/lib/rustlib/{rustlib_dir}/lib/{libtest_name} - lib/ld.so.1={sdk_dir}/arch/{target_arch}/sysroot/lib/libc.so - lib/libzircon.so={sdk_dir}/arch/{target_arch}/sysroot/lib/libzircon.so - lib/libfdio.so={sdk_dir}/arch/{target_arch}/lib/libfdio.so + lib/ld.so.1={sdk_dir}/arch/{target_arch}/sysroot/dist/lib/ld.so.1 + lib/libfdio.so={sdk_dir}/arch/{target_arch}/dist/libfdio.so """ TEST_ENV_VARS: ClassVar[List[str]] = [ @@ -844,23 +843,34 @@ class TestEnvironment: "--", "--build-id-dir", os.path.join(self.sdk_dir, ".build-id"), - "--build-id-dir", - os.path.join(self.libs_dir(), ".build-id"), ] - # Add rust source if it's available - if args.rust_src is not None: + libs_build_id_path = os.path.join(self.libs_dir(), ".build-id") + if os.path.exists(libs_build_id_path): + # Add .build-id symbols if installed libs have been stripped into a + # .build-id directory command += [ - "--build-dir", - args.rust_src, + "--build-id-dir", + libs_build_id_path, + ] + else: + # If no .build-id directory is detected, then assume that the shared + # libs contain their debug symbols + command += [ + f"--symbol-path={self.rust_dir}/lib/rustlib/{self.target}/lib", ] + # Add rust source if it's available + rust_src_map = None + if args.rust_src is not None: + # This matches the remapped prefix used by compiletest. There's no + # clear way that we can determine this, so it's hard coded. + rust_src_map = f"/rustc/FAKE_PREFIX={args.rust_src}" + # Add fuchsia source if it's available + fuchsia_src_map = None if args.fuchsia_src is not None: - command += [ - "--build-dir", - os.path.join(args.fuchsia_src, "out", "default"), - ] + fuchsia_src_map = f"./../..={args.fuchsia_src}" # Load debug symbols for the test binary and automatically attach if args.test is not None: @@ -883,7 +893,28 @@ class TestEnvironment: test_name, ) + # The fake-test-src-base directory maps to the suite directory + # e.g. tests/ui/foo.rs has a path of rust/fake-test-src-base/foo.rs + fake_test_src_base = os.path.join( + args.rust_src, + "fake-test-src-base", + ) + real_test_src_base = os.path.join( + args.rust_src, + "tests", + args.test.split(os.path.sep)[0], + ) + test_src_map = f"{fake_test_src_base}={real_test_src_base}" + with open(self.zxdb_script_path(), mode="w", encoding="utf-8") as f: + print(f"set source-map += {test_src_map}", file=f) + + if rust_src_map is not None: + print(f"set source-map += {rust_src_map}", file=f) + + if fuchsia_src_map is not None: + print(f"set source-map += {fuchsia_src_map}", file=f) + print(f"attach {test_name[:31]}", file=f) command += [ @@ -900,6 +931,20 @@ class TestEnvironment: # Connect to the running emulator with zxdb subprocess.run(command, env=self.ffx_cmd_env(), check=False) + def syslog(self, args): + subprocess.run( + [ + self.tool_path("ffx"), + "--config", + self.ffx_user_config_path(), + "log", + "--since", + "now", + ], + env=self.ffx_cmd_env(), + check=False, + ) + def start(args): test_env = TestEnvironment.from_args(args) @@ -933,6 +978,12 @@ def debug(args): return 0 +def syslog(args): + test_env = TestEnvironment.read_from_file() + test_env.syslog(args) + return 0 + + def main(): parser = argparse.ArgumentParser() @@ -1028,6 +1079,11 @@ def main(): ) debug_parser.set_defaults(func=debug) + syslog_parser = subparsers.add_parser( + "syslog", help="prints the device syslog" + ) + syslog_parser.set_defaults(func=syslog) + args = parser.parse_args() return args.func(args) diff --git a/src/doc/rustc/src/platform-support/fuchsia.md b/src/doc/rustc/src/platform-support/fuchsia.md index 0f165b268ba..63dde2aaedd 100644 --- a/src/doc/rustc/src/platform-support/fuchsia.md +++ b/src/doc/rustc/src/platform-support/fuchsia.md @@ -687,7 +687,9 @@ Rust compiler locally. See "[Targeting Fuchsia with a compiler built from source for the steps to build locally. You'll also need to download a copy of the Fuchsia SDK. The current minimum -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). +supported SDK version is [10.20221207.2.89][minimum_supported_sdk_version]. + +[minimum_supported_sdk_version]: https://chrome-infra-packages.appspot.com/p/fuchsia/sdk/core/linux-amd64/+/version:10.20221207.2.89 Fuchsia's test runner interacts with the Fuchsia emulator and is located at `src/ci/docker/scripts/fuchsia-test-runner.py`. We can use it to start our @@ -697,7 +699,7 @@ test environment with: src/ci/docker/scripts/fuchsia-test-runner.py start --rust ${RUST_SRC_PATH}/install --sdk ${SDK_PATH} - --target-triple {x86_64-unknown-fuchsia|aarch64-unknown-fuchsia} + --target {x86_64-unknown-fuchsia|aarch64-unknown-fuchsia} ``` Where `${RUST_SRC_PATH}/install` is the `prefix` set in `config.toml` and @@ -717,17 +719,11 @@ run the full `tests/ui` test suite: --target x86_64-unknown-fuchsia \ --run=always --jobs 1 \ --test-args --target-rustcflags \ - --test-args -L \ + --test-args -Lnative=${SDK_PATH}/arch/{x64|arm64}/sysroot/lib \ --test-args --target-rustcflags \ - --test-args ${SDK_PATH}/arch/{x64|arm64}/sysroot/lib \ + --test-args -Lnative=${SDK_PATH}/arch/{x64|arm64}/lib \ --test-args --target-rustcflags \ - --test-args -L \ - --test-args --target-rustcflags \ - --test-args ${SDK_PATH}/arch/{x64|arm64}/lib \ - --test-args --target-rustcflags \ - --test-args -Cpanic=abort \ - --test-args --target-rustcflags \ - --test-args -Zpanic_abort_tests \ + --test-args -Clink-arg=--undefined-version \ --test-args --remote-test-client \ --test-args src/ci/docker/scripts/fuchsia-test-runner.py \ ) @@ -736,7 +732,18 @@ run the full `tests/ui` test suite: *Note: The test suite cannot be run in parallel at the moment, so `x.py` must be run with `--jobs 1` to ensure only one test runs at a time.* -When finished, the test runner can be used to stop the test environment: +By default, `x.py` compiles test binaries with `panic=unwind`. If you built your +Rust toolchain with `-Cpanic=abort`, you need to tell `x.py` to compile test +binaries with `panic=abort` as well: + +```sh + --test-args --target-rustcflags \ + --test-args -Cpanic=abort \ + --test-args --target-rustcflags \ + --test-args -Zpanic_abort_tests \ +``` + +When finished testing, the test runner can be used to stop the test environment: ```sh src/ci/docker/scripts/fuchsia-test-runner.py stop @@ -764,8 +771,9 @@ ${SDK_PATH}/tools/${ARCH}/ffx debug connect -- \ * `--symbol-path` gets required symbol paths, which are necessary for stepping through your program. -The "[displaying source code in `zxdb`](#displaying-source-code-in-zxdb)" section describes how you can -display Rust and/or Fuchsia source code in your debugging session. +The "[displaying source code in `zxdb`](#displaying-source-code-in-zxdb)" +section describes how you can display Rust and/or Fuchsia source code in your +debugging session. ### Using `zxdb` @@ -866,6 +874,64 @@ ${SDK_PATH}/tools/${ARCH}/ffx debug connect -- \ Linking to a Fuchsia checkout can help with debugging Fuchsia libraries, such as [fdio]. +### Debugging the compiler test suite + +Debugging the compiler test suite requires some special configuration: + +First, we have to properly configure zxdb so it will be able to find debug +symbols and source information for our test. The test runner can do this for us +with: + +```sh +src/ci/docker/scripts/fuchsia-test-runner.py debug \ + --rust-src ${RUST_SRC_PATH} \ + --fuchsia-src ${FUCHSIA_SRC_PATH} \ + --test ${TEST} +``` + +where `${TEST}` is relative to Rust's `tests` directory (e.g. `ui/abi/...`). + +This will start a zxdb session that is properly configured for the specific test +being run. All three arguments are optional, so you can omit `--fuchsia-src` if +you don't have it downloaded. Now is a good time to set any desired breakpoints, +like `b main`. + +Next, we have to tell `x.py` not to optimize or strip debug symbols from our +test suite binaries. We can do this by passing some new arguments to `rustc` +through our `x.py` invocation. The full invocation is: + +```sh +( \ + source config-env.sh && \ + ./x.py \ + --config config.toml \ + --stage=2 \ + test tests/${TEST} \ + --target x86_64-unknown-fuchsia \ + --run=always --jobs 1 \ + --test-args --target-rustcflags \ + --test-args -Lnative=${SDK_PATH}/arch/{x64|arm64}/sysroot/lib \ + --test-args --target-rustcflags \ + --test-args -Lnative=${SDK_PATH}/arch/{x64|arm64}/lib \ + --test-args --target-rustcflags \ + --test-args -Clink-arg=--undefined-version \ + --test-args --target-rustcflags \ + --test-args -Cdebuginfo=2 \ + --test-args --target-rustcflags \ + --test-args -Copt-level=0 \ + --test-args --target-rustcflags \ + --test-args -Cstrip=none \ + --test-args --remote-test-client \ + --test-args src/ci/docker/scripts/fuchsia-test-runner.py \ +) +``` + +*If you built your Rust toolchain with `panic=abort`, make sure to include the +previous flags so your test binaries are also compiled with `panic=abort`.* + +Upon running this command, the test suite binary will be run and zxdb will +attach and load any relevant debug symbols. + [Fuchsia team]: https://team-api.infra.rust-lang.org/v1/teams/fuchsia.json [Fuchsia]: https://fuchsia.dev/ [source tree]: https://fuchsia.dev/fuchsia-src/get-started/learn/build