On Fri, 2023-01-06 at 17:01 +0000, Antonin Godard wrote:
> Busybox's compiling process alters autoconf.h. When compiling a second
> time (e.g. with `compile -f`), busybox uses this altered file for
> compiling, which ultimately produces different binaries.
> 
> This can produce errors like this one:
> 
> ERROR: busybox-1.35.0-r0 do_package: Error executing a python function in 
> exec_func_python() autogenerated:
> The stack trace of python calls that resulted in this exception/failure was:
> File: 'exec_func_python() autogenerated', lineno: 2, function: <module>
>      0001:
>  *** 0002:ptest_update_alternatives(d)
>      0003:
> File: '…/poky/meta/classes/ptest.bbclass', lineno: 100, function: 
> ptest_update_alternatives
>      0096:        for alt_name, alt_link, alt_target, _ in alternatives:
>      0097:            # Some alternatives are for man pages,
>      0098:            # check if the alternative is in PATH
>      0099:            if os.path.dirname(alt_link) in bin_paths:
>  *** 0100:                os.symlink(alt_target, os.path.join(ptest_bindir, 
> alt_name))
>      0101:}
>      0102:
>      0103:do_configure_ptest_base[dirs] = "${B}"
>      0104:do_compile_ptest_base[dirs] = "${B}"
> Exception: FileExistsError: [Errno 17] File exists: '/bin/busybox.suid' -> 
> '…/busybox/1.35.0-r0/package/usr/lib/busybox/ptest/bin/login'
> 
> This happens because ALTERNATIVE:busybox contains `/bin/login` twice,
> initially that's because `/bin/login` is present in both
> busybox.links.suid and busybox.links.nosuid. The reason for that is
> because of the altered autoconf.h.
> 
> Steps to reproduce above error:
> 
> <add ptest to distro configs>
> bitbake busybox -c clean
> bitbake busybox -c package -f
> bitbake busybox -c compile -f
> bitbake busybox -c package -f

Thanks. This patch looks much better and is on the right list.

I did now also confirm that the ptest in/out of DISTRO_FEATURES doesn't
matter. You just need:

bitbake busybox -c compile -f
bitbake busybox -c package -f
bitbake busybox -c compile -f
bitbake busybox -c package -f

This means it is just a re-run of do_compile problem and the issue is
the timestamps on .config and include/autoconf.h need to match.

I can see a whole load of potential bugs here so I was wondering if you
could tweak your patch to:

a) at the end of do_configure, always copy .config and
include/autoconf.h to ".orig" copies.

b) Always restore clean copies at the start of do_compile

c) At the end of the do_compile function, .config is restored, we
should also restore a matching autoconf.h

d) Add a comment about the timestamps of .config and autoconf.h needing
to match.

This should mean that a compile doesn't reuse an obsolete .orig file if
configure was rerun and ensure that the right copy of autoconf.h is
restored at the end of do_compile.

Cheers,

Richard



> 
> This patch replaces include/autoconf.h by the original if it was
> previously saved.
> 
> Signed-off-by: Antonin Godard <[email protected]>
> ---
>  meta/recipes-core/busybox/busybox.inc | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/meta/recipes-core/busybox/busybox.inc 
> b/meta/recipes-core/busybox/busybox.inc
> index 5f1c473d5e..5dd783aa24 100644
> --- a/meta/recipes-core/busybox/busybox.inc
> +++ b/meta/recipes-core/busybox/busybox.inc
> @@ -145,6 +145,13 @@ do_compile() {
>       export KCONFIG_NOTIMESTAMP=1
> 
>       if [ "${BUSYBOX_SPLIT_SUID}" = "1" -a x`grep 
> "CONFIG_FEATURE_INDIVIDUAL=y" .config` = x ]; then
> +             # Restore or save original autoconf.h to start from a clean
> +             # state since the compiling process modifies this file.
> +             if [ -f include/autoconf.h.orig ]; then
> +                     cp include/autoconf.h.orig include/autoconf.h
> +             else
> +                     cp include/autoconf.h include/autoconf.h.orig
> +             fi
>               # split the .config into two parts, and make two busybox 
> binaries
>               if [ -e .config.orig ]; then
>                       # Need to guard again an interrupted do_compile - 
> restore any backup
> --
> 2.25.1
> 
> 
> 

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#175603): 
https://lists.openembedded.org/g/openembedded-core/message/175603
Mute This Topic: https://lists.openembedded.org/mt/96097561/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to