reuse regular exported_non_generic_symbols logic in Miri#159740
reuse regular exported_non_generic_symbols logic in Miri#159740RalfJung wants to merge 2 commits into
Conversation
|
cc @rust-lang/miri |
e16cbd9 to
69ee67d
Compare
| || codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::USED_COMPILER) | ||
| || codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::USED_LINKER) |
There was a problem hiding this comment.
These two conditions are now lost I think, which would cause us to skip static constructors in dependencies.
Edit: Ah, the iter_exported_symbols change may be enough. Will take a closer look tomorrow.
There was a problem hiding this comment.
The iter_exported_symbols change makes it so we exclude statics from dependencies if they are not "used" or have external linkage.
I would assume the existing exported_non_generic_symbols query has to include all such statics otherwise how would it work for normal compilation? But I should add a cross-crate static constructor test.
There was a problem hiding this comment.
Looks like the filter in iter_exported_symbols now also excludes _RNvCshVjSbrpHdcL_7___rustc17rust_begin_unwind so that's no good. I don't understand why that symbol was previously included though but maybe it was added outside that filter somehow.
This comment has been minimized.
This comment has been minimized.
also add a test for cross-crate static initializers
69ee67d to
026f239
Compare
|
I pushed and the changes are not showing up... github is being github again... It says changes will "appear soon" but in my experience that never happens. |
026f239 to
b5cd32c
Compare
| let is_extern = codegen_attrs.contains_extern_indicator() | ||
| || codegen_attrs.flags.contains(CodegenFnAttrFlags::USED_COMPILER) | ||
| || codegen_attrs.flags.contains(CodegenFnAttrFlags::USED_LINKER); |
There was a problem hiding this comment.
This may be a bad idea. But it seems reasonable to say that #[used] statics are always reachable, even in a binary?
| // Skip over imports of items. | ||
| if tcx.is_foreign_item(def_id) { | ||
| return interp_ok(()); | ||
| } |
There was a problem hiding this comment.
I don't know why this check was here. All tests still pass without it.
Can the "exported" symbol list really contains imports?
This is some gnarly code we have duplicated in Miri, let's try to reuse the version from rustc.
r? @bjorn3