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`.
This repository provides rules for building Rust projects with Bazel.
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.
General discussions and announcements take place in the GitHub Discussions, but there are additional places where community members gather to discuss rules_rust.
Please refer to the full documentation.