make.conf optimizations

I like to run a minimal desktop on my aging hardware, so I've been reading up on /etc/make.conf optimizations / options / knobs, and would like to know if I have the right options.

Specifically, I want to use knobs to avoid applications pulling in unnecessary dependencies, programs, etc, thus causing slow compilation / updates, while maintaining stability. I'm not very interested in mucking around with optimizations because, as I understand it, they are more trouble than they are worth.

Crudely speaking, I use the base system + x11/xorg-minimal + x11-drivers/xf86-video-intel + x11-wm/spectrwm + editors/vim and a few other terminal-based applications.

So, I want to avoid QT, GTK, CUPS, any GUIs, etc. I want to "force" use of LPD and force programs like editors/vim to build without the GUI without breaking programs like graphics/mupdf.

So here is my /etc/make.conf:
Code:
#/etc/make.conf

#Optimizations
CPUTYPE?=pentium4

###################
# DON'T USE THESE #
###################
#CFLAGS=-O2 -pipe -fno-strict-aliasing
#COPTFLAGS=-O2 -pipe -funroll-loops -ffast-math -fno-strict-aliasing
#OPTIMIZED_CFLAGS=YES
#BUILD_OPTIMIZED=YES
#WITH_CPUFLAGS=YES
#WITH_OPTIMIZED_CFLAGS=YES
#WITHOUT_DEBUG=YES
#BUILD_STATIC=YES
#NO_PROFILE=YES
#NO_INET6=YES

#Knobs
WITHOUT_CUPS=YES
WITH_LPR=YES
WITHOUT_X11=YES

## added by use.perl 2012-10-30 18:17:06
PERL_VERSION=5.12.4

*** EDIT
Just found a list of knobs: http://svn.freebsd.org/ports/head/KNOBS?view=markup

So I'm assuming it would be safe to add the following to my /etc/make.conf:
Code:
WITHOUT_QT=YES
WITHOUT_QT4=YES
WITHOUT_GTK=YES
WITHOUT_GTK1=YES
WITHOUT_GTK2=YES
WITHOUT_KDE=YES
WITHOUT_KDE4=YES
WITHOUT_GUI=YES
 
You might as a test add
Code:
.if !empty(.CURDIR:M/usr/ports/*) 
CFLAGS+=-Os
.endif
Especially if it's a celeron, but in either case netburst's cache is smaller than later chips. By making the binaries smaller, you gain more optimization than -O3 might provide, since more or all of the binary might make it into the cache.

Granted, it's definitely a YMMV type optimization, so you would want to comment that out and recompile any port that gives you trouble before assuming the port is broken. It may also increase compile times slightly due to the added work of optimizing the build. It would also be worth doing some profiling of how it affected critical apps. In most cases, should be faster than no -O at all, but CFLAGS can hurt as much as help sometimes.

Still it's something I'd try if I was really trying to squeak as much performance out of an older X86 box as possible, or an embedded system etc.
 
Don't muck about with CFLAGS. You're more likely to do harm than good. For the most part everything already uses their most "optimal" compiler flags.
 
This will become even more important when clang(1) becomes the default compiler. CLANG has fewer optimization levels than gcc(1) and their semantics are different. Don't do global overrides for any compiler flags in make.conf(5).
 
I propose to create sticky thread that explains to users that they shouldn't override CFLAGS and CXXFLAGS and others....
 
I did mention it's not always useful above.

The make.conf as shown in /usr/share/example/etc/make.conf does indeed show an example overriding with -O2, for what it's worth.

I would recommend not saying "never ever", but rather you are on your own and it's not supported. There are indeed cases where a compiler is not aware of a processor feature due to its age, or because a compiler feature is desired but not by all users of FreeBSD.

If we're talking about leaving a system as stable, compatible, or portable as possible, don't touch cflags.
 
Just to be clear, I wasn't planning on using the CFLAGS or CXXFLAGS, I am more interested in the KNOBS [As I reminded myself in the comments in my /etc/make.conf.

Are global KNOBS equally problematic?

I realise editors/vim is a bad exmaple, as editors/vim-lite exists, but there are a number of other programs I have compiled without any GUI, such as multimedia/vlc. So my questions, still, remain:

Are global KNOBS like "WITHOUT_X11=YES" equally as problematic / dangerous as global CFLAGS? Is it possible for a flag like this to break a command-line X program, such as multimedia/vlc, graphics/feh etc?
 
nickednamed said:
Are global KNOBS like "WITHOUT_X11=YES" equally as problematic / dangerous as global CFLAGS?

No, not at all. For one thing, they will only affect ports that care about them, not the entire system. For another, ports have been written to expect them, as opposed to make-it-go-fast CFLAGS settings that have almost certainly not been tested.

Is it possible for a flag like this to break a command-line X program, such as multimedia/vlc, graphics/feh etc?

No. Ports are built to expect these standard options. If a port requires X11 to be installed on the system, it will not build if WITHOUT_X11 is set. A lot of X ports will build without X, because it's valid to run them from an xterm on another system.

(Can this fail sometimes? Sure. But not, it's not like CFLAGS.)
 
Back
Top