Skip to content

Commit

Permalink
Document correct reason why MTC is not set for child processes
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed Jan 14, 2024
1 parent 0514982 commit 1597e04
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,15 +385,18 @@ fn cargo_careful(args: env::Args) -> Result<()> {
// Enable Main Thread Checker on Apple platforms, as documented here:
// <https://developer.apple.com/documentation/xcode/diagnosing-memory-thread-and-crash-issues-early#Detect-improper-UI-updates-on-background-threads>
//
// `DYLD_INSERT_LIBRARIES` is not inherited by child processes, so we need
// to tell Cargo to set this environment variable for the processes it
// launches (instead of just setting it using `cmd.env`).
// Note: The main thread checker by default removes itself from
// `DYLD_INSERT_LIBRARIES` upon load, see `MTC_RESET_INSERT_LIBRARIES`:
// <https://bryce.co/main-thread-checker-configuration/#mtc_reset_insert_libraries>
// This means that it is not inherited by child processes, so we have to
// tell Cargo to set this environment variable for the processes it
// launches (instead of just setting it for Cargo itself using `cmd.env`).
//
// FIXME: We only do this if the host is running on macOS, since cargo
// doesn't currently have a good way of passing environment variables to
// only target binaries (the `env` config makes `rustc` also run under the
// main thread checker, which will probably fail on other platforms).
// See <https://github.com/rust-lang/cargo/issues/4505>.\
// _only_ target binaries (the `env` config makes `rustc` also run under
// the main thread checker, which will probably fail on other platforms).
// See <https://github.com/rust-lang/cargo/issues/4505>.
let apple_target = target.contains("-darwin")
|| target.contains("-ios")
|| target.contains("-tvos")
Expand Down

0 comments on commit 1597e04

Please sign in to comment.