LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux From Scratch
User Name
Password
Linux From Scratch This Forum is for the discussion of LFS.
LFS is a project that provides you with the steps necessary to build your own custom Linux system.

Notices


Reply
  Search this Thread
Old 12-08-2015, 02:33 PM   #1
lfslfs
LQ Newbie
 
Registered: Dec 2015
Posts: 28

Rep: Reputation: Disabled
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!

Last edited by lfslfs; 12-09-2015 at 12:29 PM.
 
Old 12-08-2015, 08:50 PM   #2
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Void, Linux From Scratch, Slackware64
Posts: 3,150

Rep: Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856
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.
 
Old 12-09-2015, 03:39 AM   #3
lfslfs
LQ Newbie
 
Registered: Dec 2015
Posts: 28

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Keith Hedger View Post
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?
 
Old 12-09-2015, 04:48 AM   #4
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Void, Linux From Scratch, Slackware64
Posts: 3,150

Rep: Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856
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.
 
Old 12-09-2015, 12:29 PM   #5
lfslfs
LQ Newbie
 
Registered: Dec 2015
Posts: 28

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Keith Hedger View Post
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!
 
Old 12-15-2015, 08:29 AM   #6
ReaperX7
LQ Guru
 
Registered: Jul 2011
Location: California
Distribution: Slackware64-15.0 Multilib
Posts: 6,558
Blog Entries: 15

Rep: Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097
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.
 
Old 12-15-2015, 04:09 PM   #7
Krejzi
Member
 
Registered: Jan 2015
Posts: 215

Rep: Reputation: Disabled
I agree with ReaperX7. In some cases, using -O3 can break compilation (rare, but happens) and even slow down some programs.
 
Old 12-15-2015, 04:28 PM   #8
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Void, Linux From Scratch, Slackware64
Posts: 3,150

Rep: Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856
-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.
 
Old 12-15-2015, 05:55 PM   #9
Krejzi
Member
 
Registered: Jan 2015
Posts: 215

Rep: Reputation: Disabled
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.
 
Old 12-15-2015, 08:36 PM   #10
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Void, Linux From Scratch, Slackware64
Posts: 3,150

Rep: Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856
Quote:
Originally Posted by Krejzi View Post
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.
 
Old 12-16-2015, 06:13 AM   #11
Krejzi
Member
 
Registered: Jan 2015
Posts: 215

Rep: Reputation: Disabled
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
 
1 members found this post helpful.
Old 12-16-2015, 11:35 AM   #12
kcirick
Member
 
Registered: Dec 2006
Distribution: Slackware 14.1; LFS 7.9-Systemd; Debian Jessie
Posts: 169

Rep: Reputation: 55
Quote:
Originally Posted by Krejzi View Post
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?
 
Old 12-19-2015, 05:21 PM   #13
ReaperX7
LQ Guru
 
Registered: Jul 2011
Location: California
Distribution: Slackware64-15.0 Multilib
Posts: 6,558
Blog Entries: 15

Rep: Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] The build is prepared but confused about the next steps to build the LFS system CBM200 Linux From Scratch 3 02-04-2014 10:47 AM
Packages required for an absolute minimum working Linux system? tubb Linux - Newbie 12 01-25-2012 01:26 PM
RHEL 5 basic build and a Build for Oracle 10g r2 bhoros Linux - Server 2 06-19-2008 03:09 PM
Build RPM packages in chrooted system yapp SUSE / openSUSE 3 10-24-2005 08:51 PM
Absolute Newbie - Help with Some Basic Functions Ingla Linux - Newbie 7 10-18-2005 02:07 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux From Scratch

All times are GMT -5. The time now is 05:30 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration