This updates the `Dockerfile` generated by `dart create` with the
`server-shelf` template to use `dart build cli` instead of `dart
compile exe`. The benefit of using the `build` command is that it runs
hooks and bundles code assets. These assets should also be present in
the container image.
TEST=Tested manually (create template, build image, run)
Change-Id: Ia8ccbba4ea6631ec6d5bb8866fd59ae4821375ba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/470661
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
`dart compile wasm` currently checks `--strip-wasm` and passes it along
if it's set.
This doesn't do anything because `--strip-wasm` is already the default
in dart2wasm, and `dart compile wasm` never passes `--no-strip-wasm`.
Instead of passing `--strip-wasm`, pass `--no-strip-wasm`.
To help debugging this kind of thing future, `--verbose` output is
improved:
- Print `--strip-wasm` flag value with other flag values.
- When running `wasm-opt` print the `wasm-opt` flags.
Change-Id: Iaa24836a439294badf5470446a2bb83031a79a98
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/469582
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
Fixes errors of the sort
```
mosum@mosum2:~/projects/i18n/pkgs/intl4x/example$ dart --enable-experiment=record-use build cli example.dart
There are multiple possible targets in the `bin/` directory, and the 'target' argument wasn't specified.mosum@mosum2
```
Change-Id: I7ed6dbd21838506c1fe60b6d69d6066406d3b7c7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/467842
Auto-Submit: Moritz Sümmermann <mosum@google.com>
Reviewed-by: Brian Quinlan <bquinlan@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
To help facilitate this we move all IO into a separate helper
library/class. This makes it easier to have symmetric read/write
functions and to do IO within compile.dart where necessary.
Adding the new `opt` phase allows us to remove the duplicated code
between dartdev and compile_benchmark simplifying those two files a lot.
It will also allow us to more easily invoke wasm-opt within our internal
build pipeline.
For compile_benchmark we still run the opt phase independently (but
through dart2wasm) to keep the benchmark data as consistent as possible.
Change-Id: Iaa855dbc3a05abfedbc3eea4af32e3ba27e84600
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464640
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
progress
This enables running one-off commands via `dart run <remote>` and
only having the stdout from the program.
TEST=pkg/dartdev/test/native_assets/run_remote_test.dart
Bug: https://github.com/dart-lang/sdk/issues/61996
Change-Id: Ia60bd2b3754b407686718b33b1934d8687dac8d4
Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-linux-release-arm64-try,pkg-linux-release-try,pkg-mac-release-arm64-try,pkg-mac-release-try,pkg-win-release-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464384
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Michael Goderbauer <goderbauer@google.com>
The user might want to access the assets from dev dependencies.
The Dart code might want to use dev dependencies. `dart run test`.
Closes: https://github.com/dart-lang/tools/issues/2237
Change-Id: Ib8c9b4a7f3f2dedb33777e1f29cb82fc678edd4f
Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-linux-release-arm64-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/+/462980
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Michael Goderbauer <goderbauer@google.com>
Enables "run-from-remote" with `dart run`.
```
Run a Dart program from a file, a local package, or a remote package.
Usage: dart [vm-options] run [arguments] [<dart-file>|<local-package>|<remote-executable> [args]]
<dart-file>
A path to a Dart script (e.g., `bin/main.dart`).
<local-package>
An executable from a local package dependency, in the format <package>[:<executable>].
For example, `test:test` runs the `test` executable from the `test` package.
If the executable is not specified, the package name is used.
<remote-executable>
An executable from a remote package. This can be from a hosted package server
(like pub.dev) or a git repository.
When running a remote executable, all other command-line flags are disabled,
except for the options for remote executables. `dart run <remote-executable>`
uses `dart install` under the hood and compiles the app into a standalone
executable, preventing passing VM options.
From a hosted package server:
<hosted-url>/<package>[@<version>][:<executable>]
Downloads the package from a hosted package server and runs the specified
executable.
If a version is provided, the specified version is downloaded.
If an executable is not specified, the package name is used.
For example, `https://pub.dev/dcli@1.0.0:dcli_complete` runs the
`dcli_complete` executable from version 1.0.0 of the `dcli` package.
From a git repository:
<git-url>[:<executable>]
Clones the git repository and runs the specified executable from it.
If an executable is not specified, the package name from the cloned
repository's pubspec.yaml is used.
The git url can be any valid git url.
```
Notable implementation decisions:
* Does not redownload if the pubspec.lock is identical from the last
remote run. Always does a pub resolve to see if the pubspec.lock
would be identical.
* pub urls must start with `https://`. This makes parsing with local
file paths more tractible.
* git urls may use either urls, or git ssh. (Git SSH is not tested due
to not wanting to run an ssh server locally.)
* Shares as much implementation with `dart install` as possible. The
`dart install` implementation was made public where necessary. The
`dart install` implementation was kept in place to keep the git diff
small.
* Test lives in pkg/dartdev/test/native_assets/ so that its not run
on a shard and xcode and git commands are available.
TEST=pkg/dartdev/test/native_assets/run_remote_test.dart
Closes: https://github.com/dart-lang/sdk/issues/61588
Change-Id: I6a641c670a61da309027d3f82c90f4b59e70933b
Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-linux-release-arm64-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/+/457640
Auto-Submit: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Currently `web/wasm/flute_stress_test` is failing on
`dart2wasm-linux-optimized-jsc` mode.
That mode runs with `--use-sdk` which makes it use `dart compile wasm`.
The reason the test is failing is because it passes both
`--enable-deferred-loading` and `--multi-module-stress-test` flags to
dart2wasm. This causes us to trigger the deferred module flow instead
of the specialized multi-module flow.
Those two flags should be independent.
Change-Id: I8cac976cd91d4e585f38632ada3062e41fce401f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/458800
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
The dart2wasm compiler - when used in -O2 sound mode - should guarantee
that no wasm traps happen. So we should be able to use
`--traps-never-happen` in deferred loading mode just like in normal
mode.
This saves around 1.2% in ACX Gallery
The original revert was done due to other reasons, not this CL.
Change-Id: I0c836c21cacf7a50417011aadac346f12b827a2e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/459280
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
The dar2wasm compiler - when used in -O2 sound mode - should guarantee
that no wasm traps happen. So we should be able to use
`--traps-never-happen` in deferred loading mode just like in normal
mode.
This saves around 1.2% in ACX Gallery
Change-Id: I3d214b636b0bc2e8b18c2ef8c4bf0c86b19c23c8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/458720
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
To support internal compilations, dart2wasm must be able to run in
phases. There are a few reasons for this:
1) Kernel transforms are run on the program after the CFE has run. We
must emit a dill that frameworks can transform and then pass the
transformed dill back to dart2wasm.
2) This allows us to avoid forge limits by running each phase of the
compiler in separate blaze actions. TFA has the chance of running long
on large programs and so it might be beneficial to run it as its own
action.
This implementation currently supports 3 phases: "cfe", "tfa", "codegen"
They can be run collectively or in any consecutive combination. Phases
are specified via a '--phases' multi-option. Any data that needs to be
passed between the phases is encoded directly into the serialized dill.
This also opens up the opportunity to make "opt" its own phase that
runs wasm-opt on the wasm emitted from the codegen phase.
Change-Id: Ide830763f7063c7ab880e8e54dc47bd32fd4e7cd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/455280
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
In order to test generated code for a function one can
* place a dart file in `pkg/dart2wasm/tets/ir_tests`
* annotate functions that shouldn't be inlined
* describe which functions we want to dump in the expectation file
* generate an expectation file.
This will allow generating renatively small expectation files for only
functions we care about and types/globals/... those functions need.
Change-Id: Ic7b6b6dece16ab453202aa2c4f9412de2fc251ae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/454840
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
The pub get was wrong on the wrong path, and the subsequent error was
not displayed.
Prevent the tests from not testing this scenario.
Closes: https://github.com/dart-lang/sdk/issues/61721
Change-Id: I88755251086f3d520fd97273f7703f6d85441692
Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-linux-release-arm64-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/+/454602
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Moritz Sümmermann <mosum@google.com>
Reviewed-by: Michael Goderbauer <goderbauer@google.com>
Shows a progress update on the interactive terminal for running hooks.
The progress update visually aligns with progress updates from pub
`Building package executable... (1.3s)` as
`Running build hooks... (0.7s)`.
Closes: https://github.com/dart-lang/native/issues/2439
Progress updates visibility:
* `dart run`, only if there are hooks to avoid cluttering stdout more.
https://github.com/dart-lang/sdk/issues/61696
* `dart test`, also only if there are any hooks.
* `dart build`, always show progress update lines.
* `dart install`, always show progress updates lines.
* `dart compile`, changed the check to check for the existence of hooks
but don't ever run them.
This CL also renames some "native assets" to "build hooks".
This CL also fixes an issue with `dart test` run without `pub get` in
a Flutter project.
Closes: https://github.com/dart-lang/sdk/issues/61697
Change-Id: I88f6e07dff1d4f5c0733f83f073640b75cc54e79
Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-linux-release-arm64-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/+/453920
Reviewed-by: Michael Goderbauer <goderbauer@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
When running on a cloudtop, for example, the tmp space may be part of a
different filesystem than the user space where the package is being
registered. In this case a simple rename doesn't work, we have to copy
the files and delete the old one.
The script was also getting confused when a previous install failed. The
partial setup was leading to errors while trying to uninstall the old
verison.
Change-Id: I67f04547bc5279adc5f0d9f528cc9224c1f54e64
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/452000
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Make it available on the stable branch.
Fix the version numbers for when it was enabled. (3.9 as experiment
enabled is not entirely correct, as the experiment was not available
on the stable channel in 3.9, only on betas of 3.9.)
And disable passing data assets under the same experiment flag.
Note: It seems that it was accidentally still marked as 3.9 and then
got swept up in https://dart-review.googlesource.com/c/sdk/+/443803.
TEST=dartdev native assets tests
Bug: https://github.com/dart-lang/sdk/issues/50565
Change-Id: I4c44ad22e32673d6a951017d0cf6d3374dd20429
Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-linux-release-arm64-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/+/449803
Reviewed-by: Ivan Inozemtsev <iinozemtsev@google.com>
Reviewed-by: Michael Goderbauer <goderbauer@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
This CL adds three new commands to `dart`:
```
Global
install Install a Dart CLI tool for global use.
installed List globally installed Dart CLI tools.
uninstall Remove a globally installed Dart CLI tool.
```
These commands are intended to replace `dart pub global` subcommands
while adding support for `hook/build.dart` and building packages in
AOT instead of running them with JIT.
Internal design doc: http://go/dart-install-cli.
Implementation details:
* The source of truth is the state of the file system. These commands
write and read directories, files, and symlinks.
* App bundles and symlinks are placed in `DART_DATA_HOME` as per
http://go/dart-data-home.
* On Unix systems we use symlinks and on Windows batchfiles to place
executables in the bin directory that point to an application
bundle. (These OS differences have been encapsulated in a single
class.)
* On Windows, when an application is running, trying to re-install it
will fail.
Test coverage:
* Installing from hosted, git, and local paths.
* Installing a package with hooks.
* Installing a package with hooks and user-defines.
* Surfacing build hook failures during install.
* Installing packages with conflicting executables names. This tests
`--overwrite` flag behavior.
* Installing a new or the same version, this should simply succeed.
* A warning is shown if the bin directory is not on the `PATH`.
* Running an installed app reports the correct exit code on exit.
* Listing all installed versions, including the versions not on
the`PATH`.
* Uninstalling, which uninstalls all versions.
* Re-installing while it is running.
* Uninstalling while it is running.
Out of scope for initial version:
* Saving the SDK version (to display in `dart installed`).
* Short-circuiting if re-installing an exactly installed version.
Bug: https://github.com/dart-lang/sdk/issues/60889
Change-Id: I8f3a60d26e013957ce6fd7f52e564bcaaff30509
Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-linux-release-arm64-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/+/441581
Reviewed-by: Sigurd Meldgaard <sigurdm@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Michael Goderbauer <goderbauer@google.com>
This allows `dart compile` to be used from the build root without a
fully built SDK.
Abstract out executable and dill retrieval in Sdk getters similar to how
snapshot retrieval was abstracted out.
Remove the hostDartAotRuntime parameter to generateKernelHelper, since
all callers always passed the same variable from generate.dart, and
instead retrieve it using Sdk.dartAotRuntime.
Remove all the top-level variables that contained paths in
dart2native.dart and generate.dart and replace their uses with
the appropriate Sdk getter.
TEST=ci
Cq-Include-Trybots: luci.dart.try:pkg-linux-release-arm64-try,pkg-linux-release-try,pkg-mac-release-arm64-try,pkg-mac-release-try,pkg-win-release-arm64-try,pkg-win-release-try,dart-sdk-linux-riscv64-try,dart-sdk-linux-arm64-try,dart-sdk-linux-try,dart-sdk-mac-try,dart-sdk-win-arm64-try,dart-sdk-win-try,dart-sdk-mac-arm64-try
Change-Id: I92d8110faff135263a9fdf1c395759a52dab914b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/442181
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Leave a stub in its place that re-exports package:dart2native/sdk.dart
and an implementation of checkArtifactExists, which used to be part of
the Sdk class, to limit the amount of changes needed.
This move is made so that followup CLs can use the Sdk class from
dart2native without causing a cyclic dependency.
TEST=ci
Cq-Include-Trybots: luci.dart.try:pkg-linux-release-arm64-try,pkg-linux-release-try,pkg-mac-release-arm64-try,pkg-mac-release-try,pkg-win-release-arm64-try,pkg-win-release-try,dart-sdk-linux-riscv64-try,dart-sdk-linux-arm64-try,dart-sdk-linux-try,dart-sdk-mac-try,dart-sdk-win-arm64-try,dart-sdk-win-try,dart-sdk-mac-arm64-try
Change-Id: I492084031efce1e6747f93f2067249425fe9b922
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/442220
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
... and not just any flag starting with "protocol".
I believe the original code used `startsWith()` to try and catch both `--protocol` as its own flag, and `--protocol=` when combined with the value. However, it also caught `--protocol-traffic-log`. `wasParsed()` should handle both of the first cases without the latter.
I also unskipped the tests for Windows because the skip was added in 44cee12ebe (Jan 2021) because the `deleteDirectory()` call failed on Windows (file locking) but f40b06a8ac (Jan 2022) already fixed that.
Fixes https://github.com/dart-lang/sdk/issues/52501
Change-Id: I931a3f12dca2683167e999e7fe59bed18159eb73
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/441780
Auto-Submit: Danny Tuppeny <danny@tuppeny.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Since current cross compilation tests are flaky due to being dependent
on the uploaded artifacts, separate them out into a separate file that
can be approved without hiding other failures in the compile test suite
until they can be more properly fixed.
Do some cleanup and refactoring to abstract out the common parts of the
cross compilation failure tests as well.
TEST=pkg/dartdev
Issue: https://github.com/dart-lang/sdk/issues/61181
Change-Id: I1bee602f6d19ebd175bd27f6aded7a1909d1944f
Cq-Include-Trybots: luci.dart.try:pkg-linux-release-arm64-try,pkg-linux-release-try,pkg-mac-release-arm64-try,pkg-mac-release-try,pkg-win-release-arm64-try,pkg-win-release-try,dart-sdk-linux-riscv64-try,dart-sdk-linux-arm64-try,dart-sdk-linux-try,dart-sdk-mac-try,dart-sdk-win-arm64-try,dart-sdk-win-try,dart-sdk-mac-arm64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/442060
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
The #ifdef block that would stop ARM cross-compilation on Windows
has been outdated for a few years now, as getting the target CPU features via TargetCPUFeatures is now handled appropriately on Windows.
TEST=ci, actual test depends on upload so will be in a followup CL
Issue: https://github.com/dart-lang/sdk/issues/28617
Change-Id: I9907145ec8fb97007769276cb3c6c2442ac9e17c
Cq-Include-Trybots: luci.dart.try:pkg-linux-release-arm64-try,pkg-linux-release-try,pkg-mac-release-arm64-try,pkg-mac-release-try,pkg-win-release-arm64-try,pkg-win-release-try,dart-sdk-linux-riscv64-try,dart-sdk-linux-arm64-try,dart-sdk-linux-try,dart-sdk-mac-try,dart-sdk-win-arm64-try,dart-sdk-win-try,dart-sdk-mac-arm64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/440224
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Ivan Inozemtsev <iinozemtsev@google.com>
- split the Dart CLI tool out of the VM into it's own embedder which
runs in AOT mode. The pure Dart VM executable is called 'dartvm' and
has no Dart CLI functionality in it
- the Dart CLI executable parses the CLI commands and invokes the rest
of the AOT tools in the same process, for the 'run' and 'test'
commands it execs a process which runs 'dartvm' to run
- 'dart hello.dart' execs the 'dartvm' process and runs 'hello.dart'
- the Dart CLI is not generated for ia32 as we are not shipping a
Dart SDK for ia32 anymore (support to execute the 'dartvm' for ia32
architecture is retained)
- the Dart CLI tool is not built in the internal Dart SDK builds
TEST=ci
Some performance improvement numbers
'dart format pkg/dartdev' goes from 1.17 secs to 0.22 secs
'dart doc pkg/dartdev' goes from 100.2 secs to 66.6 secs
'dart fix pkg/dartdev' goes from 19.3 secs to 14.5 secs
Change-Id: I66984a26cb2ab014b34dc1873f1f3d2884e13518
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/364202
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
This new flag will run the CFE to create a kernel and then run a series of checks over the resulting kernel to look for errors that could block a wasm migration.
The compiler will then exit before actually starting the wasm compilation process. This means no output file will be emitted so callers must be aware of this.
This first CL is not meant to cover every check we could add here. It adds some initial checks and we can expand on this to include more in follow-up changes.
One of the checks implemented here is also provided by a lint. While ideally we would share code between lints and these checks, the delta in the CFE vs analyzer model makes that infeasible today.
Sample output:
```
Found incompatibilities with WebAssembly.
package:dryrun/test.dart 5:15 - Cannot test a JS value against String (3)
package:dryrun/test.dart 6:7 - JS interop class 'B' cannot extend Dart class 'A'. (2)
```
Bug: https://github.com/dart-lang/sdk/issues/60050
Change-Id: Ib2c8e3501cc42d57b86ebaa749359ce6c5dba974
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/437960
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>