diff mbox series

[2/2] package/busybox: redirect errors to /dev/null

Message ID 20221007235002.79221-2-vfazio@xes-inc.com
State Rejected
Headers show
Series [1/2] package/busybox: add patch to silence build errors | expand

Commit Message

Vincent Fazio Oct. 7, 2022, 11:50 p.m. UTC
When busybox.mk gets read, pkg-conf gets executed to determine the
location of relevant libraries.

When Busybox is built with per-package directories enabled, a number of
errors related to executing pkg-conf occur because directories have not
been synced to provide pkg-confg at the point when it executes.

These errors occur in stages prior configuring the package and are of
little consequence so redirect the errors to /dev/null.

Signed-off-by: Vincent Fazio <vfazio@xes-inc.com>
---
 package/busybox/busybox.mk | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Thomas Petazzoni Nov. 1, 2022, 10:41 p.m. UTC | #1
Hello Vincent,

On Fri,  7 Oct 2022 18:50:02 -0500
Vincent Fazio <vfazio@xes-inc.com> wrote:

> When busybox.mk gets read, pkg-conf gets executed to determine the
> location of relevant libraries.
> 
> When Busybox is built with per-package directories enabled, a number of
> errors related to executing pkg-conf occur because directories have not
> been synced to provide pkg-confg at the point when it executes.

I don't get this. If pkg-config is executed before the per-package
directories are created... then how can pkg-config find libtirpc?

I just did a build of the following configuration:

BR2_arm=y
BR2_cortex_a9=y
BR2_ARM_ENABLE_VFP=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
BR2_PER_PACKAGE_DIRECTORIES=y
BR2_INIT_NONE=y
BR2_SYSTEM_BIN_SH_NONE=y
BR2_PACKAGE_BUSYBOX_SHOW_OTHERS=y
BR2_PACKAGE_LIBTIRPC=y
# BR2_TARGET_ROOTFS_TAR is not set

and I couldn't see the errors (but perhaps I missed them). Could you
provide an example configuration, the details of the error, and a
rationale as to why not finding libtirpc is not a problem when we in
fact expect to find it?

Thanks!

Thomas
Vincent Fazio Nov. 2, 2022, 12:43 p.m. UTC | #2
Hey Tom,


> -----Original Message-----
> From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
> Sent: Tuesday, November 1, 2022 5:42 PM
> To: Vincent Fazio <vfazio@xes-inc.com>
> Cc: buildroot@buildroot.org
> Subject: [External] - Re: [Buildroot] [PATCH 2/2] package/busybox: redirect
> errors to /dev/null
> 
> Hello Vincent,
> 
> On Fri,  7 Oct 2022 18:50:02 -0500
> Vincent Fazio <vfazio@xes-inc.com> wrote:
> 
> > When busybox.mk gets read, pkg-conf gets executed to determine the
> > location of relevant libraries.
> >
> > When Busybox is built with per-package directories enabled, a number of
> > errors related to executing pkg-conf occur because directories have not
> > been synced to provide pkg-confg at the point when it executes.
> 
> I don't get this. If pkg-config is executed before the per-package
> directories are created... then how can pkg-config find libtirpc?
> 

pkg-config gets executed multiple times because the commands that get built up to generate the config file looks like so:

(yes "" | PATH="/mnt/development/buildroot/output/per-package/busybox/host/bin:/mnt/development/buildroot/output/per-package/busybox/host/sbin:/home/vfazio/.pyenv/plugins/pyenv-virtualenv/shims:/home/vfazio/.pyenv/shims:/home/vfazio/.pyenv/bin:/home/vfazio/.local/bin:/home/vfazio/.asdf/shims:/home/vfazio/.asdf/bin:/home/vfazio/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/vfazio/.xes-python-apps/bin" CFLAGS="-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  -Os -g0 -D_FORTIFY_SOURCE=1 "`/mnt/development/buildroot/output/per-package/busybox/host/bin/pkg-config --cflags libtirpc`"" CFLAGS_busybox="`/mnt/development/buildroot/output/per-package/busybox/host/bin/pkg-config --libs libtirpc`"" /usr/bin/remake -j7 -C /mnt/development/buildroot/output/build/busybox-1.35.0 HOSTCC="/usr/bin/gcc" AR="/mnt/development/buildroot/output/per-package/busybox/host/bin/x86_64-linux-gcc-ar" NM="/mnt/development/buildr
 oot/output/per-package/busybox/host/bin/x86_64-linux-gcc-nm" RANLIB="/mnt/development/buildroot/output/per-package/busybox/host/bin/x86_64-linux-gcc-ranlib" CC="/mnt/development/buildroot/output/per-package/busybox/host/bin/x86_64-linux-gcc" ARCH=x86_64 PREFIX="/mnt/development/buildroot/output/per-package/busybox/target" EXTRA_LDFLAGS="" CROSS_COMPILE="/mnt/development/buildroot/output/per-package/busybox/host/bin/x86_64-linux-" CONFIG_PREFIX="/mnt/development/buildroot/output/per-package/busybox/target" SKIP_STRIP=y oldconfig)

so they get executed prior to the directories being synced.

It works subsequently after sync because those paths are always reevaluated at runtime.

> I just did a build of the following configuration:
> 
> BR2_arm=y
> BR2_cortex_a9=y
> BR2_ARM_ENABLE_VFP=y
> BR2_TOOLCHAIN_EXTERNAL=y
> BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
> BR2_PER_PACKAGE_DIRECTORIES=y
> BR2_INIT_NONE=y
> BR2_SYSTEM_BIN_SH_NONE=y
> BR2_PACKAGE_BUSYBOX_SHOW_OTHERS=y
> BR2_PACKAGE_LIBTIRPC=y
> # BR2_TARGET_ROOTFS_TAR is not set
> 
> and I couldn't see the errors (but perhaps I missed them). Could you
> provide an example configuration, the details of the error, and a
> rationale as to why not finding libtirpc is not a problem when we in
> fact expect to find it?

My configure and build log:

https://pastebin.com/w8WAGE53

for the pkg-config issues you should see:

/bin/bash: /mnt/development/buildroot/output/per-package/busybox/host/bin/pkg-config: No such file or directory
/bin/bash: /mnt/development/buildroot/output/per-package/busybox/host/bin/pkg-config: No such file or directory
/bin/bash: /mnt/development/buildroot/output/per-package/busybox/host/bin/pkg-config: No such file or directory
/bin/bash: /mnt/development/buildroot/output/per-package/busybox/host/bin/pkg-config: No such file or directory

You'll also see other errors such as:

/mnt/development/buildroot/output/build/busybox-1.35.0/scripts/gcc-version.sh: line 11: /mnt/development/buildroot/output/per-package/busybox/host/bin/x86_64-linux-gcc: No such file or directory
make[2]: /mnt/development/buildroot/output/per-package/busybox/host/bin/x86_64-linux-gcc: Command not found

but those are covered by the previous patch

> 
> Thanks!
> 
> Thomas
> --
> Thomas Petazzoni, co-owner and CEO, Bootlin
> Embedded Linux and Kernel engineering and training
> https://bootlin.com
> CAUTION: This email originated from outside of the organization. Do not click
> links or open attachments unless you recognize the sender and know the
> content is safe.

- Vincent
Yann E. MORIN Nov. 2, 2022, 9:53 p.m. UTC | #3
Thomas, Vincent, All,

On 2022-11-01 23:41 +0100, Thomas Petazzoni via buildroot spake thusly:
> Hello Vincent,
> 
> On Fri,  7 Oct 2022 18:50:02 -0500
> Vincent Fazio <vfazio@xes-inc.com> wrote:
> 
> > When busybox.mk gets read, pkg-conf gets executed to determine the
> > location of relevant libraries.
> > 
> > When Busybox is built with per-package directories enabled, a number of
> > errors related to executing pkg-conf occur because directories have not
> > been synced to provide pkg-confg at the point when it executes.
> 
> I don't get this. If pkg-config is executed before the per-package
> directories are created... then how can pkg-config find libtirpc?

We did look at this together with Vincent back then.

The issue is that pkg-config is called as part of BUSYBOX_CFLAGS and
BUSYBOX_CFLAGS_busybox, which are part of BUSYBOX_MAKE_ENV, which will
eventually be part of the environment when calling one of the kconfig
frontends, like 'config' (when applying the configuration), or
menuconfig et al.

At that time, only parts of the PPD have been gathered, and not the
parts needed to configure and build, so host-pkgconf is not rsynced to
the busybox PPD.

Then later on, when we do build, host-pkgconf is rsynced, so we do get
the libtirpc CFLAGs and LDFLAGS, and the build does succeed.

It is quite difficult to follow all the trails. Idealy, we'd want to
provide a proper rsynced PPD for configurators, maybe, but in this case,
it is superfluous, and finding the right spot was... not trivial.

So, with Vincent, we concluded that:
  - the error messages are benign
  - but hey are confusing
  - the simplest solution to get rid of them is to silence the call to
    pkg-config

[--SNIP--]
> and I couldn't see the errors (but perhaps I missed them). Could you
> provide an example configuration, the details of the error, and a
> rationale as to why not finding libtirpc is not a problem when we in
> fact expect to find it?

    BR2_x86_i686=y
    BR2_TOOLCHAIN_EXTERNAL=y
    BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_X86_I686_UCLIBC_BLEEDING_EDGE=y
    BR2_PACKAGE_LIBTIRPC=y

    $ make clean
    $ make busybox-menuconfig
    >>> busybox 1.35.0 Patching
    [...]
    Applying 0005-nslookup-sanitize-all-printed-strings-with-printable.patch using patch:
    patching file networking/nslookup.c
    /bin/sh: /home/ymorin/dev/buildroot/O/master/host/bin/pkg-config: No such file or directory
    /bin/sh: /home/ymorin/dev/buildroot/O/master/host/bin/pkg-config: No such file or directory
    /bin/sh: /home/ymorin/dev/buildroot/O/master/host/bin/pkg-config: No such file or directory
    /bin/sh: /home/ymorin/dev/buildroot/O/master/host/bin/pkg-config: No such file or directory
    Using /home/ymorin/dev/buildroot/O/master/build/busybox-1.35.0/.config as base
    #
    # merged configuration written to
    # /home/ymorin/dev/buildroot/O/master/build/busybox-1.35.0/.config
    # (needs make)
    #
    /bin/sh: /home/ymorin/dev/buildroot/O/master/host/bin/pkg-config: No such file or directory
    /bin/sh: /home/ymorin/dev/buildroot/O/master/host/bin/pkg-config: No such file or directory

    [...]

    /bin/sh: /home/ymorin/dev/buildroot/O/master/host/bin/pkg-config: No such file or directory
    /bin/sh: /home/ymorin/dev/buildroot/O/master/host/bin/pkg-config: No such file or directory
    /bin/sh: /home/ymorin/dev/buildroot/O/master/host/bin/pkg-config: No such file or directory
    /bin/sh: /home/ymorin/dev/buildroot/O/master/host/bin/pkg-config: No such file or directory
    CFLAGS="-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -g0 "`/home/ymorin/dev/buildroot/O/master/host/bin/pkg-config --cflags libtirpc`""
    CFLAGS_busybox=""`/home/ymorin/dev/buildroot/O/master/host/bin/pkg-config --libs libtirpc`"" 
    PKG_CONFIG_PATH="" /usr/bin/make 
        -j9 -C /home/ymorin/dev/buildroot/O/master/build/busybox-1.35.0
        HOSTCC="/usr/bin/gcc"
        AR="/home/ymorin/dev/buildroot/O/master/host/bin/i686-linux-gcc-ar"
        NM="/home/ymorin/dev/buildroot/O/master/host/bin/i686-linux-gcc-nm"
        RANLIB="/home/ymorin/dev/buildroot/O/master/host/bin/i686-linux-gcc-ranlib"
        CC="/home/ymorin/dev/buildroot/O/master/host/bin/i686-linux-gcc"
        ARCH=i386
        PREFIX="/home/ymorin/dev/buildroot/O/master/target"
        EXTRA_LDFLAGS=""
        CROSS_COMPILE="/home/ymorin/dev/buildroot/O/master/host/bin/i686-linux-"
        CONFIG_PREFIX="/home/ymorin/dev/buildroot/O/master/target"
        SKIP_STRIP=y
        menuconfig
    /bin/sh: /home/ymorin/dev/buildroot/O/master/host/bin/pkg-config: No such file or directory
    /bin/sh: /home/ymorin/dev/buildroot/O/master/host/bin/pkg-config: No such file or directory
      HOSTLD  scripts/kconfig/mconf
      HOSTCC  scripts/kconfig/lxdialog/checklist.o
      HOSTCC  scripts/kconfig/lxdialog/inputbox.o
      HOSTCC  scripts/kconfig/lxdialog/lxdialog.o
      HOSTCC  scripts/kconfig/lxdialog/menubox.o
      HOSTCC  scripts/kconfig/lxdialog/msgbox.o
      HOSTCC  scripts/kconfig/lxdialog/textbox.o
      HOSTCC  scripts/kconfig/lxdialog/util.o
      HOSTCC  scripts/kconfig/lxdialog/yesno.o
      HOSTLD  scripts/kconfig/lxdialog/lxdialog
    scripts/kconfig/mconf Config.in

And then again further one...

BTW, notice how CFLAGS are incorrectly quoted:

    CFLAGS="-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -g0 "`/home/ymorin/dev/buildroot/O/master/host/bin/pkg-config --cflags libtirpc`""
                                                                                     ^---------------------------------------------------------------------------^

That's because of:
    20: BUSYBOX_CFLAGS = $(TARGET_CFLAGS)
    82: BUSYBOX_CFLAGS += "`$(PKG_CONFIG_HOST_BINARY) --cflags libtirpc`"

which are then passed as:
    91: CFLAGS="$(BUSYBOX_CFLAGS)"

Vincent, could you come to fix that? ;-)

Regards,
Yann E. MORIN.
Thomas Petazzoni Nov. 2, 2022, 10:11 p.m. UTC | #4
On Wed, 2 Nov 2022 22:53:55 +0100
"Yann E. MORIN" <yann.morin.1998@free.fr> wrote:

> We did look at this together with Vincent back then.
> 
> The issue is that pkg-config is called as part of BUSYBOX_CFLAGS and
> BUSYBOX_CFLAGS_busybox, which are part of BUSYBOX_MAKE_ENV, which will
> eventually be part of the environment when calling one of the kconfig
> frontends, like 'config' (when applying the configuration), or
> menuconfig et al.
> 
> At that time, only parts of the PPD have been gathered, and not the
> parts needed to configure and build, so host-pkgconf is not rsynced to
> the busybox PPD.

But perhaps we should not pass those CFLAGS during the "configurator"
step?

Thomas
diff mbox series

Patch

diff --git a/package/busybox/busybox.mk b/package/busybox/busybox.mk
index ef628e90e9..0dec8d6d60 100644
--- a/package/busybox/busybox.mk
+++ b/package/busybox/busybox.mk
@@ -79,10 +79,10 @@  BUSYBOX_DEPENDENCIES = \
 # support for NFS mounting with BusyBox
 ifeq ($(BR2_PACKAGE_LIBTIRPC),y)
 BUSYBOX_DEPENDENCIES += libtirpc host-pkgconf
-BUSYBOX_CFLAGS += "`$(PKG_CONFIG_HOST_BINARY) --cflags libtirpc`"
+BUSYBOX_CFLAGS += "`$(PKG_CONFIG_HOST_BINARY) --cflags libtirpc 2>/dev/null`"
 # Don't use LDFLAGS for -ltirpc, because LDFLAGS is used for
 # the non-final link of modules as well.
-BUSYBOX_CFLAGS_busybox += "`$(PKG_CONFIG_HOST_BINARY) --libs libtirpc`"
+BUSYBOX_CFLAGS_busybox += "`$(PKG_CONFIG_HOST_BINARY) --libs libtirpc 2>/dev/null`"
 endif
 
 # Allows the build system to tweak CFLAGS