[klibc] [kvm-unit-tests PATCH v3 0/4] Update patch set

Bill Wendling morbo at google.com
Sat Jul 25 14:36:22 PDT 2020


On Sat, Jul 25, 2020 at 1:57 PM Ben Hutchings <ben at decadent.org.uk> wrote:
>
> On Sat, 2020-07-25 at 17:47 +0100, Ben Hutchings wrote:
> > On Sun, 2020-03-29 at 04:38 -0700, Bill Wendling wrote:
> > > - Renamed IMAGE_BASE to LD_IMAGE_BASE_OPT.
> > > - Moved "-fcommon" to KLIBCREQFLAGS in scripts/Kbuild.klibc.
> > > - Remove "dash" warning fixes which have been upstreamed.
> > > - Conditionalize the inclusion of compiler flags by using the proper
> > >   compiler name or "cc-option".
> > > - Added "-Werror" to "cc-option" to catch flags that cause warnings.
> > > - Retain "-nostdinc -iwithprefix include" and use the proper clang flag
> > >   to get the path to find "stdarg.h".
> > > - Move "-fno-builtin-bcmp" to KLIBCREQFLAGS in scripts/Kbuild.klibc.
> >
> > I'm just going to apply this series now, and we can worry about
> > cleaning up the FLAGS variable definitions later.
> >
> > Thanks for your patience,
> [...]
>
> Unfortunately this doesn't work with Clang and lld 9.0.1.
>
> Clang is now optimising some stdio calls to their _unlocked variants,
> which we don't define.  I added definitions of all those, and was then
> able to able to build everything with Clang and ld.bfd.  I've pushed
> that change following these patches.
>
> However, when I use Clang and ld.lld, it fails to link dynamically-
> linked programs:
>
>     ld.lld: error: undefined symbol: gettimeofday
>     >>> referenced by main.c:842 (usr/kinit/ipconfig/main.c:842)
>     >>>               usr/kinit/ipconfig/main.o:(ipconfig_main)
>     >>> referenced by main.c:446 (usr/kinit/ipconfig/main.c:446)
>     >>>               usr/kinit/ipconfig/main.o:(ipconfig_main)
>     >>> referenced by main.c:490 (usr/kinit/ipconfig/main.c:490)
>     >>>               usr/kinit/ipconfig/main.o:(ipconfig_main)
>
>     ld.lld: error: undefined symbol: srand48
>     >>> referenced by main.c:843 (usr/kinit/ipconfig/main.c:843)
>     >>>               usr/kinit/ipconfig/main.o:(ipconfig_main)
>
>     ld.lld: error: undefined symbol: setjmp
>     >>> referenced by main.c:846 (usr/kinit/ipconfig/main.c:846)
>     >>>               usr/kinit/ipconfig/main.o:(ipconfig_main)
> [...]
>
I upstreamed a few patches to klibc to fix a few linker errors. Some
of these might help:

  - cfc4e4c9591c73edc786aebbe83b371fec36fec8 - Conditionalized
non-supported flags.
  - 1b014f8401fc5b3dc803e2cae06ac5c803dc89cb -  Add "-fno-common"
  - 1e876662002eac9662357c7feaee12be04107d32 - Use proper libc
  - f07a8f75b8ebfea71254cd8829c0476b6b6683e1 - Adjust some flags for ld.lld
  - 7f0aa03493dc9ab8c1d2798f6586bfbc5f1de702 - Use "-ffreestanding"
(fixes using unlocked versions of calls)

There are also a bunch of clang warnings Michael Davidson fixed in the
klibc tree.

-bw


More information about the klibc mailing list