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 building libstd with cfg(miri) #60469

Closed
wants to merge 3 commits into from

Conversation

RalfJung
Copy link
Member

@RalfJung RalfJung commented May 2, 2019

Follow-up to #60156 to fix the failure in rust-lang/miri#721.

I think that build scripts get the same feature flags, but someone please correct me if I am wrong.

Also I wonder why this didn't cause #60156 to fail...

@rust-highfive
Copy link
Collaborator

r? @joshtriplett

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

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 2, 2019
@joshtriplett
Copy link
Member

joshtriplett commented May 2, 2019

Can you explain a bit more (in the commit message, not just as a comment here) about why this would only be needed for miri, and not for non-miri?

@RalfJung
Copy link
Member Author

RalfJung commented May 3, 2019

With #60156, we use SecRandomCopyBytes on macOS with Miri. But we also still need to be able to build the libstd so Miri can use it, and that builds a dylib, and I think that's what's failing here.

I added a comment to the code saying so.

@RalfJung
Copy link
Member Author

RalfJung commented May 4, 2019

This now blocks #60533

@RalfJung
Copy link
Member Author

RalfJung commented May 7, 2019

Cc @rust-lang/libs does this seem reasonable?

@SimonSapin
Copy link
Contributor

Should SecRandomCopyBytes also be used in non-miri std?

@RalfJung
Copy link
Member Author

RalfJung commented May 7, 2019

No: #59879

@alexcrichton
Copy link
Member

This seems indicative of a deeper bug that would be better fixed than linking yet another framework in the build script. Why, when running with miri, is any artifact being linked? Presumably miri just needs full metadata, right?

@RalfJung
Copy link
Member Author

RalfJung commented May 8, 2019

@alexcrichton that would be #56443

@alexcrichton
Copy link
Member

I'm not sure that really answers my question though because that issue is about producing just an rlib, but that still feels wrong because miri doesn't need anything beyond metadata?

@RalfJung
Copy link
Member Author

RalfJung commented May 9, 2019

How can we build a metadata-only libstd? We can't even figure out how to build an rlib-only libstd.

@alexcrichton
Copy link
Member

I don't really even know how you're building libstd to begin with. If you're using cargo it seems like you could use cargo check instead of cargo build. If you're doing something else it seems like you could presumably switch some flags...

I'm basically just asking that some elbow grease is applied somewhere by someone so we don't have to keep applying these hacks. I do not have the time to apply the elbow grease myself, and I can try to scrounge together enough time to at least review things. I'm sorry though but I'm not available for a back-and-forth design discussion over how to design builds of libstd for miri, that's just so far off my radar.

@joshtriplett
Copy link
Member

This is decidedly outside my area of expertise; handing off to someone more familiar with miri.

r? @Centril

@Centril
Copy link
Contributor

Centril commented May 10, 2019

Also outside of my expertise; r? @oli-obk

@rust-highfive rust-highfive assigned oli-obk and unassigned Centril May 10, 2019
@RalfJung
Copy link
Member Author

RalfJung commented May 10, 2019

I don't really even know how you're building libstd to begin with. If you're using cargo it seems like you could use cargo check instead of cargo build. If you're doing something else it seems like you could presumably switch some flags...

Interesting idea, I'll put that on the list. However, at least the way things are right now, when Miri is built as a rustc tool it shares the libstd with the rest of the build, so we'd still have to also build the full thing.

If this PR here is considered too hacky, I can also just revert #60156. This means HashMap (with the default hasher) will not work on macOS but it will work everywhere else.

@oli-obk
Copy link
Contributor

oli-obk commented May 10, 2019

My opinion is that this is ok, since it is a temporary hack anyway. It will go away once we figure out how to (fake-)open /dev/random in miri.

Until then I think it would be better to support HashMap on mac os. If you fear the hack will persisist, I think it would be reasonable to set a "kill the hack or revert and break HashMap on mac os" deadline so we miri folks have some pressure. Something like 6 months seems ok to me.

@alexcrichton
Copy link
Member

Having a deadline for the removal of this seems reasonable to me, so I would be ok with that. Has this change been tested with miri? It seems like the previous one wasn't maybe and if you're using Cargo with RUSTFLAGS this change won't work (since build scripts don't get RUSTFLAGS), so I just wanted to confirm.

@RalfJung
Copy link
Member Author

RalfJung commented May 10, 2019 via email

@alexcrichton
Copy link
Member

Ok but surely we can at least agree that before merging hacks into libstd we should at least have anyone testing to show that they do indeed satisfy the intended use case?

@RalfJung
Copy link
Member Author

I agree with the sentiment, but don't have any idea how to do so.

Miri is currently broken, so that can't get worse. ;) But I don't know if this could have an effect on the other tools, which I think are built by the same builder.

@oli-obk
Copy link
Contributor

oli-obk commented May 10, 2019 via email

@RalfJung
Copy link
Member Author

RalfJung commented May 10, 2019 via email

@RalfJung
Copy link
Member Author

Now this includes a Miri update.

But given that #60156 was able to land, I don't think this actually tests if linking works -- though I don't know why.

Maybe it is easier to just revert #60156...

@RalfJung
Copy link
Member Author

I just realized I had entirely forgotten about rust-lang/cargo#4423. So we won't see the cfg(miri) in the build script anyway -- the entire approach does not work.

@RalfJung RalfJung closed this May 13, 2019
@RalfJung RalfJung mentioned this pull request May 13, 2019
Centril added a commit to Centril/rust that referenced this pull request May 14, 2019
fix Miri

This reverts rust-lang#60156, which turned out to be a dead end (see rust-lang#60469).

r? @oli-obk
@RalfJung RalfJung deleted the macos-rand branch June 10, 2019 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants