-
Notifications
You must be signed in to change notification settings - Fork 1.7k
can't resolve against exports when loading from .dill #30448
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
Comments
I started looking into this, turns out this is not related to IKG specifically, but this is an issue in general about exports and modular compilation. Here is a small repro using the modular APIs: import 'package:front_end/src/testing/compiler_common.dart';
main() async {
var sources = <String, dynamic>{
'a.dart': 'a() => print("hi"); class A{} ',
'b.dart': 'export "a.dart";',
'c.dart': 'import "b.dart"; class C extends A {}',
};
sources['ab.dill'] = await summarize(['a.dart', 'b.dart'], sources);
await compileUnit(['c.dart'], sources, inputSummaries: ['ab.dill']);
} Run it as: This produces the following error message:
What is our current strategy for representing |
Although we can represent exports in kernel, there's currently no way to represent an export scope. In dartk, I implemented a hack to add a member named "_exports#" to a library that would contain a list of exported elements. |
Interesting - that makes sense - I recall @scheglov needed some of the export scopes for summaries as well, but I don't know if what he needs is more limited than what we need here. I'm guessing that at this time we probably want to extend kernel with special nodes for the export scope, correct? Then the VM can simply ignore those nodes when deserializing kernel? |
Yes, The idea was that we add this information into Kernel, I remember someone saying that they planning to do this. OTOH, it might be the person who left Kernel team. Anyway, I think that we should add export namespace directly into Kernel and if a client does not need export namespace, it can be ignored. |
sounds good - @peter-ahe-google I assigned you on this issue assuming that you have the full context to move this forward and can iterate quickly with Kevin on the changes in kernel, but let us know if we should have someone else help on this. |
I've discussed this with @kmillikin today, he will look for a solution in kernel, and then I'll implement it in fasta. |
Thanks both for taking a look! I should note that this issue is in the front burner for both flutter hot-reload ( |
BTW, the hack does not work nice with outline shaker. We still need real presentation of exported entities in Kernel. And for now probably another hack into shaker. |
@scheglov is the problem with the outline shaker that the field is private? |
Ah, sorry. I should have provided more information. addLibrarySource('/a.dart', 'export "b.dart";');
addLibrarySource('/b.dart', 'export "c.dart";');
addLibrarySource('/c.dart', 'class C {} enum E { v } typedef F();');
var library = await checkLibrary('import "a.dart"; C c; E e; F f;'); When we shake Well, actually I think currently this happens even for |
Are we doing incremental tree-shaking? I've always thought of tree-shaking as something that's a whole-program transformation. Am I conflating concepts here? You say "outline shaker" and I think "tree shaker", not the same thing? |
The way Bazel is supposed to work with kernels is that you take kernels of direct dependencies, and compile the target sources. Then you shake it to keep only required outlines for direct dependencies. Next target. So, yes, I think we will do incremental tree-shaking. |
So basically, what Bazel needs is outlines without private members? |
Yes, but that's not what causes the problem here. Because of the way exports are represented now (additional exports), we don't know that |
@scheglov thank you, I think I'm getting it now. What should be in the outline of |
Each kernel file is a set of libraries. So, the kernel file for The library The library The library |
Actually, I will try to implement it myself. |
We need this to be able to tree shake outline. #30448 (comment) [email protected], [email protected], [email protected], [email protected] BUG= Review-Url: https://codereview.chromium.org/3008763002 .
From chatting with Peter this morning I believe we are pretty close on this. Konstantin's fixes the general valid input. We just need to add some additional representation in kernel to handle erroneous cases. Correct? |
@kmillikin - any updates on adding the kernel representation needed for this? |
I think we need to understand what the feature you need is. I can gather from reading this issue that something still doesn't work because something is missing from Kernel. Is there an easy way that I can reproduce the thing that doesn't work so I could try to understand the problem? Or can someone who understands the problem summarize it and speculate about the missing feature (better yet, propose a Dart-like syntax for it)? |
The remaining issue boils down to representing duplicated exports that lead to a compile-time error. See #29840. |
If this issue boils down to another issue, can we close this one? |
Example:
b.dart:
a.dart:
when compiling a.dart using the batch compilation, there are no issues. If we compile it with IKG, there is a warning that
File
cannot be resolved ina.dart
.Note: if you provide
compileSdk
to the IKG options, then it works fine.The text was updated successfully, but these errors were encountered: