On 2023-08-05 21:00, adigitoleo (Leon) wrote:
> Hello,
>
> I'm new to txr and was attempting a cross-compile to armv6l,
> however configure is failing with the following error:
>
>> Errors from compilation:
>>
>> CC conftest.c -> conftest.o
>> In file included from /usr/arm-linux-gnueabihf/usr/include/features.h:392,
>> from /usr/arm-linux-gnueabihf/usr/include/bits/libc-header-start.h:33,
>> from /usr/arm-linux-gnueabihf/usr/include/limits.h:26,
>> from /usr/lib/gcc/arm-linux-gnueabihf/12.2/include-fixed/limits.h:203,
>> from /usr/lib/gcc/arm-linux-gnueabihf/12.2/include-fixed/syslimits.h:7,
>> from /usr/lib/gcc/arm-linux-gnueabihf/12.2/include-fixed/limits.h:34,
>> from conftest.c:1:
>> /usr/arm-linux-gnueabihf/usr/include/features-time64.h:26:5: error: #error "_TIME_BITS=64 is allowed only with _
Hi Leon,
I have a proposed patch for this. The idea is that we don't independently try
ways of enabling 64 bit off_t and time_t. We test them together in combinations
and skip over anything that fails to compile. If we find a combination of
options that simultaneously gives us 64 bit time_t and off_t, we use those
two options. Otherwise if we happen to find that just one or the other can be
turned on, we go with that one option.
Note that if you build on a 32 bit system in which it is found that there
is a way to turn on 64 bit time_t, the configure script will bail and
tell you to use the --big-time option to select that, or else --no-big-time
to stick with 32 bit time_t. (That's existing logic, not being added
by this patch.) I want downstream users and package maintainers to
make the choice consciously rather than foist auto-detected 64 bit
time_t on them. In the case of large files, I made that automatic though.
Cheers ...
commit a96b5599a9d108eea6931b7b3a9c62abfabbd113
Author: Kaz Kylheku <kaz@???>
Date: Sat Aug 12 22:30:55 2023 -0700
configure: fix: _TIME_BITS is tied to _FILE_OFFSET_BITS
This problem was reported by Void Linux package maintainer
adigitoleo.
* configure: in glibc, _TIME_BITS and _FILE_OFFSET_BITS
are not independent. You cannot make the former 64 if
the latter isn't. I'm rewriting the test to check for
these together, in all combinations. We succeed if
we detect a combination that makes both time_t and
off_t 64 bits. If we don't find such a combination then
we at least enable 64 bit off_t alone or 64 bit time_t
alone, if we encountered an option which does that.
diff --git a/configure b/configure
index 823fad0a..720bcd77 100755
--- a/configure
+++ b/configure
@@ -3566,10 +3566,16 @@ fi
printf "Checking how to enable 64 bit off_t and time_t ..."
+file_offset_only_define=none
+time_bits_only_define=none
file_offset_define=none
time_bits_define=none
-for try in NOTHING _LARGE_FILES=1 _FILE_OFFSET_BITS=64 _TIME_BITS=64; do
+# We have a nested loop over pairs of options for off_t and time_t
+# because in Glibc, they are not independent. _TIME_BITS=64 cannot
+# be enabled if _FILE_OFFSET_BITS=64 isn't.
+for try_f in NOTHING _LARGE_FILES=1 _FILE_OFFSET_BITS=64; do
+ for try_t in NOTHING _TIME_BITS=64; do
cat > conftest.c <<!
#include <limits.h>
#include <time.h>
@@ -3591,48 +3597,80 @@ struct sizes {
"\nSIZEOF_TIME_T=", DEC(sizeof (time_t)),
"\n"
};
-
!
- if ! conftest_o EXTRA_FLAGS=-D$try ; then
- printf "failed\n\n"
+ if ! conftest_o EXTRA_FLAGS="-D$try_f -D$try_t" ; then
+ continue
+ fi
- printf "Errors from compilation: \n\n"
- cat conftest.err
- exit 1
- fi
+ eval $(tr '\0' ' ' < conftest.o | grep SIZEOF | sed -e 's/ *//')
- eval $(tr '\0' ' ' < conftest.o | grep SIZEOF | sed -e 's/ *//')
+ if [ $SIZEOF_OFF_T -eq 0 -o $SIZEOF_BYTE -eq 0 ] ; then
+ printf "failed\n"
+ exit 1
+ fi
- if [ $SIZEOF_OFF_T -eq 0 -o $SIZEOF_BYTE -eq 0 ] ; then
- printf "failed\n"
- exit 1
- fi
+ # Regardless of what happens with time_t, if we detect the
+ # enabling of 64 bit off_t, we record then in the
+ # file_offset_only_define variable, and keep going.
+
+ if [ "$file_offset_only_define" = none ] ; then
+ if [ $(( SIZEOF_BYTE * SIZEOF_OFF_T )) -eq 64 ] ; then
+ if [ $try_f = NOTHING ] ; then
+ file_offset_only_define=
+ else
+ file_offset_only_define=$try_f
+ fi
+ fi
+ fi
- if [ "$file_offset_define" = none ] ; then
- if [ $(( SIZEOF_BYTE * SIZEOF_OFF_T )) -eq 64 ] ; then
- if [ $try = NOTHING ] ; then
- file_offset_define=
- else
- printf -- " -D%s" $try
- file_offset_define=$try
+ # Regardless of what happens with off_t, if we detect the
+ # enabling of 64 bit time_t, we record then in the
+ # time_bits_only_define variable, and keep going.
+
+ if [ "$time_bits_only_define" = none ] ; then
+ if [ $(( SIZEOF_BYTE * SIZEOF_TIME_T )) -eq 64 ] ; then
+ if [ $try_t = NOTHING ] ; then
+ time_bits_only_define=
+ else
+ time_bits_only_define=$try_t
+ fi
fi
fi
- fi
- if [ "$time_bits_define" = none ] ; then
- if [ $(( SIZEOF_BYTE * SIZEOF_TIME_T )) -eq 64 ] ; then
- if [ $try = NOTHING ] ; then
+ # If we get a combination of options (or lack thereof) that results in
+ # both 64 bit off_t and time_t, then we record those and are done.
+
+ if [ $(( SIZEOF_BYTE * SIZEOF_OFF_T )) -eq 64 ] && \
+ [ $(( SIZEOF_BYTE * SIZEOF_TIME_T )) -eq 64 ]
+ then
+ if [ $try_f = NOTHING ] ; then
+ file_offset_define=
+ else
+ file_offset_define=$try_f
+ fi
+ if [ $try_t = NOTHING ] ; then
time_bits_define=
else
- printf -- " -D%s" $try
- time_bits_define=$try
+ time_bits_define=$try_t
fi
- fi
- fi
- [ "$file_offset_define" = none -o "$time_bits_define" = none ] || break
+ break
+ fi
+ done
done
+# If 64 bit time_t was not detected, here we check whether we did
+# detect 64 bit off_t in above loop; and copy that auxiliary variable.
+if [ "$time_bits_define" = none -a -n "$file_offset_only_define" ] ; then
+ file_offset_define=$file_offset_only_define
+fi
+
+# Vice versa, if 64 bit off_t was not detected, here we check whether we did
+# detect 64 bit time_t in above loop; and copy that auxiliary variable.
+if [ "$file_offset_define" = none -a -n "$time_bits_only_define" ] ; then
+ time_bits_define=$time_bits_only_define
+fi
+
case "$time_bits_define" in
none )
if [ "$big_time" ] ; then
@@ -3663,6 +3701,7 @@ esac
if [ "$file_offset_define" = none ] ; then
printf " (no 64 bit off_t)"
elif [ -n "$file_offset_define" ] ; then
+ printf -- " -D%s" "$file_offset_define"
printf "#define CONFIG_LARGE_FILE_OFFSET 1\n" >> config.h
lang_flags="$lang_flags -D$file_offset_define"
fi
@@ -3670,6 +3709,7 @@ fi
if [ "$time_bits_define" = none ] ; then
printf " (no 64 bit time_t)"
elif [ -n "$time_bits_define" ] ; then
+ printf -- " -D%s" "$time_bits_define"
lang_flags="$lang_flags -D$time_bits_define"
fi