sajmons / CollimationCircles

Collimation Circles is application for precise telescope collimation
https://www.saimons-astronomy.com/software/collimation-circles
GNU Lesser General Public License v3.0
40 stars 2 forks source link

[LINUX] strip breaks the binary #7

Closed MattBlack85 closed 1 year ago

MattBlack85 commented 1 year ago

Hi @sajmons

I found a weird issue which I am not sure where it originates from since I am a .NET sheep.

So, everything works correctly if I run the commands you gave me and the app starts, but when packaging for Arch the package got broken.

The error:

❯ /usr/bin/CollimationCircles
Failure processing application bundle; possible file corruption.
Arithmetic overflow while reading bundle.
A fatal error occurred while processing application bundle

After some investigations I found out that stripping symbols completely breaks the executable.

strip is generally used to remove unneeded symbols from libs/bins and it helps making also the program smaller (122MB not stripped VS 21MB stripped)

do you know if there is a way to strip safely an executable generated with the .NET sdk?

in the meanwhile I will skip stripping for the ArchLinux package

to replicate:

sajmons commented 1 year ago

I guess that .NET eqvivalent of strip would be trim.

You can read about it here: https://ivanderevianko.com/2020/09/make-apps-small-again-trimming-net-5

But as my knowledge currently only trimmode CopyUsed working with AvaloniaUI. See comment in CollimationCircles.csproj file:

More here:

You can try with trimmode CopyUsed but it's not guaranted to work either. You can further limit trimming with adding tags in csproj file as described here: https://ivanderevianko.com/2020/09/make-apps-small-again-trimming-net-5.

In future versions I will try to publish trimmed application. Will addit to TODO list.

Hope that that helps.

sajmons commented 1 year ago

Hmm, I guess dotnet trim si not strip eqvivalent: acording to https://github.com/dotnet/runtime/issues/37334

Maybe we should merge multiple files in single executable before strip. This can be done with ILMerge.exe or ILRepack. But I guess both are only available on windows.

I think it's not worth the effort.

sajmons commented 1 year ago

Good news Mattia! I have revisited my publish workflow and discovered nice option for C# project file true. Enabling this option drastically reduces final executable file size. From 113MB to 51MB. I think this is all I can do. I think Linux strip command can not be used with dotnet apps. I have removed debug PDB files too. See this in action in next version.

sajmons commented 1 year ago

Im using this command now for publishing:

dotnet publish -c Release -f net7.0 -r linux-arm64 -o d:/Projekti/Publish/linux-arm64 --self-contained true /p:PublishSingleFile=true /p:PublishReadyToRun=true /p:DebugType=None /p:DebugSymbols=false

MattBlack85 commented 1 year ago

@sajmons thanks! I will update my build script ASAP :rocket:

sajmons commented 1 year ago

@MattBlack85 I have just released new version 2.1.0

MattBlack85 commented 1 year ago

yup, already compiling and packaging for archlinux :)

sajmons commented 1 year ago

Great! Thank you very much!