diff mbox series

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

Message ID CA+h8R2qSV+Yd=HDfNKKFvERdWRTdsXxpsnZe9DHG26pEigphaQ@mail.gmail.com
State Not Applicable
Headers show
Series build failure on Ubuntu 22.04 LTS: TIME_BITS=64 is allowed only with FILE_OFFSET_BITS=64 | expand

Commit Message

Christian Stewart Feb. 17, 2024, 9:32 a.m. UTC
On a fresh Ubuntu 22.04.4 LTS VM:

git clone https://github.com/buildroot/buildroot
cd buildroot

# master as of this e-mail
git checkout 6c455505eb5ed8ed5bbf090f2bfb6241c9f153a2

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

# 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 <christian@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: https://github.com/skiffos/SkiffOS/issues/306

Signed-off-by: Christian Stewart <christian@aperture.us>
---
 package/Makefile.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

 HOST_CXXFLAGS += $(HOST_CFLAGS)

Comments

Christian Stewart Feb. 17, 2024, 10:28 a.m. UTC | #1
Hi,

The fix I included in the e-mail below does not work in all cases.

This works to specifically fix the sudo build failure on Ubuntu 22.04.4 LTS:

On Sat, Feb 17, 2024 at 1:32 AM Christian Stewart <christian@aperture.us> wrote:
>
> On a fresh Ubuntu 22.04.4 LTS VM:
>
> git clone https://github.com/buildroot/buildroot
> cd buildroot
>
> # master as of this e-mail
> git checkout 6c455505eb5ed8ed5bbf090f2bfb6241c9f153a2
>
> 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
>
> # fails with error shown below
> make sudo
>

Here is an alternative fix which patches Sudo specifically:

From 3e39260ea5ee16d95363f51d5684447636269096 Mon Sep 17 00:00:00 2001
From: Christian Stewart <christian@aperture.us>
Date: Sat, 17 Feb 2024 01:16:09 -0800
Subject: [PATCH] package/sudo: set FILE_OFFSET_BITS and TIME_BITS for host
 mksiglist

Add flags for 64 bit timestamps when building host mksiglist.

-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: https://github.com/skiffos/SkiffOS/issues/306

Signed-off-by: Christian Stewart <christian@aperture.us>
---
 ...e.in-set-TIME_BITS-and-FILE_OFFSET_B.patch | 28 +++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100644
package/sudo/0001-lib-util-Makefile.in-set-TIME_BITS-and-FILE_OFFSET_B.patch

diff --git a/package/sudo/0001-lib-util-Makefile.in-set-TIME_BITS-and-FILE_OFFSET_B.patch
b/package/sudo/0001-lib-util-Makefile.in-set-TIME_BITS-and-FILE_OFFSET_B.patch
new file mode 100644
index 0000000000..fb84002c24
--- /dev/null
+++ b/package/sudo/0001-lib-util-Makefile.in-set-TIME_BITS-and-FILE_OFFSET_B.patch
@@ -0,0 +1,28 @@
+From 7a0074a82248228062054476bd317b9a40af58dd Mon Sep 17 00:00:00 2001
+From: Christian Stewart <christian@aperture.us>
+Date: Sat, 17 Feb 2024 02:22:46 -0800
+Subject: [PATCH] lib/util/Makefile.in: set TIME_BITS and FILE_OFFSET_BITS to
+ 64
+
+Fixes a build failure building mksiglist on Ubuntu 22.04.4 LTS.
+
+Signed-off-by: Christian Stewart <christian@aperture.us>
+---
+ lib/util/Makefile.in | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/lib/util/Makefile.in b/lib/util/Makefile.in
+index 05455f701..a8c84888b 100644
+--- a/lib/util/Makefile.in
++++ b/lib/util/Makefile.in
+@@ -72,6 +72,7 @@ CPPDEFS = -D_PATH_SUDO_CONF=\"@sudo_conf@\"
+ CPPFLAGS = -I$(incdir) -I$(top_builddir) -I. -I$(srcdir) $(CPPDEFS) \
+         @CPPFLAGS@ -DDEFAULT_TEXT_DOMAIN=\"@PACKAGE_NAME@\"
+ HOSTCPPFLAGS = -I$(incdir) -I$(top_builddir) -I. -I$(srcdir) $(CPPDEFS) \
++           -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 \
+            @CPPFLAGS_FOR_BUILD@ -DDEFAULT_TEXT_DOMAIN=\"@PACKAGE_NAME@\"
+
+ # Usually -O and/or -g
+--
+2.43.1
+
Yann E. MORIN Feb. 17, 2024, 11:55 a.m. UTC | #2
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@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@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@aperture.us
> [3] https://github.com/skiffos/SkiffOS/issues/306
> [4] mailto:christian@aperture.us

> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot
Yann E. MORIN Feb. 17, 2024, 5:31 p.m. UTC | #3
Christian, All,

On 2024-02-17 12:55 +0100, Yann E. MORIN spake thusly:
> 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.
[--SNIP--]
>     /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"
>           |     ^~~~~
[--SNIP--]
>     @@ -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?

I've now sent a patch for that:

https://patchwork.ozlabs.org/project/buildroot/patch/20240217172923.3629905-1-yann.morin.1998@free.fr/

Regards,
Yann E. MORIN.
Yann E. MORIN Feb. 17, 2024, 5:46 p.m. UTC | #4
Christian, All,

On 2024-02-17 12:55 +0100, Yann E. MORIN spake thusly:
[--SNIP--]
> 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)

I've now sent a patch for that:

    https://github.com/sudo-project/sudo/pull/360

Regards,
Yann E. MORIN.
diff mbox series

Patch

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)