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

Fix passing of links-overrides with target-applies-to-host and an implicit target #14205

Merged
merged 2 commits into from
Jul 18, 2024

Conversation

gmorenz
Copy link
Contributor

@gmorenz gmorenz commented Jul 6, 2024

What does this PR try to resolve?

This fixes the link-overrides half of #14195, both the panic, and the fact that the field is being discarded, the latter of which caused the former as discussed in the issue.

It does so following the blueprint laid out in #13900 - which is also in my opinion the current best summary of the broader context.

How should we test and review this PR?

For reviewing, comparing to the changes in #13900 might be useful.

Additional information

I'm pushing a PR for the other half of #14195 simultaneously. I thought it better to keep the PRs small since they're independent, though if merged simultaneously there will be a conflict over the ordering of fields in Unit.

@rustbot
Copy link
Collaborator

rustbot commented Jul 6, 2024

r? @epage

rustbot has assigned @epage.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added A-build-scripts Area: build.rs scripts A-cargo-targets Area: selection and definition of targets (lib, bins, examples, tests, benches) A-cfg-expr Area: Platform cfg expressions S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 6, 2024
@gmorenz
Copy link
Contributor Author

gmorenz commented Jul 6, 2024

@rustbot label: Z-target-applies-to-host

r? @weihanglo if you're willing to look at this too

@rustbot rustbot added the Z-target-applies-to-host Nightly: target-applies-to-host label Jul 6, 2024
@rustbot rustbot assigned weihanglo and unassigned epage Jul 6, 2024
@gmorenz gmorenz marked this pull request as draft July 6, 2024 18:11
@gmorenz
Copy link
Contributor Author

gmorenz commented Jul 6, 2024

Well, the test doesn't work on windows, converting to draft until I fix that.

@gmorenz
Copy link
Contributor Author

gmorenz commented Jul 11, 2024

Marking this as ready for review, but leaving the fix for the test on windows as a separate commit for now because I'm hoping that there's a better way to link to a cdylib built with cargo on windows that I'm missing. See the last commit for my current understanding of what you have to do to do that.

If there isn't a better way, I should probably squash the last commit into the first commit that introduces the test before this is merged.

@gmorenz gmorenz marked this pull request as ready for review July 11, 2024 20:47
src/cargo/core/compiler/unit.rs Outdated Show resolved Hide resolved
@@ -61,7 +61,7 @@ const OLD_CARGO_WARNING_SYNTAX: &str = "cargo:warning=";
/// [the doc]: https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#cargo-warning
const NEW_CARGO_WARNING_SYNTAX: &str = "cargo::warning=";
/// Contains the parsed output of a custom build script.
#[derive(Clone, Debug, Hash, Default)]
#[derive(Clone, Debug, Hash, Default, PartialEq, Eq, PartialOrd, Ord)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also realized that there is an implication that these newly added fields would affect the order of any sorted units list. I don't think that would cause real issues though.

Copy link
Contributor Author

@gmorenz gmorenz Jul 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True... if this is a significant concern we could move the new fields to the end.

Ultimately I don't think I have the context to decide if it is. I think it is almost certainly publicly exposed given comments like this one, and where these fields currently are in the struct is probably high enough to change the order in the cases described in this comment. I wouldn't have thought that the ordering of units was something that was guaranteed to be stable between cargo versions.

I'll hold off on updating the rustflags Arc to Rc until we've decided if we need to move it to the bottom since that might as well be one PR.

@gmorenz
Copy link
Contributor Author

gmorenz commented Jul 16, 2024

Made promised changes, rebased on master. Removed part about test from the initial github comment since it's no longer relevant.

Copy link
Member

@weihanglo weihanglo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Looks pretty great!

@weihanglo
Copy link
Member

weihanglo commented Jul 18, 2024

@bors r+

Haven't got time to review #14206, though I guess you need to rebase?

@bors
Copy link
Contributor

bors commented Jul 18, 2024

📌 Commit 9098072 has been approved by weihanglo

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 18, 2024
@bors
Copy link
Contributor

bors commented Jul 18, 2024

⌛ Testing commit 9098072 with merge 61424d6...

@bors
Copy link
Contributor

bors commented Jul 18, 2024

☀️ Test successful - checks-actions
Approved by: weihanglo
Pushing 61424d6 to master...

@bors bors merged commit 61424d6 into rust-lang:master Jul 18, 2024
22 checks passed
@gmorenz
Copy link
Contributor Author

gmorenz commented Jul 18, 2024

Haven't got time to review #14206, though I guess you need to rebase?

Yeah, also I need to incorporate the Arc -> Rc feedback. Will get to this later today, I've just been a bit busy and was putting it off (though I don't anticipate it taking more than 10 minutes).

When you say "haven't got time" are you looking forwards and saying I should ask someone else to review it, or just "not yet/right now"?

@weihanglo
Copy link
Member

weihanglo commented Jul 18, 2024

It is in my queue, and I am happy to review when ready :)

bors added a commit that referenced this pull request Jul 20, 2024
Use `Rc` instead of `Arc` for storing rustflags

# What does this PR try to resolve?

There's no reason that these reference counted pointers (which I introduced in #13900) need to be atomic, so let's use non-atomic pointers.

# Additional information

First noticed by `@weihanglo` [here](#14205 (comment)).

r? `@weihanglo`
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 21, 2024
Update cargo

9 commits in a2b58c3dad4d554ba01ed6c45c41ff85390560f2..5f6b9a92201d78af75dc24f14662c3e2dacbbbe1
2024-07-16 00:52:02 +0000 to 2024-07-19 18:09:17 +0000
- Add `TomlPackage::new`, `Default` for `TomlWorkspace` (rust-lang/cargo#14271)
- fix(test): Move 'cargo_home' from 'install' to 'paths' (rust-lang/cargo#14270)
- fix(test)!: Clarify extension trait role with rename (rust-lang/cargo#14269)
- feat(test): Re-export ProcessBuilder (rust-lang/cargo#14268)
- fix(test): Move path2url to CargoPathExt::to_url (rust-lang/cargo#14266)
- Fix passing of links-overrides with target-applies-to-host and an implicit target (rust-lang/cargo#14205)
- fix(toml): Improve error on missing package and workspace (rust-lang/cargo#14261)
- Migrate global_cache_tracker snapbox (rust-lang/cargo#14244)
- make summary sync by using Arc not Rc (rust-lang/cargo#14260)
@rustbot rustbot added this to the 1.82.0 milestone Jul 21, 2024
lnicola pushed a commit to lnicola/rust-analyzer that referenced this pull request Jul 28, 2024
Update cargo

9 commits in a2b58c3dad4d554ba01ed6c45c41ff85390560f2..5f6b9a92201d78af75dc24f14662c3e2dacbbbe1
2024-07-16 00:52:02 +0000 to 2024-07-19 18:09:17 +0000
- Add `TomlPackage::new`, `Default` for `TomlWorkspace` (rust-lang/cargo#14271)
- fix(test): Move 'cargo_home' from 'install' to 'paths' (rust-lang/cargo#14270)
- fix(test)!: Clarify extension trait role with rename (rust-lang/cargo#14269)
- feat(test): Re-export ProcessBuilder (rust-lang/cargo#14268)
- fix(test): Move path2url to CargoPathExt::to_url (rust-lang/cargo#14266)
- Fix passing of links-overrides with target-applies-to-host and an implicit target (rust-lang/cargo#14205)
- fix(toml): Improve error on missing package and workspace (rust-lang/cargo#14261)
- Migrate global_cache_tracker snapbox (rust-lang/cargo#14244)
- make summary sync by using Arc not Rc (rust-lang/cargo#14260)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-build-scripts Area: build.rs scripts A-cargo-targets Area: selection and definition of targets (lib, bins, examples, tests, benches) A-cfg-expr Area: Platform cfg expressions S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. Z-target-applies-to-host Nightly: target-applies-to-host
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants