Generally, the library order doesn't matter.
However, after lowering we need to post process
lowered klibs in topological order:
- commit incremental cache artifacts,
- produce JS AST.
The patch uses an ability of the Kotlin library resolver to load klibs
in topological order and drops its reimplementation from IC infrastructure.
There is one side effect:
klibs which are not reachable from the main module, will produce their JS.
This should be more correct than just ignoring them.
Replace loading the whole world IR with loading only exported (reachable) IR.
For that purpose the direct and inverse dependency graph is used.
It is stored in a cache directory and the cache updater keeps it up to date.
If after loading it is found that other files must be also implicitly rebuilt
(see rebuilt reasons below), IR for that files also will be loaded.
This algorithm repeats until the number of implicitly rebuilt files is not 0.
More rebuilt reasons (dirty state) have been added:
- added file: this is a new file;
- modified ir: ir of the file has been updated;
- updated exports: exports from the file have been added or removed
(e.g. a function has been used from another file);
- updated inline imports: imported inline function has been modified
(transitively);
- removed inverse depends: a dependent file has been removed;
- removed direct depends: a dependency file has been removed;
- removed file: this file has been removed.
Incremental cache tests has been refactored:
- The supporting of all rebuilt reasons (dirty states) has been added;
- New file name format "*.$suffix.kt" for the test steps has been allowed,
so the syntax highlight works now;
- Explicit stdlib dependency usage has been removed.