Skip to content

Document that cargo sets CARGO for build scripts #4764

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

Merged
merged 1 commit into from
Nov 29, 2017

Conversation

matklad
Copy link
Member

@matklad matklad commented Nov 29, 2017

This documents and tests the current behavior.

However, I have two questions:

  • Do we support recursively invoking Cargo from the build script?

  • Do we support recursively invoking Cargo on the crate's own sources (ie, stuff inside CARGO_HOME which gets extracted from .crate files, and which in general is not byte-equal to the original sources).

Here's an interesting problem that Servo faced:

  • Servo is a workspace.
  • Servo's CARGO_HOME is inside sources.
  • One of Servo's deps uses cbindgen from build.rs
  • cbindgen invokes Cargo to read Cargo.toml from a crate inside CARGO_HOME (which is inside worksapce).

This all failed to work as expected, because Cargo invoked by bindgen thought that workspace configuration was wrong.

The problem was fixed on the Servo side by using exclude key for workspace.

But do we actually guarantee that this is supposed to work? :) If we do, we might want to apply fix suggested by @nox and avoid looking for workspace root if we are inside CARGO_HOME.

Note that cbindgen will probably be broken for crates which are workspaces themselves, because we rewrite members to path dependencies, but, if you have an explicit members key, cargo metadata inside such workspace in CARGO_HOME will complain.

Original IRC discussion: https://botbot.me/mozilla/cargo/2017-11-29/?msg=94061970&page=3

cc @nox

@rust-highfive
Copy link

r? @alexcrichton

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

@alexcrichton
Copy link
Member

@bors: r+

Looks good!

As to whether that's expected to work, who knows! It's not like we made a decision one way or another about stuff like that... In any case it seems reasonable to at least attempt to get things to "work by default" more often, so where that's possible seems like we should?

@bors
Copy link
Contributor

bors commented Nov 29, 2017

📌 Commit 94db2d1 has been approved by alexcrichton

@bors
Copy link
Contributor

bors commented Nov 29, 2017

⌛ Testing commit 94db2d1 with merge c016957...

bors added a commit that referenced this pull request Nov 29, 2017
Document that cargo sets `CARGO` for build scripts

This documents and tests the current behavior.

However, I have two questions:

* Do we support recursively invoking Cargo from the build script?

* Do we support recursively invoking Cargo on the crate's own sources (ie, stuff inside `CARGO_HOME` which gets extracted from `.crate` files, and which in general is not byte-equal to the original sources).

Here's an interesting problem that Servo faced:

* Servo is a workspace.
* Servo's `CARGO_HOME` is inside sources.
* One of Servo's deps uses cbindgen from build.rs
* cbindgen [invokes](https://github.com/eqrion/cbindgen/blob/ef3bd8d307f01ad1171ab69cf911b712fbd73583/src/bindgen/cargo/cargo_metadata.rs#L106) Cargo to read Cargo.toml from a crate inside CARGO_HOME (which is inside worksapce).

This all failed to work as expected, because Cargo invoked by bindgen thought that workspace configuration was wrong.

The problem was fixed on the Servo side by using `exclude` key for workspace.

But do we actually guarantee that this is supposed to work? :) If we do, we might want to apply fix suggested by @nox and avoid looking for workspace root if we are inside `CARGO_HOME`.

Note that cbindgen will probably be broken for crates which are workspaces themselves, because we rewrite members to path dependencies, but, if you have an explicit `members` key, `cargo metadata` inside such workspace in `CARGO_HOME` will complain.

Original IRC discussion: https://botbot.me/mozilla/cargo/2017-11-29/?msg=94061970&page=3

cc @nox
@matklad
Copy link
Member Author

matklad commented Nov 29, 2017

In any case it seems reasonable to at least attempt to get things to "work by default" more often, so where that's possible seems like we should?

Ok, I'll log an issue then: I am to overloaded to fix it myself at the moment :(

@bors
Copy link
Contributor

bors commented Nov 29, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: alexcrichton
Pushing c016957 to master...

@bors bors merged commit 94db2d1 into rust-lang:master Nov 29, 2017
@matklad matklad deleted the yo-dawg branch March 17, 2018 08:39
@ehuss ehuss added this to the 1.24.0 milestone Feb 6, 2022
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.

5 participants