summaryrefslogtreecommitdiffstats
path: root/sys/conf
diff options
context:
space:
mode:
authorbdrewery <bdrewery@FreeBSD.org>2015-11-06 04:45:29 +0000
committerbdrewery <bdrewery@FreeBSD.org>2015-11-06 04:45:29 +0000
commita175970362c0b42ce2ec8b2de664870b0edbcacc (patch)
tree6c99cd7369f3154f392e847a99d64007e79daa8d /sys/conf
parent0731342a6997de4a6d6a58691febbcdc2ed399ce (diff)
downloadFreeBSD-src-a175970362c0b42ce2ec8b2de664870b0edbcacc.zip
FreeBSD-src-a175970362c0b42ce2ec8b2de664870b0edbcacc.tar.gz
Add a FAST_DEPEND option, off by default, which speeds up the build significantly.
This speeds up buildworld by 16% on my system and buildkernel by 35%. Rather than calling mkdep(1), which is just a wrapper around 'cc -E', use the modern -MD -MT -MF flags to gather and generate dependencies during compilation. This flag was introduced in GCC "a long time ago", in GCC 3.0, and is also supported by Clang. (It appears that ICC also supports this but I do not have access to test it). This avoids running the preprocessor *twice* for every build, in both 'make depend' and 'make all'. This is especially noticeable when using ccache since it does not cache preprocessor results from mkdep(1) / 'cc -E', but still speeds up compilation with the -MD flags. For 'make depend' a tree-walk is still done to ensure that all DPSRCS are generated when expected, and that beforedepend/afterdepend and _EXTRADEPEND are all still respected. In time this may change but for now I've been conservative. The time for a tree-walk with -j combined with SUBDIR_PARALLEL is not significant. For example, it takes about 9 seconds with -j15 to walk all of src/ for 'make depend' now on my system. A .depend file is still generated with the various rules that apply to the final target, or custom rules. Otherwise there are now per-built-object-file .depend files, such as .depend.filename.o. These are included directly by make rather than populating .depend with a loop and .depend lines, which only added overhead to the now almost-NOP 'make depend' phase. Before this I experimented with having mkdep(1) called in parallel per-file. While this improved the kernel and lib/libc 'make depend' phase, it resulted in slower build times overall. The -M flags are removed from CFLAGS when linking since they have no effect. Enabling this by default, for src or out-of-src, can be done once more testing has been done, such as a ports exp-run, and with more compilers. The system I used for testing was: WITNESS Build options: -j20 WITH_LLDB=yes WITH_DEBUG_FILES=yes WITH_FAST_DEPEND=yes DISK: ZFS 3-way mirror with very slow disks using SSD l2arc/log. The arc was fully populated with src tree files. RAM: 76GiB CPU: Intel(R) Xeon(R) CPU L5520 @2.27GHz 2 package(s) x 4 core(s) x 2 SMT threads = hw.ncpu=16 buildworld: x buildworld-before + buildworld-fastdep +-------------------------------------------------------------------------------+ |+ | |+ | |+ xx x| | |_MA___|| |A | +-------------------------------------------------------------------------------+ N Min Max Median Avg Stddev x 3 3744.13 3794.31 3752.25 3763.5633 26.935139 + 3 3153.34 3155.16 3154.2 3154.2333 0.91045776 Difference at 95.0% confidence -609.33 +/- 43.1943 -16.1902% +/- 1.1477% (Student's t, pooled s = 19.0569) buildkernel: x buildkernel-before + buildkernel-fastdep +-------------------------------------------------------------------------------+ |+ x | |++ xx| | A|| |A| | +-------------------------------------------------------------------------------+ N Min Max Median Avg Stddev x 3 571.57 573.94 571.79 572.43333 1.3094401 + 3 369.12 370.57 369.3 369.66333 0.79033748 Difference at 95.0% confidence -202.77 +/- 2.45131 -35.4225% +/- 0.428227% (Student's t, pooled s = 1.0815) Sponsored by: EMC / Isilon Storage Division MFC after: 3 weeks Relnotes: yes
Diffstat (limited to 'sys/conf')
-rw-r--r--sys/conf/kern.opts.mk1
-rw-r--r--sys/conf/kern.post.mk37
2 files changed, 29 insertions, 9 deletions
diff --git a/sys/conf/kern.opts.mk b/sys/conf/kern.opts.mk
index f94ffb7..2e77c4f 100644
--- a/sys/conf/kern.opts.mk
+++ b/sys/conf/kern.opts.mk
@@ -45,6 +45,7 @@ __DEFAULT_YES_OPTIONS = \
__DEFAULT_NO_OPTIONS = \
EISA \
+ FAST_DEPEND \
NAND \
OFED
diff --git a/sys/conf/kern.post.mk b/sys/conf/kern.post.mk
index ddf828e..bf24d17 100644
--- a/sys/conf/kern.post.mk
+++ b/sys/conf/kern.post.mk
@@ -198,18 +198,37 @@ kernel-depend: .depend
SRCS= assym.s vnode_if.h ${BEFORE_DEPEND} ${CFILES} \
${SYSTEM_CFILES} ${GEN_CFILES} ${SFILES} \
${MFILES:T:S/.m$/.h/}
+DEPENDFILES= .depend
+.if ${MK_FAST_DEPEND} == "yes"
+DEPENDFILES+= .depend.*
+DEPEND_CFLAGS+= -MD -MP -MF.depend.${.TARGET}
+DEPEND_CFLAGS+= -MT${.TARGET}
+CFLAGS+= ${DEPEND_CFLAGS}
+DEPENDOBJS+= ${SYSTEM_OBJS}
+.for __obj in ${DEPENDOBJS:O:u}
+.sinclude ".depend.${__obj}"
+DEPENDFILES_OBJS+= .depend.${__obj}
+.endfor
+.endif # ${MK_FAST_DEPEND} == "yes"
+
+.NOPATH: .depend ${DEPENDFILES_OBJS}
+
.depend: .PRECIOUS ${SRCS}
- rm -f .newdep
+.if ${MK_FAST_DEPEND} == "no"
+ rm -f ${.TARGET}.tmp
${MAKE} -V CFILES_NOCDDL -V SYSTEM_CFILES -V GEN_CFILES | \
- MKDEP_CPP="${CC} -E" CC="${CC}" xargs mkdep -a -f .newdep ${CFLAGS}
+ CC="${CC}" xargs mkdep -a -f ${.TARGET}.tmp ${CFLAGS}
${MAKE} -V CFILES_CDDL | \
- MKDEP_CPP="${CC} -E" CC="${CC}" xargs mkdep -a -f .newdep ${ZFS_CFLAGS} ${FBT_CFLAGS} ${DTRACE_CFLAGS}
+ CC="${CC}" xargs mkdep -a -f ${.TARGET}.tmp ${ZFS_CFLAGS} \
+ ${FBT_CFLAGS} ${DTRACE_CFLAGS}
${MAKE} -V SFILES_NOCDDL | \
- MKDEP_CPP="${CC} -E" xargs mkdep -a -f .newdep ${ASM_CFLAGS}
+ CC="${CC}" xargs mkdep -a -f ${.TARGET}.tmp ${ASM_CFLAGS}
${MAKE} -V SFILES_CDDL | \
- MKDEP_CPP="${CC} -E" xargs mkdep -a -f .newdep ${ZFS_ASM_CFLAGS}
- rm -f .depend
- mv .newdep .depend
+ CC="${CC}" xargs mkdep -a -f ${.TARGET}.tmp ${ZFS_ASM_CFLAGS}
+ mv ${.TARGET}.tmp ${.TARGET}
+.else
+ : > ${.TARGET}
+.endif
_ILINKS= machine
.if ${MACHINE} != ${MACHINE_CPUARCH} && ${MACHINE} != "arm64"
@@ -237,8 +256,8 @@ ${_ILINKS}:
ln -s $$path ${.TARGET}
# .depend needs include links so we remove them only together.
-kernel-cleandepend:
- rm -f .depend ${_ILINKS}
+kernel-cleandepend: .PHONY
+ rm -f ${DEPENDFILES} ${_ILINKS}
kernel-tags:
@[ -f .depend ] || { echo "you must make depend first"; exit 1; }
OpenPOWER on IntegriCloud