NetBSD Problem Report #55174

From www@netbsd.org  Tue Apr 14 00:41:28 2020
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 86EE71A9219
	for <gnats-bugs@gnats.NetBSD.org>; Tue, 14 Apr 2020 00:41:28 +0000 (UTC)
Message-Id: <20200414004127.4172F1A924B@mollari.NetBSD.org>
Date: Tue, 14 Apr 2020 00:41:27 +0000 (UTC)
From: joaopaulo1511@hotmail.com
Reply-To: joaopaulo1511@hotmail.com
To: gnats-bugs@NetBSD.org
Subject: build.sh has trouble with CFLAGS on /etc/mk.conf if it was used "+=" instead of "="
X-Send-Pr-Version: www-1.0

>Number:         55174
>Category:       toolchain
>Synopsis:       build.sh has trouble with CFLAGS on /etc/mk.conf if it was used "+=" instead of "="
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    toolchain-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Apr 14 00:45:00 +0000 2020
>Last-Modified:  Tue Apr 14 15:25:01 +0000 2020
>Originator:     Joćo Paulo Vinha Bittar
>Release:        9.0
>Organization:
home user
>Environment:
NetBSD localhost 9.0 NetBSD 9.0 (GENERIC) #0: Fri Feb 14 00:06:28 UTC 2020 mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/i386/compile/GENERIC i386
>Description:
The build.sh does not accept compiler flags lines with "+="  /etc/mk.conf, only lines with "=".

One can add, for example, "CFLAGS+=-O2" because there are instructions to use "+=" so to not get "problems with packages that need to add their own flags" (http://www.netbsd.org/docs/pkgsrc/configuring.html#conf.cflags), but then it breaks build.sh which accepts only "=" on the compiler flags (in this example, it would be "CFLAGS=-O2").
>How-To-Repeat:
1) Create the /etc/mk.conf if it does not exist and add the following line:

CFLAGS+="-O2 -pipe"

2) Run "/usr/src/build.sh -U -O ~/OBJ -x release" (without quotes) to build NetBSD and X.org without having root privileges.

3) Wait a little bit, so the tools are built correctly;

4) After the tools are built, the actual building of NetBSD and X suddenly stops.
>Fix:
The only workaround I know is to change the compiler flags on /etc/mk.conf to use only "=" instead of "+=" before running /usr/src/build.sh.

It would be nice if, until build.sh is fixed, to add a warning to the NetBSD Guide, Chapter 31 (http://netbsd.org/docs/guide/en/chap-build.html), so we know that using "+=" instead of "=" as it was told on http://www.netbsd.org/docs/pkgsrc/configuring.html#conf.cflags will break the build.sh.  The page at http://www.netbsd.org/docs/pkgsrc/configuring.html#conf.cflags should also note that using "+=" will break build.sh.  Other places, as man pages or the default output of build.sh without arguments could also warn about using only "=" on /etc/mk.conf.

>Audit-Trail:
From: Valery Ushakov <uwe@stderr.spb.ru>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: toolchain/55174: build.sh has trouble with CFLAGS on
 /etc/mk.conf if it was used "+=" instead of "="
Date: Tue, 14 Apr 2020 15:29:10 +0300

 The netbsd guide and pkgsrc guide should tell to protect pkg-related
 settings with proper ifdefs.  I was pretty sure this is documented,
 but apparetnly it's not and is only in the lore.

 # /etc/mk.conf example
 .ifndef BSD_PKG_MK

 .if "${MACHINE_ARCH}" == "foo"
 CPUFLAGS = -mfancy-thing
 ...
 .endif

 .if "${MACHINE_ARCH}" == "bar"
 DBG = -Os
 ...
 .endif

 .else # pkgsrc

 PAPERSIZE=A4

 PKG_DEFAULT_OPTIONS = -doc

 PKG_OPTIONS.emacs = xaw
 PKG_OPTIONS.emacs += -dbus
 ...

 ACCEPTABLE_LICENSES+= free-as-in-beer
 ...

 .endif # pkgsrc

 -uwe

From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: toolchain/55174: build.sh has trouble with CFLAGS on
 /etc/mk.conf if it was used "+=" instead of "="
Date: Tue, 14 Apr 2020 17:20:19 +0200

 On Tue, Apr 14, 2020 at 12:30:03PM +0000, Valery Ushakov wrote:
 >  The netbsd guide and pkgsrc guide should tell to protect pkg-related
 >  settings with proper ifdefs.  I was pretty sure this is documented,
 >  but apparetnly it's not and is only in the lore.

 Also the example should be changed - blindly forcing specific optimization
 flags is a bad idea in general.

 Forcing -pipe is ok, here is a working example:

 .if !defined(_ETC_MK_PIPE_DONE)
 _ETC_MK_PIPE_DONE=1
 CFLAGS += -pipe
 .endif

 The duplicate protection is needed due to make lazy variable expansion
 and resulting dependency loops (but I forgot the details).

 Martin

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.