Discussion:
``make buildkernel'' fails when /usr/obj is empty
(too old to reply)
Gary Jennejohn
2018-05-31 07:52:22 UTC
Permalink
There's something totally screwy about trying to build a kernel when
/usr/obj is not populated.

I ran ``make clean'' in /usr/src and then ``make buildkernel''. This
fails with
make[2]: "/usr/src/sys/conf/kern.pre.mk" line 125: amd64 kernel
requires linker ifunc support

This is total BS because

/usr/bin/ld --version
LLD 6.0.0 (FreeBSD 326565-1200002) (compatible with GNU linkers)

which is exactly what bsd.linker.mk is looking for to set ifunc.

If I do this:

mkdir -p /usr/obj/usr/src/amd64.amd64/tmp/legacy/usr/bin
cp /usr/bin/ld /usr/obj/usr/src/amd64.amd64/tmp/legacy/usr/bin

the buildkernel then succeeds.

Considering that (reformatted output from make)

PATH=/usr/obj/usr/src/amd64.amd64/tmp/legacy/usr/sbin:
/usr/obj/usr/src/amd64.amd64/tmp/legacy/usr/bin:
/usr/obj/usr/src/amd64.amd64/tmp/legacy/bin:
/usr/obj/usr/src/amd64.amd64/tmp/usr/sbin:
/usr/obj/usr/src/amd64.amd64/tmp/usr/bin:
/sbin:/bin:/usr/sbin:/usr/bin

it seems like /usr/bin/ld should be found by bsd.linker.mk and no
error should be reported.
--
Gary Jennejohn
Gary Jennejohn
2018-05-31 07:58:50 UTC
Permalink
On Thu, 31 May 2018 09:52:22 +0200
Post by Gary Jennejohn
There's something totally screwy about trying to build a kernel when
/usr/obj is not populated.
I ran ``make clean'' in /usr/src and then ``make buildkernel''. This
fails with
make[2]: "/usr/src/sys/conf/kern.pre.mk" line 125: amd64 kernel
requires linker ifunc support
This is total BS because
/usr/bin/ld --version
LLD 6.0.0 (FreeBSD 326565-1200002) (compatible with GNU linkers)
which is exactly what bsd.linker.mk is looking for to set ifunc.
mkdir -p /usr/obj/usr/src/amd64.amd64/tmp/legacy/usr/bin
cp /usr/bin/ld /usr/obj/usr/src/amd64.amd64/tmp/legacy/usr/bin
the buildkernel then succeeds.
Considering that (reformatted output from make)
/sbin:/bin:/usr/sbin:/usr/bin
it seems like /usr/bin/ld should be found by bsd.linker.mk and no
error should be reported.
OK, it seems that ``make clean'' does not remove the contents of
/usr/obj/usr/src/amd64.amd64/tmp/legacy. If I delete everything
under /usr/obj then ``make buildkernel'' works.

Still, it seems pretty strange to me to make building a kernel
depend on some random junk which is left laying around under
/usr/obj.
--
Gary Jennejohn
Benjamin Kaduk
2018-05-31 16:04:06 UTC
Permalink
Post by Gary Jennejohn
On Thu, 31 May 2018 09:52:22 +0200
Post by Gary Jennejohn
There's something totally screwy about trying to build a kernel when
/usr/obj is not populated.
I ran ``make clean'' in /usr/src and then ``make buildkernel''. This
fails with
make[2]: "/usr/src/sys/conf/kern.pre.mk" line 125: amd64 kernel
requires linker ifunc support
This is total BS because
/usr/bin/ld --version
LLD 6.0.0 (FreeBSD 326565-1200002) (compatible with GNU linkers)
which is exactly what bsd.linker.mk is looking for to set ifunc.
mkdir -p /usr/obj/usr/src/amd64.amd64/tmp/legacy/usr/bin
cp /usr/bin/ld /usr/obj/usr/src/amd64.amd64/tmp/legacy/usr/bin
the buildkernel then succeeds.
Considering that (reformatted output from make)
/sbin:/bin:/usr/sbin:/usr/bin
it seems like /usr/bin/ld should be found by bsd.linker.mk and no
error should be reported.
OK, it seems that ``make clean'' does not remove the contents of
/usr/obj/usr/src/amd64.amd64/tmp/legacy. If I delete everything
under /usr/obj then ``make buildkernel'' works.
Still, it seems pretty strange to me to make building a kernel
depend on some random junk which is left laying around under
/usr/obj.
Whatever happened to the "run buildworld or kernel-toolchain before
buildkernel" requirement?

-Ben
Dimitry Andric
2018-05-31 17:47:57 UTC
Permalink
Post by Benjamin Kaduk
Post by Gary Jennejohn
On Thu, 31 May 2018 09:52:22 +0200
Post by Gary Jennejohn
There's something totally screwy about trying to build a kernel when
/usr/obj is not populated.
I ran ``make clean'' in /usr/src and then ``make buildkernel''. This
fails with
make[2]: "/usr/src/sys/conf/kern.pre.mk" line 125: amd64 kernel
requires linker ifunc support
This is total BS because
/usr/bin/ld --version
LLD 6.0.0 (FreeBSD 326565-1200002) (compatible with GNU linkers)
which is exactly what bsd.linker.mk is looking for to set ifunc.
mkdir -p /usr/obj/usr/src/amd64.amd64/tmp/legacy/usr/bin
cp /usr/bin/ld /usr/obj/usr/src/amd64.amd64/tmp/legacy/usr/bin
the buildkernel then succeeds.
Considering that (reformatted output from make)
/sbin:/bin:/usr/sbin:/usr/bin
it seems like /usr/bin/ld should be found by bsd.linker.mk and no
error should be reported.
OK, it seems that ``make clean'' does not remove the contents of
/usr/obj/usr/src/amd64.amd64/tmp/legacy. If I delete everything
under /usr/obj then ``make buildkernel'' works.
Still, it seems pretty strange to me to make building a kernel
depend on some random junk which is left laying around under
/usr/obj.
Whatever happened to the "run buildworld or kernel-toolchain before
buildkernel" requirement?
That is still a requirement, yes. Otherwise, you might have outdated
toolchain components are in your /usr/obj.

-Dimitry
Warner Losh
2018-05-31 18:11:52 UTC
Permalink
Post by Dimitry Andric
Post by Benjamin Kaduk
Post by Gary Jennejohn
On Thu, 31 May 2018 09:52:22 +0200
Post by Gary Jennejohn
There's something totally screwy about trying to build a kernel when
/usr/obj is not populated.
I ran ``make clean'' in /usr/src and then ``make buildkernel''. This
fails with
make[2]: "/usr/src/sys/conf/kern.pre.mk" line 125: amd64 kernel
requires linker ifunc support
This is total BS because
/usr/bin/ld --version
LLD 6.0.0 (FreeBSD 326565-1200002) (compatible with GNU linkers)
which is exactly what bsd.linker.mk is looking for to set ifunc.
mkdir -p /usr/obj/usr/src/amd64.amd64/tmp/legacy/usr/bin
cp /usr/bin/ld /usr/obj/usr/src/amd64.amd64/tmp/legacy/usr/bin
the buildkernel then succeeds.
Considering that (reformatted output from make)
/sbin:/bin:/usr/sbin:/usr/bin
it seems like /usr/bin/ld should be found by bsd.linker.mk and no
error should be reported.
OK, it seems that ``make clean'' does not remove the contents of
/usr/obj/usr/src/amd64.amd64/tmp/legacy. If I delete everything
under /usr/obj then ``make buildkernel'' works.
Still, it seems pretty strange to me to make building a kernel
depend on some random junk which is left laying around under
/usr/obj.
Whatever happened to the "run buildworld or kernel-toolchain before
buildkernel" requirement?
That is still a requirement, yes. Otherwise, you might have outdated
toolchain components are in your /usr/obj.
Usually you can get away without doing that, and now that clang is the
toolchain that's rebuilt (and that's not fast) people try to get away with
it more and more...

Warner
Dimitry Andric
2018-05-31 18:19:20 UTC
Permalink
Post by Dimitry Andric
Post by Benjamin Kaduk
Post by Gary Jennejohn
On Thu, 31 May 2018 09:52:22 +0200
...
Post by Dimitry Andric
Post by Benjamin Kaduk
Whatever happened to the "run buildworld or kernel-toolchain before
buildkernel" requirement?
That is still a requirement, yes. Otherwise, you might have outdated
toolchain components are in your /usr/obj.
Usually you can get away without doing that, and now that clang is the toolchain that's rebuilt (and that's not fast) people try to get away with it more and more...
Actually clang doesn't get updated *that* often, but there is a minor
snag that one of llvm's config files (lib/clang/include/llvm/Config/config.h)
includes <osreldate.h>, so each time __FreeBSD_version is bumped, quite
a lot of dependencies get triggered...

The version is only used for two checks:

#if __FreeBSD_version >= 1000052
/* Define to 1 if you have the `backtrace' function. */
#define HAVE_BACKTRACE TRUE

and:

/* Define to 1 if you have the `futimens' function. */
#if __FreeBSD_version >= 1100056
#define HAVE_FUTIMENS 1
#endif

Maybe the first check could be dropped, assuming that backtrace() is
always available, but I'm not sure about futimens(). Is there any
supported version of FreeBSD left that does *not* have it?

-Dimitry
Konstantin Belousov
2018-05-31 19:50:03 UTC
Permalink
Post by Dimitry Andric
Post by Dimitry Andric
Post by Benjamin Kaduk
Post by Gary Jennejohn
On Thu, 31 May 2018 09:52:22 +0200
...
Post by Dimitry Andric
Post by Benjamin Kaduk
Whatever happened to the "run buildworld or kernel-toolchain before
buildkernel" requirement?
That is still a requirement, yes. Otherwise, you might have outdated
toolchain components are in your /usr/obj.
Usually you can get away without doing that, and now that clang is the toolchain that's rebuilt (and that's not fast) people try to get away with it more and more...
Actually clang doesn't get updated *that* often, but there is a minor
snag that one of llvm's config files (lib/clang/include/llvm/Config/config.h)
includes <osreldate.h>, so each time __FreeBSD_version is bumped, quite
a lot of dependencies get triggered...
#if __FreeBSD_version >= 1000052
/* Define to 1 if you have the `backtrace' function. */
#define HAVE_BACKTRACE TRUE
/* Define to 1 if you have the `futimens' function. */
#if __FreeBSD_version >= 1100056
#define HAVE_FUTIMENS 1
#endif
Maybe the first check could be dropped, assuming that backtrace() is
always available, but I'm not sure about futimens(). Is there any
supported version of FreeBSD left that does *not* have it?
Or you can manually define the symbols as needed on each branch,
eliminating the need for osreldate.h and reusable if some other
configuration variable needs to be conditionally set.
Matt Smith
2018-06-03 10:31:09 UTC
Permalink
Post by Konstantin Belousov
Post by Dimitry Andric
Post by Dimitry Andric
Post by Benjamin Kaduk
Post by Gary Jennejohn
On Thu, 31 May 2018 09:52:22 +0200
...
Post by Dimitry Andric
Post by Benjamin Kaduk
Whatever happened to the "run buildworld or kernel-toolchain before
buildkernel" requirement?
That is still a requirement, yes. Otherwise, you might have outdated
toolchain components are in your /usr/obj.
Usually you can get away without doing that, and now that clang is the toolchain that's rebuilt (and that's not fast) people try to get away with it more and more...
Actually clang doesn't get updated *that* often, but there is a minor
snag that one of llvm's config files (lib/clang/include/llvm/Config/config.h)
includes <osreldate.h>, so each time __FreeBSD_version is bumped, quite
a lot of dependencies get triggered...
#if __FreeBSD_version >= 1000052
/* Define to 1 if you have the `backtrace' function. */
#define HAVE_BACKTRACE TRUE
/* Define to 1 if you have the `futimens' function. */
#if __FreeBSD_version >= 1100056
#define HAVE_FUTIMENS 1
#endif
Maybe the first check could be dropped, assuming that backtrace() is
always available, but I'm not sure about futimens(). Is there any
supported version of FreeBSD left that does *not* have it?
Or you can manually define the symbols as needed on each branch,
eliminating the need for osreldate.h and reusable if some other
configuration variable needs to be conditionally set.
Are these the kind of things that could get done in current and stable?
Currently llvm/clang is rebuilt on pretty much every buildworld cycle
that I do because of this which makes using things like WITH_META_MODE
pretty pointless.

It would be great to get this kind of change in the trees.
--
Matt
Eitan Adler
2018-06-03 15:11:46 UTC
Permalink
Post by Dimitry Andric
Post by Dimitry Andric
Post by Benjamin Kaduk
Post by Gary Jennejohn
On Thu, 31 May 2018 09:52:22 +0200
...
Post by Dimitry Andric
Post by Benjamin Kaduk
Whatever happened to the "run buildworld or kernel-toolchain before
buildkernel" requirement?
That is still a requirement, yes. Otherwise, you might have outdated
toolchain components are in your /usr/obj.
Usually you can get away without doing that, and now that clang is the toolchain that's rebuilt (and that's not fast) people try to get away with it more and more...
Actually clang doesn't get updated *that* often, but there is a minor
snag that one of llvm's config files (lib/clang/include/llvm/Config/config.h)
includes <osreldate.h>, so each time __FreeBSD_version is bumped, quite
a lot of dependencies get triggered...
#if __FreeBSD_version >= 1000052
/* Define to 1 if you have the `backtrace' function. */
#define HAVE_BACKTRACE TRUE
/* Define to 1 if you have the `futimens' function. */
#if __FreeBSD_version >= 1100056
#define HAVE_FUTIMENS 1
#endif
Maybe the first check could be dropped, assuming that backtrace() is
always available, but I'm not sure about futimens(). Is there any
supported version of FreeBSD left that does *not* have it?
10.4 is supported until October 31, 2018 but it might be worth making
the change in -current ?
--
Eitan Adler
Shane Ambler
2018-05-31 22:09:06 UTC
Permalink
Post by Warner Losh
Post by Dimitry Andric
Post by Benjamin Kaduk
Post by Gary Jennejohn
On Thu, 31 May 2018 09:52:22 +0200
Post by Gary Jennejohn
There's something totally screwy about trying to build a kernel when
/usr/obj is not populated.
I ran ``make clean'' in /usr/src and then ``make buildkernel''. This
fails with
make[2]: "/usr/src/sys/conf/kern.pre.mk" line 125: amd64 kernel
requires linker ifunc support
This is total BS because
/usr/bin/ld --version
LLD 6.0.0 (FreeBSD 326565-1200002) (compatible with GNU linkers)
which is exactly what bsd.linker.mk is looking for to set ifunc.
mkdir -p /usr/obj/usr/src/amd64.amd64/tmp/legacy/usr/bin
cp /usr/bin/ld /usr/obj/usr/src/amd64.amd64/tmp/legacy/usr/bin
the buildkernel then succeeds.
Considering that (reformatted output from make)
/sbin:/bin:/usr/sbin:/usr/bin
it seems like /usr/bin/ld should be found by bsd.linker.mk and no
error should be reported.
OK, it seems that ``make clean'' does not remove the contents of
/usr/obj/usr/src/amd64.amd64/tmp/legacy. If I delete everything
under /usr/obj then ``make buildkernel'' works.
Still, it seems pretty strange to me to make building a kernel
depend on some random junk which is left laying around under
/usr/obj.
Whatever happened to the "run buildworld or kernel-toolchain before
buildkernel" requirement?
That is still a requirement, yes. Otherwise, you might have outdated
toolchain components are in your /usr/obj.
Usually you can get away without doing that, and now that clang is the
toolchain that's rebuilt (and that's not fast) people try to get away with
it more and more...
There is WITH_SYSTEM_COMPILER to not bootstrap if possible.
--
FreeBSD - the place to B...Software Developing

Shane Ambler
Rodney W. Grimes
2018-05-31 14:14:05 UTC
Permalink
Post by Gary Jennejohn
There's something totally screwy about trying to build a kernel when
/usr/obj is not populated.
I ran ``make clean'' in /usr/src and then ``make buildkernel''. This
fails with
make[2]: "/usr/src/sys/conf/kern.pre.mk" line 125: amd64 kernel
requires linker ifunc support
This is total BS because
/usr/bin/ld --version
LLD 6.0.0 (FreeBSD 326565-1200002) (compatible with GNU linkers)
which is exactly what bsd.linker.mk is looking for to set ifunc.
mkdir -p /usr/obj/usr/src/amd64.amd64/tmp/legacy/usr/bin
cp /usr/bin/ld /usr/obj/usr/src/amd64.amd64/tmp/legacy/usr/bin
the buildkernel then succeeds.
Considering that (reformatted output from make)
/sbin:/bin:/usr/sbin:/usr/bin
it seems like /usr/bin/ld should be found by bsd.linker.mk and no
error should be reported.
AHH!! That explains why I was still seeing this too!
I been forcing the LD= work around and just ignoring
this failure thinking it was something in my not so
normal setup, but infact I always start with an empty
/usr/obj due to a zfs rollback pool/usr/***@empty

So this is a "confirmed" this occurs, including in a 20180521
freshly installed snapshot.
--
Rod Grimes ***@freebsd.org
Loading...