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

Allow rust binaries to remove dead code #5855

Merged
merged 1 commit into from
Sep 26, 2023
Merged

Conversation

bhansconnect
Copy link
Contributor

This simple solution seems to just work, I am a bit surprised, I swear that I tried it before and hit linker issues. Anyway, if we update the basic-cli platform it drops from about 100MB to about 15MB.

Note: we may need to add a special init function to stop linker based dead code elimination. That or special linker commands to keep roc_* functions. Currently this is working on my x86 machine without it though.

Guide here if needed on the init function:
https://stackoverflow.com/questions/43712979/how-to-export-a-symbol-from-a-rust-executable

Note: we may need to add a special init function to stop linker based dead code elimination.
That or special linker commands to keep `roc_*` functions.
Currently this is working on my x86 machine without it though.

Guide here if needed on the init function:
https://stackoverflow.com/questions/43712979/how-to-export-a-symbol-from-a-rust-executable
@bhansconnect
Copy link
Contributor Author

bhansconnect commented Sep 25, 2023

Given test's pass on all platforms, this change should be safe and work across systems. There is still a small chance that a complex enough platform could hit an issue, but i think that is unlikely given the cli example platform is working on all of these systems.

Copy link
Collaborator

@Anton-4 Anton-4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent find, thanks @bhansconnect!

@bhansconnect bhansconnect merged commit b0608c3 into main Sep 26, 2023
11 checks passed
@bhansconnect bhansconnect deleted the rust-binary-size branch September 26, 2023 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants