lint: repurpose the '-d' option to specify DESTDIR

Previously, passing '-nostdinc -isystem $dir' only searched the given
directory but not any compiler-specific directories.

Discovered by fontconfig, which includes <stdatomic.h> from C11, which
lives in /usr/include/gcc-10 instead of /usr/include.

Change the preprocessor options to '--sysroot' instead, to align them
with how the compiler is invoked using build.sh.
This commit is contained in:
rillig 2023-01-22 15:20:01 +00:00
parent 750e84418f
commit e928d09a9d
3 changed files with 10 additions and 11 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: bsd.sys.mk,v 1.311 2023/01/06 15:48:29 christos Exp $ # $NetBSD: bsd.sys.mk,v 1.312 2023/01/22 15:20:01 rillig Exp $
# #
# Build definitions used for NetBSD source tree builds. # Build definitions used for NetBSD source tree builds.
@ -163,7 +163,7 @@ CWARNFLAGS+= ${CWARNFLAGS.${ACTIVE_CC}}
CPPFLAGS+= ${AUDIT:D-D__AUDIT__} CPPFLAGS+= ${AUDIT:D-D__AUDIT__}
_NOWERROR= ${defined(NOGCCERROR) || (${ACTIVE_CC} == "clang" && defined(NOCLANGERROR)):?yes:no} _NOWERROR= ${defined(NOGCCERROR) || (${ACTIVE_CC} == "clang" && defined(NOCLANGERROR)):?yes:no}
CFLAGS+= ${${_NOWERROR} == "no" :?-Werror:} ${CWARNFLAGS} CFLAGS+= ${${_NOWERROR} == "no" :?-Werror:} ${CWARNFLAGS}
LINTFLAGS+= ${DESTDIR:D-d ${DESTDIR}/usr/include} LINTFLAGS+= ${DESTDIR:D-d ${DESTDIR}}
.if !defined(NOSSP) && (${USE_SSP:Uno} != "no") && (${BINDIR:Ux} != "/usr/mdec") .if !defined(NOSSP) && (${USE_SSP:Uno} != "no") && (${BINDIR:Ux} != "/usr/mdec")
. if !defined(KERNSRCDIR) && !defined(KERN) # not for kernels / kern modules . if !defined(KERNSRCDIR) && !defined(KERN) # not for kernels / kern modules

View File

@ -1,4 +1,4 @@
.\" $NetBSD: lint.1,v 1.55 2022/10/01 09:42:40 rillig Exp $ .\" $NetBSD: lint.1,v 1.56 2023/01/22 15:20:01 rillig Exp $
.\" .\"
.\" Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. .\" Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
.\" Copyright (c) 1994, 1995 Jochen Pohl .\" Copyright (c) 1994, 1995 Jochen Pohl
@ -30,7 +30,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\" .\"
.Dd July 5, 2022 .Dd January 21, 2023
.Dt LINT 1 .Dt LINT 1
.Os .Os
.Sh NAME .Sh NAME
@ -239,9 +239,9 @@ is defined as 1.
.It Fl d Ns Ar directory .It Fl d Ns Ar directory
Use Use
.Ar directory .Ar directory
instead of as the root directory
.Pa /usr/include .Pq Va DESTDIR
as the default place to find include files. to find include files.
.It Fl e .It Fl e
Complain about unusual operations on Complain about unusual operations on
.Sy enum .Sy enum

View File

@ -1,4 +1,4 @@
/* $NetBSD: xlint.c,v 1.107 2023/01/21 11:29:30 rillig Exp $ */ /* $NetBSD: xlint.c,v 1.108 2023/01/22 15:20:01 rillig Exp $ */
/* /*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@ -38,7 +38,7 @@
#include <sys/cdefs.h> #include <sys/cdefs.h>
#if defined(__RCSID) #if defined(__RCSID)
__RCSID("$NetBSD: xlint.c,v 1.107 2023/01/21 11:29:30 rillig Exp $"); __RCSID("$NetBSD: xlint.c,v 1.108 2023/01/22 15:20:01 rillig Exp $");
#endif #endif
#include <sys/param.h> #include <sys/param.h>
@ -512,8 +512,7 @@ main(int argc, char *argv[])
if (dflag) if (dflag)
usage("%c flag already specified", 'd'); usage("%c flag already specified", 'd');
dflag = true; dflag = true;
list_add(&cpp.flags, "-nostdinc"); list_add(&cpp.flags, "--sysroot");
list_add(&cpp.flags, "-isystem");
list_add(&cpp.flags, optarg); list_add(&cpp.flags, optarg);
break; break;