Skip to content

Commit

Permalink
Discontinue dart2native (use dart compile)
Browse files Browse the repository at this point in the history
TEST=Existing tests updated to use dart compile

Change-Id: Ia3478069df2354a3bf057fedae0f1eea9415de95
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210241
Commit-Queue: Michael Thomsen <[email protected]>
Reviewed-by: Devon Carew <[email protected]>
Reviewed-by: Tess Strickland <[email protected]>
Reviewed-by: Ben Konyi <[email protected]>
  • Loading branch information
mit-mit authored and [email protected] committed Aug 23, 2021
1 parent 0c16583 commit 6c5fb84
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 261 deletions.
131 changes: 0 additions & 131 deletions pkg/dart2native/bin/dart2native.dart

This file was deleted.

3 changes: 0 additions & 3 deletions pkg/dart2native/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ executables:
dart2native:

dependencies:
args: ^1.4.0
front_end:
path: ../front_end
path: any

dev_dependencies:
Expand Down
9 changes: 8 additions & 1 deletion pkg/dartdev/lib/src/commands/compile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,13 @@ For example: dart compile $commandName --packages=/tmp/pkgs main.dart''')
defaultsTo: null)
..addOption('save-debugging-info', abbr: 'S', valueHelp: 'path', help: '''
Remove debugging information from the output and save it separately to the specified file.
<path> can be relative or absolute.''');
<path> can be relative or absolute.''')
..addMultiOption(
'extra-gen-snapshot-options',
help: 'Pass additional options to gen_snapshot.',
hide: true,
valueHelp: 'opt1,opt2,...',
);

addExperimentalFlags(argParser, verbose);
}
Expand Down Expand Up @@ -277,6 +283,7 @@ Remove debugging information from the output and save it separately to the speci
debugFile: argResults['save-debugging-info'],
verbose: verbose,
verbosity: argResults['verbosity'],
extraOptions: argResults['extra-gen-snapshot-options'],
);
return 0;
} catch (e) {
Expand Down
16 changes: 5 additions & 11 deletions pkg/native_stack_traces/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ translated output.

```dart
@pragma('vm:prefer-inline')
bar() => throw null;
bar() => throw Null;
@pragma('vm:never-inline')
foo() => bar();
Expand All @@ -44,24 +44,18 @@ Now we run the following commands:

```bash
# Make sure that we have the native_stack_traces package.
$ pub get native_stack_traces
$ pub global activate native_stack_traces
$ dart pub global activate native_stack_traces

# We compile the example program, removing the source location information
# from the snapshot and saving the debugging information into throws.debug.
$ dart2native -k aot -S throws.debug -o throws.aotsnapshot throws.dart
$ dart compile exe -S throws.debug throws.dart

# Run the program, saving the error output to throws.err.
$ dartaotruntime throws.aotsnapshot 2>throws.err
$ ./throws.exe 2>throws.err

# Using the saved debugging information, we can translate the stack trace
# contained in throws.err to its symbolic form.
$ pub global run native_stack_traces:decode translate -d throws.debug -i throws.err

# We can also just pipe the output of running the program directly into
# the utility.
$ dartaotruntime throws.aotsnapshot |& \
pub global run native_stack_traces:decode translate -d throws.debug
$ dart pub global run native_stack_traces:decode translate -d throws.debug -i throws.err
```

## Features and bugs
Expand Down
17 changes: 9 additions & 8 deletions pkg/vm_snapshot_analysis/test/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,15 @@ import 'dart:io';
import 'package:path/path.dart' as path;
import 'package:test/test.dart';

final dart2native = () {
final dartCompile = () {
final sdkBin = path.dirname(Platform.executable);
final dart2native =
path.join(sdkBin, Platform.isWindows ? 'dart2native.bat' : 'dart2native');
final dartCmd = path.join(sdkBin, Platform.isWindows ? 'dart.bat' : 'dart');

if (!File(dart2native).existsSync()) {
throw 'Failed to locate dart2native in the SDK';
if (!File(dartCmd).existsSync()) {
throw 'Failed to locate `dart` in the SDK';
}

return path.canonicalize(dart2native);
return path.canonicalize(dartCmd);
}();

class AotSnapshot {
Expand Down Expand Up @@ -61,6 +60,8 @@ void main(List<String> args) => input.main(args);
];

final args = [
'compile',
'exe',
'-o',
snapshot.outputBinary,
'--packages=$packages',
Expand All @@ -69,12 +70,12 @@ void main(List<String> args) => input.main(args);
];

// Compile input.dart to native and output instruction sizes.
final result = await Process.run(dart2native, args);
final result = await Process.run(dartCompile, args);

expect(result.exitCode, equals(0), reason: '''
Compilation completed with exit code ${result.exitCode}.
Command line: $dart2native ${args.join(' ')}
Command line: $dartCompile ${args.join(' ')}
stdout: ${result.stdout}
stderr: ${result.stderr}
Expand Down
Loading

0 comments on commit 6c5fb84

Please sign in to comment.