Declare the dSYM for iOS cdylib and bin targets (#4367)

Fixes #4366.

`rustc_compile_action` declared the `.dSYM` for `cdylib` and `bin`
crates only when `target_os in ["macos", "darwin"]`. rustc writes it on
every Apple target, so on iOS it was dropped with the action's
undeclared outputs and `dsym_folder` was missing.

This switches the check to `target_os.startswith(("mac", "darwin",
"ios"))`, the same prefix check `rustc.bzl` already uses to pick the
Darwin link flags. tvOS and visionOS also default to packed debuginfo;
#4346 and #2621 add those to that check, and they'd want to add them
here too.

### Test

`lib_dsym_ios_test` in `test/unit/debug_info` analyzes the existing
`rust_shared_library` for an iOS platform with a mock toolchain,
following the pattern in `test/unit/dlltool`, so it runs on any host. It
fails on `main` with no file in `dsym_folder` and passes with this
change. The existing macOS dSYM tests still pass.

It covers the library only. Under `bazel coverage
--instrument_test_targets` the binary under test gets built, which a
mock rustc can't do. Both crate types take the same branch.

Checked on macOS arm64 with Bazel 9.3.1: `bazel test
//test/unit/debug_info:all`, the same under `bazel coverage` with the
presubmit coverage flags, and buildifier 8.5.1 from
`//crate_universe/private/vendor:buildifier`.
2 files changed
tree: 1c225b7a7b3232be77bbbaeba6441c5e10088e6a
  1. .bazelci/
  2. .bcr/
  3. .github/
  4. cargo/
  5. crate_universe/
  6. docs/
  7. examples/
  8. extensions/
  9. ffi/
  10. nix/
  11. rust/
  12. test/
  13. tools/
  14. util/
  15. .bazelignore
  16. .bazelrc
  17. .clang-format
  18. .clippy.toml
  19. .envrc
  20. .gitattributes
  21. .gitignore
  22. .pre-commit-config.yaml
  23. .prettierrc.toml
  24. .rustfmt.toml
  25. .typos.toml
  26. ARCHITECTURE.md
  27. AUTHORS
  28. BUILD.bazel
  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.

Starter repo

The fastest way to try this in an empty project is to click the green “Use this template” button on https://github.com/bazel-starters/rust.

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.