Skip to content

Instantly share code, notes, and snippets.

@maks
Created September 6, 2020 08:14
Show Gist options
  • Save maks/eb393d2ed4e19f08c460b03e1357af4d to your computer and use it in GitHub Desktop.
Save maks/eb393d2ed4e19f08c460b03e1357af4d to your computer and use it in GitHub Desktop.
getting dart2native Linux executables running on FreeBSD

I used a FreeBSD 11 VM runing on GCE

To get Linux exe's working on BSD

  • compile with dart2native, eg I used DSG from a zip of exe's built here: https://github.com/maks/dsg/actions/runs/198892581
  • sudo brandelf -t linux exe-filename
  • edit /etc/rc.conf and add: linux_enable="YES"
  • then: sudo service abi restart
  • cd /usr/ports/emulators/linux_base-c7 then make install
  • go back to where you have your dart2native linux exe and run it

For some reason the dart2native exe runs the Dart VM but doesn't run the aot snapshot thats embedded in it. eg. I see:

$ ./dsg
Usage: dart [<vm-flags>] <dart-script-file> [<script-arguments>]

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

Common VM flags:
--enable-asserts
...

I'm not sure why that's happening but I ran out of time to investigate further, but it does seem to demonstrate to me that the Linux DartVM thats generated for dart2nativeseems to be able to run on FreeBSD 11 with its Linux x64 compat layer.

@saper
Copy link

saper commented Sep 10, 2020

two questions:

  • I suppose dart2native generates a native Linux binary? Does it run?
  • What is the exact problem with the Dart VM? the ./dsg output seem to be a mere parameter problem (no script added)

@maks
Copy link
Author

maks commented Sep 11, 2020

@saper yes it is a linux binary and yes it does run, per above BUT: what it actually is is the Dart VM linux binary "bundled" with the AOT snapshot of your app's Dart code and a little bit of glue that runs that aot snapshot using the Dart VM. SO whats happening above is that for some reason that bit of glue code that is responsible for running the aot snapshot with the vm is not working, so I just see the error message from the dartvm, hence what I said about showing the Dart VM is able to run using the linux compat layer.
Of course there still maybe something about the aot snapshot that makes it incompatible with the freebsd linux compat layer, but I suspect thats not the case and there's just something about the compat layer that is tripping up that loader code.

@RandalSchwartz
Copy link

Boy, if you ever get this working, I'd be interested too. And beware, dart2native has been replaced in mostly name only with dart compile exe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment