problem building linux client: binary code is 20x bigger than before

Message boards : BOINC client : problem building linux client: binary code is 20x bigger than before
Message board moderation

To post messages, you must log in.

AuthorMessage
Profile Joseph Stateson
Volunteer tester
Avatar

Send message
Joined: 27 Jun 08
Posts: 641
United States
Message 93599 - Posted: 9 Nov 2019, 14:13:19 UTC
Last modified: 9 Nov 2019, 15:00:26 UTC

I am not an expert on gcc compilers

I have two previous build of the linux boinc client and both builds were small:
jstateson@jyslinux1:~/Downloads/boinc-master/client$ ls -l boinc
-rwxrwxr-x 2 jstateson jstateson 1517832 Nov  1 01:22 boinc
jstateson@jyslinux1:~/Downloads/boinc-master/client$


I decided to use a better system and did a new install of git and the client
I followed the same procedure as here except that package gm4 was not found.

Used https://boinc.berkeley.edu/trac/wiki/SourceCodeGit to get the master.

unaccountably, the final executable was 20x bigger. I assume it is full of debugging stuff? Why is it that big? I want it reduced down to the smaller size but do not know enough about gcc or the make files to do that
jstateson@jysdualxeon:~/boinc$ cd client
jstateson@jysdualxeon:~/boinc/client$ ls -l boinc
-rwxr-xr-x 2 root root 20075752 Nov  9 08:00 boinc


The program runs ok but is way to big. Must have the proverbial kitchen sink in it.

[edit] using the old makefiles did not help. I copied the 4 "Makefile" from the other Linux system and "touched" version.h but still ended up with a huge executable
ID: 93599 · Report as offensive
Profile Joseph Stateson
Volunteer tester
Avatar

Send message
Joined: 27 Jun 08
Posts: 641
United States
Message 93601 - Posted: 9 Nov 2019, 17:40:14 UTC

It is big because it has debug stuff. I grep for "--strip-debug" but it was there so I am at a loss to why all the debug stuff was in the executable. my older project from 2 months ago was obtained the same way and has no debug stuff

stateson@jysdualxeon:~/boinc/client$ file boinc
boinc: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/l, for GNU/Linux 3.2.0, BuildID[sha1]=753642cbdfe8381bf86e41d736eece30774dd318, with debug_info, not stripped


so how do I strip the debug from it?
ID: 93601 · Report as offensive
Profile Keith Myers
Volunteer tester
Help desk expert
Avatar

Send message
Joined: 17 Nov 16
Posts: 866
United States
Message 93606 - Posted: 10 Nov 2019, 2:00:55 UTC
Last modified: 10 Nov 2019, 2:16:47 UTC

Depends on the compiler. The modern compilers default to pie mode now. The older compilers defaulted to --no-pie so the executables were a lot smaller. When you run with the current defaults you end up with a application/x-sharedlib binary. When you use the --no-pie compiler flag you get the older application/x-executable binary. You also see that the different binaries get different icons. The x-executable gets the traditional diamond Linux icon and the new sharedlib one gets the document icon. I run my configure with this line:

./configure CXX='g++ -no-pie' --disable-server --disable-manager


keith@Serenity:~/Desktop/BOINC$ file boinc
boinc: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/l, for GNU/Linux 3.2.0, BuildID[sha1]=27829cfe32bab24811b220470a22b5b9ee2b9ea9, with debug_info, not stripped


Best would be to use compiler flags to not use the debug symbols in the first place but you can strip the symbols out afterwards with the strip command.

strip --strip-debug boinc


keith@Serenity:~/Desktop/BOINC$ ls -l boinc
-rwxr-xr-x 1 keith keith 1186392 Nov  9 18:13 boinc
ID: 93606 · Report as offensive
Profile Keith Myers
Volunteer tester
Help desk expert
Avatar

Send message
Joined: 17 Nov 16
Posts: 866
United States
Message 93608 - Posted: 10 Nov 2019, 2:25:12 UTC - in response to Message 93601.  
Last modified: 10 Nov 2019, 2:35:30 UTC

It is big because it has debug stuff. I grep for "--strip-debug" but it was there so I am at a loss to why all the debug stuff was in the executable. my older project from 2 months ago was obtained the same way and has no debug stuff

stateson@jysdualxeon:~/boinc/client$ file boinc
boinc: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/l, for GNU/Linux 3.2.0, BuildID[sha1]=753642cbdfe8381bf86e41d736eece30774dd318, with debug_info, not stripped


so how do I strip the debug from it?

Oh, sorry I see you what you are saying now. You mean you see the --strip-debug in the CXX flags in the makefile and yet the symbols still get included.

[Edit] Look for the CXX configure line for the -g option
Most programs and libraries are, by default, compiled with debugging symbols included (with gcc's -g option)
ID: 93608 · Report as offensive
Profile Joseph Stateson
Volunteer tester
Avatar

Send message
Joined: 27 Jun 08
Posts: 641
United States
Message 93610 - Posted: 10 Nov 2019, 2:51:09 UTC - in response to Message 93606.  


./configure CXX='g++ -no-pie' --disable-server --disable-manager


Best would be to use compiler flags to not use the debug symbols in the first place but you can strip the symbols out afterwards with the strip command.


the above flags had no effect on size
jstateson@jysdualxeon:~/boinc/client$ ls -l boinc
-rwxr-xr-x 2 root root 20073976 Nov  9 20:41 boinc



strip --strip-debug boinc



this worked!
jstateson@jysdualxeon:~/boinc/client$ sudo strip --strip-debug boinc
jstateson@jysdualxeon:~/boinc/client$ ls -l boinc
-rwxr-xr-x 2 root root 1187568 Nov  9 20:44 boinc
jstateson@jysdualxeon:~/boinc/client$


the grep I did only got a hits at
config.status:old_striplib='strip --strip-debug'
configure:  test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
libtool:old_striplib="strip --strip-debug"

and all 3 of those "hits" showed up in the old dev system and the new one. Also I don't know the significance of those "hits" FWIW.
ID: 93610 · Report as offensive
Profile Keith Myers
Volunteer tester
Help desk expert
Avatar

Send message
Joined: 17 Nov 16
Posts: 866
United States
Message 93611 - Posted: 10 Nov 2019, 3:40:21 UTC - in response to Message 93610.  


./configure CXX='g++ -no-pie' --disable-server --disable-manager


Best would be to use compiler flags to not use the debug symbols in the first place but you can strip the symbols out afterwards with the strip command.


the above flags had no effect on size
jstateson@jysdualxeon:~/boinc/client$ ls -l boinc
-rwxr-xr-x 2 root root 20073976 Nov  9 20:41 boinc



strip --strip-debug boinc



this worked!
jstateson@jysdualxeon:~/boinc/client$ sudo strip --strip-debug boinc
jstateson@jysdualxeon:~/boinc/client$ ls -l boinc
-rwxr-xr-x 2 root root 1187568 Nov  9 20:44 boinc
jstateson@jysdualxeon:~/boinc/client$


the grep I did only got a hits at
config.status:old_striplib='strip --strip-debug'
configure:  test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
libtool:old_striplib="strip --strip-debug"

and all 3 of those "hits" showed up in the old dev system and the new one. Also I don't know the significance of those "hits" FWIW.



Yes, I realized after posting you weren't concerned about the ELF binary type, just the size. The binary type was a pet peeve of my developer friend that did not like the sharedlib binary because of the icon. I figured out the compiler flag to get the executable binary type for him.

It all depends on if the linker defaults to pulling in the debug symbol library. The compilers all default to having debug symbols because it is a pain to debug a binary without them if you need to it seems. Been reading up on the topic this afternoon. Seems like an easy fix to reduce the size down after the fact with the strip command. I'm not really concerned about the size, have plenty of both storage and memory. Would and could be a different story on my SBC computers. Need to see if the size is large with debug in the binary on those systems since they have limited memory and storage.

Would like to test whether the stripped binary is any faster than one with debug symbols. On the client it probably doesn't matter much or even with the manager. I bet it has a much bigger effect on the science apps. I'm most interested in that.
ID: 93611 · Report as offensive
Profile Keith Myers
Volunteer tester
Help desk expert
Avatar

Send message
Joined: 17 Nov 16
Posts: 866
United States
Message 93616 - Posted: 10 Nov 2019, 16:14:57 UTC

Maybe you could try the -Wl --strip-all configure parameters the next time you compile your client.
https://software.intel.com/en-us/cpp-compiler-developer-guide-and-reference-strip-symbols-from-your-binaries
ID: 93616 · Report as offensive
Profile Joseph Stateson
Volunteer tester
Avatar

Send message
Joined: 27 Jun 08
Posts: 641
United States
Message 93622 - Posted: 10 Nov 2019, 20:24:07 UTC
Last modified: 10 Nov 2019, 20:46:54 UTC

Made some progress tracking down why debug was enabled

the " -g " is controlled by

ac_cv_prog_cc_g

if = yes then debug is on
if = no then off

that variable iis in the script "configure" which is created by _autosetup

In one folder "boinc" if I run autosetup I get that flag set to "yes" and get debug stuff "-g -O2"

in another folder "boinc-master" if I run autosetup I get that flag set to 'no" and all I get is -O3

using diff there is no difference between the two _autosetup
nor the two Makefile.in
nor the two Makefile.am
nor the two Makefile.incl
there is a difference between the final "Makefile" as the -g O2 is in one and the -O3 is in the other but that is expected due to that flag being set to "yes"

One folder came from going to GitHub and a download of a zip
the other folder came from
git clone https://github.com/BOINC/boinc boinc

Maybe that is how the difference came about, maybe not.
Not going to pursue this any further. as that strip command you suggested works fine
Going to "smashin crab" for late lunch as I have given up on smashing this bug.
ID: 93622 · Report as offensive

Message boards : BOINC client : problem building linux client: binary code is 20x bigger than before

Copyright © 2024 University of California.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.