Re: building 9.1 kernel with /usr/src elsewhere?

2023-03-08 Thread Mouse
>> Does it make a difference if you set
>> NETBSDSRCDIR=/home/abcxyz/netbsd-9.1/usr/src when you run make?
> Yes, that appears to make the symptom go away.

Also, I can reproduce the problem by setting
NETBSDSRCDIR=/infibulated/gonkulator when running make depend even with
a source tree in /usr/src.

Is this enough of a bug that it's worth sending-pr?  Or is this a case
of me expecting something that's no longer supported to work?

/~\ The ASCII Mouse
\ / Ribbon Campaign
 X  Against HTMLmo...@rodents-montreal.org
/ \ Email!   7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B


Re: building 9.1 kernel with /usr/src elsewhere?

2023-03-08 Thread Taylor R Campbell
> Date: Wed, 8 Mar 2023 08:58:47 -0500 (EST)
> From: Mouse 
> 
> Ugh, I hate using build.sh for small things like individual kernels.
> It always (well, far too often, at least) insists on rebuilding make,
> which takes significant time on some machines, like my shark, and
> requires extra writable filesystem space.  If there's a reasonably easy
> way to avoid it, I prefer to.

You could just cross-build on a modern machine for your shark...

> I don't squawk much about build.sh because it does bring benefits; the
> biggest one I notice is probably painless cross-compiles.  But I'd
> never run into this price before.  5.2 doesn't exhibit the misbehaviour
> at all, so I couldn't've noticed it except at work, and I think I've
> never tried to build a kernel without /usr/src in place before (at work
> or not).
> [...]
> > The problem is that NETBSDSRCDIR cannot be inferred for a randomly
> > located kernel builddir and sys/lib/libkern/Makefile.compiler-rt uses
> > it.
> 
> In that case, maybe config(1) should write a suitable setting of
> NETBSDSRCDIR into the Makefile it generates?  At least when -s is given
> with an absolute path?

It does put `S=/path/to/src/sys' into the kernel makefile, and _most_
of the kernel makefiles are written to use paths relative to $S, but
it looks like some ${NETBSDSRCDIR} has crept in between 5.2 and 9.1.

It probably wouldn't be wrong to make them use $S instead of
${NETBSDSRCDIR}, but you might be the first person to be affected by
this in years.


Re: building 9.1 kernel with /usr/src elsewhere?

2023-03-08 Thread Mouse
Omnibus reply here.  Thank you, everyone; I have a better understanding
of the actual problem (admittedly that's a low bar, given how little I
understood it before) and two different workarounds.

[Brian Buhrow]

> hello.  I regularly build kernels outside of the /usr/src location.

But does /usr/src exist at the time?

> My technique is to install the source in some location:
> /usr/local/netbsd/src-91, for example, then put my configuration file
> in: /usr/local/netbsd/src-91/sys/arch//conf/
> Then
> cd /usr/local/netbsd/src-91/sys/arch//conf
> config 
> cd ../compile/
> make -j 4 >& make.log

I'd prefer to avoid assuming the user who wants to build the kernel can
write into the source directory tree.  You may note the source tree was
(admittedly only by implication) owned by abcxyz but I was doing the
build as mouse.

That said, this does appear to work.  (Well, I didn't use -j, but then,
I practically never do, and the machine I'm doing this on is
single-core.)  I didn't wait for the whole build, but it doesn't fail
fast the way the run that prompted my mail did.

[Taylor R Campbell]

> Does it make a difference if you set
> NETBSDSRCDIR=/home/abcxyz/netbsd-9.1/usr/src when you run make?

Yes, that appears to make the symptom go away.  (I probably would not
have stumbled across that; /usr/src/BUILDING mentions NETBSDSRCDIR only
twice, neither time documenting it, only mentioning it in examples.  It
likely would have taken enough digging to locate the actual culprit for
me to discover it.  But still, it does seem to work.)

> I always build out of my home directory, never /usr/src, but I also
> always use build.sh and the make wrapper it creates [...]

Ugh, I hate using build.sh for small things like individual kernels.
It always (well, far too often, at least) insists on rebuilding make,
which takes significant time on some machines, like my shark, and
requires extra writable filesystem space.  If there's a reasonably easy
way to avoid it, I prefer to.

That said, if NetBSD wants to desupport building even kernels without
using build.sh, that's its choice; what I think of it does't matter.
(But I do think that, in that case, config(1) should be documented as
an internal tool, not intended for use other than by build.sh.)

[Johnny Billquist]

> You should build the kernel using build.sh, [...]

See above.

> Don't try to make things complicated by doing all that stuff by hand.
> :-)

build.sh _is_ the complicated way, to me.  It's a large, complex, and
slow tool I find even less understandable than config(1) and make(1).
It also has way too much "when we want your opinion we'll give it to
you" for my taste.

Which I suppose is just another way of saying that NetBSD, having lost
interest in users like me, is moving even farther in that same
direction.  Sic transit gloria mundi.

I don't squawk much about build.sh because it does bring benefits; the
biggest one I notice is probably painless cross-compiles.  But I'd
never run into this price before.  5.2 doesn't exhibit the misbehaviour
at all, so I couldn't've noticed it except at work, and I think I've
never tried to build a kernel without /usr/src in place before (at work
or not).

[matthew green]

>> make[1]: don't know how to make absvdi2.c. Stop
> what happens if you run "make USETOOLS=no"?

Fast failure, superficially looking like the same one.

[Valery Ushakov]

> Mail-Followup-To: matthew green ,
>   Mouse , tech-kern@netbsd.org

Um, why would you think I'd want people to mail followups to _me_?  I
would prefer - though admittedly it's a weak preference, weak enough I
practically never mention it - that people _not_ mail me when they're
already sending to the list.

> The problem is that NETBSDSRCDIR cannot be inferred for a randomly
> located kernel builddir and sys/lib/libkern/Makefile.compiler-rt uses
> it.

In that case, maybe config(1) should write a suitable setting of
NETBSDSRCDIR into the Makefile it generates?  At least when -s is given
with an absolute path?

> Our makefile spaghetti is a bit out of control.

I've felt so often enough myself.

/~\ The ASCII Mouse
\ / Ribbon Campaign
 X  Against HTMLmo...@rodents-montreal.org
/ \ Email!   7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B


Re: building 9.1 kernel with /usr/src elsewhere?

2023-03-08 Thread Valery Ushakov
On Wed, Mar 08, 2023 at 15:22:11 +1100, matthew green wrote:

> > This completed apparently normally, reporting the build directory and
> > telling me to remember to make depend.  I then went to ~/kbuild/GEN91
> > and ran make depend && make.  It failed fast - no more than a second or
> > two - with
> >
> > make[1]: don't know how to make absvdi2.c. Stop
> 
> what happens if you run "make USETOOLS=no"?

That's orthogonal.  The problem is that NETBSDSRCDIR cannot be
inferred for a randomly located kernel builddir and
sys/lib/libkern/Makefile.compiler-rt uses it.  I don't know enough
about sys Makefiles, but may be using $S instead of
${NETBSDSRCDIR}/sys will just fix it.  But may be will also break
something else.  Our makefile spaghetti is a bit out of control.

-uwe


re: building 9.1 kernel with /usr/src elsewhere?

2023-03-07 Thread matthew green
> This completed apparently normally, reporting the build directory and
> telling me to remember to make depend.  I then went to ~/kbuild/GEN91
> and ran make depend && make.  It failed fast - no more than a second or
> two - with
>
> make[1]: don't know how to make absvdi2.c. Stop

what happens if you run "make USETOOLS=no"?


.mrg.


Re: building 9.1 kernel with /usr/src elsewhere?

2023-03-07 Thread Johnny Billquist
You should build the kernel using build.sh, with the tools and all from 
there.


./build.sh kernel=foobar

Don't try to make things complicated by doing all that stuff by hand. :-)

  Johnny

On 2023-03-08 00:32, Mouse wrote:

Okay, I'm trying to help someone with a NetBSD 9.1 machine at work.
Today's issue is one I had trying to build a kernel.  We needed to do
this because that project has a few customziations in the system needed
to build the application layer, and more needed to run it.

He installed stock 9.1, but did not install any source; /usr/src and
/usr/xsrc did not exist.  We then set up the customized source trees in
his homedir, which I will here call /home/abcxyz, under a directory
9.1.  Thus, the path to kernel source, for example, was
/home/abcxyz/netbsd-9.1/usr/src/sys.

Then I copied in a kernel config (GEN91) into my ~/kconf/GEN91, from
back when I was working on that project.  I then ran

% config -b ~/kbuild/GEN91 -s /home/abcxyz/netbsd-9.1/usr/src/sys ~/kconf/GEN91

This completed apparently normally, reporting the build directory and
telling me to remember to make depend.  I then went to ~/kbuild/GEN91
and ran make depend && make.  It failed fast - no more than a second or
two - with

make[1]: don't know how to make absvdi2.c. Stop

(full log below).  I then moved /home/abcxyz/netbsd-9.1/usr/{src,xsrc}
to /usr/{src,xsrc}, chowned them -R to 0, destroyed ~/kbuild/GEN91, and
repeated, only this time I passed /usr/src/sys to config's -s flag.

This time the kernel built fine (at least apparently - we haven't tried
booting it yet, but I've built enough kernels to be confident there are
no obvious red flags in the log; it certainly did not fail a second or
two in with a cryptic message about absvdi2.c).  Note in particular
that the source tree content was identical; only the path and ownership
differed.

Is this a bug?  Or am I doing something wrong?

/~\ The ASCII Mouse
\ / Ribbon Campaign
  X  Against HTML   mo...@rodents-montreal.org
/ \ Email!   7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B

The logfile includes one line that's over 3300 characters long,
guaranteeing that it'd get mangled by email (soft limit 78 characters,
hard limit 998).  So, I ran the logfile through bzip2 and then
base64-encoded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3GA6D4mvuANDYUESE1XGG9JKlu+DVtUdYidGAibhE
4iJ/4u5IpwoSH5lojCA=


--
Johnny Billquist  || "I'm on a bus
  ||  on a psychedelic trip
email: b...@softjar.se ||  Reading murder books
pdp is alive! ||  tryin' to stay hip" - B. Idol


Re: building 9.1 kernel with /usr/src elsewhere?

2023-03-07 Thread Taylor R Campbell
> Date: Tue, 7 Mar 2023 18:32:46 -0500 (EST)
> From: Mouse 
> 
> This completed apparently normally, reporting the build directory and
> telling me to remember to make depend.  I then went to ~/kbuild/GEN91
> and ran make depend && make.  It failed fast - no more than a second or
> two - with
> 
> make[1]: don't know how to make absvdi2.c. Stop

Does it make a difference if you set
NETBSDSRCDIR=/home/abcxyz/netbsd-9.1/usr/src when you run make?

I always build out of my home directory, never /usr/src, but I also
always use build.sh and the make wrapper it creates to pass all the
right options to make (including for cross-builds).  My usual build
incantation is:

./build.sh -O ../obj.amd64 -U -u -m amd64 -j4 -N1 tools kernel=GENERIC

or

./build.sh -O ../obj.arm64 -U -u -m evbarm64 -j4 -N1 -V MKCROSSGDB=yes -V 
MKDEBUG=yes -V USE_PIGZGZIP=yes tools kernel=GENERIC64

or similar.

(Once `tools' is built once, no need to build it again during kernel
development.)

FYI, if you use build.sh, you don't need to do the build from inside
netbsd-9.1 on the same architecture.  I mostly do development of
netbsd-current on 9.x, but you could also do it from macOS or Linux
too.  I suspect that explicitly running /usr/bin/config for a
non-cross-build is an unusual use case these days.  And you will get a
more consistent toolchain, and a more consistent build product
(including the option of a 100% reproducible build with MKREPRO), if
you use build.sh.


Re: building 9.1 kernel with /usr/src elsewhere?

2023-03-07 Thread Brian Buhrow
hello.  I regularly build kernels outside of the /usr/src location.  My 
technique is to
install the source in some location: /usr/local/netbsd/src-91, for example, 
then put my
configuration file in: /usr/local/netbsd/src-91/sys/arch//conf/
Then
cd /usr/local/netbsd/src-91/sys/arch//conf
config 
cd ../compile/
make -j 4 >& make.log
And, I'm off to the races.

Does that not work for you?
-Brian