Skip to content

AOT compiled apps fail when run on Apple Silicon #44001

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

Closed
mit-mit opened this issue Oct 30, 2020 · 5 comments
Closed

AOT compiled apps fail when run on Apple Silicon #44001

mit-mit opened this issue Oct 30, 2020 · 5 comments
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.

Comments

@mit-mit
Copy link
Member

mit-mit commented Oct 30, 2020

The following steps fail when run on Apple Silicon with an "File offset must be page-aligned."-error:

$ dart create testapp
$ cd testapp
$ dart compile exe ./bin/main.dart
$ ./bin/main.dart

=>

Loading failed: File offset must be page-aligned.
Usage: dart [<vm-flags>] <dart-script-file> [<script-arguments>]

Executes the Dart script <dart-script-file> with the given list of <script-arguments>.

@devoncarew devoncarew added the area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. label Oct 30, 2020
@mkustermann
Copy link
Member

/cc @a-siva You might be the only one with one of those devices I assume. Could you take a look?

@rmacnak-google
Copy link
Contributor

This message comes from the VM's implementation of an ELF loader. ELF is generated with the assumption of 4kB pages, but Apple chose a different page size for ARM Macs. The ELF loader should not be running on a Mac, and the application should have generated Mach-O and be using the system Mach-O loader. This is a bug in dart create, not the VM.

@rmacnak-google rmacnak-google removed the area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. label Oct 30, 2020
@mkustermann
Copy link
Member

mkustermann commented Oct 31, 2020

@rmacnak-google We introduced the ELF loader when we needed BSS support in AOT snapshots and decided against adding BSS support to the old blobs format - so instead we made the ELF loader, supporting only the limited subset our ELF writer produces.

For AOT we can rely on assembler atm, but let's say we want our AppJIT snapshots to also have a BSS section in them, we would probably want to use the same ELF writer + ELF loader mechanism, possibly on all platforms.

So if it's not too much effort we might want to adjust ELF writer + ELF loader to support MacOS.

@devoncarew
Copy link
Member

Re-triaging to area-vm, which is I believe that best place to track this bug.

@devoncarew devoncarew added the area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. label Nov 2, 2020
@a-siva
Copy link
Contributor

a-siva commented Jun 11, 2021

Tried the above commands indicated in the description and it works

> bin/dart create testapp            
  ╔════════════════════════════════════════════════════════════════════════════╗
  ║ The Dart tool uses Google Analytics to anonymously report feature usage    ║
  ║ statistics and to send basic crash reports. This data is used to help      ║
  ║ improve the Dart platform and tools over time.                             ║
  ║                                                                            ║
  ║ To disable reporting of anonymous analytics, run:                          ║
  ║                                                                            ║
  ║   dart --disable-analytics                                                 ║
  ║                                                                            ║
  ╚════════════════════════════════════════════════════════════════════════════╝

Creating /Users/dartuser/dart-sdk/testapp using template console-simple...

  .gitignore
  CHANGELOG.md
  README.md
  analysis_options.yaml
  bin/testapp.dart
  pubspec.yaml

Running pub get...                     2.0s
  Resolving dependencies...
  Downloading pedantic 1.11.0...
  Changed 1 dependency!

Created project testapp! In order to get started, type:

> cd testapp

> dart compile exe ./bin/testapp.dart
Info: Compiling without sound null safety
Generated: /Users/dartuser/dart-sdk/testapp/bin/testapp.exe

> ./bin/testapp.exe 
Hello world!

@a-siva a-siva closed this as completed Jun 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.
Projects
None yet
Development

No branches or pull requests

5 participants