Skip to content

Commit

Permalink
build: provide a default WARNS for all in-tree builds
Browse files Browse the repository at this point in the history
The current default is provided in various Makefile.inc in some top-level
directories and covers a good portion of the tree, but doesn't cover parts
of the build a little deeper (e.g. libcasper).

Provide a default in src.sys.mk and set WARNS to it in bsd.sys.mk if that
variable is defined. This lets us relatively cleanly provide a default WARNS
no matter where you're building in the src tree without breaking things
outside of the tree.

Crunchgen has been updated as a bootstrap tool to work on this change
because it needs r365605 at a minimum to succeed. The cleanup necessary to
successfully walk over this change on WITHOUT_CLEAN builds has been added.

There is a supplemental project to this to list all of the warnings that are
encountered when the environment has WARNS=6 NO_WERROR=yes:
https://warns.kevans.dev -- this project will hopefully eventually go away
in favor of CI doing a much better job than it.

Reviewed by:	emaste, brooks, ngie (all earlier version)
Reviewed by:	emaste, arichardson (depend-cleanup.sh change)
Differential Revision:	https://reviews.freebsd.org/D26455
  • Loading branch information
kevans91 committed Sep 18, 2020
1 parent f9cc841 commit fe81533
Show file tree
Hide file tree
Showing 36 changed files with 62 additions and 22 deletions.
9 changes: 3 additions & 6 deletions Makefile.inc1
Original file line number Diff line number Diff line change
Expand Up @@ -2226,12 +2226,9 @@ _crunchide= usr.sbin/crunch/crunchide
_bootstrap_tools_links+=crunchide
.endif

# r285986 crunchen: use STRIPBIN rather than STRIP
# 1100113: Support MK_AUTO_OBJ
# 1200006: META_MODE fixes
.if ${BOOTSTRAPPING} < 1100078 || \
(${MK_AUTO_OBJ} == "yes" && ${BOOTSTRAPPING} < 1100114) || \
(${MK_META_MODE} == "yes" && ${BOOTSTRAPPING} < 1200006)
# 1300115: Higher WARNS fixes
.if ${BOOTSTRAPPING} < 1202502 || \
(${BOOTSTRAPPING} > 1300000 && ${BOOTSTRAPPING} < 1300115)
_crunchgen= usr.sbin/crunch/crunchgen
.else
_bootstrap_tools_links+=crunchgen
Expand Down
1 change: 0 additions & 1 deletion bin/Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
.include <src.opts.mk>

BINDIR?= /bin
WARNS?= 6

.if ${MK_DYNAMICROOT} == "no"
NO_SHARED?= YES
Expand Down
2 changes: 2 additions & 0 deletions gnu/lib/libregex/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ SHLIB_MAJOR= 5
REGEXDIR= ${SRCTOP}/contrib/libgnuregex
.PATH: ${REGEXDIR}

WARNS?= 1

SRCS= gnuregex.c
INCSGROUPS= INCS WRINCS PXINCS
INCS= regex.h.patched
Expand Down
2 changes: 2 additions & 0 deletions gnu/usr.bin/diff3/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ CFLAGS+=-I${SRCTOP}/contrib/diff/lib
CFLAGS+=-DHAVE_CONFIG_H
CFLAGS+=-DDEFAULT_DIFF_PROGRAM=\"/usr/bin/diff\"

WARNS?= 0

.for f in diff3.c
${f}: ${DIFFSRC}/${f} ${.CURDIR}/${f}.diff
patch -s -o ${.TARGET} < ${.CURDIR}/${f}.diff ${DIFFSRC}/${f}
Expand Down
2 changes: 2 additions & 0 deletions gnu/usr.bin/gdb/Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

.include <src.opts.mk>

WARNS?= 0

VERSION= "6.1.1 [FreeBSD]"
VENDOR= marcel

Expand Down
2 changes: 2 additions & 0 deletions gnu/usr.bin/grep/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ SRCS= closeout.c dfa.c error.c exclude.c grep.c grepmat.c hard-locale.c \
xstrtoumax.c
CLEANFILES+= gnugrep.1

WARNS?= 0

CFLAGS+=-I${.CURDIR} -I${SYSROOT:U${DESTDIR}}/usr/include/gnu -DHAVE_CONFIG_H

.if ${MK_BSD_GREP} != "yes"
Expand Down
2 changes: 0 additions & 2 deletions lib/Makefile.inc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# $FreeBSD$
# Default version for system libs (override in <lib>/Makefile if necessary)
SHLIB_MAJOR?= 5

WARNS?= 6
2 changes: 2 additions & 0 deletions lib/clang/Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ DEBUG_FILES_CFLAGS= -gline-tables-only
.else
DEBUG_FILES_CFLAGS= -g1
.endif

WARNS?= 0
2 changes: 2 additions & 0 deletions lib/libarchive/tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

PACKAGE= tests

WARNS?= 3

_LIBARCHIVEDIR= ${SRCTOP}/contrib/libarchive

ATF_TESTS_SH+= functional_test
Expand Down
1 change: 1 addition & 0 deletions lib/libc/tests/regex/Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
.include <bsd.own.mk>

BINDIR?= ${TESTSDIR}
WARNS?= 3

# SKIP_LEFTASSOC -> these testcases fail on FreeBSD.
IMPLEMENTATION?= -DREGEX_SPENCER -DSKIP_LEFTASSOC
Expand Down
2 changes: 0 additions & 2 deletions lib/libcasper/services/cap_dns/tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,4 @@ CFLAGS+=-DWITH_CASPER
.endif
LIBADD+= nv

WARNS?= 3

.include <bsd.test.mk>
2 changes: 0 additions & 2 deletions lib/libcasper/services/cap_grp/tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,4 @@ CFLAGS+=-DWITH_CASPER
.endif
LIBADD+= nv

WARNS?= 3

.include <bsd.test.mk>
2 changes: 0 additions & 2 deletions lib/libcasper/services/cap_pwd/tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,4 @@ CFLAGS+=-DWITH_CASPER
.endif
LIBADD+= nv

WARNS?= 3

.include <bsd.test.mk>
2 changes: 0 additions & 2 deletions lib/libcasper/services/cap_sysctl/tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ CFLAGS+=-DWITH_CASPER
.endif
LIBADD+= nv

WARNS?= 3

TEST_METADATA.sysctl_test+= required_user="root"

.include <bsd.test.mk>
2 changes: 2 additions & 0 deletions lib/libthr/tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

PACKAGE= tests

WARNS?= 3

TESTSRC= ${SRCTOP}/contrib/netbsd-tests/lib/libpthread

# TODO: t_name (missing pthread_getname_np support in FreeBSD)
Expand Down
2 changes: 2 additions & 0 deletions lib/libthr/tests/dlopen/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

TESTSRC= ${SRCTOP}/contrib/netbsd-tests/lib/libpthread/dlopen

WARNS?= 2

.include <bsd.own.mk>

TESTSDIR= ${TESTSBASE}/lib/libthr/dlopen
Expand Down
1 change: 1 addition & 0 deletions lib/libthr/tests/dlopen/dso/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# $FreeBSD$

TESTSRC= ${SRCTOP}/contrib/netbsd-tests/lib/libpthread/dlopen/dso
WARNS?= 3

SHLIB= h_pthread_dlopen
SHLIB_MAJOR= 1
Expand Down
2 changes: 2 additions & 0 deletions lib/libxo/tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

PACKAGE= tests

WARNS?= 1

LIBXOSRC= ${SRCTOP}/contrib/libxo

# Override the default suffix transformation rules for .c/.o -> .out
Expand Down
2 changes: 2 additions & 0 deletions lib/ofed/Makefile.inc
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# $FreeBSD$

WARNS?= 0
2 changes: 2 additions & 0 deletions rescue/librescue/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ INTERNALLIB= # Don't install this library
SRCS= exec.c getusershell.c login_class.c popen.c rcmdsh.c \
sysctl.c system.c

WARNS?= 3

CFLAGS+= -DRESCUE
# Flags copied from src/lib/libc and src/lib/libutil
# libc/db/Makefile.inc
Expand Down
1 change: 0 additions & 1 deletion sbin/Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
.include <src.opts.mk>

BINDIR?= /sbin
WARNS?= 6

.if ${MK_DYNAMICROOT} == "no"
NO_SHARED?= YES
Expand Down
2 changes: 2 additions & 0 deletions secure/lib/libcrypto/engines/Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ CFLAGS+= -DB_ENDIAN
CFLAGS+= -DNDEBUG

.PATH: ${LCRYPTO_SRC}/engines

WARNS?= 0
8 changes: 8 additions & 0 deletions share/mk/bsd.sys.mk
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ CFLAGS+= -std=${CSTD}
CXXFLAGS+= -std=${CXXSTD}
.endif

# This gives the Makefile we're evaluating at the top-level a chance to set
# WARNS. If it doesn't do so, we may freely pull a DEFAULTWARNS if it's set
# and use that. This allows us to default WARNS to 6 for src builds without
# needing to set the default in various Makefile.inc.
.if !defined(WARNS) && defined(DEFAULTWARNS)
WARNS= ${DEFAULTWARNS}
.endif

# -pedantic is problematic because it also imposes namespace restrictions
#CFLAGS+= -pedantic
.if defined(WARNS)
Expand Down
2 changes: 2 additions & 0 deletions share/mk/src.sys.mk
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ __postrcconf_${var}:= ${MK_${var}:U-}${WITHOUT_${var}:Uno:Dyes}${WITH_${var}:Uno
CFCOMMONFLAG?= -fno-common
CFLAGS+= ${CFCOMMONFLAG}

DEFAULTWARNS= 6

# tempting, but bsd.compiler.mk causes problems this early
# probably need to remove dependence on bsd.own.mk
#.include "src.opts.mk"
2 changes: 2 additions & 0 deletions tests/sys/cddl/zfs/bin/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ MAN=
BINDIR= ${TESTSBASE}/sys/cddl/zfs/bin
SCRIPTSDIR= ${TESTSBASE}/sys/cddl/zfs/bin

WARNS?= 0

SCRIPTS+= bsddisks.ksh
SCRIPTS+= dircmp.ksh
SCRIPTS+= dumpadm.ksh
Expand Down
3 changes: 3 additions & 0 deletions tests/sys/cddl/zfs/tests/Makefile.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# $FreeBSD$

WARNS?= 0
2 changes: 2 additions & 0 deletions tests/sys/geom/class/eli/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

PACKAGE= tests

WARNS?= 3

TESTSDIR= ${TESTSBASE}/sys/geom/class/${.CURDIR:T}

ATF_TESTS_C= pbkdf2_test
Expand Down
1 change: 1 addition & 0 deletions tests/sys/net/routing/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# $FreeBSD$

PACKAGE= tests
WARNS?= 1

TESTSDIR= ${TESTSBASE}/sys/net/routing

Expand Down
7 changes: 7 additions & 0 deletions tools/build/depend-cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,10 @@ if [ -e "$OBJTOP"/cddl/lib/libzfs/.depend.libzfs_changelist.o ] && \
echo "Removing old ZFS tree"
rm -rf "$OBJTOP"/cddl "$OBJTOP"/obj-lib32/cddl
fi

# 20200916 WARNS bumped, need bootstrapped crunchgen stubs
if [ -e "$OBJTOP"/rescue/rescue/rescue.c ] && \
! grep -q 'crunched_stub_t' "$OBJTOP"/rescue/rescue/rescue.c; then
echo "Removing old rescue(8) tree"
rm -rf "$OBJTOP"/rescue/rescue
fi
2 changes: 0 additions & 2 deletions usr.bin/Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,3 @@
# $FreeBSD$

BINDIR?= /usr/bin

WARNS?= 6
1 change: 1 addition & 0 deletions usr.bin/ofed/infiniband-diags/Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ CFLAGS+= -DHAVE_CONFIG_H=1
CFLAGS+= -I${_spath} -I${_spath}/src
LIBADD+= osmcomp ibmad ibumad

WARNS?= 0
1 change: 1 addition & 0 deletions usr.bin/ofed/libibverbs/Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ BINDIR?= /usr/bin
CFLAGS+= -I${_spath}
LIBADD+= ibverbs mlx4 mlx5 cxgb4 pthread

WARNS?= 2
2 changes: 2 additions & 0 deletions usr.bin/ofed/librdmacm/Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ _spath=${SRCTOP}/contrib/ofed/librdmacm
BINDIR?= /usr/bin
CFLAGS+= -I${SRCTOP}/contrib/ofed
LIBADD+= ibverbs rdmacm mlx4 mlx5 cxgb4 pthread

WARNS?= 0
2 changes: 2 additions & 0 deletions usr.bin/tar/tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

PACKAGE= tests

WARNS?= 3

_LIBARCHIVEDIR= ${SRCTOP}/contrib/libarchive

ATF_TESTS_SH+= functional_test
Expand Down
2 changes: 0 additions & 2 deletions usr.sbin/Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,3 @@
# $FreeBSD$

BINDIR?= /usr/sbin

WARNS?= 6
2 changes: 2 additions & 0 deletions usr.sbin/wpa/Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

BINDIR?= /usr/sbin

WARNS?= 0

WPA_DISTDIR?= ${SRCTOP}/contrib/wpa/
WPA_SUPPLICANT_DISTDIR?=${WPA_DISTDIR}/wpa_supplicant
HOSTAPD_DISTDIR?= ${WPA_DISTDIR}/hostapd
Expand Down

0 comments on commit fe81533

Please sign in to comment.