pkgsrc-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Bootstrapping pbulk in sandbox fails on Loongson/mips64el.



On Sat, Dec 18, 2021 at 10:54 AM Alistair Crooks <agc%pkgsrc.org@localhost> wrote:
>
> platform/NetBSD.mk tries to guess the OBJECT_FMT
>
> _OPSYS_SHLIB_TYPE=      ${_OPSYS_SHLIB_TYPE_cmd:sh}     # shared library type
> _OPSYS_SHLIB_TYPE_cmd=  \
>         output=`/usr/bin/file /sbin/sysctl`;    \
>         case $$output in                        \
>         *ELF*dynamically*)      echo ELF ;;     \
>         *shared*library*)       echo a.out ;;   \
>         *dynamically*)          echo a.out ;;   \
>         *)                      echo ELF ;;     \
>         esac
>
> So you could try:
>
> /usr/bin/file /sbin/sysctl
>
> to see the message that is returned, and
>
> bmake show-var VARNAME=OBJECT_FMT
>
> (which will show a.out, but whatever)
>
> For NetBSD (that's what uname -s returns, right?), the object format defaults to ELF if the library type is unusual or unknown, so something is setting it to a.out
>
> The normal PKG_DEBUG_LEVEL definition to spew loads of information is not enabled for the basic infrastructure stuff, so we may have to work a bit harder to narrow this down

Thanks Alistair!  I've tried to find those info with the following commands:

```
yeeloong-netbsd# /home/pbulk/sandbox chroot
yeeloong-netbsd# pwd  # To verify I'm in chroot
/
yeeloong-netbsd# /usr/bin/file /sbin/sysctl
/sbin/sysctl: ELF 32-bit LSB shared object, MIPS, N32 MIPS-III version
1 (SYSV), dynamically linked, interpreter /libexec/ld.elf_so, for
NetBSD 8.2, not stripped
yeeloong-netbsd# cd /usr/pkgsrc/pkgtools/digest/
yeeloong-netbsd# /usr/pbulk/bin/bmake show-var VARNAME=OBJECT_FMT
a.out
yeeloong-netbsd# /usr/bin/make show-var VARNAME=OBJECT_FMT
ELF
yeeloong-netbsd# uname -s
NetBSD
```

So "/usr/bin/file /sbin/sysctl" should be working in chroot, and
system make reports OBJECT_FMT to be ELF, however the bmake
bootstrapped in pbulk reports a.out.  Will try to keep digging into
this, but hopefully the info above may help some developers to figure
out what could be wrong.

Thanks again!

>
> On Sat, 18 Dec 2021 at 02:52, manphiz <manphiz%gmail.com@localhost> wrote:
>>
>> (It seems my previous mail somehow didn't reach the mailing list.
>> Retry sending.)
>>
>> On Thu, Dec 16, 2021 at 8:29 AM manphiz <manphiz%gmail.com@localhost> wrote:
>> >
>> > Hi,
>> >
>> > I'm trying to bootstrap pbulk on my Loongson2f machine which is
>> > running NetBSD 8.2 but was encountering some issue when building
>> > digest during bootstrapping.  The relevant build logs are included
>> > below:
>> >
>> > ```
>> > ===> Installing for digest-20211023
>> > => Generating pre-install file lists
>> > /bin/sh ./mkinstalldirs
>> > /tmp/obj-pbulk/pkgtools/digest/work/.destdir/usr/pbulk/bin
>> > mkdir /tmp/obj-pbulk/pkgtools/digest/work/.destdir/usr/pbulk/bin
>> > /usr/bin/install -c -s -o root -g wheel -m 755 digest
>> > /tmp/obj-pbulk/pkgtools/digest/work/.destdir/usr/pbulk/bin/digest
>> > /bin/sh ./mkinstalldirs
>> > /tmp/obj-pbulk/pkgtools/digest/work/.destdir/usr/pbulk/man/man1
>> > mkdir /tmp/obj-pbulk/pkgtools/digest/work/.destdir/usr/pbulk/man
>> > mkdir /tmp/obj-pbulk/pkgtools/digest/work/.destdir/usr/pbulk/man/man1
>> > /usr/bin/install -c -o root -g wheel -m 644 digest.1
>> > /tmp/obj-pbulk/pkgtools/digest/work/.destdir/usr/pbulk/man/man1/digest.1
>> > => Automatic manual page handling
>> > => Generating post-install file lists
>> > => Checking file-check results for digest-20211023
>> > => Checking for non-existent script interpreters in digest-20211023
>> > => Checking for missing run-time search paths in digest-20211023
>> > /usr/bin/awk: no program filename
>> >
>> > *** Error code 2
>> >
>> > Stop.
>> > bmake[3]: stopped in /usr/pkgsrc/pkgtools/digest
>> > *** Error code 1
>> >
>> > Stop.
>> > bmake[2]: stopped in /usr/pkgsrc/pkgtools/digest
>> > *** Error code 1
>> >
>> > Stop.
>> > bmake[1]: stopped in /usr/pkgsrc/sysutils/checkperms
>> > *** Error code 1
>> >
>> > Stop.
>> > bmake: stopped in /usr/pkgsrc/pkgtools/pbulk
>> > ```
>> >
>> > So I googled the error message and found this old thread[1] (which now
>> > looks like this[2]) suggesting that $OBJECT_FMT is not properly set.
>> > So I used the following patch to trick bmake to properly set
>> > everything it needs
>> > ```
>> > Index: check-shlibs.mk
>> > ===================================================================
>> > RCS file: /cvsroot/pkgsrc/mk/check/check-shlibs.mk,v
>> > retrieving revision 1.34
>> > diff -u -r1.34 check-shlibs.mk
>> > --- check-shlibs.mk     11 Oct 2021 20:26:28 -0000      1.34
>> > +++ check-shlibs.mk     16 Dec 2021 13:42:57 -0000
>> > @@ -67,6 +67,11 @@
>> >  .    if defined(DARWIN_NO_SYSTEM_LIBS)
>> >  CHECK_SHLIBS_NATIVE_ENV+=      SKIP_SYSTEM_LIBS=1
>> >  .    endif
>> > +.  else
>> > +USE_TOOLS+=                    readelf
>> > +CHECK_SHLIBS_NATIVE=           ${PKGSRCDIR}/mk/check/check-shlibs-elf.awk
>> > +CHECK_SHLIBS_NATIVE_ENV+=      PLATFORM_RPATH=${_OPSYS_SYSTEM_RPATH:Q}
>> > +CHECK_SHLIBS_NATIVE_ENV+=      READELF=${TOOLS_PATH.readelf:Q}
>> >  .  endif
>> >  CHECK_SHLIBS_NATIVE_ENV+=      CROSS_DESTDIR=${_CROSS_DESTDIR:Q}
>> >  CHECK_SHLIBS_NATIVE_ENV+=      PKG_INFO_CMD=${PKG_INFO:Q}
>> > ```
>> > And then the bootstrapping of pbulk succeeded.
>> >
>> > Apparently the proper fix should be let bmake properly detect that we
>> > are NetBSD with elf support.  So I dug a little more and found this[3]
>> > in bmake source which I think should have properly set OBJECT_FMT to
>> > ELF.  I checked in the chroot there it is:
>> >
>> > ```
>> > # file /usr/libexec/ld.elf_so
>> > /usr/libexec/ld.elf_so: symbolic link to /libexec/ld.elf_so
>> > # file /libexec/ld.elf_so
>> > /libexec/ld.elf_so: ELF 32-bit LSB shared object, MIPS, N32 MIPS-III
>> > version 1 (SYSV), dynamically linked, for NetBSD 8.2, not stripped
>> > ```
>> >
>> > But somehow this didn't happen.
>> >
>> > Would like to know what could be the cause and how to properly fix
>> > this.  Thanks!
>> >
>> > [1] https://mail-index.netbsd.org/tech-pkg/2015/12/09/msg016090.html
>> > [2] https://github.com/NetBSD/pkgsrc/blob/trunk/mk/check/check-shlibs.mk#L60
>> > [3] https://github.com/NetBSD/pkgsrc/blob/trunk/devel/bmake/files/mk/own.mk#L199-L202
>>
>> So I did some more testing by making a short Makefile trying to test
>> how bmake handles the OBJECT_FMT in
>> /usr/pkgsrc/devel/bmake/files/mk/own.mk.  Please see the following
>> command line output.
>>
>> ```
>> yeeloong-netbsd# /home/pbulk/sandbox
>> # pwd
>> /
>> # cat /tmp/Makefile
>> .if exists(/usr/libexec/ld.elf_so)
>> OBJECT_FMT=ELF
>> .endif
>>
>> OBJECT_FMT?=a.out
>>
>> all:
>>         @echo ${OBJECT_FMT}
>> # /usr/pbulk/bin/bmake -f /tmp/Makefile
>> ELF
>> ```
>>
>> So it seems that bmake should have properly set ${OBJECT_FMT} to "ELF", but
>> somehow in "/usr/pkgsrc/mk/check/check-shlibs.mk" it's value is no
>> longer "ELF"?  Would be great if someone could shed some light here.
>>


Home | Main Index | Thread Index | Old Index