Skip to content

Use object crate from crates.io to fix windows build error #143492

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 2 commits into from
Jul 6, 2025

Conversation

Diggsey
Copy link
Contributor

@Diggsey Diggsey commented Jul 5, 2025

@rustbot
Copy link
Collaborator

rustbot commented Jul 5, 2025

r? @compiler-errors

rustbot has assigned @compiler-errors.
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 S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 5, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jul 5, 2025

Some changes occurred in compiler/rustc_codegen_gcc

cc @antoyo, @GuillaumeGomez

@antoyo
Copy link
Contributor

antoyo commented Jul 5, 2025

Can you please confirm that this is sufficient to fix the build on Windows?

@Diggsey
Copy link
Contributor Author

Diggsey commented Jul 5, 2025

It certainly fixed ./x check --stage 0 compiler. Previously this would always fail with the error:

error[E0464]: multiple candidates for `rmeta` dependency `object` found

With this change this error does not occur.

@@ -27,7 +27,6 @@
#![allow(clippy::needless_lifetimes, clippy::uninlined_format_args)]

// Some "regular" crates we want to share with rustc
extern crate object;
extern crate smallvec;
Copy link
Member

Choose a reason for hiding this comment

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

So, we apparently run the risk of eventually having the same problem with smallvec. Should we just make this a crates.io dependency as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can do - what's the policy here? Should only rustc_* crates be pulled from sysroot?

Copy link
Member

Choose a reason for hiding this comment

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

I don't think we have a policy, we just discovered this problem.^^

tracing needs to be pulled from the sysroot since it manages a singleton. Other than that, the main thing is avoiding duplicates... but also, if there's a SmallVec in a rustc type, then ofc it needs to use the sysroot version of the crate.

We can also just wait if one of the other crates becomes a problem. But it's going to be hard to notice that if we don't even build this on CI. So maybe the more important thing is to ensure these crates get check-built on more targets. @Kobzol might have an idea how to do that?

Copy link
Contributor

@antoyo antoyo Jul 5, 2025

Choose a reason for hiding this comment

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

I used to pull as much as I could from the sysroot to save on compile time, but unfortunately, we have to stop doing this for Windows it seems.

Copy link
Member

Choose a reason for hiding this comment

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

These aren't very big crates we are talking about, so compile time shouldn't be a big deal.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@antoyo this is not a windows-specific problem in general, it just so happens that in the windows build, the compiler doesn't load object beforehand, and there are multiple candidates.

That's why I asked about a policy - we need to say what crates are guaranteed to exist exactly once in the sysroot, as these can be pulled in safely, and no others.

Copy link
Member

@RalfJung RalfJung Jul 5, 2025

Choose a reason for hiding this comment

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

It's hard to say which ones are guaranteed to exist only once (other than the rustc crates of course). OTOH, this in principle affects all rustc drivers (clippy, Miri, rustdoc) and hardly ever seems to be a problem... but also, at least in Miri we hardly use extern crate, so maybe that's why.

Copy link
Member

Choose a reason for hiding this comment

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

We can also just wait if one of the other crates becomes a problem. But it's going to be hard to notice that if we don't even build this on CI. So maybe the more important thing is to ensure these crates get check-built on more targets. @Kobzol might have an idea how to do that?

We don't check almost anything on CI, but we could build the GCC backend on more OSes. We haven't done that so far because it's not even in blocking (auto) CI on Linux yet, but that's for tests. For just building the backend, I guess we could try to add it to more runners.

Copy link
Member

Choose a reason for hiding this comment

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

Building might be harder than checking and require a full GCC... but maybe it can be done. Just seems like overkill when the main goal is to allow contributors to fix compilation failures.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it would make sense to do any further changes like re-exporting smallvec as a separate PR, so would be great if I could get an approval on this.

@AngelicosPhosphoros
Copy link
Contributor

I don't have any suggestions/comment but just want to say thank you @Diggsey for doing this.

@AngelicosPhosphoros
Copy link
Contributor

#142754

@RalfJung
Copy link
Member

RalfJung commented Jul 6, 2025

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Jul 6, 2025

📌 Commit ea7b756 has been approved by RalfJung

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 6, 2025
bors added a commit that referenced this pull request Jul 6, 2025
Rollup of 4 pull requests

Successful merges:

 - #143252 (Rewrite empty attribute lint for new attribute parser)
 - #143492 (Use `object` crate from crates.io to fix windows build error)
 - #143514 (Organize macro tests a bit more)
 - #143518 (rustc_builtin_macros: Make sure registered attributes stay sorted)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit bae6714 into rust-lang:master Jul 6, 2025
11 checks passed
@rustbot rustbot added this to the 1.90.0 milestone Jul 6, 2025
rust-timer added a commit that referenced this pull request Jul 6, 2025
Rollup merge of #143492 - Diggsey:db-fix-object-ambiguity, r=RalfJung

Use `object` crate from crates.io to fix windows build error

See https://rust-lang.zulipchat.com/#narrow/channel/386786-rustc-codegen-gcc/topic/Cannot.20compile.20rustc.20on.20Windows.2010/with/527240094
@Diggsey Diggsey deleted the db-fix-object-ambiguity branch July 6, 2025 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants