Skip to content
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

[native_assets_cli] HookOutput dependencies should not have to include any Dart files #1256

Closed
dcharkes opened this issue Jul 2, 2024 · 4 comments
Labels
P1 A high priority bug; for example, a single project is unusable or has many test failures package:native_assets_builder package:native_assets_cli package:native_toolchain_c

Comments

@dcharkes
Copy link
Collaborator

dcharkes commented Jul 2, 2024

The compiler should know what Dart source files have been used running a Dart script. So we shouldn't request hook writers to list transitively all Dart files in HookOutput.dependencies.

Currently the hook is run as dart path/to/some/hook/<hookname>.dart --config=path/to/config.json.

In order to get a list of all Dart files used, we have multiple options:

  1. Manually compiling to kernel first, and having that output a .d file (not preferred, I'd rather not depend on SDK internals.).
  2. Adding a --dependencies=path/to/deps.d to dart. dart --dependencies=path/to/deps.d path/to/some/hook/<hookname>.dart --config=path/to/config.json. This could be used for other use cases as well. (preferred)

Then we can also get rid of the weird dartBuildFiles for the CBuilder:

        final cbuilder = CBuilder.library(
          sources: [addCUri.toFilePath()],
          name: name,
          assetName: name,
          pic: pic,
          dartBuildFiles: ['hook/build.dart'],
        );

Thanks @kustermann!

@dcharkes dcharkes added P1 A high priority bug; for example, a single project is unusable or has many test failures package:native_assets_cli package:native_toolchain_c package:native_assets_builder labels Jul 2, 2024
@dcharkes
Copy link
Collaborator Author

dcharkes commented Jul 8, 2024

@jensjoha can the CFE output a list of dart source files?

@jensjoha
Copy link

jensjoha commented Jul 8, 2024

The frontend_server for instance lists the keys in component.uriToSource (as in +file1\n+file2 etc). Is that what you want? (I seem to be missing some context here).

@mkustermann
Copy link
Member

We could even make flutter build and dart build:

  • Figure out transitive package dependencies
  • Find all the N hook/* scripts.
  • Compile all of them to kernel: We could do that using P parallel incremental compilers that are given the N scripts to compile
  • A compilation will emit kernel and a .d file containing dependencies
  • We do the compilations in DFS order
  • As soon as a kernel compilation has finished we can run it (assuming dependencies are ready)

Most of our tools already support emitting .d dependency files (e.g. dart --snapshot-kind=kernel --snapshot=test.dill --depfile=test.dill.d test.dart, frontend-server, dart2js, dart2wasm, ...) - because flutter already needs those dependency files to detect whether to rebuild things.

We should be really optimizing for compile times in dart build / flutter build, e.g. if the package graphs depth is 30 and all of them use hooks, saving a single second (e.g. via parallel compile of hooks to kernel) would save half a minute for a developer.

auto-submit bot pushed a commit that referenced this issue Jul 12, 2024
So we can roll to Flutter:

* #1256
auto-submit bot pushed a commit that referenced this issue Jul 12, 2024
copybara-service bot pushed a commit to dart-lang/sdk that referenced this issue Jul 12, 2024
Bug: dart-lang/native#1256
Change-Id: Ife1e77d2372b2edbeae43902a1c616d1d446dbf4
Cq-Include-Trybots: luci.dart.try:pkg-linux-release-arm64-try,pkg-linux-debug-try,pkg-linux-release-try,pkg-mac-release-arm64-try,pkg-mac-release-try,pkg-win-release-arm64-try,pkg-win-release-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/375461
Auto-Submit: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Moritz Sümmermann <mosum@google.com>
Commit-Queue: Moritz Sümmermann <mosum@google.com>
auto-submit bot pushed a commit to flutter/flutter that referenced this issue Jul 13, 2024
Roll deps to address:

* dart-lang/native#1256

Cross-linking Dart standalone CL: https://dart-review.googlesource.com/c/sdk/+/375461 (no breaking API changes)
@kustermann
Copy link

kustermann commented Jul 15, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 A high priority bug; for example, a single project is unusable or has many test failures package:native_assets_builder package:native_assets_cli package:native_toolchain_c
Projects
None yet
Development

No branches or pull requests

4 participants