Skip to content
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

x/mobile: reduce size of generated artifacts #40348

Open
ToJen opened this issue Jul 22, 2020 · 3 comments
Open

x/mobile: reduce size of generated artifacts #40348

ToJen opened this issue Jul 22, 2020 · 3 comments

Comments

@ToJen
Copy link

@ToJen ToJen commented Jul 22, 2020

The size of Go builds can be shrunk with the ldflags build option like this:
go build -ldflags '-s -w' -o my_app.exe

This can be reduced further with UPX as such:
upx -o my_app_min.exe my_app.exe

More on this here.

I'm able to pass the ldflags into gomobile like this:
gomobile bind -ldflags '-s -w' -target=android github.com/my/app.

I would like to "inject" UPX somewhere in the bind process to reduce the size of my generated .aar and .framework.

A possible flow is this:

  1. Build: go build -ldflags '-s -w' -o my_app.exe
  2. Shrink: upx -o my_app_min.exe my_app.exe
  3. Pass into gomobile:gomobile bind --from-build=my_app_min.exe -target=android github.com/my/app
@toothrot
Copy link
Contributor

@toothrot toothrot commented Jul 22, 2020

/cc @hyangah

@ToJen
Copy link
Author

@ToJen ToJen commented Jul 24, 2020

@toothrot @hyangah what's a place to start the investigation. I believe many users will benefit from a smaller aar and framework. Would it make sense at all to achieve it this way?

@ToJen ToJen changed the title x/mobile: include UPX compression option between go build and bind x/mobile: reduce size of generated artifacts Aug 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.