Support emitting debug logs in rules_rust process wrapper. (#2845)

When debugging an action it can be incredibly helpful to have the exact
command used to invoke `rustc`. This PR updates the rustc process
wrapper to emit debug logs when the `RULES_RUST_PROCESS_WRAPPER_DEBUG`
environment variable is enabled.

Example:
```bash
bazel build //test/... --action_env=RULES_RUST_PROCESS_WRAPPER_DEBUG=1
```
```
INFO: From Generating Rustdoc for @//test/unit/rustdoc:lib_with_proc_macro:
Command: Command {
    program: "bazel-out/darwin_arm64-fastbuild/bin/external/rust_darwin_aarch64__aarch64-apple-darwin__stable_tools/rust_toolchain/bin/rustdoc",
    args: [
        "bazel-out/darwin_arm64-fastbuild/bin/external/rust_darwin_aarch64__aarch64-apple-darwin__stable_tools/rust_toolchain/bin/rustdoc",
        "test/unit/rustdoc/rustdoc_lib.rs",
        "--crate-name=lib_with_proc_macro",
        "--crate-type=rlib",
        "--error-format=human",
        "--codegen=opt-level=0",
        "--codegen=debuginfo=0",
        "--codegen=strip=none",
        "--color=always",
        "--target=aarch64-apple-darwin",
        "-L",
        "bazel-out/darwin_arm64-fastbuild/bin/external/rust_darwin_aarch64__aarch64-apple-darwin__stable_tools/rust_toolchain/lib/rustlib/aarch64-apple-darwin/lib",
        "--output",
        "bazel-out/darwin_arm64-fastbuild/bin/test/unit/rustdoc/lib_with_proc_macro_doc.rustdoc",
        "--extern",
        "lib_with_proc_macro=bazel-out/darwin_arm64-fastbuild/bin/test/unit/rustdoc/liblib_with_proc_macro-78138021.rlib",
        "--edition=2018",
        "--codegen=linker=external/local_config_cc/cc_wrapper.sh",
        "--codegen=link-arg=-mmacosx-version-min=14.5",
        "--codegen=link-arg=-no-canonical-prefixes",
        "--codegen=link-arg=-fobjc-link-runtime",
        "--codegen=link-arg=-headerpad_max_install_names",
        "--codegen=link-arg=-lc++",
        "--codegen=link-arg=-lm",
        "--extern=rustdoc_proc_macro=bazel-out/darwin_arm64-opt-exec-ST-a828a81199fe/bin/test/unit/rustdoc/librustdoc_proc_macro-2600278351.dylib",
        "-Ldependency=bazel-out/darwin_arm64-opt-exec-ST-a828a81199fe/bin/test/unit/rustdoc",
        "--sysroot=bazel-out/darwin_arm64-fastbuild/bin/external/rust_darwin_aarch64__aarch64-apple-darwin__stable_tools/rust_toolchain",
    ],
    env: CommandEnv {
        clear: true,
        vars: {
            "CARGO_CFG_TARGET_ARCH": Some(
                "aarch64",
            ),
            "CARGO_CFG_TARGET_OS": Some(
                "darwin",
            ),
            "CARGO_CRATE_NAME": Some(
                "lib_with_proc_macro",
            ),
            "CARGO_MANIFEST_DIR": Some(
                "/private/var/tmp/_bazel_user/76282c66b0dfe3c5cb9a230bdc913a52/sandbox/darwin-sandbox/1151/execroot/rules_rust/test/unit/rustdoc",
            ),
            "CARGO_PKG_AUTHORS": Some(
                "",
            ),
            "CARGO_PKG_DESCRIPTION": Some(
                "",
            ),
            "CARGO_PKG_HOMEPAGE": Some(
                "",
            ),
            "CARGO_PKG_NAME": Some(
                "lib_with_proc_macro",
            ),
            "CARGO_PKG_VERSION": Some(
                "0.0.0",
            ),
            "CARGO_PKG_VERSION_MAJOR": Some(
                "0",
            ),
            "CARGO_PKG_VERSION_MINOR": Some(
                "0",
            ),
            "CARGO_PKG_VERSION_PATCH": Some(
                "0",
            ),
            "CARGO_PKG_VERSION_PRE": Some(
                "",
            ),
            "REPOSITORY_NAME": Some(
                "",
            ),
            "RULES_RUST_PROCESS_WRAPPER_DEBUG": Some(
                "1",
            ),
            "TMPDIR": Some(
                "/var/folders/hf/phjl9q7501gb5wt_qr4ltn3m0000gn/T/",
            ),
            "ZERO_AR_DATE": Some(
                "1",
            ),
            "__CF_USER_TEXT_ENCODING": Some(
                "0x1F5:0x0:0x0",
            ),
        },
    },
    stdout: Some(
        Inherit,
    ),
    stderr: Some(
        MakePipe,
    ),
}
```

---------

Co-authored-by: Daniel Wagner-Hall <dawagner@gmail.com>
1 file changed
tree: f233ad397aaf11d5680b18e36be44dd2e21c764f
  1. .bazelci/
  2. .bcr/
  3. .github/
  4. bindgen/
  5. cargo/
  6. crate_universe/
  7. docs/
  8. examples/
  9. ffi/
  10. nix/
  11. proto/
  12. rust/
  13. test/
  14. tools/
  15. util/
  16. wasm_bindgen/
  17. .bazelignore
  18. .bazelrc
  19. .clang-format
  20. .envrc
  21. .gitattributes
  22. .gitignore
  23. .prettierrc.toml
  24. .rustfmt.toml
  25. ARCHITECTURE.md
  26. AUTHORS
  27. BUILD.bazel
  28. buildifier
  29. CODEOWNERS
  30. COMPATIBILITY.md
  31. CONTRIBUTING.md
  32. CONTRIBUTORS
  33. LICENSE.txt
  34. MODULE.bazel
  35. README.md
  36. version.bzl
  37. WORKSPACE.bazel
README.md

Rust Rules

  • Postsubmit Build status

Overview

This repository provides rules for building Rust projects with Bazel.

Community

General discussions and announcements take place in the GitHub Discussions, but there are additional places where community members gather to discuss rules_rust.

Documentation

Please refer to the full documentation.