-
Notifications
You must be signed in to change notification settings - Fork 14.1k
Externally implementable items #146348
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
base: main
Are you sure you want to change the base?
Externally implementable items #146348
Conversation
This comment has been minimized.
This comment has been minimized.
| // `SymbolExportLevel::Rust` export level but may end up being exported in dylibs. | ||
| || codegen_attrs.flags.contains(CodegenFnAttrFlags::USED_COMPILER) | ||
| || codegen_attrs.flags.contains(CodegenFnAttrFlags::USED_LINKER) | ||
| // Right now, the only way to get "foreign item symbol aliases" is by being an EII-implementation. |
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.
TODO: do we need this:
- option 1: we do and implement our own reachability analysis based on it separate from
RUSTC_STD_INTERNAL_SYMBOL. option 2: we don't cause we also useRUSTC_STD_INTERNAL_SYMBOLon all EIIs. In that case we should renameSTD_INTERNAL_SYMBOL- option 3: same as option 2 but maybe we shouldn't use
RUSTC_STD_INTERNAL_SYMBOLin the first place; we leave it as-is and create a new flag thta's like it but specifically for EIIs and named something else likeRUSTC_USED_BY_NONDIRECT_DEP_CRATEor whatever nicer name we can think of that (as long as it doesn't use STD since it's not really specific to that anymore)
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.
despite STD_INTERNAL_SYMBOL working, and we can test with it for a bit, this is not the way we should do it. i.e. not option 2.
|
|
||
| #[eii(eii1)] | ||
| pub fn decl1(x: u64) { | ||
| //~^ WARN function `decl1` is never used |
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.
It took me a little bit to decide what is the expected behavior here. We might want to remove this warning. Defaults are in some way expected to be unused. However, here we can prove it because the explicit impl is in the same crate hence the warning.
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.
removing the warning actually makes the code a tiny bit trickier
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@bors2 try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
[DONT MERGE] externally implementable items
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (d5a6633): comparison URL. Overall result: ❌ regressions - please read the text belowBenchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary 1.7%, secondary 3.9%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 3.1%, secondary -1.3%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary 0.0%, secondary 0.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 468.052s -> 471.14s (0.66%) |
|
Well, shit. I think I know some fixes but I hoped this wouldn't happen |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
[DONT MERGE] externally implementable items
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (d5ffbde): comparison URL. Overall result: ❌✅ regressions and improvements - please read the text belowBenchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary 1.5%, secondary -0.9%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 1.4%, secondary 4.3%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary 0.0%, secondary 0.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 474.886s -> 480.638s (1.21%) |
|
Some changes occurred in diagnostic error codes Some changes occurred in src/tools/clippy cc @rust-lang/clippy Some changes occurred in compiler/rustc_builtin_macros/src/autodiff.rs cc @ZuseZ4 |
|
r? lcnr |
| fn main() {} | ||
| ``` | ||
|
|
||
| To fix this, `y`'s signature must match that of `x`: |
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.
Can you explain why it fails as well please?
|
Did you manage to get weak aliases to work at all on x86_64-pc-windows-gnu? Also I think this is missing the code that allows exporting weak aliases from dylibs on msvc. |
|
So, marked it ready for review. Some updates:
This PR merges the implementation of EII for just llvm + not windows, doesn't yet contain like a new panic handler implementation or alloc handler. With this implementation, it would support implementing the panic handler in terms of EII already since it requires no default implementation so no weak symbols The PR has been open in various forms for about a year now, but I feel that having some implementation merged to build upon |
| @@ -0,0 +1,157 @@ | |||
| //! Validity checking for weak lang items | |||
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.
This comment should be updated.
| .map(|(decl_did, (decl, impls))| ( | ||
| decl_did, | ||
| (decl, impls.into_iter().collect()) | ||
| )).collect() |
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.
nit: Please indent the contents of this block. Rustfmt doesn't as this is a macro.
|
Reminder, once the PR becomes ready for a review, use |
|
If I have an EII with a default body. What symbol names get used. Do callers of the EII use the regular symbol name of the function as symbol to call and does the EII default body get a different name with a weak alias from the regular symbol name to said different name? And for the final implementation of the EII does it directly use the symbol name of the EII or does that also involve a symbol alias. Or is it implemented some other way? |
|
Also I'm thinking if perhaps for now we should avoid weak symbols and instead do something similar to the allocator shim for implementing default bodies. And then use weak symbols later as optimization on targets where it actually works. |
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.
some final nits wrt to the type system parts of this change, otherwise r=me from my end
| ObligationCauseCode::CompareEii { external_impl, declaration }, | ||
| ); | ||
|
|
||
| let param_env = ty::ParamEnv::empty(); |
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.
given that we support implied bounds, should we just use the where-bounds of the declaration here?
I think we should accept some fn foo<'a, 'b: 'a>() even if we don't support generic params
| // | ||
| // FIXME: We manually instantiate the implementation here as we need | ||
| // to manually compute its implied bounds. Otherwise this could just | ||
| // be ocx.sub(impl_sig, trait_sig). |
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.
comment outdated
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.
we manually instantiate the declaration here to get its implied bounds
Supersedes #140010
Tracking issue: #125418
Getting started:
This PR merges the implementation of EII for just llvm + not windows, doesn't yet contain like a new panic handler implementation or alloc handler. With this implementation, it would support implementing the panic handler in terms of EII already since it requires no default implementation so no weak symbols
The PR has been open in various forms for about a year now, but I feel that having some implementation merged to build upon