1994-08-04 21:09:27 +00:00
|
|
|
# from: @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91
|
1999-08-28 00:22:10 +00:00
|
|
|
# $FreeBSD$
|
1994-05-30 19:09:18 +00:00
|
|
|
|
2002-04-17 13:49:29 +00:00
|
|
|
.include <bsd.init.mk>
|
2014-05-07 18:15:02 +00:00
|
|
|
.include <bsd.compiler.mk>
|
2019-08-15 12:48:17 +00:00
|
|
|
.include <bsd.linker.mk>
|
1994-05-30 19:09:18 +00:00
|
|
|
|
2016-11-01 21:27:42 +00:00
|
|
|
.SUFFIXES: .out .o .bc .c .cc .cpp .cxx .C .m .y .l .ll .ln .s .S .asm
|
1994-05-30 19:09:18 +00:00
|
|
|
|
2004-08-13 14:30:26 +00:00
|
|
|
# XXX The use of COPTS in modern makefiles is discouraged.
|
2003-08-31 15:20:17 +00:00
|
|
|
.if defined(COPTS)
|
2016-04-01 23:31:57 +00:00
|
|
|
.warning ${.CURDIR}: COPTS should be CFLAGS.
|
2003-08-31 15:20:17 +00:00
|
|
|
CFLAGS+=${COPTS}
|
|
|
|
.endif
|
|
|
|
|
2006-09-11 05:35:57 +00:00
|
|
|
.if ${MK_ASSERT_DEBUG} == "no"
|
|
|
|
CFLAGS+= -DNDEBUG
|
2021-01-06 17:55:06 +00:00
|
|
|
# XXX: shouldn't we ensure that !asserts marks potentially unused variables as
|
|
|
|
# __unused instead of disabling -Werror globally?
|
|
|
|
MK_WERROR= no
|
2006-09-11 05:35:57 +00:00
|
|
|
.endif
|
|
|
|
|
2003-08-31 15:20:17 +00:00
|
|
|
.if defined(DEBUG_FLAGS)
|
|
|
|
CFLAGS+=${DEBUG_FLAGS}
|
2010-02-18 03:32:51 +00:00
|
|
|
CXXFLAGS+=${DEBUG_FLAGS}
|
2008-05-22 01:14:43 +00:00
|
|
|
|
2011-11-30 18:11:49 +00:00
|
|
|
.if ${MK_CTF} != "no" && ${DEBUG_FLAGS:M-g} != ""
|
2008-05-22 01:14:43 +00:00
|
|
|
CTFFLAGS+= -g
|
|
|
|
.endif
|
2003-08-31 15:20:17 +00:00
|
|
|
.endif
|
|
|
|
|
2013-06-07 21:40:02 +00:00
|
|
|
.if defined(PROG_CXX)
|
|
|
|
PROG= ${PROG_CXX}
|
|
|
|
.endif
|
|
|
|
|
2014-09-02 19:05:34 +00:00
|
|
|
.if !empty(LDFLAGS:M-Wl,*--oformat,*) || !empty(LDFLAGS:M-static)
|
2013-06-07 21:40:02 +00:00
|
|
|
MK_DEBUG_FILES= no
|
|
|
|
.endif
|
|
|
|
|
2018-11-06 15:52:49 +00:00
|
|
|
# ELF hardening knobs
|
|
|
|
.if ${MK_BIND_NOW} != "no"
|
|
|
|
LDFLAGS+= -Wl,-znow
|
|
|
|
.endif
|
2020-06-02 00:46:15 +00:00
|
|
|
.if ${MK_PIE} != "no"
|
|
|
|
# Static PIE is not yet supported/tested.
|
|
|
|
.if !defined(NO_SHARED) || ${NO_SHARED:tl} == "no"
|
2019-02-15 22:22:38 +00:00
|
|
|
CFLAGS+= -fPIE
|
|
|
|
CXXFLAGS+= -fPIE
|
|
|
|
LDFLAGS+= -pie
|
|
|
|
.endif
|
2020-06-02 00:46:15 +00:00
|
|
|
.endif
|
2018-10-21 00:27:59 +00:00
|
|
|
.if ${MK_RETPOLINE} != "no"
|
2019-08-15 12:48:17 +00:00
|
|
|
.if ${COMPILER_FEATURES:Mretpoline} && ${LINKER_FEATURES:Mretpoline}
|
2018-10-21 00:27:59 +00:00
|
|
|
CFLAGS+= -mretpoline
|
|
|
|
CXXFLAGS+= -mretpoline
|
2018-11-19 20:48:47 +00:00
|
|
|
# retpolineplt is broken with static linking (PR 233336)
|
2019-02-15 22:48:50 +00:00
|
|
|
.if !defined(NO_SHARED) || ${NO_SHARED:tl} == "no"
|
2018-10-21 00:27:59 +00:00
|
|
|
LDFLAGS+= -Wl,-zretpolineplt
|
|
|
|
.endif
|
2019-08-15 12:48:17 +00:00
|
|
|
.else
|
|
|
|
.warning Retpoline requested but not supported by compiler or linker
|
|
|
|
.endif
|
2018-11-19 20:48:47 +00:00
|
|
|
.endif
|
2018-10-21 00:27:59 +00:00
|
|
|
|
2020-11-10 19:15:13 +00:00
|
|
|
# Initialize stack variables on function entry
|
|
|
|
.if ${MK_INIT_ALL_ZERO} == "yes"
|
|
|
|
.if ${COMPILER_FEATURES:Minit-all}
|
|
|
|
CFLAGS+= -ftrivial-auto-var-init=zero \
|
|
|
|
-enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
|
|
|
|
CXXFLAGS+= -ftrivial-auto-var-init=zero \
|
|
|
|
-enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
|
|
|
|
.else
|
|
|
|
.warning InitAll (zeros) requested but not support by compiler
|
|
|
|
.endif
|
|
|
|
.elif ${MK_INIT_ALL_PATTERN} == "yes"
|
|
|
|
.if ${COMPILER_FEATURES:Minit-all}
|
|
|
|
CFLAGS+= -ftrivial-auto-var-init=pattern
|
|
|
|
CXXFLAGS+= -ftrivial-auto-var-init=pattern
|
|
|
|
.else
|
|
|
|
.warning InitAll (pattern) requested but not support by compiler
|
|
|
|
.endif
|
|
|
|
.endif
|
|
|
|
|
2020-01-08 17:49:34 +00:00
|
|
|
.if ${MACHINE_CPUARCH} == "riscv" && ${LINKER_FEATURES:Mriscv-relaxations} == ""
|
|
|
|
CFLAGS += -mno-relax
|
|
|
|
.endif
|
|
|
|
|
2003-08-31 15:20:17 +00:00
|
|
|
.if defined(CRUNCH_CFLAGS)
|
2003-06-29 18:16:26 +00:00
|
|
|
CFLAGS+=${CRUNCH_CFLAGS}
|
2013-06-07 21:40:02 +00:00
|
|
|
.else
|
|
|
|
.if ${MK_DEBUG_FILES} != "no" && empty(DEBUG_FLAGS:M-g) && \
|
|
|
|
empty(DEBUG_FLAGS:M-gdwarf-*)
|
2017-08-23 23:30:25 +00:00
|
|
|
CFLAGS+= ${DEBUG_FILES_CFLAGS}
|
2013-06-07 21:40:02 +00:00
|
|
|
CTFFLAGS+= -g
|
|
|
|
.endif
|
2003-08-31 15:20:17 +00:00
|
|
|
.endif
|
1994-05-30 19:09:18 +00:00
|
|
|
|
1994-09-16 14:30:25 +00:00
|
|
|
.if !defined(DEBUG_FLAGS)
|
1994-05-30 19:09:18 +00:00
|
|
|
STRIP?= -s
|
1994-09-16 14:30:25 +00:00
|
|
|
.endif
|
1994-05-30 19:09:18 +00:00
|
|
|
|
2015-02-13 00:16:05 +00:00
|
|
|
.if defined(NO_ROOT)
|
|
|
|
.if !defined(TAGS) || ! ${TAGS:Mpackage=*}
|
2019-09-05 14:15:47 +00:00
|
|
|
TAGS+= package=${PACKAGE:Uutilities}
|
2015-02-13 00:16:05 +00:00
|
|
|
.endif
|
|
|
|
TAG_ARGS= -T ${TAGS:[*]:S/ /,/g}
|
|
|
|
.endif
|
|
|
|
|
2019-02-15 23:41:54 +00:00
|
|
|
.if defined(NO_SHARED) && ${NO_SHARED:tl} != "no"
|
1994-08-04 21:09:27 +00:00
|
|
|
LDFLAGS+= -static
|
|
|
|
.endif
|
1994-05-30 19:09:18 +00:00
|
|
|
|
2019-10-02 17:18:18 +00:00
|
|
|
# clang currently defaults to dynamic TLS for mips64 binaries
|
|
|
|
.if ${MACHINE_ARCH:Mmips64*} && ${COMPILER_TYPE} == "clang"
|
|
|
|
CFLAGS+= -ftls-model=initial-exec
|
|
|
|
.endif
|
|
|
|
|
2013-06-07 21:40:02 +00:00
|
|
|
.if ${MK_DEBUG_FILES} != "no"
|
|
|
|
PROG_FULL=${PROG}.full
|
|
|
|
# Use ${DEBUGDIR} for base system debug files, else .debug subdirectory
|
|
|
|
.if defined(BINDIR) && (\
|
|
|
|
${BINDIR} == "/bin" ||\
|
2015-10-14 19:19:44 +00:00
|
|
|
${BINDIR:C%/libexec(/.*)?%/libexec%} == "/libexec" ||\
|
2013-06-07 21:40:02 +00:00
|
|
|
${BINDIR} == "/sbin" ||\
|
2016-06-24 18:45:16 +00:00
|
|
|
${BINDIR:C%/usr/(bin|bsdinstall|libexec|lpr|sendmail|sm.bin|sbin|tests)(/.*)?%/usr/bin%} == "/usr/bin" ||\
|
|
|
|
${BINDIR} == "/usr/lib" \
|
2013-06-07 21:40:02 +00:00
|
|
|
)
|
|
|
|
DEBUGFILEDIR= ${DEBUGDIR}${BINDIR}
|
|
|
|
.else
|
|
|
|
DEBUGFILEDIR?= ${BINDIR}/.debug
|
2016-03-03 18:08:58 +00:00
|
|
|
.endif
|
|
|
|
.if !exists(${DESTDIR}${DEBUGFILEDIR})
|
2013-06-07 21:40:02 +00:00
|
|
|
DEBUGMKDIR=
|
|
|
|
.endif
|
|
|
|
.else
|
|
|
|
PROG_FULL= ${PROG}
|
2002-04-11 10:44:30 +00:00
|
|
|
.endif
|
|
|
|
|
1994-05-30 19:09:18 +00:00
|
|
|
.if defined(PROG)
|
2013-03-26 20:32:46 +00:00
|
|
|
PROGNAME?= ${PROG}
|
2013-06-07 21:40:02 +00:00
|
|
|
|
1994-05-30 19:09:18 +00:00
|
|
|
.if defined(SRCS)
|
|
|
|
|
2017-09-16 05:42:27 +00:00
|
|
|
OBJS+= ${SRCS:N*.h:${OBJS_SRCS_FILTER:ts:}:S/$/.o/g}
|
1994-08-04 21:09:27 +00:00
|
|
|
|
2017-10-18 00:33:20 +00:00
|
|
|
# LLVM bitcode / textual IR representations of the program
|
|
|
|
BCOBJS+=${SRCS:N*.[hsS]:N*.asm:${OBJS_SRCS_FILTER:ts:}:S/$/.bco/g}
|
|
|
|
LLOBJS+=${SRCS:N*.[hsS]:N*.asm:${OBJS_SRCS_FILTER:ts:}:S/$/.llo/g}
|
|
|
|
|
2010-09-10 16:21:09 +00:00
|
|
|
.if target(beforelinking)
|
2012-12-31 21:54:43 +00:00
|
|
|
beforelinking: ${OBJS}
|
2013-06-07 21:40:02 +00:00
|
|
|
${PROG_FULL}: beforelinking
|
2010-09-10 16:21:09 +00:00
|
|
|
.endif
|
2016-06-03 19:25:36 +00:00
|
|
|
${PROG_FULL}: ${OBJS}
|
2002-04-12 16:25:13 +00:00
|
|
|
.if defined(PROG_CXX)
|
Add built-in ccache build support via WITH_CCACHE_BUILD option.
ccache is mostly beneficial for frequent builds where -DNO_CLEAN is not
used to achieve a safe pseudo-incremental build. This is explained in
more detail upstream [1] [2]. It incurs about a 20%-28% hit to populate the
cache, but with a full cache saves 30-50% in build times. When combined with
the WITH_FAST_DEPEND feature it saves up to 65% since ccache does cache the
resulting dependency file, which it does not do when using mkdep(1)/'CC
-E'. Stats are provided at the end of this message.
This removes the need to modify /etc/make.conf with the CC:= and CXX:=
lines which conflicted with external compiler support [3] (causing the
bootstrap compiler to not be built which lead to obscure failures [4]),
incorrectly invoked ccache in various stages, required CCACHE_CPP2 to avoid
Clang errors with parenthesis, and did not work with META_MODE.
The option name was picked to match the existing option in ports. This
feature is available for both in-src and out-of-src builds that use
/usr/share/mk.
Linking, assembly compiles, and pre-processing avoid using ccache since it is
only overhead. ccache does nothing special in these modes, although there is
no harm in calling it for them.
CCACHE_COMPILERCHECK is set to 'content' when using the in-tree bootstrap
compiler to hash the content of the compiler binary to determine if it
should be a cache miss. For external compilers the 'mtime' option is used
as it is more efficient and likely to be correct. Future work may optimize the
'content' check using the same checks as whether a bootstrap compiler is needed
to be built.
The CCACHE_CPP2 pessimization is currently default in our devel/ccache
port due to Clang requiring it. Clang's -Wparentheses-equality,
-Wtautological-compare, and -Wself-assign warnings do not mix well with
compiling already-pre-processed code that may have expanded macros that
trigger the warnings. GCC has so far not had this issue so it is allowed to
disable the CCACHE_CPP2 default in our port.
Sharing a cache between multiple checkouts, or systems, is explained in
the ccache manual. Sharing a cache over NFS would likely not be worth
it, but syncing cache directories between systems may be useful for an
organization. There is also a memcached backend available [5]. Due to using
an object directory outside of the source directory though you will need to
ensure that both are in the same prefix and all users use the same layout. A
possible working layout is as follows:
Source: /some/prefix/src1
Source: /some/prefix/src2
Source: /some/prefix/src3
Objdir: /some/prefix/obj
Environment: CCACHE_BASEDIR='${SRCTOP:H}' MAKEOBJDIRPREFIX='${SRCTOP:H}/obj'
This will use src*/../obj as the MAKEOBJDIRPREFIX and tells ccache to replace
all absolute paths to be relative. Using something like this is required due
to -I and -o flags containing both SRC and OBJDIR absolute paths that ccache
adds into its hash for the object without CCACHE_BASEDIR.
distcc can be hooked into by setting CCACHE_PREFIX=/usr/local/bin/distcc.
I have not personally tested this and assume it will not mix well with
using the bootstrap compiler.
The cache from buildworld can be reused in a subdir by first running
'make buildenv' (from r290424).
Note that the cache is currently different depending on whether -j is
used or not due to ccache enabling -fdiagnostics-color automatically if
stderr is a TTY, which bmake only does if not using -j.
The system I used for testing was:
WITNESS
Build options: -j20 WITH_LLDB=yes WITH_DEBUG_FILES=yes WITH_CCACHE_BUILD=yes
DISK: ZFS 3-way mirror with very slow disks using SSD l2arc/log.
The arc was fully populated with src tree files and ccache objects.
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
The WITH_FAST_DEPEND feature was used for comparison here as well to show
the dramatic time savings with a full cache.
buildworld:
x buildworld-before
+ buildworld-ccache-empty
* buildworld-ccache-full
% buildworld-ccache-full-fastdep
# buildworld-fastdep
+-------------------------------------------------------------------------------+
|% * # +|
|% * # +|
|% * # xxx +|
| |A |
| A|
| A |
|A |
| A |
+-------------------------------------------------------------------------------+
N Min Max Median Avg Stddev
x 3 3744.13 3794.31 3752.25 3763.5633 26.935139
+ 3 4519 4525.04 4520.73 4521.59 3.1104823
Difference at 95.0% confidence
758.027 +/- 43.4565
20.1412% +/- 1.15466%
(Student's t, pooled s = 19.1726)
* 3 1823.08 1827.2 1825.62 1825.3 2.0785572
Difference at 95.0% confidence
-1938.26 +/- 43.298
-51.5007% +/- 1.15045%
(Student's t, pooled s = 19.1026)
% 3 1266.96 1279.37 1270.47 1272.2667 6.3971113
Difference at 95.0% confidence
-2491.3 +/- 44.3704
-66.1952% +/- 1.17895%
(Student's t, pooled s = 19.5758)
# 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-ccache-empty
* buildkernel-ccache-empty-fastdep
% buildkernel-ccache-full
# buildkernel-ccache-full-fastdep
@ buildkernel-fastdep
+-------------------------------------------------------------------------------+
|# @ % * |
|# @ % * x + |
|# @ % * xx ++|
| MA |
| MA|
| A |
| A |
|A |
| A |
+-------------------------------------------------------------------------------+
N Min Max Median Avg Stddev
x 3 571.57 573.94 571.79 572.43333 1.3094401
+ 3 727.97 731.91 728.06 729.31333 2.2492295
Difference at 95.0% confidence
156.88 +/- 4.17129
27.4058% +/- 0.728695%
(Student's t, pooled s = 1.84034)
* 3 527.1 528.29 528.08 527.82333 0.63516402
Difference at 95.0% confidence
-44.61 +/- 2.33254
-7.79305% +/- 0.407478%
(Student's t, pooled s = 1.02909)
% 3 400.4 401.05 400.62 400.69 0.3306055
Difference at 95.0% confidence
-171.743 +/- 2.16453
-30.0023% +/- 0.378128%
(Student's t, pooled s = 0.954969)
# 3 201.94 203.34 202.28 202.52 0.73020545
Difference at 95.0% confidence
-369.913 +/- 2.40293
-64.6212% +/- 0.419774%
(Student's t, pooled s = 1.06015)
@ 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)
[1] https://ccache.samba.org/performance.html
[2] http://www.mail-archive.com/ccache@lists.samba.org/msg00576.html
[3] https://reviews.freebsd.org/D3484
[5] https://github.com/jrosdahl/ccache/pull/30
PR: 182944 [4]
MFC after: 3 weeks
Sponsored by: EMC / Isilon Storage Division
Relnotes: yes
2015-11-08 00:50:18 +00:00
|
|
|
${CXX:N${CCACHE_BIN}} ${CXXFLAGS:N-M*} ${LDFLAGS} -o ${.TARGET} \
|
|
|
|
${OBJS} ${LDADD}
|
2002-04-12 16:25:13 +00:00
|
|
|
.else
|
Add built-in ccache build support via WITH_CCACHE_BUILD option.
ccache is mostly beneficial for frequent builds where -DNO_CLEAN is not
used to achieve a safe pseudo-incremental build. This is explained in
more detail upstream [1] [2]. It incurs about a 20%-28% hit to populate the
cache, but with a full cache saves 30-50% in build times. When combined with
the WITH_FAST_DEPEND feature it saves up to 65% since ccache does cache the
resulting dependency file, which it does not do when using mkdep(1)/'CC
-E'. Stats are provided at the end of this message.
This removes the need to modify /etc/make.conf with the CC:= and CXX:=
lines which conflicted with external compiler support [3] (causing the
bootstrap compiler to not be built which lead to obscure failures [4]),
incorrectly invoked ccache in various stages, required CCACHE_CPP2 to avoid
Clang errors with parenthesis, and did not work with META_MODE.
The option name was picked to match the existing option in ports. This
feature is available for both in-src and out-of-src builds that use
/usr/share/mk.
Linking, assembly compiles, and pre-processing avoid using ccache since it is
only overhead. ccache does nothing special in these modes, although there is
no harm in calling it for them.
CCACHE_COMPILERCHECK is set to 'content' when using the in-tree bootstrap
compiler to hash the content of the compiler binary to determine if it
should be a cache miss. For external compilers the 'mtime' option is used
as it is more efficient and likely to be correct. Future work may optimize the
'content' check using the same checks as whether a bootstrap compiler is needed
to be built.
The CCACHE_CPP2 pessimization is currently default in our devel/ccache
port due to Clang requiring it. Clang's -Wparentheses-equality,
-Wtautological-compare, and -Wself-assign warnings do not mix well with
compiling already-pre-processed code that may have expanded macros that
trigger the warnings. GCC has so far not had this issue so it is allowed to
disable the CCACHE_CPP2 default in our port.
Sharing a cache between multiple checkouts, or systems, is explained in
the ccache manual. Sharing a cache over NFS would likely not be worth
it, but syncing cache directories between systems may be useful for an
organization. There is also a memcached backend available [5]. Due to using
an object directory outside of the source directory though you will need to
ensure that both are in the same prefix and all users use the same layout. A
possible working layout is as follows:
Source: /some/prefix/src1
Source: /some/prefix/src2
Source: /some/prefix/src3
Objdir: /some/prefix/obj
Environment: CCACHE_BASEDIR='${SRCTOP:H}' MAKEOBJDIRPREFIX='${SRCTOP:H}/obj'
This will use src*/../obj as the MAKEOBJDIRPREFIX and tells ccache to replace
all absolute paths to be relative. Using something like this is required due
to -I and -o flags containing both SRC and OBJDIR absolute paths that ccache
adds into its hash for the object without CCACHE_BASEDIR.
distcc can be hooked into by setting CCACHE_PREFIX=/usr/local/bin/distcc.
I have not personally tested this and assume it will not mix well with
using the bootstrap compiler.
The cache from buildworld can be reused in a subdir by first running
'make buildenv' (from r290424).
Note that the cache is currently different depending on whether -j is
used or not due to ccache enabling -fdiagnostics-color automatically if
stderr is a TTY, which bmake only does if not using -j.
The system I used for testing was:
WITNESS
Build options: -j20 WITH_LLDB=yes WITH_DEBUG_FILES=yes WITH_CCACHE_BUILD=yes
DISK: ZFS 3-way mirror with very slow disks using SSD l2arc/log.
The arc was fully populated with src tree files and ccache objects.
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
The WITH_FAST_DEPEND feature was used for comparison here as well to show
the dramatic time savings with a full cache.
buildworld:
x buildworld-before
+ buildworld-ccache-empty
* buildworld-ccache-full
% buildworld-ccache-full-fastdep
# buildworld-fastdep
+-------------------------------------------------------------------------------+
|% * # +|
|% * # +|
|% * # xxx +|
| |A |
| A|
| A |
|A |
| A |
+-------------------------------------------------------------------------------+
N Min Max Median Avg Stddev
x 3 3744.13 3794.31 3752.25 3763.5633 26.935139
+ 3 4519 4525.04 4520.73 4521.59 3.1104823
Difference at 95.0% confidence
758.027 +/- 43.4565
20.1412% +/- 1.15466%
(Student's t, pooled s = 19.1726)
* 3 1823.08 1827.2 1825.62 1825.3 2.0785572
Difference at 95.0% confidence
-1938.26 +/- 43.298
-51.5007% +/- 1.15045%
(Student's t, pooled s = 19.1026)
% 3 1266.96 1279.37 1270.47 1272.2667 6.3971113
Difference at 95.0% confidence
-2491.3 +/- 44.3704
-66.1952% +/- 1.17895%
(Student's t, pooled s = 19.5758)
# 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-ccache-empty
* buildkernel-ccache-empty-fastdep
% buildkernel-ccache-full
# buildkernel-ccache-full-fastdep
@ buildkernel-fastdep
+-------------------------------------------------------------------------------+
|# @ % * |
|# @ % * x + |
|# @ % * xx ++|
| MA |
| MA|
| A |
| A |
|A |
| A |
+-------------------------------------------------------------------------------+
N Min Max Median Avg Stddev
x 3 571.57 573.94 571.79 572.43333 1.3094401
+ 3 727.97 731.91 728.06 729.31333 2.2492295
Difference at 95.0% confidence
156.88 +/- 4.17129
27.4058% +/- 0.728695%
(Student's t, pooled s = 1.84034)
* 3 527.1 528.29 528.08 527.82333 0.63516402
Difference at 95.0% confidence
-44.61 +/- 2.33254
-7.79305% +/- 0.407478%
(Student's t, pooled s = 1.02909)
% 3 400.4 401.05 400.62 400.69 0.3306055
Difference at 95.0% confidence
-171.743 +/- 2.16453
-30.0023% +/- 0.378128%
(Student's t, pooled s = 0.954969)
# 3 201.94 203.34 202.28 202.52 0.73020545
Difference at 95.0% confidence
-369.913 +/- 2.40293
-64.6212% +/- 0.419774%
(Student's t, pooled s = 1.06015)
@ 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)
[1] https://ccache.samba.org/performance.html
[2] http://www.mail-archive.com/ccache@lists.samba.org/msg00576.html
[3] https://reviews.freebsd.org/D3484
[5] https://github.com/jrosdahl/ccache/pull/30
PR: 182944 [4]
MFC after: 3 weeks
Sponsored by: EMC / Isilon Storage Division
Relnotes: yes
2015-11-08 00:50:18 +00:00
|
|
|
${CC:N${CCACHE_BIN}} ${CFLAGS:N-M*} ${LDFLAGS} -o ${.TARGET} ${OBJS} \
|
|
|
|
${LDADD}
|
2002-04-12 16:25:13 +00:00
|
|
|
.endif
|
2011-11-30 18:11:49 +00:00
|
|
|
.if ${MK_CTF} != "no"
|
2011-11-29 08:38:47 +00:00
|
|
|
${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${OBJS}
|
|
|
|
.endif
|
2002-04-12 16:25:13 +00:00
|
|
|
|
2005-04-11 07:13:29 +00:00
|
|
|
.else # !defined(SRCS)
|
1994-05-30 19:09:18 +00:00
|
|
|
|
2002-04-12 16:25:13 +00:00
|
|
|
.if !target(${PROG})
|
2002-04-11 10:44:30 +00:00
|
|
|
.if defined(PROG_CXX)
|
|
|
|
SRCS= ${PROG}.cc
|
|
|
|
.else
|
1994-08-28 15:32:10 +00:00
|
|
|
SRCS= ${PROG}.c
|
2002-04-11 10:44:30 +00:00
|
|
|
.endif
|
1994-05-30 19:09:18 +00:00
|
|
|
|
1994-08-28 15:32:10 +00:00
|
|
|
# Always make an intermediate object file because:
|
|
|
|
# - it saves time rebuilding when only the library has changed
|
|
|
|
# - the name of the object gets put into the executable symbol table instead of
|
|
|
|
# the name of a variable temporary object.
|
|
|
|
# - it's useful to keep objects around for crunching.
|
2017-10-18 00:33:20 +00:00
|
|
|
OBJS+= ${PROG}.o
|
|
|
|
BCOBJS+= ${PROG}.bc
|
|
|
|
LLOBJS+= ${PROG}.ll
|
|
|
|
CLEANFILES+= ${PROG}.o ${PROG}.bc ${PROG}.ll
|
1998-02-19 14:53:29 +00:00
|
|
|
|
2010-09-10 16:21:09 +00:00
|
|
|
.if target(beforelinking)
|
2012-12-31 21:54:43 +00:00
|
|
|
beforelinking: ${OBJS}
|
2013-06-07 21:40:02 +00:00
|
|
|
${PROG_FULL}: beforelinking
|
2010-09-10 16:21:09 +00:00
|
|
|
.endif
|
2016-06-03 19:25:36 +00:00
|
|
|
${PROG_FULL}: ${OBJS}
|
2002-04-12 08:17:24 +00:00
|
|
|
.if defined(PROG_CXX)
|
Add built-in ccache build support via WITH_CCACHE_BUILD option.
ccache is mostly beneficial for frequent builds where -DNO_CLEAN is not
used to achieve a safe pseudo-incremental build. This is explained in
more detail upstream [1] [2]. It incurs about a 20%-28% hit to populate the
cache, but with a full cache saves 30-50% in build times. When combined with
the WITH_FAST_DEPEND feature it saves up to 65% since ccache does cache the
resulting dependency file, which it does not do when using mkdep(1)/'CC
-E'. Stats are provided at the end of this message.
This removes the need to modify /etc/make.conf with the CC:= and CXX:=
lines which conflicted with external compiler support [3] (causing the
bootstrap compiler to not be built which lead to obscure failures [4]),
incorrectly invoked ccache in various stages, required CCACHE_CPP2 to avoid
Clang errors with parenthesis, and did not work with META_MODE.
The option name was picked to match the existing option in ports. This
feature is available for both in-src and out-of-src builds that use
/usr/share/mk.
Linking, assembly compiles, and pre-processing avoid using ccache since it is
only overhead. ccache does nothing special in these modes, although there is
no harm in calling it for them.
CCACHE_COMPILERCHECK is set to 'content' when using the in-tree bootstrap
compiler to hash the content of the compiler binary to determine if it
should be a cache miss. For external compilers the 'mtime' option is used
as it is more efficient and likely to be correct. Future work may optimize the
'content' check using the same checks as whether a bootstrap compiler is needed
to be built.
The CCACHE_CPP2 pessimization is currently default in our devel/ccache
port due to Clang requiring it. Clang's -Wparentheses-equality,
-Wtautological-compare, and -Wself-assign warnings do not mix well with
compiling already-pre-processed code that may have expanded macros that
trigger the warnings. GCC has so far not had this issue so it is allowed to
disable the CCACHE_CPP2 default in our port.
Sharing a cache between multiple checkouts, or systems, is explained in
the ccache manual. Sharing a cache over NFS would likely not be worth
it, but syncing cache directories between systems may be useful for an
organization. There is also a memcached backend available [5]. Due to using
an object directory outside of the source directory though you will need to
ensure that both are in the same prefix and all users use the same layout. A
possible working layout is as follows:
Source: /some/prefix/src1
Source: /some/prefix/src2
Source: /some/prefix/src3
Objdir: /some/prefix/obj
Environment: CCACHE_BASEDIR='${SRCTOP:H}' MAKEOBJDIRPREFIX='${SRCTOP:H}/obj'
This will use src*/../obj as the MAKEOBJDIRPREFIX and tells ccache to replace
all absolute paths to be relative. Using something like this is required due
to -I and -o flags containing both SRC and OBJDIR absolute paths that ccache
adds into its hash for the object without CCACHE_BASEDIR.
distcc can be hooked into by setting CCACHE_PREFIX=/usr/local/bin/distcc.
I have not personally tested this and assume it will not mix well with
using the bootstrap compiler.
The cache from buildworld can be reused in a subdir by first running
'make buildenv' (from r290424).
Note that the cache is currently different depending on whether -j is
used or not due to ccache enabling -fdiagnostics-color automatically if
stderr is a TTY, which bmake only does if not using -j.
The system I used for testing was:
WITNESS
Build options: -j20 WITH_LLDB=yes WITH_DEBUG_FILES=yes WITH_CCACHE_BUILD=yes
DISK: ZFS 3-way mirror with very slow disks using SSD l2arc/log.
The arc was fully populated with src tree files and ccache objects.
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
The WITH_FAST_DEPEND feature was used for comparison here as well to show
the dramatic time savings with a full cache.
buildworld:
x buildworld-before
+ buildworld-ccache-empty
* buildworld-ccache-full
% buildworld-ccache-full-fastdep
# buildworld-fastdep
+-------------------------------------------------------------------------------+
|% * # +|
|% * # +|
|% * # xxx +|
| |A |
| A|
| A |
|A |
| A |
+-------------------------------------------------------------------------------+
N Min Max Median Avg Stddev
x 3 3744.13 3794.31 3752.25 3763.5633 26.935139
+ 3 4519 4525.04 4520.73 4521.59 3.1104823
Difference at 95.0% confidence
758.027 +/- 43.4565
20.1412% +/- 1.15466%
(Student's t, pooled s = 19.1726)
* 3 1823.08 1827.2 1825.62 1825.3 2.0785572
Difference at 95.0% confidence
-1938.26 +/- 43.298
-51.5007% +/- 1.15045%
(Student's t, pooled s = 19.1026)
% 3 1266.96 1279.37 1270.47 1272.2667 6.3971113
Difference at 95.0% confidence
-2491.3 +/- 44.3704
-66.1952% +/- 1.17895%
(Student's t, pooled s = 19.5758)
# 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-ccache-empty
* buildkernel-ccache-empty-fastdep
% buildkernel-ccache-full
# buildkernel-ccache-full-fastdep
@ buildkernel-fastdep
+-------------------------------------------------------------------------------+
|# @ % * |
|# @ % * x + |
|# @ % * xx ++|
| MA |
| MA|
| A |
| A |
|A |
| A |
+-------------------------------------------------------------------------------+
N Min Max Median Avg Stddev
x 3 571.57 573.94 571.79 572.43333 1.3094401
+ 3 727.97 731.91 728.06 729.31333 2.2492295
Difference at 95.0% confidence
156.88 +/- 4.17129
27.4058% +/- 0.728695%
(Student's t, pooled s = 1.84034)
* 3 527.1 528.29 528.08 527.82333 0.63516402
Difference at 95.0% confidence
-44.61 +/- 2.33254
-7.79305% +/- 0.407478%
(Student's t, pooled s = 1.02909)
% 3 400.4 401.05 400.62 400.69 0.3306055
Difference at 95.0% confidence
-171.743 +/- 2.16453
-30.0023% +/- 0.378128%
(Student's t, pooled s = 0.954969)
# 3 201.94 203.34 202.28 202.52 0.73020545
Difference at 95.0% confidence
-369.913 +/- 2.40293
-64.6212% +/- 0.419774%
(Student's t, pooled s = 1.06015)
@ 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)
[1] https://ccache.samba.org/performance.html
[2] http://www.mail-archive.com/ccache@lists.samba.org/msg00576.html
[3] https://reviews.freebsd.org/D3484
[5] https://github.com/jrosdahl/ccache/pull/30
PR: 182944 [4]
MFC after: 3 weeks
Sponsored by: EMC / Isilon Storage Division
Relnotes: yes
2015-11-08 00:50:18 +00:00
|
|
|
${CXX:N${CCACHE_BIN}} ${CXXFLAGS:N-M*} ${LDFLAGS} -o ${.TARGET} \
|
|
|
|
${OBJS} ${LDADD}
|
2002-04-12 08:17:24 +00:00
|
|
|
.else
|
Add built-in ccache build support via WITH_CCACHE_BUILD option.
ccache is mostly beneficial for frequent builds where -DNO_CLEAN is not
used to achieve a safe pseudo-incremental build. This is explained in
more detail upstream [1] [2]. It incurs about a 20%-28% hit to populate the
cache, but with a full cache saves 30-50% in build times. When combined with
the WITH_FAST_DEPEND feature it saves up to 65% since ccache does cache the
resulting dependency file, which it does not do when using mkdep(1)/'CC
-E'. Stats are provided at the end of this message.
This removes the need to modify /etc/make.conf with the CC:= and CXX:=
lines which conflicted with external compiler support [3] (causing the
bootstrap compiler to not be built which lead to obscure failures [4]),
incorrectly invoked ccache in various stages, required CCACHE_CPP2 to avoid
Clang errors with parenthesis, and did not work with META_MODE.
The option name was picked to match the existing option in ports. This
feature is available for both in-src and out-of-src builds that use
/usr/share/mk.
Linking, assembly compiles, and pre-processing avoid using ccache since it is
only overhead. ccache does nothing special in these modes, although there is
no harm in calling it for them.
CCACHE_COMPILERCHECK is set to 'content' when using the in-tree bootstrap
compiler to hash the content of the compiler binary to determine if it
should be a cache miss. For external compilers the 'mtime' option is used
as it is more efficient and likely to be correct. Future work may optimize the
'content' check using the same checks as whether a bootstrap compiler is needed
to be built.
The CCACHE_CPP2 pessimization is currently default in our devel/ccache
port due to Clang requiring it. Clang's -Wparentheses-equality,
-Wtautological-compare, and -Wself-assign warnings do not mix well with
compiling already-pre-processed code that may have expanded macros that
trigger the warnings. GCC has so far not had this issue so it is allowed to
disable the CCACHE_CPP2 default in our port.
Sharing a cache between multiple checkouts, or systems, is explained in
the ccache manual. Sharing a cache over NFS would likely not be worth
it, but syncing cache directories between systems may be useful for an
organization. There is also a memcached backend available [5]. Due to using
an object directory outside of the source directory though you will need to
ensure that both are in the same prefix and all users use the same layout. A
possible working layout is as follows:
Source: /some/prefix/src1
Source: /some/prefix/src2
Source: /some/prefix/src3
Objdir: /some/prefix/obj
Environment: CCACHE_BASEDIR='${SRCTOP:H}' MAKEOBJDIRPREFIX='${SRCTOP:H}/obj'
This will use src*/../obj as the MAKEOBJDIRPREFIX and tells ccache to replace
all absolute paths to be relative. Using something like this is required due
to -I and -o flags containing both SRC and OBJDIR absolute paths that ccache
adds into its hash for the object without CCACHE_BASEDIR.
distcc can be hooked into by setting CCACHE_PREFIX=/usr/local/bin/distcc.
I have not personally tested this and assume it will not mix well with
using the bootstrap compiler.
The cache from buildworld can be reused in a subdir by first running
'make buildenv' (from r290424).
Note that the cache is currently different depending on whether -j is
used or not due to ccache enabling -fdiagnostics-color automatically if
stderr is a TTY, which bmake only does if not using -j.
The system I used for testing was:
WITNESS
Build options: -j20 WITH_LLDB=yes WITH_DEBUG_FILES=yes WITH_CCACHE_BUILD=yes
DISK: ZFS 3-way mirror with very slow disks using SSD l2arc/log.
The arc was fully populated with src tree files and ccache objects.
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
The WITH_FAST_DEPEND feature was used for comparison here as well to show
the dramatic time savings with a full cache.
buildworld:
x buildworld-before
+ buildworld-ccache-empty
* buildworld-ccache-full
% buildworld-ccache-full-fastdep
# buildworld-fastdep
+-------------------------------------------------------------------------------+
|% * # +|
|% * # +|
|% * # xxx +|
| |A |
| A|
| A |
|A |
| A |
+-------------------------------------------------------------------------------+
N Min Max Median Avg Stddev
x 3 3744.13 3794.31 3752.25 3763.5633 26.935139
+ 3 4519 4525.04 4520.73 4521.59 3.1104823
Difference at 95.0% confidence
758.027 +/- 43.4565
20.1412% +/- 1.15466%
(Student's t, pooled s = 19.1726)
* 3 1823.08 1827.2 1825.62 1825.3 2.0785572
Difference at 95.0% confidence
-1938.26 +/- 43.298
-51.5007% +/- 1.15045%
(Student's t, pooled s = 19.1026)
% 3 1266.96 1279.37 1270.47 1272.2667 6.3971113
Difference at 95.0% confidence
-2491.3 +/- 44.3704
-66.1952% +/- 1.17895%
(Student's t, pooled s = 19.5758)
# 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-ccache-empty
* buildkernel-ccache-empty-fastdep
% buildkernel-ccache-full
# buildkernel-ccache-full-fastdep
@ buildkernel-fastdep
+-------------------------------------------------------------------------------+
|# @ % * |
|# @ % * x + |
|# @ % * xx ++|
| MA |
| MA|
| A |
| A |
|A |
| A |
+-------------------------------------------------------------------------------+
N Min Max Median Avg Stddev
x 3 571.57 573.94 571.79 572.43333 1.3094401
+ 3 727.97 731.91 728.06 729.31333 2.2492295
Difference at 95.0% confidence
156.88 +/- 4.17129
27.4058% +/- 0.728695%
(Student's t, pooled s = 1.84034)
* 3 527.1 528.29 528.08 527.82333 0.63516402
Difference at 95.0% confidence
-44.61 +/- 2.33254
-7.79305% +/- 0.407478%
(Student's t, pooled s = 1.02909)
% 3 400.4 401.05 400.62 400.69 0.3306055
Difference at 95.0% confidence
-171.743 +/- 2.16453
-30.0023% +/- 0.378128%
(Student's t, pooled s = 0.954969)
# 3 201.94 203.34 202.28 202.52 0.73020545
Difference at 95.0% confidence
-369.913 +/- 2.40293
-64.6212% +/- 0.419774%
(Student's t, pooled s = 1.06015)
@ 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)
[1] https://ccache.samba.org/performance.html
[2] http://www.mail-archive.com/ccache@lists.samba.org/msg00576.html
[3] https://reviews.freebsd.org/D3484
[5] https://github.com/jrosdahl/ccache/pull/30
PR: 182944 [4]
MFC after: 3 weeks
Sponsored by: EMC / Isilon Storage Division
Relnotes: yes
2015-11-08 00:50:18 +00:00
|
|
|
${CC:N${CCACHE_BIN}} ${CFLAGS:N-M*} ${LDFLAGS} -o ${.TARGET} ${OBJS} \
|
|
|
|
${LDADD}
|
1994-05-30 19:09:18 +00:00
|
|
|
.endif
|
2011-11-30 18:11:49 +00:00
|
|
|
.if ${MK_CTF} != "no"
|
2011-11-29 08:38:47 +00:00
|
|
|
${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${OBJS}
|
|
|
|
.endif
|
2013-06-07 21:40:02 +00:00
|
|
|
.endif # !target(${PROG})
|
1998-02-19 14:53:29 +00:00
|
|
|
|
2012-12-14 18:30:01 +00:00
|
|
|
.endif # !defined(SRCS)
|
1994-05-30 19:09:18 +00:00
|
|
|
|
2013-06-07 21:40:02 +00:00
|
|
|
.if ${MK_DEBUG_FILES} != "no"
|
2016-06-03 19:25:36 +00:00
|
|
|
${PROG}: ${PROG_FULL} ${PROGNAME}.debug
|
2013-06-07 21:40:02 +00:00
|
|
|
${OBJCOPY} --strip-debug --add-gnu-debuglink=${PROGNAME}.debug \
|
|
|
|
${PROG_FULL} ${.TARGET}
|
|
|
|
|
2016-06-03 19:25:36 +00:00
|
|
|
${PROGNAME}.debug: ${PROG_FULL}
|
2013-06-07 21:40:02 +00:00
|
|
|
${OBJCOPY} --only-keep-debug ${PROG_FULL} ${.TARGET}
|
|
|
|
.endif
|
|
|
|
|
2016-11-01 21:27:42 +00:00
|
|
|
.if defined(LLVM_LINK)
|
|
|
|
${PROG_FULL}.bc: ${BCOBJS}
|
|
|
|
${LLVM_LINK} -o ${.TARGET} ${BCOBJS}
|
|
|
|
|
|
|
|
${PROG_FULL}.ll: ${LLOBJS}
|
|
|
|
${LLVM_LINK} -S -o ${.TARGET} ${LLOBJS}
|
|
|
|
|
2017-10-18 00:30:15 +00:00
|
|
|
CLEANFILES+= ${PROG_FULL}.bc ${PROG_FULL}.ll
|
2016-11-01 21:27:42 +00:00
|
|
|
.endif # defined(LLVM_LINK)
|
|
|
|
|
2006-03-17 18:54:44 +00:00
|
|
|
.if ${MK_MAN} != "no" && !defined(MAN) && \
|
2001-03-26 08:04:11 +00:00
|
|
|
!defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \
|
1994-05-30 19:09:18 +00:00
|
|
|
!defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \
|
2013-01-16 23:21:04 +00:00
|
|
|
!defined(MAN7) && !defined(MAN8) && !defined(MAN9)
|
2001-03-28 15:07:48 +00:00
|
|
|
MAN= ${PROG}.1
|
|
|
|
MAN1= ${MAN}
|
1994-05-30 19:09:18 +00:00
|
|
|
.endif
|
2012-12-14 18:30:01 +00:00
|
|
|
.endif # defined(PROG)
|
1994-05-30 19:09:18 +00:00
|
|
|
|
2012-08-22 19:25:57 +00:00
|
|
|
.if defined(_SKIP_BUILD)
|
|
|
|
all:
|
|
|
|
.else
|
2016-02-16 02:09:48 +00:00
|
|
|
all: ${PROG} ${SCRIPTS}
|
2006-03-17 18:54:44 +00:00
|
|
|
.if ${MK_MAN} != "no"
|
2016-02-26 22:13:31 +00:00
|
|
|
all: all-man
|
2001-03-26 08:04:11 +00:00
|
|
|
.endif
|
2012-08-22 19:25:57 +00:00
|
|
|
.endif
|
1994-05-30 19:09:18 +00:00
|
|
|
|
2003-08-31 15:20:17 +00:00
|
|
|
.if defined(PROG)
|
2016-11-01 21:27:42 +00:00
|
|
|
CLEANFILES+= ${PROG} ${PROG}.bc ${PROG}.ll
|
2013-06-07 21:40:02 +00:00
|
|
|
.if ${MK_DEBUG_FILES} != "no"
|
2017-10-18 00:30:15 +00:00
|
|
|
CLEANFILES+= ${PROG_FULL} ${PROGNAME}.debug
|
2013-06-07 21:40:02 +00:00
|
|
|
.endif
|
2003-08-31 15:20:17 +00:00
|
|
|
.endif
|
|
|
|
|
|
|
|
.if defined(OBJS)
|
2016-11-01 21:27:42 +00:00
|
|
|
CLEANFILES+= ${OBJS} ${BCOBJS} ${LLOBJS}
|
2003-08-31 15:20:17 +00:00
|
|
|
.endif
|
1994-05-30 19:09:18 +00:00
|
|
|
|
2004-02-09 14:05:17 +00:00
|
|
|
.include <bsd.libnames.mk>
|
|
|
|
|
2000-01-09 15:40:32 +00:00
|
|
|
.if defined(PROG)
|
2016-06-21 21:55:03 +00:00
|
|
|
.if !defined(NO_EXTRADEPEND)
|
1997-04-09 16:10:27 +00:00
|
|
|
_EXTRADEPEND:
|
2004-02-09 14:05:17 +00:00
|
|
|
.if defined(LDFLAGS) && !empty(LDFLAGS:M-nostdlib)
|
|
|
|
.if defined(DPADD) && !empty(DPADD)
|
2015-02-13 17:33:27 +00:00
|
|
|
echo ${PROG_FULL}: ${DPADD} >> ${DEPENDFILE}
|
2004-02-09 14:05:17 +00:00
|
|
|
.endif
|
|
|
|
.else
|
2015-02-13 17:33:27 +00:00
|
|
|
echo ${PROG_FULL}: ${LIBC} ${DPADD} >> ${DEPENDFILE}
|
2014-05-10 16:38:03 +00:00
|
|
|
.if defined(PROG_CXX)
|
2015-02-13 17:33:27 +00:00
|
|
|
echo ${PROG_FULL}: ${LIBCPLUSPLUS} >> ${DEPENDFILE}
|
1997-08-30 23:23:18 +00:00
|
|
|
.endif
|
2004-02-09 14:05:17 +00:00
|
|
|
.endif
|
2016-06-21 21:55:03 +00:00
|
|
|
.endif # !defined(NO_EXTRADEPEND)
|
2012-08-25 19:30:15 +00:00
|
|
|
.endif
|
1997-04-09 16:10:27 +00:00
|
|
|
|
1994-05-30 19:09:18 +00:00
|
|
|
.if !target(install)
|
|
|
|
|
2004-11-12 13:24:34 +00:00
|
|
|
.if defined(PRECIOUSPROG)
|
2004-12-21 09:53:14 +00:00
|
|
|
.if !defined(NO_FSCHG)
|
2004-11-03 18:01:21 +00:00
|
|
|
INSTALLFLAGS+= -fschg
|
|
|
|
.endif
|
2004-11-12 13:24:34 +00:00
|
|
|
INSTALLFLAGS+= -S
|
|
|
|
.endif
|
2004-11-03 18:01:21 +00:00
|
|
|
|
1999-07-31 20:27:33 +00:00
|
|
|
_INSTALLFLAGS:= ${INSTALLFLAGS}
|
|
|
|
.for ie in ${INSTALLFLAGS_EDIT}
|
|
|
|
_INSTALLFLAGS:= ${_INSTALLFLAGS${ie}}
|
|
|
|
.endfor
|
|
|
|
|
2004-02-09 14:05:17 +00:00
|
|
|
.if !target(realinstall) && !defined(INTERNALPROG)
|
2002-05-07 15:30:49 +00:00
|
|
|
realinstall: _proginstall
|
2002-07-03 12:28:03 +00:00
|
|
|
.ORDER: beforeinstall _proginstall
|
2002-05-07 15:30:49 +00:00
|
|
|
_proginstall:
|
1994-05-30 19:09:18 +00:00
|
|
|
.if defined(PROG)
|
2015-02-13 00:16:05 +00:00
|
|
|
${INSTALL} ${TAG_ARGS} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
|
2001-04-02 11:44:20 +00:00
|
|
|
${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}/${PROGNAME}
|
2013-06-07 21:40:02 +00:00
|
|
|
.if ${MK_DEBUG_FILES} != "no"
|
|
|
|
.if defined(DEBUGMKDIR)
|
2020-05-20 19:45:22 +00:00
|
|
|
${INSTALL} ${TAG_ARGS:D${TAG_ARGS},dbg} -d ${DESTDIR}${DEBUGFILEDIR}/
|
2013-06-07 21:40:02 +00:00
|
|
|
.endif
|
2020-05-20 19:45:22 +00:00
|
|
|
${INSTALL} ${TAG_ARGS:D${TAG_ARGS},dbg} -o ${BINOWN} -g ${BINGRP} -m ${DEBUGMODE} \
|
2013-06-07 21:40:02 +00:00
|
|
|
${PROGNAME}.debug ${DESTDIR}${DEBUGFILEDIR}/${PROGNAME}.debug
|
|
|
|
.endif
|
2001-04-02 11:44:20 +00:00
|
|
|
.endif
|
2005-04-11 07:13:29 +00:00
|
|
|
.endif # !target(realinstall)
|
1994-05-30 19:09:18 +00:00
|
|
|
|
2001-04-07 11:13:46 +00:00
|
|
|
.if defined(SCRIPTS) && !empty(SCRIPTS)
|
|
|
|
realinstall: _scriptsinstall
|
2002-07-03 12:28:03 +00:00
|
|
|
.ORDER: beforeinstall _scriptsinstall
|
2001-04-07 11:13:46 +00:00
|
|
|
|
|
|
|
SCRIPTSDIR?= ${BINDIR}
|
|
|
|
SCRIPTSOWN?= ${BINOWN}
|
|
|
|
SCRIPTSGRP?= ${BINGRP}
|
|
|
|
SCRIPTSMODE?= ${BINMODE}
|
|
|
|
|
2013-01-29 00:07:54 +00:00
|
|
|
STAGE_AS_SETS+= scripts
|
|
|
|
stage_as.scripts: ${SCRIPTS}
|
|
|
|
FLAGS.stage_as.scripts= -m ${SCRIPTSMODE}
|
|
|
|
STAGE_FILES_DIR.scripts= ${STAGE_OBJTOP}
|
2001-04-07 11:13:46 +00:00
|
|
|
.for script in ${SCRIPTS}
|
|
|
|
.if defined(SCRIPTSNAME)
|
|
|
|
SCRIPTSNAME_${script:T}?= ${SCRIPTSNAME}
|
|
|
|
.else
|
|
|
|
SCRIPTSNAME_${script:T}?= ${script:T:R}
|
|
|
|
.endif
|
|
|
|
SCRIPTSDIR_${script:T}?= ${SCRIPTSDIR}
|
|
|
|
SCRIPTSOWN_${script:T}?= ${SCRIPTSOWN}
|
|
|
|
SCRIPTSGRP_${script:T}?= ${SCRIPTSGRP}
|
|
|
|
SCRIPTSMODE_${script:T}?= ${SCRIPTSMODE}
|
2013-01-29 00:07:54 +00:00
|
|
|
STAGE_AS_${script:T}= ${SCRIPTSDIR_${script:T}}/${SCRIPTSNAME_${script:T}}
|
2001-12-17 13:59:35 +00:00
|
|
|
_scriptsinstall: _SCRIPTSINS_${script:T}
|
|
|
|
_SCRIPTSINS_${script:T}: ${script}
|
2015-02-13 00:16:05 +00:00
|
|
|
${INSTALL} ${TAG_ARGS} -o ${SCRIPTSOWN_${.ALLSRC:T}} \
|
2001-04-07 11:13:46 +00:00
|
|
|
-g ${SCRIPTSGRP_${.ALLSRC:T}} -m ${SCRIPTSMODE_${.ALLSRC:T}} \
|
2002-04-17 16:29:02 +00:00
|
|
|
${.ALLSRC} \
|
2001-04-07 11:13:46 +00:00
|
|
|
${DESTDIR}${SCRIPTSDIR_${.ALLSRC:T}}/${SCRIPTSNAME_${.ALLSRC:T}}
|
|
|
|
.endfor
|
|
|
|
.endif
|
|
|
|
|
2002-07-02 12:37:09 +00:00
|
|
|
NLSNAME?= ${PROG}
|
|
|
|
.include <bsd.nls.mk>
|
|
|
|
|
2015-10-09 21:57:42 +00:00
|
|
|
.include <bsd.confs.mk>
|
2002-06-03 14:49:34 +00:00
|
|
|
.include <bsd.files.mk>
|
2002-05-15 16:19:54 +00:00
|
|
|
.include <bsd.incs.mk>
|
2018-06-29 16:07:56 +00:00
|
|
|
|
|
|
|
LINKOWN?= ${BINOWN}
|
|
|
|
LINKGRP?= ${BINGRP}
|
|
|
|
LINKMODE?= ${BINMODE}
|
2002-07-02 12:16:54 +00:00
|
|
|
.include <bsd.links.mk>
|
2002-05-12 16:01:00 +00:00
|
|
|
|
2006-03-17 18:54:44 +00:00
|
|
|
.if ${MK_MAN} != "no"
|
2016-02-26 22:13:31 +00:00
|
|
|
realinstall: maninstall
|
|
|
|
.ORDER: beforeinstall maninstall
|
1994-08-04 21:09:27 +00:00
|
|
|
.endif
|
2002-05-07 15:30:49 +00:00
|
|
|
|
2015-09-23 23:20:49 +00:00
|
|
|
.endif # !target(install)
|
1994-05-30 19:09:18 +00:00
|
|
|
|
2006-03-17 18:54:44 +00:00
|
|
|
.if ${MK_MAN} != "no"
|
1994-05-30 19:09:18 +00:00
|
|
|
.include <bsd.man.mk>
|
1998-03-12 20:02:17 +00:00
|
|
|
.endif
|
|
|
|
|
Add limited sandbox capability to "make check"
== Rationale ==
r295380 introduced "make check" and consolidated means for running
test code in an attempt to simplify running tests. One could either
install files/libraries/programs and run "make check", or run "make check"
with an explicit CHECKDIR, e.g., `make check CHECKDIR=$(make -V.OBJDIR)``.
One criticism that was received is that "make check" should be run with
the intent of making dev->test->commit easier, which means that the target
audience's workflow should be developers. One developer pattern available
in other opensource projects is to run test code from a developer sandbox,
instead of installing to a system.
== Method ==
This approach is slightly different from the standard approach, in the sense
that it builds and installs into a deterministic directory under .OBJDIR (as I call it,
the "sandbox"), then runs "make check" against that. In the event the test
run is successful, the deterministic directory is removed to save space.
== Approach ==
bsd.lib.mk, bsd.prog.mk:
To support this functionality, a new variable `HAS_TESTS` is being added.
HAS_TESTS enables appropriate behavior with bsd.lib.mk and bsd.prog.mk, as
follows:
- Add "make check" as an available target from the directory.
- Pass down appropriate variables via ${TESTS_ENV}, i.e.,
${TESTS_LD_LIBRARY_PATH} and ${TESTS_PATH}.
One should add "HAS_TESTS" to directories containing tests in them, e.g. from
bin/sh/Makefile,
HAS_TESTS=
SUBDIR.${MK_TESTS}+= tests
HAS_TESTS doesn't automatically add the tests subdirectory for flexibility
reasons.
bsd.opts.mk, src.opts.mk:
- The knob ${MK_MAKE_CHECK_USE_SANDBOX} has been added, both to explicitly
direct (internally) when to set a deterministic ${DESTDIR} and to also allow
users to disable this behavior globally, i.e., via src.conf.
- MK_TESTS has been promoted from src.opts.mk to bsd.opts.mk to leverage
syntactic sugar for having MK_TESTS be a dependency for
MK_MAKE_CHECK_USE_SANDBOX, but to also ensure that src.opts.mk isn't required
to use suite.test.mk (which is a dependency of bsd.test.mk).
suite.test.mk:
- beforecheck behavior (when MK_MAKE_CHECK_USE_SANDBOX is enabled) is modified
from a no-op to:
-- Build.
-- Run "make hierarchy" on the sandbox dir.
-- Install the tests/files to the sandbox dir.
- aftercheck behavior (when MK_MAKE_CHECK_USE_SANDBOX is enabled) is modified
from a no-op to:
-- Remove the sandbox dir.
Again, because the dependency order set in bsd.test.mk is
beforecheck -> check -> aftercheck, "make check" will not be run unless
"beforecheck" completes successfully, and "aftercheck" will not be run unless
"beforecheck" and "check" complete successfully.
== Caveats ==
- This target must either be run with MK_INSTALL_AS_USER or as root. Otherwise
it will fail when running "make install" as the default user/group for many
makefiles when calling INSTALL is root/wheel.
- This target must be run from a suitable top-level directory. For example,
running tests from `tests/sys/fs/tmpfs` won't work, but `tests/sys/fs` will,
because `tests/sys/fs/tmpfs` relies on files installed by `tests/sys/fs`.
- Running MK_INSTALL_AS_USER may introduce determinism issues. However, using
it could identify deficiences in tests in terms of needing to be run as
root, which are not properly articulated in the test requirements.
- The doesn't negate the need for running "make installworld" and
"make checkworld", etc. Again, this just is intended to simplify the
dev->test->commit workflow.
== Cleanup done ==
- CHECKDIR is removed; one can use "MK_MAKE_CHECK_USE_SANDBOX=no" to enable
"legacy" (r295380) behavior.
MFC after: 2 months
Relnotes: yes (CHECKDIR removed; "make check" behavior changed)
Requested by: jhb
Reviewed by: arch (silence), testing (silence)
Differential Revision: D11905
2017-08-14 19:03:05 +00:00
|
|
|
.if defined(HAS_TESTS)
|
|
|
|
MAKE+= MK_MAKE_CHECK_USE_SANDBOX=yes
|
|
|
|
SUBDIR_TARGETS+= check
|
|
|
|
TESTS_LD_LIBRARY_PATH+= ${.OBJDIR}
|
|
|
|
TESTS_PATH+= ${.OBJDIR}
|
|
|
|
.endif
|
|
|
|
|
2016-02-24 17:19:05 +00:00
|
|
|
.if defined(PROG)
|
|
|
|
OBJS_DEPEND_GUESS+= ${SRCS:M*.h}
|
2016-03-02 21:03:42 +00:00
|
|
|
.endif
|
|
|
|
|
|
|
|
.include <bsd.dep.mk>
|
2016-02-26 22:14:00 +00:00
|
|
|
.include <bsd.clang-analyze.mk>
|
1996-06-24 04:26:21 +00:00
|
|
|
.include <bsd.obj.mk>
|
2001-05-19 23:18:21 +00:00
|
|
|
.include <bsd.sys.mk>
|