Skip to content

Commit

Permalink
Better document why we use env config instead of just cmd.env
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed Dec 26, 2023
1 parent e82f698 commit 0514982
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,16 +384,20 @@ 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`).
//
// 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>.\
let apple_target = target.contains("-darwin")
|| target.contains("-ios")
|| target.contains("-tvos")
|| target.contains("-watchos");
// 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 only
// to target binaries when using `cargo run` or `cargo test` (and this
// means that `rustc` is also run under the main thread checker, which will
// probably fail on other platforms).
// See <https://github.com/rust-lang/cargo/issues/4505>.
if apple_target && cfg!(target_os = "macos") {
if let Some(path) = main_thread_checker_path()? {
cmd.arg("--config");
Expand Down

0 comments on commit 0514982

Please sign in to comment.