Skip to content

dart2native: strip option #38731

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
ghost opened this issue Oct 6, 2019 · 8 comments
Closed

dart2native: strip option #38731

ghost opened this issue Oct 6, 2019 · 8 comments
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.

Comments

@ghost
Copy link

ghost commented Oct 6, 2019

Now that dart2native can create a single file, it would be nice if a way was
available for Dart to strip the created files. Currently I am using something
like this:

dart2native one.dart
strip one

I noticed that dartaotruntime itself has already been stripped, as its the
same size as a "hello world" example after you strip it yourself.

@ghost
Copy link
Author

ghost commented Oct 6, 2019

Hm, actually, it looks like stripping destroys the program:

$ cat one.dart
main() {
   var bye = 'Hello world!';
   print("$bye");
}

$ ./dart2native.bat one.dart
Generated: d:\desktop\dartsdk-windows-x64-release\dart-sdk\bin\one.exe

$ ./one.exe
Hello world!

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

@cachapa
Copy link

cachapa commented Oct 6, 2019

I had a similar issue even without stripping, maybe it's related:

$ dart2native main.dart -o fireutil
Generated: /home/cachapa/fireutil/bin/fireutil

$ ./fireutil 
Utility to manage Firestore databases.
[...]

$ sudo mv fireutil /usr/local/bin
$ fireutil 
Usage: dart [<vm-flags>] <dart-script-file> [<script-arguments>]
[...]

@ghost
Copy link
Author

ghost commented Oct 6, 2019

To be fair, it fails with Go too:

$ cat one.go
package main
func main() {
   println("hello world")
}

$ go build one.go
$ ./one.exe
hello world

$ strip one.exe
$ ./one.exe
sh: ./one.exe: cannot execute binary file: Exec format error

but it doesnt matter as Go has a strip option:

$ go build -ldflags -s one.go
$ ./one.exe
hello world

and it does work with D:

$ cat one.d
import std.stdio;
void main() {
   writeln("hello world");
}

$ dmd one.d
$ ./one.exe
hello world

$ strip one.exe
$ ./one.exe
hello world

and works with Nim:

$ cat one.nim
echo "hello world"

$ nim c --gcc.exe:x86_64-w64-mingw32-gcc \
> --gcc.linkerexe:x86_64-w64-mingw32-gcc one.nim
$ ./one.exe
hello world

$ strip one.exe
$ ./one.exe
hello world

@vsmenon vsmenon added the area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. label Oct 7, 2019
@berkant
Copy link

berkant commented Oct 7, 2019

@cup Can you confirm if UPX works with dart2native?

@ghost
Copy link
Author

ghost commented Oct 7, 2019

@0xbkt this issue is about strip, not UPX

https://wikipedia.org/wiki/Strip_(Unix)

@mraleph
Copy link
Member

mraleph commented Oct 8, 2019

strip is not going to do anything useful to the binary that dart2native produced so we have no plans to support it right now.

@mraleph mraleph closed this as completed Oct 8, 2019
@jamesderlin
Copy link
Contributor

strip is not going to do anything useful to the binary that dart2native produced so we have no plans to support it right now.

Currently running strip not only is not useful, it's detrimental.

Is there anything we can do to at least make strip not break the generated binary?

@mraleph
Copy link
Member

mraleph commented Nov 6, 2019

@jamesderlin not with the current approach - the generated binary is essentially AOT runtime and an AOT snapshot simply concatenated together. strip just throws AOT snapshot away because it is not a real section.

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