[Buildroot] build failure on Ubuntu 22.04 LTS: TIME_BITS=64 is allowed only with FILE_OFFSET_BITS=64

Yann E. MORIN yann.morin.1998 at free.fr
Sat Feb 17 11:55:41 UTC 2024


Christian, All,

On 2024-02-17 01:32 -0800, Christian Stewart via buildroot spake thusly:
> On a fresh Ubuntu 22.04.4 LTS VM:

That also happens on Fedora 39.

> cat <<EOF >> defconfig
> BR2_arm=y
> BR2_cortex_a7=y
> BR2_BINUTILS_VERSION_2_41_X=y
> BR2_GCC_VERSION_13_X=y
> BR2_TOOLCHAIN_BUILDROOT_CXX=y
> BR2_CCACHE=y
> BR2_PACKAGE_SUDO=y
> EOF
> 
> make defconfig BR2_DEFCONFIG=defconfig

It would have been easier to debug if the full error message and the
offending command were provided, so here it is:

    >>> sudo 1.9.15p5 Configuring
    [--SNIP--]
    /usr/bin/make \
        PATH="/home/ymorin/dev/buildroot/O/master/per-package/sudo/host/bin:....]:/usr/bin:/usr/sbin" 
        [--SNIP--]
        AR="/usr/bin/ar" \
        AS="/usr/bin/as" \
        LD="/usr/bin/ld" \
        NM="/usr/bin/nm"
        CC="/usr/bin/gcc" \
        GCC="/usr/bin/gcc" \
        CXX="/usr/bin/g++" \
        CPP="/usr/bin/cpp" \
        OBJCOPY="/usr/bin/objcopy" \
        RANLIB="/usr/bin/ranlib" \
        CPPFLAGS="-I/home/ymorin/dev/buildroot/O/master/per-package/sudo/host/include" \
        CFLAGS="-O2 -I/home/ymorin/dev/buildroot/O/master/per-package/sudo/host/include" \
        CXXFLAGS="-O2 -I/home/ymorin/dev/buildroot/O/master/per-package/sudo/host/include" \
        LDFLAGS="-L/home/ymorin/dev/buildroot/O/master/per-package/sudo/host/lib -Wl,-rpath,/home/ymorin/dev/buildroot/O/master/per-package/sudo/host/lib" \
        CPPFLAGS="-I/home/ymorin/dev/buildroot/O/master/per-package/sudo/host/include -I../../include -I../.." \
        -C /home/ymorin/dev/buildroot/O/master/build/sudo-1.9.15p5/lib/util \
        mksigname mksiglist
    /usr/bin/cpp \
        -I/home/ymorin/dev/buildroot/O/master/per-package/sudo/host/include \
        -I../../include \
        -I../.. \
        ./sys_signame.h \
    | /usr/bin/sed -e '1,/^int sudo_end_of_headers;/d' -e '/^#/d' > mksigname.h
    In file included from /usr/include/features.h:394,
                     from /usr/include/sys/types.h:25,
                     from ./sys_signame.h:4:
    /usr/include/features-time64.h:26:5: error: #error "_TIME_BITS=64 is allowed only with _FILE_OFFSET_BITS=64"
       26 | #   error "_TIME_BITS=64 is allowed only with _FILE_OFFSET_BITS=64"
          |     ^~~~~
    /usr/bin/gcc -I../../include -I../.. -I. -I. \
        -D_PATH_SUDO_CONF=\"/etc/sudo.conf\"
        -I/home/ymorin/dev/buildroot/O/master/per-package/sudo/host/include \
        -DDEFAULT_TEXT_DOMAIN=\"sudo\" \
        -O2 \
        -I/home/ymorin/dev/buildroot/O/master/per-package/sudo/host/include \
        ./mksigname.c -o mksigname
    In file included from /usr/include/features.h:394,
                     from /usr/include/bits/libc-header-start.h:33,
                     from /usr/include/stdlib.h:26,
                     from ./mksigname.c:27:
    /usr/include/features-time64.h:26:5: error: #error "_TIME_BITS=64 is allowed only with _FILE_OFFSET_BITS=64"
       26 | #   error "_TIME_BITS=64 is allowed only with _FILE_OFFSET_BITS=64"
          |     ^~~~~
    make[2]: *** [Makefile:263: mksigname] Error 1

In fact, there are *two* issues there.

The first, which is the easiest to fix, is that the call to cpp is
piped into a call to sed. cpp fails, but because of the pipe, its exit
status is lost. The sed succeeds, though, so the rule as a whole
succeeds. Then the call to gcc fails, which is fortunate, or we'd have
missed the previous failure of cpp. This is trivial to fix: use a temp
file for the output of cpp, and run the sed with that temp file as
input, as a separate command in the same rule:

    --- lib/util/Makefile.orig	2024-02-17 12:25:13.554448884 +0100
    +++ lib/util/Makefile	2024-02-17 12:26:20.727968989 +0100
    @@ -273,10 +273,12 @@
     	fi
     
     mksiglist.h: $(srcdir)/sys_siglist.h
    -	$(CPP) $(CPPFLAGS) $(srcdir)/sys_siglist.h | $(SED) -e '1,/^int sudo_end_of_headers;/d' -e '/^#/d' > mksiglist.h
    +	$(CPP) $(CPPFLAGS) $(srcdir)/sys_siglist.h > mksiglist.h.tmp
    +	$(SED) -e '1,/^int sudo_end_of_headers;/d' -e '/^#/d' < mksiglist.h.tmp > mksiglist.h
     
     mksigname.h: $(srcdir)/sys_signame.h
    -	$(CPP) $(CPPFLAGS) $(srcdir)/sys_signame.h | $(SED) -e '1,/^int sudo_end_of_headers;/d' -e '/^#/d' > mksigname.h
    +	$(CPP) $(CPPFLAGS) $(srcdir)/sys_signame.h > mksigname.h.tmp
    +	$(SED) -e '1,/^int sudo_end_of_headers;/d' -e '/^#/d' < mksigname.h.tmp > mksigname.h
     
     closefrom_test: $(CLOSEFROM_TEST_OBJS) libsudo_util.la
     	$(LIBTOOL) $(LTFLAGS) --mode=link $(CC) -o $@ $(CLOSEFROM_TEST_OBJS) libsudo_util.la $(ASAN_LDFLAGS) $(PIE_LDFLAGS) $(HARDENING_LDFLAGS) $(TEST_LDFLAGS) $(TEST_LIBS)

The second issue is quite more involved. Indeed, those are hapenning
while running the SUDO_BUILD_MKSIGNAME_MKSIGLIST_HOST post-configure
hook. It has been present for quite a while now, so let's revisit this.

First, what hapenns for host-sudo? Well, we don't have it, so let's try
a dirty hack with:

    @@ -87,3 +87,22 @@ endef
     SUDO_POST_INSTALL_TARGET_HOOKS += SUDO_ENABLE_SUDO_GROUP_RULE
    
     $(eval $(autotools-package))
    +
    +HOST_SUDO_CONF_OPTS = \
    +       --without-lecture \
    +       --without-sendmail \
    +       --without-umask \
    +       --with-logging=syslog \
    +       --without-interfaces \
    +       --with-env-editor \
    +       --without-pam \
    +       --disable-zlib \
    +       --without-ldap \
    +       --disable-openssl
    +
    +HOST_SUDO_INSTALL_OPTS = \
    +       INSTALL_OWNER="" \
    +       DESTDIR="$(HOST_DIR)" \
    +       install
    +
    +$(eval $(host-autotools-package))

    $ make host-sudo-build 2>&1 |tee host-sudo.log
    [ succeeds ]

    $ grep -E 'mksig(list|name)' host-sudo.log
    [ empty ]

So, a host build does not need to run those tools... Let's try to get
rid of them in the target build as well...

    @@ -65,7 +65,7 @@ define SUDO_BUILD_MKSIGNAME_MKSIGLIST_HOST
     	-C $(@D)/lib/util mksigname mksiglist
     endef

    -SUDO_POST_CONFIGURE_HOOKS += SUDO_BUILD_MKSIGNAME_MKSIGLIST_HOST
    +#SUDO_POST_CONFIGURE_HOOKS += SUDO_BUILD_MKSIGNAME_MKSIGLIST_HOST

     define SUDO_PERMISSIONS
     	/usr/bin/sudo f 4755 0 0 - - - - -

    $ make sudo-build
    [ succeeds ]

OK, so is that supperfluous at all nowadays?

Can you further investigate, enabling PAM et al in turn and see if any
optional dependency triggers a call to those two utilities? If not, can
you look sunce when that is no longer needed and why?

Oh, and could you work on my proposed fix and send iut upstream?

Regards,
Yann E. MORIN.

> # fails with error shown below
> make sudo
> 
> I was able to fix it with this patch, but I'm not sure if this is the "correct"
> fix:
> 
> From 6dc2b9350ceffc808fe7d048ff9dbe585649c304 Mon Sep 17 00:00:00 2001
> From: Christian Stewart <[2]christian at aperture.us>
> Date: Sat, 17 Feb 2024 01:16:09 -0800
> Subject: [PATCH] package/Makefile.in: fix build failure on Ubuntu 22.04 LTS
> 
> Add flags for 64 bit timestamps when building host packages.
> 
> -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
> 
> Build failure fixed:
> 
> /usr/include/features-time64.h:26:5: error: #error "_TIME_BITS=64 is allowed
> only with _FILE_OFFSET_BITS=64"
>    26 | #   error "_TIME_BITS=64 is allowed only with _FILE_OFFSET_BITS=64"
> 
> Fixes: [3]https://github.com/skiffos/SkiffOS/issues/306
> 
> Signed-off-by: Christian Stewart <[4]christian at aperture.us>
> ---
>  package/Makefile.in | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/package/Makefile.in b/package/Makefile.in
> index 3e276d23d6..82d3a435fd 100644
> --- a/package/Makefile.in
> +++ b/package/Makefile.in
> @@ -246,7 +246,7 @@ UNZIP := $(shell which unzip || type -p unzip) -q
>  
>  APPLY_PATCHES = PATH=$(HOST_DIR)/bin:$$PATH support/scripts/apply-patches.sh $
> (if $(QUIET),-s)
>  
> -HOST_CPPFLAGS  = -I$(HOST_DIR)/include
> +HOST_CPPFLAGS  = -I$(HOST_DIR)/include -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
>  HOST_CFLAGS   ?= -O2
>  HOST_CFLAGS   += $(HOST_CPPFLAGS)
>  HOST_CXXFLAGS += $(HOST_CFLAGS)
> --
> 2.43.1
> 
> Thanks,
> Christian Stewart
> 
> 
> References:
> 
> [1] https://github.com/buildroot/buildroot
> [2] mailto:christian at aperture.us
> [3] https://github.com/skiffos/SkiffOS/issues/306
> [4] mailto:christian at aperture.us

> _______________________________________________
> buildroot mailing list
> buildroot at buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot


-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'



More information about the buildroot mailing list