Skip to content

Commit

Permalink
Strip symbols from the Sequitur binary.
Browse files Browse the repository at this point in the history
This saves about 30 MiBs...
  • Loading branch information
Humdinger committed Oct 14, 2015
1 parent 64c20cf commit 7fce22c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion haiku-apps/sequitur/sequitur-2.1.2.recipe
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ bend MIDI data.
* Read and write standard MIDI files."
HOMEPAGE="https://github.com/HaikuArchives/Sequitur"
SOURCE_URI="git+https://github.com/HaikuArchives/Sequitur#aef233a"
REVISION="1"
REVISION="2"
LICENSE="Public Domain"
COPYRIGHT="2001 Eric Hackborn"

Expand Down Expand Up @@ -62,6 +62,9 @@ INSTALL()
mkdir -p $docDir

cd Sequitur
strip -S Sequitur
xres -o Sequitur Sequitur.rsrc SequiturSkin.rsrc

cp -a lib/libAmKernel.so $appsDir/Sequitur/lib
cp -rL add-ons $appsDir/Sequitur
cp -a Sequitur $appsDir/Sequitur
Expand Down

7 comments on commit 7fce22c

@pulkomandy
Copy link
Member

Choose a reason for hiding this comment

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

Please use defineDebugInfoPackage() and extractDebugInfo() to create a debug package instead of doing things manually.

@diversys
Copy link
Member

Choose a reason for hiding this comment

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

Also, it seems that addons and libs should be stripped as well.

@humdingerb
Copy link
Member

Choose a reason for hiding this comment

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

Please use defineDebugInfoPackage() and extractDebugInfo() to create a debug package instead of doing things manually.

I can use a defineDebugInfoPackage which results in a _debuginfo package and stripped files in the installation package. But where and how do I use extractDebugInfo to add ressources back into those files before they are packaged into the installation package? Those ressources contain icons and graphics.

Or did you mean to do the stripping with defineDebugInfoPackage and then adding the ressources again manually with xres?

@pulkomandy
Copy link
Member

Choose a reason for hiding this comment

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

Yes, I think you still need xres to re-add the resources. We should fix our strip to not remove the resources...

@humdingerb
Copy link
Member

Choose a reason for hiding this comment

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

I'm a bit mystified now. Here's the recipe: http://sprunge.us/NIFK
And here is the tail of the output when haikuportering it: http://sprunge.us/JDcd

I end up with a debug_info package, which is good. I also get an installation package that has only stripped files without ressources! If I look into the sources in the working directory, I see all files unstripped.
Now, when exactly get the files stripped? When should I xres the ressources?

@weinhold
Copy link
Contributor

Choose a reason for hiding this comment

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

The defineDebugInfoPackage shell function (defined in ShellScriptlets.py) records the paths of the files whose debug info shall be extracted. After the INSTALL function of the recipe is finished, packageDebugInfos is called which in turn calls extractDebugInfo for each recorded file path. extractDebugInfo is where the extraction of the debug info happens and where the original files are stripped afterwards.

The stripping is what also removes the resources. The back story here is the following: ELF is container file format. The file content is organized in (arbitrarily) named sections. A table at the beginning of the file lists the name, size, and in-file offset of all sections. That allows ELF tools to work with files that contain section types they don't know anything about. Unfortunately the Be Inc. devs decided not to add a new section type to store resources, but rather just append them at the end of the file. Due to that ELF tools are generally unaware of the additional data and remove them when modifying the file.

One could, as Adrien suggests, "fix" strip. But in fact one would have to "fix" every tool modifying ELF files. A cleaner solution would be to transition to a new resource format where the resources are contained in an ELF section. For the time being extractDebugInfo should be adjusted to first check whether the file has resources and, if so, save them before stripping and re-add them afterwards.

@humdingerb
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the info, Ingo.
So, currently that means I can't use defineDebugInfoPackage to strip files and create a _debuginfo package, because the stripping will occur after my INSTALL() where I could've re-added the resources.
Until extractDebugInfo is adjusted to preserve non-debug resources, would it be acceptable to use this recipe: http://sprunge.us/ZJCC and run it twice.

  1. with the defineDebugInfoPackage() uncommented and the strip/xres block under INSTALL() commented out to create the _debuginfo package.
  2. with defineDebugInfoPackage() commented out, but with the strip/xres block active to create the installation package with the stripped files.

The recipe could be marked unsupported (ARCHITECTURES="!x86_gcc2") to show it has to be manually built in the described two-step process. Otherwise the soon-to-be-opened(?) Kitchen won't build the _debuginfo package.

Please sign in to comment.