Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustc_driver: Frob the global PATH less #26382

Merged
merged 1 commit into from
Jun 20, 2015

Conversation

alexcrichton
Copy link
Member

Environment variables are global state so this can lead to surprising results if
the driver is called in a multithreaded environment (e.g. doctests). There
shouldn't be any memory corruption that's possible, but a lot of the bots have
been failing because they can't find cc or gcc in the path during doctests,
and I highly suspect that it is due to the compiler modifying PATH in a
multithreaded fashion.

This commit moves the logic for appending to PATH to only affect the child
process instead of also affecting the parent, at least for the linking stage.
When loading dynamic libraries the compiler still modifies PATH on Windows,
but this may be more difficult to fix than spawning off a new process.

Environment variables are global state so this can lead to surprising results if
the driver is called in a multithreaded environment (e.g. doctests). There
shouldn't be any memory corruption that's possible, but a lot of the bots have
been failing because they can't find `cc` or `gcc` in the path during doctests,
and I highly suspect that it is due to the compiler modifying `PATH` in a
multithreaded fashion.

This commit moves the logic for appending to `PATH` to only affect the child
process instead of also affecting the parent, at least for the linking stage.
When loading dynamic libraries the compiler still modifies `PATH` on Windows,
but this may be more difficult to fix than spawning off a new process.
@alexcrichton
Copy link
Member Author

r? @brson

@rust-highfive rust-highfive assigned brson and unassigned pnkfelix Jun 18, 2015
@rust-highfive
Copy link
Collaborator

r? @pnkfelix

(rust_highfive has picked a reviewer for you, use r? to override)

@alexcrichton
Copy link
Member Author

This is an example of problems I expect this PR to fix. That recently happened on the Windows bots.

@brson
Copy link
Contributor

brson commented Jun 18, 2015

@bors r+

@bors
Copy link
Contributor

bors commented Jun 18, 2015

📌 Commit fcd99aa has been approved by brson

bors added a commit that referenced this pull request Jun 20, 2015
Environment variables are global state so this can lead to surprising results if
the driver is called in a multithreaded environment (e.g. doctests). There
shouldn't be any memory corruption that's possible, but a lot of the bots have
been failing because they can't find `cc` or `gcc` in the path during doctests,
and I highly suspect that it is due to the compiler modifying `PATH` in a
multithreaded fashion.

This commit moves the logic for appending to `PATH` to only affect the child
process instead of also affecting the parent, at least for the linking stage.
When loading dynamic libraries the compiler still modifies `PATH` on Windows,
but this may be more difficult to fix than spawning off a new process.
@bors
Copy link
Contributor

bors commented Jun 20, 2015

⌛ Testing commit fcd99aa with merge c057802...

@bors bors merged commit fcd99aa into rust-lang:master Jun 20, 2015
@retep998
Copy link
Member

As of this PR, the msvc buildbot is now always failing to compile:

rustc: x86_64-pc-windows-msvc/stage1/bin/rustlib/x86_64-pc-windows-msvc/lib/libcore
error: could not exec `llvm-ar.exe`: The system cannot find the file specified.
 (os error 2)
error: aborting due to previous error

alexcrichton added a commit to alexcrichton/rust that referenced this pull request Jun 22, 2015
This commit ensures that the modifications made in rust-lang#26382 also apply to the
archive commands run in addition to the linker commands.
@alexcrichton alexcrichton deleted the less-racy-path branch June 22, 2015 03:49
bors added a commit that referenced this pull request Jun 23, 2015
This commit ensures that the modifications made in #26382 also apply to the
archive commands run in addition to the linker commands.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants