Sdk: dart2aot doesn't list command-line options

Created on 9 May 2019  路  7Comments  路  Source: dart-lang/sdk

dart2aot --help prints:

Usage: dart2aot [options] <dart-source-file> <dart-aot-file>

Dart AOT (ahead-of-time) compile Dart source code into native machine code.

This indicates that there are options that can be passed, but it doesn't indicate what they are.

area-vm

All 7 comments

Hi Natalie,
have you found details on this?

Also, for me, while doing "dart2aot main.dart main.dart.aot" from the project directory, it shows

"C:\Program' is not recognized as an internal or external command,
operable program or batch file."

System: windows7

Thanks,
Gaurav

Here facing with the same issue, @GauravPatni

@GauravPatni @sayhicoelho I experienced this problem ('C:\Program' not recognized...) and created an issue here with my workaround until the issue is resolved officially:

37130

After some digging, the accepted options are:

  • --packages
  • --enable-asserts
  • --build-elf - Build an assembly file that is then assembled into an ELF format object
  • --tfa, --no-tfa - "Enable global type flow analysis and related transformations in AOT mode."
  • -Dfoo, -Dfoo=bar - these options are passed directly to gen_kernel
  • Any other remaining options starting with -- are passed directly to gen_snapshot.

gen_kernel = dart $DART_SDK/bin/snapshots/gen_kernel.dart.snapshot
and gen_snapshot = $DART_SDK/utils/gen_snapshot (not a Dart file, it's a standalone executable)

Hopefully this is helpful to someone. This Github issue was the first result for "dart2aot options", so maybe it will be.

Nice detective work! :male_detective: Can you tell if --tfa is enabled by default?

Thanks! And yes, it is:

   --[no-]tfa                            Enable global type flow analysis and related transformations in AOT mode.
                                          (defaults to on)

The current dart2native does print available options:

% dart2native --help
Usage: dart2native <main-dart-file> [<options>]

Generates an executable or an AOT snapshot from <main-dart-file>.

-D, --define=<key=value>            Set values of environment variables. To specify multiple variables, use multiple options or use commas to separate key-value pairs.
                                    E.g.: dart2native -Da=1,b=2 main.dart
    --enable-asserts                Enable assert statements.
-h, --help                          Display this help message.
-k, --output-kind=<aot|exe>         
          [aot]                     Generate an AOT snapshot.
          [exe] (default)           Generate a standalone executable.

-o, --output=<path>                 Set the output filename. <path> can be relative or absolute.
                                    E.g.: dart2native main.dart -o ../bin/my_app.exe
-p, --packages=<path>               Get package locations from the specified file instead of .packages. <path> can be relative or absolute.
                                    E.g.: dart2native --packages=/tmp/pkgs main.dart
-S, --save-debugging-info=<path>    Remove debugging information from the output and save it separately to the specified file. <path> can be relative or absolute.
-v, --verbose                       Show verbose output.

So I'm assuming this issue has been addressed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

55555Mohit55555 picture 55555Mohit55555  路  3Comments

DartBot picture DartBot  路  3Comments

jmesserly picture jmesserly  路  3Comments

Hixie picture Hixie  路  3Comments

DartBot picture DartBot  路  3Comments