NetBSD Problem Report #49535
From gson@gson.org Sun Jan 4 14:28:04 2015
Return-Path: <gson@gson.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
by mollari.NetBSD.org (Postfix) with ESMTPS id 0A96DA6555
for <gnats-bugs@gnats.NetBSD.org>; Sun, 4 Jan 2015 14:28:04 +0000 (UTC)
Message-Id: <20150104142754.0C602744197@guava.gson.org>
Date: Sun, 4 Jan 2015 16:27:53 +0200 (EET)
From: gson@gson.org (Andreas Gustafsson)
Reply-To: gson@gson.org (Andreas Gustafsson)
To: gnats-bugs@gnats.NetBSD.org
Subject: Examples in BUILDING don't work as-is
X-Send-Pr-Version: 3.95
>Number: 49535
>Category: toolchain
>Synopsis: Examples in BUILDING don't work as-is
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: toolchain-manager
>State: open
>Class: doc-bug
>Submitter-Id: net
>Arrival-Date: Sun Jan 04 14:30:00 +0000 2015
>Last-Modified: Sun Jan 04 15:25:01 +0000 2015
>Originator: Andreas Gustafsson
>Release: NetBSD-current, souce date 2014.12.17.06.54.48
>Organization:
>Environment:
System: NetBSD
Architecture: x86_64
Machine: amd64
>Description:
If you do a full installation of NetBSD using sysinst, including the
source sets, cd to /usr/src, read the BUILDING file, and try to run
the first example listed under EXAMPLES,
1. % ./build.sh [options] tools kernel=GENERIC
as an unprivileged user without specifying any options, i.e.,
$ ./build.sh tools kernel=GENERIC
the build will fail with:
ERROR: -U or -E must be set for build as an unprivileged use
If you do it as root, it fails with:
ERROR: Can't create top level object directory using make obj
I think having an example that works as-is would be helpful,
particularly to new users.
>How-To-Repeat:
See above.
>Fix:
First of all, presumably the shell prompt in Example 1 should be
changed from "%" to "#" to indicate that the command is to be run as
root, because unprivileged builds are covered separately in example
number 2.
As for the lack of a /usr/obj, there are many ways that could be
fixed, but I have no idea which one is correct. I can think of
at least four:
1. If /usr/obj is supposed to exist in a fresh install, it should be
added to the release.
2. If you are supposed to specify a -O or -M option to build.sh to
force the object directory to be created, the example should contain
such an option.
3. If you are supposed to manually mkdir /usr/obj, the example should
include that command.
4. If build.sh is supposed to create the object directory
automatically, it should be changed to do so.
>Audit-Trail:
From: Alan Barrett <apb@cequrux.com>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: toolchain/49535: Examples in BUILDING don't work as-is
Date: Sun, 4 Jan 2015 16:59:12 +0200
On Sun, 04 Jan 2015, Andreas Gustafsson wrote:
> 1. % ./build.sh [options] tools kernel=GENERIC
>>Fix:
>
>First of all, presumably the shell prompt in Example 1 should be
>changed from "%" to "#" to indicate that the command is to be run as
>root, because unprivileged builds are covered separately in example
>number 2.
No, let's rather add "-U" to the example. We should not encourage
builds as root.
>As for the lack of a /usr/obj, there are many ways that could be
>fixed, but I have no idea which one is correct. I can think of
>at least four:
>
>1. If /usr/obj is supposed to exist in a fresh install, it should be
>added to the release.
>
>2. If you are supposed to specify a -O or -M option to build.sh to
>force the object directory to be created, the example should contain
>such an option.
>
>3. If you are supposed to manually mkdir /usr/obj, the example should
>include that command.
>
>4. If build.sh is supposed to create the object directory
>automatically, it should be changed to do so.
build.sh does attempt to create the top-level object directory.
See this code:
1693 if [ -n "$TOP_obj" ]; then
1694 ${runcmd} mkdir -p "${TOP_obj}" ||
1695 bomb "Can't create top level object directory" \
1696 "${TOP_obj}"
1697 else
1698 ${runcmd} "${make}" -m ${TOP}/share/mk obj NOSUBDIR= ||
1699 bomb "Can't create top level object directory" \
1700 "using make obj"
1701 fi
There are many ways to choose the object directory name, using
various combinations of environment variables, mk.conf settings,
build.sh command line options, bsd.obj.mk rules, and built-in
defaults in make itself. build.sh attempts to follow the same
rules that would be used if you ran make directly, but the rules
are so complex that it could make a mistake in some cases.
The error message you saw "Can't create ... using make obj"
appears only if build.sh's attempts to guess the correct directoy
name are unsuccessful (the $TOP_obj variable is not set), and
make(1) is also unable to create the directory.
In this case, the src directory was /usr/src, and you expected the obj
directory to be /usr/obj, but build.sh did not make that guess. I have
no idea why "make -m /usr/src/share/mk obj NOSUBDIR=" was unable to
create the directory. Let's try to figure that out first.
--apb (Alan Barrett)
From: Andreas Gustafsson <gson@gson.org>
To: apb@cequrux.com
Cc: gnats-bugs@NetBSD.org
Subject: Re: toolchain/49535: Examples in BUILDING don't work as-is
Date: Sun, 4 Jan 2015 17:21:12 +0200
Alan Barrett wrote:
> No, let's rather add "-U" to the example. We should not encourage
> builds as root.
If we do that, we should also specify an explicit object directory in
the example, because /usr/obj will not be writable by an unprivileged
user.
> In this case, the src directory was /usr/src, and you expected the obj
> directory to be /usr/obj, but build.sh did not make that guess. I have
> no idea why "make -m /usr/src/share/mk obj NOSUBDIR=" was unable to
> create the directory. Let's try to figure that out first.
This is what I get if I run it manually:
# make -m /usr/src/share/mk obj NOSUBDIR=
BSDOBJDIR /usr/obj does not exist, bailing...
*** Error code 1
--
Andreas Gustafsson, gson@gson.org
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.