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

openrc: remove duplicate multicall binaries, symlink instead #29

Open
wants to merge 1 commit into
base: langdale
Choose a base branch
from

Conversation

mqqc
Copy link
Contributor

@mqqc mqqc commented Apr 17, 2023

There is a bunch of binaries in OpenRC that are essentially multicall binaries, but redundantly compiled multiple times:

https://github.com/OpenRC/openrc/blob/0.45.2/src/einfo/meson.build
https://github.com/OpenRC/openrc/blob/0.45.2/src/service/meson.build
https://github.com/OpenRC/openrc/blob/0.45.2/src/mark_service/meson.build
https://github.com/OpenRC/openrc/blob/0.45.2/src/value/meson.build

By symlinking them to one 'main' multicall binary per group, we can reduce rootfs size. As the minimum ARM binary size is pretty big thanks to default 64 kiB alignment in newer binutils, this can be pretty sizable. This saved about 8MB on my test build.

@mqqc mqqc force-pushed the fix/trim-openrc-multicalls branch from 8c38b8a to 0df1c66 Compare April 17, 2023 12:48
@jsbronder
Copy link
Owner

Is this something that's been proposed upstream and rejected? It looks easy enough to patch the build itself.

diff --git a/src/einfo/meson.build b/src/einfo/meson.build
index df11d5fd..b402961c 100644
--- a/src/einfo/meson.build
+++ b/src/einfo/meson.build
@@ -1,6 +1,5 @@
 einfo_execs = [
   'einfon',
-  'einfo',
   'ewarnn',
   'ewarn',
   'eerrorn',
@@ -22,11 +21,15 @@ einfo_execs = [
   'veoutdent',
   ]
 
+executable('einfo',
+  ['einfo.c', version_h],
+  include_directories: [incdir, einfo_incdir, rc_incdir],
+  link_with: [libeinfo, librc],
+  install: true,
+  install_dir: rc_bindir)
+
 foreach exec: einfo_execs
-  executable(exec,
-    ['einfo.c', version_h],
-    include_directories: [incdir, einfo_incdir, rc_incdir],
-    link_with: [libeinfo, librc],
-    install: true,
-    install_dir: rc_bindir)
+  install_symlink(exec,
+    install_dir: rc_bindir,
+    pointing_to: 'einfo')
 endforeach

It seems fine to me, but I would rather carry these as a patchset with the Upstream-Status tag, https://www.openembedded.org/wiki/Commit_Patch_Message_Guidelines#Patch_Header_Recommendations:_Upstream-Status. If you like, I'm happy to submit to upstream on your behalf.

My preference for the patchset is that'll it'll be more likely to work over version updates. If the patches apply, we likely are getting every binary. If not, then we should be looking at the list of executables in meson regardless.

@mqqc
Copy link
Contributor Author

mqqc commented Apr 26, 2023

Sorry for not getting back to you earlier, I got caught up in a few other things.

That's fine and makes sense to me, I'll adjust and submit it upstream.

jsbronder added a commit to jsbronder/openrc that referenced this pull request Nov 8, 2023
Rather then have many copies of the same executable, that differ in only
name, create a single copy and symlink all the others.  This saves a
non-negligible amount of disk space as noted here
jsbronder/meta-openrc#29
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