From owner-dev-commits-src-main@freebsd.org Thu Jan 7 11:05:55 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C862D4CCB77; Thu, 7 Jan 2021 11:05:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DBNh35Hm8z4tQ2; Thu, 7 Jan 2021 11:05:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A6E8C7F81; Thu, 7 Jan 2021 11:05:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 107B5tEw011308; Thu, 7 Jan 2021 11:05:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 107B5tPe011307; Thu, 7 Jan 2021 11:05:55 GMT (envelope-from git) Date: Thu, 7 Jan 2021 11:05:55 GMT Message-Id: <202101071105.107B5tPe011307@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alex Richardson Subject: git: 4e64fb9f4901 - main - Fix warnings during bootstrap on Linux systems MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arichardson X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4e64fb9f4901e99ce02f13d45f370e75d53075a6 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Jan 2021 11:05:55 -0000 The branch main has been updated by arichardson: URL: https://cgit.FreeBSD.org/src/commit/?id=4e64fb9f4901e99ce02f13d45f370e75d53075a6 commit 4e64fb9f4901e99ce02f13d45f370e75d53075a6 Author: Alex Richardson AuthorDate: 2020-12-14 10:52:15 +0000 Commit: Alex Richardson CommitDate: 2021-01-07 09:30:50 +0000 Fix warnings during bootstrap on Linux systems Most warnings are currently off for the boostrap phase, but once D27598 lands they will be enabled again. --- tools/build/Makefile | 2 ++ tools/build/cross-build/capsicum_stubs.c | 7 +++-- tools/build/cross-build/fake_sysctl.c | 6 ++-- .../{include/linux/sys/sysctl.h => fflags.c} | 34 +++++++++++++++++----- tools/build/cross-build/include/common/grp.h | 2 +- tools/build/cross-build/include/common/pwd.h | 2 +- tools/build/cross-build/include/common/sys/cdefs.h | 24 --------------- tools/build/cross-build/include/common/sys/param.h | 26 +++++++++++++++++ tools/build/cross-build/include/common/unistd.h | 2 +- tools/build/cross-build/include/linux/limits.h | 4 --- tools/build/cross-build/include/linux/unistd.h | 22 ++------------ tools/build/mk/Makefile.boot | 7 ++++- 12 files changed, 74 insertions(+), 64 deletions(-) diff --git a/tools/build/Makefile b/tools/build/Makefile index ee9d9692df3b..28257a2ea2e5 100644 --- a/tools/build/Makefile +++ b/tools/build/Makefile @@ -174,6 +174,8 @@ CFLAGS.closefrom.c+= -DSTDC_HEADERS -DHAVE_SYS_DIR_H -DHAVE_DIRENT_H \ -DHAVE_DIRFD -DHAVE_SYSCONF # Provide warnc/errc/getprogname/setprograme SRCS+= err.c progname.c +# Stub implementations of fflagstostr/strtofflags +SRCS+= fflags.c .endif # Provide the same arc4random implementation on Linux/macOS CFLAGS.arc4random.c+= -I${SRCTOP}/sys/crypto/chacha20 -D__isthreaded=1 diff --git a/tools/build/cross-build/capsicum_stubs.c b/tools/build/cross-build/capsicum_stubs.c index b042796c069f..227ef3496b09 100644 --- a/tools/build/cross-build/capsicum_stubs.c +++ b/tools/build/cross-build/capsicum_stubs.c @@ -42,19 +42,20 @@ __FBSDID("$FreeBSD$"); #include int -cap_ioctls_limit(int fd, const cap_ioctl_t *cmds, size_t ncmds) +cap_ioctls_limit(int fd __unused, const cap_ioctl_t *cmds __unused, + size_t ncmds __unused) { return 0; /* Just pretend that it succeeded */ } int -cap_fcntls_limit(int fd, uint32_t fcntlrights) +cap_fcntls_limit(int fd __unused, uint32_t fcntlrights __unused) { return 0; /* Just pretend that it succeeded */ } int -cap_rights_limit(int fd, const cap_rights_t *rights) +cap_rights_limit(int fd __unused, const cap_rights_t *rights __unused) { return 0; /* Just pretend that it succeeded */ } diff --git a/tools/build/cross-build/fake_sysctl.c b/tools/build/cross-build/fake_sysctl.c index 7b9524e1626b..289fb83652f6 100644 --- a/tools/build/cross-build/fake_sysctl.c +++ b/tools/build/cross-build/fake_sysctl.c @@ -37,13 +37,15 @@ #include __FBSDID("$FreeBSD$"); +#include + #include #include #include int -__freebsd_sysctlbyname( - const char *name, void *oldp, size_t *oldlenp, void *newp, size_t newlen) +__freebsd_sysctlbyname(const char *name, void *oldp, size_t *oldlenp, + const void *newp, size_t newlen) { if (strcmp(name, "kern.vm_guest") == 0) { if (!oldp || !oldlenp) diff --git a/tools/build/cross-build/include/linux/sys/sysctl.h b/tools/build/cross-build/fflags.c similarity index 76% rename from tools/build/cross-build/include/linux/sys/sysctl.h rename to tools/build/cross-build/fflags.c index d24a85b4a266..f1d23c3637b6 100644 --- a/tools/build/cross-build/include/linux/sys/sysctl.h +++ b/tools/build/cross-build/fflags.c @@ -12,6 +12,9 @@ * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) * ("CTSRD"), as part of the DARPA CRASH research programme. * + * This work was supported by Innovate UK project 105694, "Digital Security by + * Design (DSbD) Technology Platform Prototype". + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -32,11 +35,28 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ -#pragma once -/* The Linux sysctl struct has a member called __unused */ -#undef __unused -#include_next -#define __unused __attribute__((unused)) + +#include +#include + +char * +fflagstostr(u_long flags __unused) +{ + return strdup(""); +} + +int +strtofflags(char **stringp __unused, u_long *setp, u_long *clrp) +{ + /* On linux just ignore the file flags for now */ + /* + * XXX: this will prevent makefs from setting noschg on libc, etc. + * so we should really find a way to support flags in disk images. + */ + if (setp) + *setp = 0; + if (clrp) + *clrp = 0; + return (0); /* success */ +} diff --git a/tools/build/cross-build/include/common/grp.h b/tools/build/cross-build/include/common/grp.h index add44b9f8695..08a8bc540569 100644 --- a/tools/build/cross-build/include/common/grp.h +++ b/tools/build/cross-build/include/common/grp.h @@ -53,7 +53,7 @@ const char *group_from_gid(gid_t gid, int noname); #ifdef __linux__ static inline int -setgroupent(int stayopen) +setgroupent(int stayopen __unused) { setgrent(); return (1); diff --git a/tools/build/cross-build/include/common/pwd.h b/tools/build/cross-build/include/common/pwd.h index 243da3a1332f..e167fe47701f 100644 --- a/tools/build/cross-build/include/common/pwd.h +++ b/tools/build/cross-build/include/common/pwd.h @@ -52,7 +52,7 @@ const char *user_from_uid(uid_t uid, int noname); #ifdef __linux__ static inline int -setpassent(int stayopen) +setpassent(int stayopen __unused) { setpwent(); return (1); diff --git a/tools/build/cross-build/include/common/sys/cdefs.h b/tools/build/cross-build/include/common/sys/cdefs.h index c86369ab778a..c129542b6180 100644 --- a/tools/build/cross-build/include/common/sys/cdefs.h +++ b/tools/build/cross-build/include/common/sys/cdefs.h @@ -59,15 +59,6 @@ #define __IDSTRING(name, string) #endif -#ifndef rounddown -#define rounddown(x, y) (((x) / (y)) * (y)) -#define rounddown2(x, y) ((x) & (~((y)-1))) /* if y is power of two */ -#define roundup(x, y) ((((x) + ((y)-1)) / (y)) * (y)) /* to any y */ -#define roundup2(x, y) \ - (((x) + ((y)-1)) & (~((y)-1))) /* if y is powers of two */ -#define powerof2(x) ((((x)-1) & (x)) == 0) -#endif - #ifndef __pure #define __pure __attribute__((__pure__)) #endif @@ -145,12 +136,6 @@ #define __malloc_like __attribute__((__malloc__)) #endif -#ifndef nitems -// https://stackoverflow.com/questions/1598773/is-there-a-standard-function-in-c-that-would-return-the-length-of-an-array/1598827#1598827 -#define nitems(x) \ - ((sizeof(x) / sizeof(0 [x])) / ((size_t)(!(sizeof(x) % sizeof(0 [x]))))) -#endif - #ifndef __min_size #if !defined(__cplusplus) #define __min_size(x) static(x) @@ -181,15 +166,6 @@ #define __printf0__ __printf__ #endif -/* - * These should probably be in sys/types.h but mtree expects them to exist - * without including - */ -typedef unsigned char u_char; -typedef unsigned short u_short; -typedef unsigned int u_int; -typedef unsigned long u_long; - /* On MacOS __CONCAT is defined as x ## y, which won't expand macros */ #undef __CONCAT #define __CONCAT1(x, y) x##y diff --git a/tools/build/cross-build/include/common/sys/param.h b/tools/build/cross-build/include/common/sys/param.h index a197fe3ea9ff..f672b1067d46 100644 --- a/tools/build/cross-build/include/common/sys/param.h +++ b/tools/build/cross-build/include/common/sys/param.h @@ -12,6 +12,9 @@ * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) * ("CTSRD"), as part of the DARPA CRASH research programme. * + * This work was supported by Innovate UK project 105694, "Digital Security by + * Design (DSbD) Technology Platform Prototype". + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -63,3 +66,26 @@ #ifndef __PAST_END #define __PAST_END(array, offset) (((__typeof__(*(array)) *)(array))[offset]) #endif + +#ifndef nitems +// https://stackoverflow.com/questions/1598773/is-there-a-standard-function-in-c-that-would-return-the-length-of-an-array/1598827#1598827 +#define nitems(x) \ + ((sizeof(x) / sizeof(0 [x])) / ((size_t)(!(sizeof(x) % sizeof(0 [x]))))) +#endif + +#ifndef rounddown +#define rounddown(x, y) (((x) / (y)) * (y)) +#endif +#ifndef rounddown2 +#define rounddown2(x, y) ((x) & (~((y)-1))) /* if y is power of two */ +#endif +#ifndef roundup +#define roundup(x, y) ((((x) + ((y)-1)) / (y)) * (y)) /* to any y */ +#endif +#ifndef roundup2 +#define roundup2(x, y) \ + (((x) + ((y)-1)) & (~((y)-1))) /* if y is powers of two */ +#endif +#ifndef powerof2 +#define powerof2(x) ((((x)-1) & (x)) == 0) +#endif diff --git a/tools/build/cross-build/include/common/unistd.h b/tools/build/cross-build/include/common/unistd.h index f438b8936105..593dd700f140 100644 --- a/tools/build/cross-build/include/common/unistd.h +++ b/tools/build/cross-build/include/common/unistd.h @@ -40,7 +40,7 @@ #include static inline int -check_utility_compat(const char *utility) +check_utility_compat(const char *utility __unused) { /* * The check_utility_compat() function returns zero if utility should diff --git a/tools/build/cross-build/include/linux/limits.h b/tools/build/cross-build/include/linux/limits.h index 98523fe0d7a3..833b49b49348 100644 --- a/tools/build/cross-build/include/linux/limits.h +++ b/tools/build/cross-build/include/linux/limits.h @@ -39,10 +39,6 @@ #include_next #endif -#ifdef __STRICT_ANSI__ -#warning __STRICT_ANSI__ defined -#endif - #if __has_include() #include #endif diff --git a/tools/build/cross-build/include/linux/unistd.h b/tools/build/cross-build/include/linux/unistd.h index 0a6b6296a9de..9d1bd1bf4025 100644 --- a/tools/build/cross-build/include/linux/unistd.h +++ b/tools/build/cross-build/include/linux/unistd.h @@ -62,26 +62,8 @@ issetugid(void) } #endif -static inline char * -fflagstostr(u_long flags) -{ - return strdup(""); -} - -static inline int -strtofflags(char **stringp, u_long *setp, u_long *clrp) -{ - /* On linux just ignore the file flags for now */ - /* - * XXXAR: this will prevent makefs from setting noschg on libc, etc - * so we should really build the version from libc - */ - if (setp) - *setp = 0; - if (clrp) - *clrp = 0; - return (0); /* success */ -} +char *fflagstostr(unsigned long flags); +int strtofflags(char **stringp, u_long *setp, u_long *clrp); /* * getentropy() was added in glibc 2.25. Declare it for !glibc and older diff --git a/tools/build/mk/Makefile.boot b/tools/build/mk/Makefile.boot index ada14e6112f4..4adc04b0ea9a 100644 --- a/tools/build/mk/Makefile.boot +++ b/tools/build/mk/Makefile.boot @@ -45,6 +45,11 @@ CFLAGS+= -Werror=implicit-function-declaration -Werror=implicit-int \ -Werror=return-type -Wundef CFLAGS+= -DHAVE_NBTOOL_CONFIG_H=1 CFLAGS+= -I${SRCTOP}/tools/build/cross-build/include/common +# This is needed for code that compiles for pre-C11 C standards +CWARNFLAGS+= -Wno-typedef-redefinition +# bsd.sys.mk explicitly turns on -Wsystem-headers, but that's extremely +# noisy when building on Linux. +CWARNFLAGS+= -Wno-system-headers # b64_pton and b64_ntop is in libresolv on MacOS and Linux: # TODO: only needed for uuencode and uudecode @@ -52,7 +57,7 @@ LDADD+=-lresolv .if ${.MAKE.OS} == "Linux" CFLAGS+= -I${SRCTOP}/tools/build/cross-build/include/linux -CFLAGS+= -std=gnu99 -D_GNU_SOURCE=1 +CFLAGS+= -D_GNU_SOURCE=1 # Needed for sem_init, etc. on Linux (used by usr.bin/sort) LDADD+= -pthread