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

Miri doesn't respect target-feature in doc tests #3869

Closed
Kixunil opened this issue Sep 8, 2024 · 8 comments
Closed

Miri doesn't respect target-feature in doc tests #3869

Kixunil opened this issue Sep 8, 2024 · 8 comments

Comments

@Kixunil
Copy link
Contributor

Kixunil commented Sep 8, 2024

When code under miri reaches a function annotated with #[target_feature(enable = "...")] in doc tests miri throws an error saying "calling a function that requires unavailable target features" despite this being in the if block that checks the features using is_x86_feature_enabled! and despite having -C target-feature=... on the command line. The same issue is not present in non-doc tests and the same code works fine.

@Kixunil Kixunil changed the title Miri doesn't respect target-feature in some environments Miri doesn't respect target-feature in doc tests Sep 8, 2024
@RalfJung
Copy link
Member

RalfJung commented Sep 8, 2024 via email

@Kixunil
Copy link
Contributor Author

Kixunil commented Sep 8, 2024

I guess e-mail didn't show you my edit, I found it's actually doc tests that have this problem (on both machines).

@RalfJung
Copy link
Member

RalfJung commented Sep 8, 2024

How are you setting -Ctarget-feature? If you are using RUSTFLAGS, then you need to also set RUSTDOCFLAGS for doctests. MIRIFLAGS should apply everywhere... hopefully...

Please show the full command you are using. It's hard to guess that and details matter. :)

@Kixunil
Copy link
Contributor Author

Kixunil commented Sep 8, 2024

you need to also set RUSTDOCFLAGS

Oh, that helped, thanks!

@Kixunil Kixunil closed this as completed Sep 8, 2024
@RalfJung
Copy link
Member

RalfJung commented Sep 8, 2024

FWIW that's a cargo thing, RUSTFLAGS is simply not set on doctests.

@RalfJung
Copy link
Member

Reading rust-lang/rust#67533 I actually don't understand how setting RUSTDOCFLAGS helps... if rustdoc doesn't pass the flags to the rustc it invokes, then it shouldn't help with -Ctarget-features either?

@RalfJung
Copy link
Member

I guess rustdoc must be forwarding -C flags to the rustc it invokes, but not other flags like --cap-lints.

@Kixunil
Copy link
Contributor Author

Kixunil commented Sep 16, 2024

Not sure which flags rustdoc passes but FTR I set both RUSTFLAGS and RUSTDOCFLAGS in CI to configure target-features and it works fine.

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

No branches or pull requests

2 participants