Share your make.conf and src.conf

Yep, most of these variables just need to be defined, their contents doesn't really matter.
 
I used the following /etc/make.conf in the past:

KERNCONF=MYKERNEL
.if ${.CURDIR:M*/usr/src/*} || ${.CURDIR:M*/usr/obj/*}
CFLAGS+= -O2 -fno-strict-aliasing -pipe
CXXFLAGS+= -O2 -fno-strict-aliasing -pipe
COPTFLAGS= -O2 -fno-strict-aliasing -pipe
.endif

I am aware that the default make is set to optimize, including the optimizations above.
 
Remove them, the kernel and userland sources already contain the most optimal compiler settings. Yours are only going to interfere with that. It will not result in "better" optimizations or any other measurable improvements. You're only more likely to run into problems.
 
If/When you run into problems the first thing everybody is going to suggest is to remove /etc/make.conf and /etc/src.conf.

i agree, if your talking about "make World" (base system and or kernel, not a config of ports)

hacking security libs in from (ubuntu?) would be a virus thing to do and NOT something people with install questions should be considering in "install questions" thread (infact - i'd tell them never ever to hack those options at any time)

also: X.org is NOT X11 compatible it is an X12 (if you like i can prove that - x.org completely damages many X11 compatible softwares). if make.conf is for base or kernel builds not for ports - then X.org doesn't belong in it anywhere. X11 or X12 is not part of the "base system".

if your talking about a "make.conf" for ports then i'd say: there should be nothing in it since any port should expect and have the freedom that "there are no pre-conditions and restraints added" other than base system.
 
I have observed a few things.

Code:
MAKE_JOBS_NUMBER
seems to be ignored in my testing in ports. Some ports will use multi make's regardless of this setting which might give the impression it works, but I have noticed various ports only use one make process, and as such build very slowly, unless I add something like
Code:
MAKE_ARGS+=-j4
in the make.conf. However I observed using the make flags modifier breaks some ports even with -j1, so it isn't safe so don't use it. Instead just have to put up with some ports compiling at snail's pace due to been stuck on one compile process.

Also
Code:
OPTIONS_SET
been dead for me since the day dialog boxes were added for options, again completely ignored by ports. Unless it acts as an override (overriding what's selected in dialog box rather than affecting default selections).
 
ok that explains that then, thanks.

any thoughts on my make jobs observations?

Two example port's are 'exim' and 'percona57-server'. 'exim' actually breaks with multi make's so maybe that one is forcefully made one make process only for safety, but percona doesn't, and just uses one make process ignoring the make jobs variable.
 
ZFS has always been a module and can't be statically linked in it (don't know why, it's what I've understood from it). Everything is actually built as a module, the kernel config simply defines which modules are statically linked into it. The setting in src.conf defines whether or not you want to build the code at all.
 
In linux I could understand it as a license thing.
That's certainly not the case on FreeBSD, the CDDL is compatible enough with the BSD license.

If I recall correctly it was a technical issue but don't know the exact details. It probably has something to do with its dependency on the OpenSolaris layer.
 
Use something like ports-mgmt/poudriere or ports-mgmt/synth to build your own packages with your own options/defaults. Much easier to use.

Yeah I recently started looking into synth, I however only like to use software I have experience with and can configure how I want, so I am not quite ready to be using synth yet, but its definitely on my TODO list.

Back on to the subject at hand though, the make.conf, I am curious if this has been deliberately disabled in code, a bug or I have simply broken it with my configuration. I have managed to now get 'MAKE_ARGS' working well, and if any ports such as mail/exim which require strict ordering, then I found '.undef MAKE_ARGS' does the job. Its not the documented method but for whatever reason 'MAKE_JOBS_NUMBER' seems to now be defunct.
 
Hopefully I don't wreck it...

I wanted to move my big list from NanoBSD but it was stale. So I started over on FreeBSD 12.
This is so minimal I don't recommend it for anyone without maximum caution. Firewalls removed.
I don't use a src.conf. I am building images from a custom makefile directory, modified from /usr/src/release.
I copy my /etc/make.conf in to position after building world and kernel.
The below makefile WITHOUT_ directives were found in /usr/src/tools/build/options/
/etc/make.conf
Code:
TARGET_ARCH=amd64
TARGET_CPUTYPE=amd64
TARGET=amd64
#######  FROM FREEBSD 12.0-STABLE SOURCE r342891  ##########
WITHOUT_ACCT=
WITHOUT_AMD=
WITHOUT_APM=
WITHOUT_ASSERT_DEBUG=
WITHOUT_AT=
WITHOUT_ATM=
WITHOUT_AUDIT=
WITHOUT_AUTHPF=
WITHOUT_AUTOFS=
WITHOUT_AUTO_OBJ=
WITHOUT_BHYVE=
WITHOUT_BINUTILS=
WITHOUT_BINUTILS_BOOTSTRAP=
WITHOUT_BLACKLIST_SUPPORT=
WITHOUT_BLUETOOTH=
WITHOUT_BMAKE=
WITHOUT_BOOTPARAMD=
WITHOUT_BOOTPD=
WITHOUT_BSDINSTALL=
WITHOUT_BSD_CPIO=
WITHOUT_BSNMP=
WITHOUT_BZIP2=
WITHOUT_BZIP2_SUPPORT=
WITHOUT_CALENDAR=
WITHOUT_CCD=
WITHOUT_CDDL=
WITHOUT_CLANG=
WITHOUT_CLANG_BOOTSTRAP=
WITHOUT_CLANG_FULL=
WITHOUT_CLANG_IS_CC=
WITHOUT_CPP=
WITHOUT_CROSS_COMPILER=
WITHOUT_CTM=
WITHOUT_CUSE=
WITHOUT_CVS=
WITHOUT_CXGBETOOL=
WITHOUT_DEBUG_FILES=
WITHOUT_DIALOG=
WITHOUT_DICT=
WITHOUT_DMAGENT=
WITHOUT_DOCCOMPRESS=
WITHOUT_DYNAMICROOT=
WITHOUT_ED_CRYPTO=
WITHOUT_ELFTOOLCHAIN_BOOTSTRAP=
WITHOUT_EXAMPLES=
WITHOUT_FDT=
WITHOUT_FINGER=
WITHOUT_FLOPPY=
WITHOUT_FMTREE=
WITHOUT_FORMAT_EXTENSIONS=
WITHOUT_FORTH=
WITHOUT_FP_LIBC=
WITHOUT_FREEBSD_UPDATE=
WITHOUT_FTP=
WITHOUT_GAMES=
WITHOUT_GCC=
WITHOUT_GCC_BOOTSTRAP=
WITHOUT_GCOV=
WITHOUT_GDB=
WITHOUT_GDB_LIBEXEC=
WITHOUT_GNUCXX=
WITHOUT_GNU_DIFF=
WITHOUT_GNU_GREP_COMPAT=
WITHOUT_GPIO=
WITHOUT_GPL_DTC=
WITHOUT_HAST=
WITHOUT_HTML=
WITHOUT_HYPERV=
WITHOUT_ICONV=
WITHOUT_INCLUDES=
WITHOUT_INET6=
WITHOUT_INET6_SUPPORT=
WITHOUT_INFO=
WITHOUT_INSTALLLIB=
WITHOUT_IPFILTER=
WITHOUT_IPFW=
WITHOUT_ISCSI=
WITHOUT_JAIL=
WITHOUT_KDUMP=
WITHOUT_KERNEL_RETPOLINE=
WITHOUT_KERNEL_SYMBOLS=
WITHOUT_KVM=
WITHOUT_KVM_SUPPORT=
WITHOUT_LIB32=
WITHOUT_LIBCPLUSPLUS=
WITHOUT_LLD=
WITHOUT_LLDB=
WITHOUT_LLD_BOOTSTRAP=
WITHOUT_LLD_IS_LD=
WITHOUT_LLVM_COV=
WITHOUT_LLVM_TARGET_AARCH64=
WITHOUT_LLVM_TARGET_ALL=
WITHOUT_LLVM_TARGET_ARM=
WITHOUT_LLVM_TARGET_MIPS=
WITHOUT_LLVM_TARGET_POWERPC=
WITHOUT_LLVM_TARGET_SPARC=
WITHOUT_LLVM_TARGET_X86=
WITHOUT_LOADER_GELI=
WITHOUT_LOADER_OFW=
WITHOUT_LOADER_UBOOT=
WITHOUT_LOCALES=
WITHOUT_LOCATE=
WITHOUT_LPR=
WITHOUT_LS_COLORS=
WITHOUT_LZMA_SUPPORT=
WITHOUT_MAIL=
WITHOUT_MAILWRAPPER=
WITHOUT_MAKE=
WITHOUT_MAKE_CHECK_USE_SANDBOX=
WITHOUT_MAN=
WITHOUT_MANCOMPRESS=
WITHOUT_MAN_UTILS=
WITHOUT_MLX5TOOL=
WITHOUT_MODULE_DRM=
WITHOUT_MODULE_DRM2=
WITHOUT_NAND=
WITHOUT_NCP=
WITHOUT_NDIS=
WITHOUT_NETCAT=
WITHOUT_NETGRAPH=
WITHOUT_NETGRAPH_SUPPORT=
WITHOUT_NLS=
WITHOUT_NLS_CATALOGS=
WITHOUT_NS_CACHING=
WITHOUT_NTP=
WITHOUT_PC_SYSINSTALL=
WITHOUT_PF=
WITHOUT_PMC=
WITHOUT_PORTSNAP=
WITHOUT_PPP=
WITHOUT_PROFILE=
WITHOUT_QUOTAS=
WITHOUT_RADIUS_SUPPORT=
WITHOUT_RBOOTD=
WITHOUT_REPRODUCIBLE_BUILD=
WITHOUT_RESCUE=
WITHOUT_ROUTED=
WITHOUT_SENDMAIL=
WITHOUT_SERVICESDB=
WITHOUT_SETUID_LOGIN=
WITHOUT_SHAREDOCS=
WITHOUT_SOURCELESS=
WITHOUT_SOURCELESS_HOST=
WITHOUT_SOURCELESS_UCODE=
WITHOUT_SSP=
WITHOUT_SVNLITE=
WITHOUT_SYMVER=
WITHOUT_SYSCONS=
WITHOUT_SYSTEM_COMPILER=
WITHOUT_SYSTEM_LINKER=
WITHOUT_TALK=
WITHOUT_TCP_WRAPPERS=
WITHOUT_TELNET=
WITHOUT_TESTS=
WITHOUT_TESTS_SUPPORT=
WITHOUT_TEXTPROC=
WITHOUT_TFTP=
WITHOUT_TIMED=
WITHOUT_TOOLCHAIN=
WITHOUT_UNBOUND=
WITHOUT_UNIFIED_OBJDIR=
WITHOUT_USB_GADGET_EXAMPLES=
WITHOUT_UTMPX=
WITHOUT_VI=
WITHOUT_WARNS=
WITHOUT_WIRELESS=
WITHOUT_WIRELESS_SUPPORT=
WITHOUT_WPA_SUPPLICANT_EAPOL=
WITHOUT_ZFS=
WITHOUT_ZONEINFO=


How low can you go?? I have mine down to 205MB for starting embedded builds.
# ls -ll /usr/obj/usr/src/amd64.amd64/custom/memstick.img
-rw-r--r-- 1 root wheel 205103616 Jun 6 21:45 /usr/obj/usr/src/amd64.amd64/custom/memstick.img

This is as low as I can go with networking, sshd and dhclient available. I can install software with pkg.
How awesome is it that FreeBSD is so configurable.

Hi,Phishfry
Thanks for your share.
I'm trying to build a nano image and am very excited to see your sharing
but I try to use it for FreeBSD 12.1, it's not working it.


Code:
ld: error: unable to find library -legacy
cc: error: linker command failed with exit code 1 (use -v to see invocation)
*** Error code 1

so. I try to find and fix it.
remove the line for make.conf
WITHOUT_INSTALLLIB=

but...

Code:
/usr/src/contrib/libunwind/src/libunwind.cpp:18:10: fatal error: 'new' file not found
#include <new>
         ^~~~~
1 error generated.
*** Error code 1

Stop.
make[4]: stopped in /usr/src/lib/libgcc_eh
*** Error code 1


I don't know how to solve it, can you share the nano world configuration file that supports 12.1?
thanks.
 
Sure, I'll bite!

ghost% cat /etc/make.conf
Code:
CPUTYPE?=haswell
#CFLAGS=-O2 -pipe -fno-strict-aliasing
#COPTFLAGS=-O2 -pipe -fno-strict-aliasing
MALLOC_PRODUCTION="YES"
MAKE_JOBS_NUMBER=4

# CC
CC=/usr/local/bin/clang80
CXX=/usr/local/bin/clang++80
CPP=/usr/local/bin/clang-cpp80
#LD=/usr/local/bin/ld

# Ports stuffs
#FORCE_MAKE_JOBS=YES
DEFAULT_VERSIONS+=    ssl=libressl python=3.8 python3=3.8 perl5=5.30 llvm=8.0
DEVELOPER=YES
OPTIONS_SET+=SAFESTACK CFIHARDEN IPV6 SSL PERL TCL \
             PYTHON THREADS MANPAGES OPENSSL PCRE
OPTIONS_UNSET+=DEBUG DOCS EXAMPLES GNUTLS
WITH_CCACHE_BUILD="yes"

ghost% cat /etc/src.conf

ghost% cat /etc/src.conf
Code:
WITH_CCACHE_BUILD=
WITHOUT_AMD=
WITHOUT_ASSERT_DEBUG=
WITHOUT_CLANG=
WITHOUT_FLOPPY=
WITHOUT_FREEBSD_UPDATE=
# Need to verify Kerberos from ports before disabling crypto
#WITHOUT_CRYPT=
WITHOUT_FTP=
WITHOUT_HTML=
WITHOUT_IPFILTER=
WITHOUT_IPFW=
WITHOUT_IPX=
WITHOUT_GDB=
WITHOUT_GAMES=
WITHOUT_TESTS=
WITHOUT_DEBUG_FILES=
WITHOUT_INETD=
WITHOUT_LDNS=
WITHOUT_LLDB=
WITHOUT_LPR=
WITHOUT_NETCAT=
WITHOUT_NIS=
WITH_PIE=
WITHOUT_PPP=
WITH_RATELIMIT=
WITHOUT_PROFILE=
WITHOUT_RCS=
WITHOUT_REPRODUCIBLE_BUILD=
WITH_RETPOLINE=
WITHOUT_TALK=
WITHOUT_TELNET=
WITHOUT_LLVM_TARGET_ALL=
 
/etc/make.conf
Code:
MALLOC_PRODUCTION=yes
CPUTYPE?=haswell
MAKE_JOBS_NUMBER?=4
WITH_FAST_DEPEND=yes

.if ${.CURDIR:M*/usr/src*} || ${.CURDIR:M*/usr/obj*}
KERNCONF=LAPTOP
WITH_CCACHE_BUILD=yes
CCACHE_DIR=/var/ccache/freebsd
.endif

.if ${.CURDIR:M*/usr/ports*}
WITH_CCACHE_BUILD=yes
CCACHE_DIR=/var/ccache/ports
DEFAULT_VERSIONS+= ssl=libressl
OPTIONS_UNSET+= DEBUG PULSEAUDIO CUPS IPV6 LPR COLORD DBUS GCONF PRINT TEST TESTS VDPAU SMB XINERAMA
OPTIONS_SET+= OPTIMIZED_CFLAGS SIMD OPUS WEBP
DISABLE_VULNERABILITIES=yes
.endif

.if ${.CURDIR:M*/audio/musicpd}
OPTIONS_UNSET+= CURL
OPTIONS_SET+= FAAD
.endif

.if ${.CURDIR:M*/emulators/virtualbox-ose}
OPTIONS_UNSET+= UDPTUNNEL VNC WEBSERVICE
.endif

.if ${.CURDIR:M*/www/chromium*}
CCACHE_DIR=/var/ccache/chromium
OPTIONS_UNSET+= KERBEROS DRIVER
.endif

.if ${.CURDIR:M*/misc/mc}
OPTIONS_UNSET+= SFTP SUBSHELL X11
.endif

.if ${.CURDIR:M*/ftp/curl}
OPTIONS_UNSET+= GSSAPI_BASE COOKIES
OPTIONS_SET+= GSSAPI_NONE
.endif

/etc/src.conf
Code:
CPUTYPE?=haswell
MALLOC_PRODUCTION=yes
WITH_CCACHE_BUILD=yes
WITHOUT_ATM=
WITHOUT_BLACKLIST_SUPPORT=
WITHOUT_BLACKLIST=
WITHOUT_CALENDAR=
WITHOUT_DEBUG_FILES=
WITHOUT_FLOPPY=
WITHOUT_FTP=
WITHOUT_GAMES=
WITHOUT_GDB=
WITHOUT_GOOGLETEST=
WITHOUT_HTML=
WITHOUT_HYPERV=
WITHOUT_INET6_SUPPORT=
WITHOUT_INET6=
WITHOUT_INETD=
WITHOUT_IPFILTER=
WITHOUT_KERNEL_SYMBOLS=
WITHOUT_LDNS=
WITHOUT_LPR=
WITHOUT_NLS_CATALOGS=
WITHOUT_NLS=
WITHOUT_NTP=
WITHOUT_NVME=
#WITHOUT_PF=
WITHOUT_PPP=
WITHOUT_RADIUS_SUPPORT=
WITHOUT_RCMDS=
WITHOUT_RCS=
WITHOUT_RESCUE=
WITHOUT_SENDMAIL=
WITHOUT_SHAREDOCS=
WITHOUT_TALK=
WITHOUT_TELNET=
WITHOUT_TESTS_SUPPORT=
WITHOUT_TESTS=
WITHOUT_TFTP=
WITHOUT_TIMED=
WITHOUT_UNBOUND=
WITH_PIE=
WITH_RETPOLINE=
WITHOUT_LLVM_TARGET_ALL=
WITH_LLVM_TARGET_X86=
WITHOUT_CLANG_FULL=
WITH_RATELIMIT=

/etc/src-env.conf
Code:
WITH_META_MODE=yes
 
I was curious what others have found useful with /etc/make.conf. This seems more like an opinion post than trouble-shooting, so I figured Off-Topic was the right place. Lately I've been using this:
Code:
CPUTYPE?=native
CFLAGS=-O3 -pipe -fno-strict-aliasing -fstack-protector-all -Wstack-protector --param ssp-buffer-size=4 -fPIC -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security 
COPTFLAGS=-O3 -pipe -funroll-loops -ffast-math -fno-strict-aliasing -fstack-protector-all -Wstack-protector --param ssp-buffer-size=4 -fPIC -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security 
KERNCONF=BSD GENERIC
OPTIMIZED_CFLAGS=YES
WITHOUT_X11=YES
BUILD_OPTIMIZED=YES
WITH_CPUFLAGS=YES
WITH_OPTIMIZED_CFLAGS=YES
WITHOUT_DEBUG=YES
BUILD_STATIC=YES
NO_PROFILE=YES
NO_INET6=YES
I know some will say never go above -O2 with CFLAGS, and others say -O3 is fine and to only worry about anything higher. I've rebuilt all ports with the above and the only package failures I experienced breakage with were not related to this make.conf. I'm open to any criticism or suggestions though. What have you found useful?
 
Remove those CFLAGS and COPTFLAGS. The system already picks the most optimal settings, setting them by hand interferes with that.
 
Every single time I see funroll-loops :D

The system already picks the most optimal settings
Depends on what you call "optimal" – it picks sane settings known to build without issues and of course using sane compiler optimizations.

The main thing is, adding all kinds of "funny" (pun intended) flags typically doesn't give even measurable speed improvement. Speed bottlenecks are I/O, of course the kernel (FreeBSD 13 improved a lot here), bad handling of locks with threads, and so on. In the rare cases when processing speed on the CPU is really relevant (e.g. with multimedia/ffmpeg), upstream already uses (well-tested) compiler flags for useful optimizations, or even offers part of the code in assembler.

So, if you really think you have to optimize anything here, the only knob you should ever use is CPUTYPE. The benefit of it is questionable as well, but it will be safe. Of course, the drawback is that your binaries won't run on any other machine…
 
It would be nice that experienced users shared their make.conf and src.conf to help new users like me :)
I know that there are man pages and I read both of them, but real user's configurations are IMHO also helpful!
On my experimental desktop machine I have only one line in /etc/make.conf

MINITUBE_GOOGLE_API_KEY=<secret_google_api_key>

That is for building multimedia/minitube
 
it picks sane settings known to build without issues and of course using sane compiler optimizations.
I'm calling those the most optimal. It's rather pointless to tweak the compiler settings to such an extend you get really small and/or fast code only to have it become utterly unstable or not even run. In my opinion the best settings are already picked by the port maintainer and/or upstream. There's nothing to gain by mucking with those unless you know what you're doing. Most people, including myself, have no idea what most of those compiler settings actually do. So, after 20 years of building FreeBSD and hundreds, if not thousands of ports, I found it's best to leave them alone.
 
Back
Top