-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Teach compiletest to parse arbitrary cfg options #87396
Conversation
(rust-highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
dc1f5d4
to
2db8489
Compare
This comment has been minimized.
This comment has been minimized.
2db8489
to
0d82467
Compare
I don't see how this handles situations where the test specifies specific flags for rustc, e.g. like this: // compile-flags: --target=wasm32-unknown-unknown -Ctarget-feature=+simd128
// cfg-target-feature: simd128 should probably work. |
It doesn't. I agree that it would be lovely if that were supported. However, I'd really prefer not to implement it right now. The current code is structured so that configuration parameters are resolved solely based on the main target, rather than any compile-flags. That means that compile-flag information isn't presently available to the section of the code that parses configurations. To add this feature, I'd have to restructure the code so that Fortunately, there's a relatively easy workaround for that case: just check whether the feature you want is supported on the target you have requested. It's not perfect, but it's a lot more workable than checking whether the feature is supported on every individual target, having to account for the possibility that future targets with different features might be added. Thus, the feature I'm adding here is quite useful on its own. Given all that, I don't think we should block this on adding |
I think it is fairly important that writing a test (possibly by combining concepts seen in other tests) is easy to get correct. My view of this specific implementation is that the behaviour is not intuitive at all. I don't mind this being a separate PR, but from what I can tell, a better integrated implementation would have to redo most of this PR either way. At the very least I want to see a tidy lint that disallows tricky combinations, if we land this feature as-is. |
That seems fair. This isn't any worse than the other Also, you're right that a PR that did that would have to rewrite a fair portion of this: I'd estimate about 50%. |
I think I'm going to temporarily close this. I am working on it again though. Hopefully I'll have progress soon, and I'll reopen then. |
0d82467
to
e600e46
Compare
I feel like this is worth reopening for another round of comments. I believe that I've implemented all of the feedback I previously received. I'm sincerely sorry that this took so long. It's been a busy few months, but that's no excuse. Things that are missing from this implementation are caching of the results and testing. I'd like hear people's thoughts about whether caching is necessary and how to go about it; I'll leave a comment on the relevant area of code. I think testing would likely be advisable, but I'm still working out the best way to go about it. I'm also clarifying some of the relevant details with someone else at the moment. One other specific thing that I wanted to draw attention to is that I changed the code to refer to the sort of thing that goes after an Please feel welcome to point out anything that I've missed, and of course any new comments as well. I'm sure there are places where the code could be improved. CC @Mark-Simulacrum and @nagisa, who reviewed this previously. |
This comment has been minimized.
This comment has been minimized.
.unwrap() | ||
.stdout; | ||
let cfg_data = String::from_utf8(cfg_data).unwrap(); | ||
let cfg_data = cfg_data.replace('"', ""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cfg_data
could be cached somewhere around this point. Doing so could presumably result in some small performance saving for the case where target == self.target
, which is likely to come up with the most frequency. I'm not sure whether this is worthwhile, or if so, how to go about it.
As an amusing anecdote, I actually fiddled around with a version where all of the targets had their information calculated in advance and it was stored in Config
. I figured that computing all of that would only take a few extra seconds. It took me a few days to figure out why doing so was causing a one third to one half regression in testing times. It turns out that Config
gets cloned a fair number of times, and by the end was taking enough memory that it was vastly increasing the duration of forking the threads to execute the tests. At least, that's what it was as far as I can tell. In any case, not doing that again!
74033e4
to
ae92083
Compare
I added tests! |
I think I agree with @nagisa that this should respect compile-flags -- or, at least, abort if any such flags are specified so that it can't be combined with compile-flags by accident in a way that leads to misleading behavior. Is that implemented in the current version of the PR? I'll also note that I feel a little uncertain about the exact shape of these options. It feels like they're an improvement over the manual listing of various targets to ignore, but are a little weak in terms of readability -- |
Well, I thought it was, but... I only made it respect the
I feel uncertain about that too. |
☔ The latest upstream changes (presumably #94134) made this pull request unmergeable. Please resolve the merge conflicts. |
@inquisitivecrystal any updates on this? |
I apologize for the delay. I know this PR has been hanging around for ages at this point. I'm still planning on finishing everything up sooner or later, but it may be a month or so before I have time to work on it again, as I'm extremely busy IRL. Unfortunately, the "proper" fix is so complicated that I don't know how to implement it cleanly (and the difference wouldn't be relevant all that often, in any case). When I do implement this, I'm planning to go with a simpler implementation (using tidy to reject confusing combinations, rather than trying to support them). In the meantime, I don't know how to handle the PR. We can close it so WG-triage doesn't have to deal with keeping track of it or leave it open if that's more convenient. I'm even happy to let someone else take over, if there's someone who wants to work on that. In any case, I once again apologize for how long it's taken me to handle this. |
Nothing to apologise about. I am going to close it for now, but feel free to reoopen it if nobody has got to it yet. |
This gives compiletest the ability to check for any cfg option that rustc sets by default for certain platforms. For instance, it is now possible to only run a test on targets where
target_has_atomic="8"
is true.Resolves #87377.