Repository navigation
check_export: validate export_stable on non-sdylib crates - #163872
NaitikVerma6776 wants to merge 2 commits into
Conversation
|
Thanks for the pull request, and welcome! The Rust Project has assigned @nnethercote (or someone else) to review your changes, you should hear from them (or someone else) within the next two weeks. Please see the contribution instructions and our LLM policy for more information. Why was this reviewer chosen?The reviewer was selected based on:
|
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…try> check_export: validate export_stable on non-sdylib crates
This comment has been minimized.
This comment has been minimized.
|
Should we not deny |
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (bd16461): comparison URL. Overall result: ❌ regressions - please read:Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf. Next, please: If you can, justify the regressions found in this try perf run in writing along with @bors rollup=never rustc-perf Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (secondary -1.3%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary -3.0%, secondary -4.5%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis perf run didn't have relevant results for this metric. Bootstrap: 489.693s -> 489.31s (-0.08%) |
|
hii @JonathanBrouwer I’ve pushed the follow-up changes to address the CI failures and the changes only update the affected |
How does this work if you want to build multiple crate type outputs for your crate? Would you need to create build scripts to emit cfgs and use That sounds extremely annoying. I think it would be more practical if it's a no-op on non-sdylib crates but otherwise has the same errors and restrictions. In any case, such a decision should be part of the RFC. |
|
We could allow it if any of the crate types passed to rustc is sdylib. But even so I'm not sure if allowing sdylib together with other crate types is ok. If I recall correctly sdylib was messing with symbol mangling, which would break other crate types. |
|
Another option is a lint, such as for #![warn(linker_messages)] |
that question is orthogonal to this pr, if we decide to make this an error we should still display all the target errors as well. |
|
|
The |
If I understand the RFC correctly,
Literally interpreting "have no effect" would mean completely ignoring them, but I don't think that's the intention of the original text. I think the intention is a no-op but with the same errors and restrictions. In my opinion, not validating attributes just because they're not being used is a bad idea. Library authors might make the mistake to not build their library as an sdylib in their CI, and then miss that they're using the attributes wrong. I don't see why we should accept code that is incorrect.
This is a separate issue than the one this PR is solving, if you can make a reproducer for it I'd say open an issue |
| @@ -333,10 +333,6 @@ impl<'tcx, 'a> TypeVisitor<TyCtxt<'tcx>> for ExportableItemsChecker<'tcx, 'a> { | |||
| /// 3. Non-generic functions with a stable ABI (e.g. extern "C") for which every user | |||
| /// defined type used in the signature is also marked as `#[export]`. | |||
| fn exportable_items_provider_local<'tcx>(tcx: TyCtxt<'tcx>, _: LocalCrate) -> &'tcx [DefId] { | |||
There was a problem hiding this comment.
Could you short circuit the function to return an empty slice if the feature gate for export_stable is disabled? That should solve the perf regression
There was a problem hiding this comment.
This would just be a temporary fix, right? I'm assuming we'll want to stabilize this at some point. Is it possible to run this query based on whether #[export_stable] is present anywhere in the crate?
There was a problem hiding this comment.
That's true but I think that keeping track of whether export_stable exists is a lot more code to maintain for a feature that is probably not getting stabilized anytime soon. When this feature is closer to stabilization we can reconsider doing this
There was a problem hiding this comment.
The perf effect is relatively small as well so it's probably just never worth the code
|
Reminder, once the PR becomes ready for a review, use |
|
☔ The latest upstream changes (presumably #165151) made this pull request unmergeable. Please resolve the merge conflicts by rebasing. |
Fixes #158227.
#[export_stable]currently performs its exportability checks only forsdylibcrates. This change moves the crate-type check after the exportability validation so the same checks are also performed for non-sdylibcrate types.Non-
sdylibcrates still return an empty exportable-items list, so their existing export behavior is unchanged.Updated the relevant UI tests to cover the validation on non-
sdylibcrate types.