LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux From Scratch (https://www.linuxquestions.org/questions/linux-from-scratch-13/)
-   -   absolute necessary packages to build a basic system? (https://www.linuxquestions.org/questions/linux-from-scratch-13/absolute-necessary-packages-to-build-a-basic-system-4175560991/)

lfslfs 12-08-2015 02:33 PM

absolute necessary packages to build a basic system?
 
hey guys. I followed the lfs book and made my own lfs distro and image. But the system all together is about 900 MB, which is bigger than I thought. I actually found some image from internet that is about 500 MB big and works all fine, it even got things like apt and dpkg.

I went through the list again, can't really judge by now which are the necessary packages. I mean, I probably will remove man-db and bison. But others I'm just not sure.

it would be awesome if you guys can share about the which packages I can throw out. Thanks!

Keith Hedger 12-08-2015 08:50 PM

Unless you have specifically set the make flags when building your basic system you should be able to save quite a bit of space by changing from the default -g -O2 to -O3, removing the -g will not include debug symbols and -O3 adds a bit more optimizion, also don't forget to strip the binarys, but frankly do you need to save a couple of hundred megs? in this day and age of 1T+drive saving such a amall amount seems futile, even if you plan to put your system on a usb stick you are probably stll looking at having a least a couple of gigs.

lfslfs 12-09-2015 03:39 AM

Quote:

Originally Posted by Keith Hedger (Post 5461695)
Unless you have specifically set the make flags when building your basic system you should be able to save quite a bit of space by changing from the default -g -O2 to -O3, removing the -g will not include debug symbols and -O3 adds a bit more optimizion, also don't forget to strip the binarys, but frankly do you need to save a couple of hundred megs? in this day and age of 1T+drive saving such a amall amount seems futile, even if you plan to put your system on a usb stick you are probably stll looking at having a least a couple of gigs.

hey Keith, thanks for the reply. I'm building it on a embedded system so every MB counts. I know busybox could be a better option but I am not sure how hard is it to compile gcc on it. So I thought it's better just try to shrink the lfs system at first...
and the binaries? can you indicate where are they or how it should be done? you mean the chapter 5.35 and 6.71?

Keith Hedger 12-09-2015 04:48 AM

All the stuff from chapter 5 is in the tools folder when you have built your real system you should have removed the tools folder, the bianary's are all the stuff in /bin, /usr/bin, /lib and /usr/lib.

Fair enough if you are building on an embedded system, I wouldn't bother stripping etc the tool chain or changing the build flags as you are going to get rid of it but for instance when building 'less' in chapter 6 without chanchanging the make flags you get this ( exerpt from stat )
Code:

File: '/media/SkyNet/LFSSourceArchives-7.8/SYSTEM/less-458/less-458/less'
  Size: 515368            Blocks: 1016      IO Block: 4096  regular file ...

If when you configure it you add use
Code:

CFLAGS="-O3" ./configure
And then build you get
Code:

File: '/media/SkyNet/LFSSourceArchives-7.8/SYSTEM/less-458/less-458/less'
  Size: 215880            Blocks: 432        IO Block: 4096  regular file ...

As you can see the second version without the -g flag and with -O3 instead of the default -O2 results in a file thats less than half the size of the original, if you then use
Code:

strip --strip-unneeded ./less
the final size comes to
Code:

File: '/media/SkyNet/LFSSourceArchives-7.8/SYSTEM/less-458/less-458/less'
  Size: 183680            Blocks: 368        IO Block: 4096  regular file ...

Sizes will vary slightly depending on your system, there are other problems with such agresize optimization/stripping ie debugging would be a nightmare.

lfslfs 12-09-2015 12:29 PM

Quote:

Originally Posted by Keith Hedger (Post 5461815)
All the stuff from chapter 5 is in the tools folder when you have built your real system you should have removed the tools folder, the bianary's are all the stuff in /bin, /usr/bin, /lib and /usr/lib.

Fair enough if you are building on an embedded system, I wouldn't bother stripping etc the tool chain or changing the build flags as you are going to get rid of it but for instance when building 'less' in chapter 6 without chanchanging the make flags you get this ( exerpt from stat )
Code:

File: '/media/SkyNet/LFSSourceArchives-7.8/SYSTEM/less-458/less-458/less'
  Size: 515368            Blocks: 1016      IO Block: 4096  regular file ...

If when you configure it you add use
Code:

CFLAGS="-O3" ./configure
And then build you get
Code:

File: '/media/SkyNet/LFSSourceArchives-7.8/SYSTEM/less-458/less-458/less'
  Size: 215880            Blocks: 432        IO Block: 4096  regular file ...

As you can see the second version without the -g flag and with -O3 instead of the default -O2 results in a file thats less than half the size of the original, if you then use
Code:

strip --strip-unneeded ./less
the final size comes to
Code:

File: '/media/SkyNet/LFSSourceArchives-7.8/SYSTEM/less-458/less-458/less'
  Size: 183680            Blocks: 368        IO Block: 4096  regular file ...

Sizes will vary slightly depending on your system, there are other problems with such agresize optimization/stripping ie debugging would be a nightmare.

thanks for the reply! that indeed was very helpful!

ReaperX7 12-15-2015 08:29 AM

I will be forward on this, but be careful with optimization -O3. A lot of packages will work well with it, but the safest bet is -O2 so you don't break anything.

Krejzi 12-15-2015 04:09 PM

I agree with ReaperX7. In some cases, using -O3 can break compilation (rare, but happens) and even slow down some programs.

Keith Hedger 12-15-2015 04:28 PM

-O3 optimization should never break compilation of code and I have never seen this, it can in certain cases make the code less efficient if the code is self modifying and what would usually be run in the cpu cache needs to be constantly refreshed because of that modifacation, it's a case of suck it and see but the OP is concerned with sueezing every last byte out of OS so it is a possible saving, the OP would have to decide if the savings outway the possible code slowdown.

Krejzi 12-15-2015 05:55 PM

I've seen build failures on few packages that use -Werror and certain warning flags. -O3 would trigger a warning on such packages and -Werror would cause gcc to fail.

As for the size, there's also -Os flag (optimize for size), which should provide fair optimization, while reducing overall size.

Keith Hedger 12-15-2015 08:36 PM

Quote:

Originally Posted by Krejzi (Post 5464803)
I've seen build failures on few packages that use -Werror and certain warning flags. -O3 would trigger a warning on such packages and -Werror would cause gcc to fail.

As for the size, there's also -Os flag (optimize for size), which should provide fair optimization, while reducing overall size.

What packages? what flags?

Never seen -Os I'll look it up.

Krejzi 12-16-2015 06:13 AM

I think it may have been mutter (GNOME's compositor). I just turned off warning flags by passing --enable-warnings=minimum or something like that to configure, so I don't know which flag caused it.

See here for explanation of gcc optimization flags https://gcc.gnu.org/onlinedocs/gcc/O...e-Options.html

-Ofast looks interesting, especially since I saw https://openbenchmarking.org/result/...GA-GCCOPTIMI95

kcirick 12-16-2015 11:35 AM

Quote:

Originally Posted by Krejzi (Post 5465016)
I think it may have been mutter (GNOME's compositor). I just turned off warning flags by passing --enable-warnings=minimum or something like that to configure, so I don't know which flag caused it.

See here for explanation of gcc optimization flags https://gcc.gnu.org/onlinedocs/gcc/O...e-Options.html

-Ofast looks interesting, especially since I saw https://openbenchmarking.org/result/...GA-GCCOPTIMI95

:thumbup: for the references. I saw it once and couldn't remember where I saw it.

Anyway, for embedded systems and small/old laptops, -Os maybe the best option, which seems to be -O2 minus flags that would increase the size. Unless if the performance outweighs the size, in which case one would opt for -O3.

Also, I wonder if these options are used for building small distros like tinycore?

ReaperX7 12-19-2015 05:21 PM

In the past when I ran Gentoo at times, using optimization level -O3 often resulted in broken package builds which caused me numerous reinstalls, so I have sense stuck to -O2 unless recommended or utilized in the makefiles by the package upstream authors. Back in kernel 2.6.xx I broke a few kernel modules for realtek hardware this way as well.

Yes, it shouldn't break things.

I once saw a makefile for an experimental build of the emulator bsnes (before it was melded into higan) with about 15~20 compile time optimizations literally that made me cringe. When I ran it with verbose output, just for shits and giggles, it spat out warnings like no tomorrow.


All times are GMT -5. The time now is 12:25 AM.