ifuncs check flawed?

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

ifuncs check flawed?

Dan Allen
I have been building FreeBSD for many years, as in since 2.2.8.

Currently my amd64 build of 12-STABLE is built with the following src.conf:

WITHOUT_BHYVE=1
WITHOUT_CAPSICUM=1
WITHOUT_CDDL=1
WITHOUT_CLANG_EXTRAS=1
WITHOUT_CLANG_FULL=1
WITHOUT_CROSS_COMPILER=1
WITHOUT_DEBUG_FILES=1
WITHOUT_EXAMPLES=1
WITHOUT_HYPERV=1
WITHOUT_JAIL=1
WITHOUT_LOCALES=1
WITHOUT_PROFILE=1
WITHOUT_QUOTAS=1
WITHOUT_TESTS=1

And a make.conf of:

BATCH=yes
MK_CDDL=no
MK_CLANG_EXTRAS=no
MK_DEBUG_FILES=no
MK_NO_PROFILE=yes
MK_TESTS=no
OPTIONS_UNSET=JAVA
WITH_JADETEX=no
WITHOUT_CDDL=yes
WITHOUT_CLANG_FULL=yes
WITHOUT_CTF=yes
WITHOUT_CTM=yes
DISABLE_VULNERABILITIES=yes

So far, so good.  (I do this to fit the whole thing onto a CD-image.)

Fooling around, and using xhyve on my Mac, I want to build a i386 version in a VM.

So I grabbed the 20190314 snapshot of 12-STABLE, i386 flavor, and installed it.  Works great.

Now to rebuild the world.

The buildworld and buildkernel steps both immediately fail due to the linker not supporting ifuncs.

The code that stops the buildworld is this from /usr/src/lib/libc/Makefile:

---
.if (${LIBC_ARCH} == amd64 || ${LIBC_ARCH} == i386) && \
     ${.TARGETS:Mall} == all && \
     defined(LINKER_FEATURES) && ${LINKER_FEATURES:Mifunc} == ""
.error ${LIBC_ARCH} libc requires linker ifunc support
.endif
---

However the linker on my system is the lld linker that supports ifuncs!  Why does this check fail?

I am building on i386 but I am only building i386, as in I am not building all targets or amd64.

I edited the two Makefiles that have this check to remove the check and the builds proceed just fine.

So it appears that these checks are flawed, or I am soon to learn something new about FreeBSD!

Thanks,

Dan Allen



_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

re: ifuncs check flawed?

Dan Allen
The ifuncs check for buildkernel is identical to the one in

  /usr/src/lib/libc/Makefile

and is here:

  /usr/src/sys/conf/kern.pre.mk

Dan

_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

re: ifuncs check flawed?

Dan Allen
In reply to this post by Dan Allen
Well, everything built fine, but the kernel faults on boot, so the checks are probably needed. ;-)

I still do not understand why the linker that is part of 12-STABLE does not provide the support needed.

The directives in my src.conf and make.conf do not delete the lld linker.  They just cut down on extra llvm parts that I do not need, or so I am led to believe.

Still puzzled.

Dan


_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

re: ifuncs check flawed?

Dan Allen
In reply to this post by Dan Allen
Another data point:

I did the whole experiment with the latest 12-STABLE but for amd64 and everything builds fine without changes, and runs fine too.

I used the same src.conf and make.conf.  So the problem is definitely with i386.

Dan

_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: ifuncs check flawed?

Ed Maste-2
In reply to this post by Dan Allen
On Mon, 18 Mar 2019 at 13:03, Dan Allen <[hidden email]> wrote:
>
> The buildworld and buildkernel steps both immediately fail due to the linker not supporting ifuncs.

By default FreeBSD/i386 uses lld as the bootstrap linker (i.e., the
linker used for building the kernel, libraries, and userland binaries)
but still installs GNU ld as /usr/bin/ld on stable/12 due to issues in
the ports tree.

There are a few different ways you could address this:
1. Build either the buildworld or kernel-toolchain targets before make
buildkernel, which will then use the built toolchain including lld.
2. Set LD=ld.lld to explicitly use lld for the kernel link.
3. Build and install world WITH_LLD_IS_LD in src.conf, so that
/usr/bin/ld is lld.
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: ifuncs check flawed?

Dan Allen


> On 19 Mar 2019, at 9:34 AM, Ed Maste <[hidden email]> wrote:
>
> There are a few different ways you could address this:
> 1. Build either the buildworld or kernel-toolchain targets before make
> buildkernel, which will then use the built toolchain including lld.

I did this, and it did not work.  I always build the system in the canonical order:

buildworld
buildkernel
installkernel
installworld

That is why I think the check is flawed!  I am using the lld linker.  It is present in the snapshot.  The system should be using it, but it immediately fails due to the aforementioned checks.  That is the bug that I am raising.

Dan

_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: ifuncs check flawed?

Ed Maste-2
On Tue, 19 Mar 2019 at 16:54, Dan Allen <[hidden email]> wrote:
>
> That is why I think the check is flawed!

The check works as intended, as suggested by the non-booting kernel
produced with the checks removed.

To help track this down can you run `make buildenv` and then in the
resulting shell collect the output of `which ld` and `ld --version`?
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: ifuncs check flawed?

Dan Allen


> On 23 Mar 2019, at 10:13 AM, Ed Maste <[hidden email]> wrote:
>
> To help track this down can you run `make buildenv` and then in the
> resulting shell collect the output of `which ld` and `ld --version`?

Thanks for the info & help Ed.

I did the same experiment with the latest 12-SNAPSHOT without any changes to src.conf or make.conf and it built fine, which was my main worry.  

Apparently one of my custom build settings causes the failure and I will see if I can track it down sometime.

Dan


_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to "[hidden email]"