Message ID | 20220225171148.701977-1-romain.naour@gmail.com |
---|---|
State | Accepted |
Headers | show |
Series | package/Makefile.in: year2038 makes time_t 64-bit for glibc toolchains | expand |
>>>>> "Romain" == Romain Naour <romain.naour@gmail.com> writes: > To use time_t 64-bit for glibc >= 2.34 toolchains we have to set both > _FILE_OFFSET_BITS=64 and _TIME_BITS=64 for glibc toolchains. Buildroot > already define _FILE_OFFSET_BITS=64 since 2008 [1] before the first > release tag 2009.02. > _TIME_BITS is not needed for musl libc since it already year2038 > ready [2]. > The uclibc-ng libc only support time_t 32-bit (long int) so it will be > affected by the year2038 issue [3]. > Fixes (in French, chapter Buildroot 2022 and GlibC): > https://www.blaess.fr/christophe/2038 > Runtime tested with qemu_arm_vexpress_defconfig and the Bootlin glibc > bleeding-edge 2021.11-1 toolchain. > Before: > # date > Tue Jan 19 03:14:07 UTC 2038 > # date > Thu Jan 1 00:00:00 UTC 1970 > After: > # date > Tue Jan 19 03:14:07 UTC 2038 > # date > Tue Jan 19 03:14:08 UTC 2038 > # date > Tue Jan 19 03:14:09 UTC 2038 Ahh, good catch. Maybe something to add a runtime test for? Committed, thanks. > [1] 60b5eee76edfa153ef118d2788c74ac8da1497a0 > [2] https://git.musl-libc.org/cgit/musl/tree/include/alltypes.h.in?h=v1.2.2#n3 > [3] https://cgit.uclibc-ng.org/cgi/cgit/uclibc-ng.git/tree/include/time.h?h=v1.0.40#n75 > https://cgit.uclibc-ng.org/cgi/cgit/uclibc-ng.git/tree/libc/sysdeps/linux/common/bits/types.h?h=v1.0.40#n106 > Signed-off-by: Romain Naour <romain.naour@gmail.com> > Cc: Christophe Blaess <christophe.blaess@logilin.fr> > --- > package/Makefile.in | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > diff --git a/package/Makefile.in b/package/Makefile.in > index 508ea7c366..cde050ca82 100644 > --- a/package/Makefile.in > +++ b/package/Makefile.in > @@ -167,7 +167,7 @@ else ifeq ($(BR2_FORTIFY_SOURCE_2),y) > TARGET_HARDENED += -D_FORTIFY_SOURCE=2 > endif > -TARGET_CPPFLAGS += -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 > +TARGET_CPPFLAGS += -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64 > TARGET_CFLAGS = $(TARGET_CPPFLAGS) $(TARGET_ABI) $(TARGET_OPTIMIZATION) $(TARGET_DEBUGGING) $(TARGET_HARDENED) > TARGET_CXXFLAGS = $(TARGET_CFLAGS) > TARGET_FCFLAGS = $(TARGET_ABI) $(TARGET_OPTIMIZATION) $(TARGET_DEBUGGING) > -- > 2.35.1 > _______________________________________________ > buildroot mailing list > buildroot@buildroot.org > https://lists.buildroot.org/mailman/listinfo/buildroot
Hello Peter, Le 07/03/2022 à 20:54, Peter Korsgaard a écrit : >>>>>> "Romain" == Romain Naour <romain.naour@gmail.com> writes: > > > To use time_t 64-bit for glibc >= 2.34 toolchains we have to set both > > _FILE_OFFSET_BITS=64 and _TIME_BITS=64 for glibc toolchains. Buildroot > > already define _FILE_OFFSET_BITS=64 since 2008 [1] before the first > > release tag 2009.02. > > > _TIME_BITS is not needed for musl libc since it already year2038 > > ready [2]. > > > The uclibc-ng libc only support time_t 32-bit (long int) so it will be > > affected by the year2038 issue [3]. > > > Fixes (in French, chapter Buildroot 2022 and GlibC): > > https://www.blaess.fr/christophe/2038 > > > Runtime tested with qemu_arm_vexpress_defconfig and the Bootlin glibc > > bleeding-edge 2021.11-1 toolchain. > > > Before: > > # date > > Tue Jan 19 03:14:07 UTC 2038 > > # date > > Thu Jan 1 00:00:00 UTC 1970 > > > After: > > # date > > Tue Jan 19 03:14:07 UTC 2038 > > # date > > Tue Jan 19 03:14:08 UTC 2038 > > # date > > Tue Jan 19 03:14:09 UTC 2038 > > Ahh, good catch. Maybe something to add a runtime test for? > > Committed, thanks. Sorry but I guess this patch needs more testing. > > > [1] 60b5eee76edfa153ef118d2788c74ac8da1497a0 > > [2] https://git.musl-libc.org/cgit/musl/tree/include/alltypes.h.in?h=v1.2.2#n3 > > [3] https://cgit.uclibc-ng.org/cgi/cgit/uclibc-ng.git/tree/include/time.h?h=v1.0.40#n75 > > https://cgit.uclibc-ng.org/cgi/cgit/uclibc-ng.git/tree/libc/sysdeps/linux/common/bits/types.h?h=v1.0.40#n106 > > > Signed-off-by: Romain Naour <romain.naour@gmail.com> > > Cc: Christophe Blaess <christophe.blaess@logilin.fr> > > --- > > package/Makefile.in | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > diff --git a/package/Makefile.in b/package/Makefile.in > > index 508ea7c366..cde050ca82 100644 > > --- a/package/Makefile.in > > +++ b/package/Makefile.in > > @@ -167,7 +167,7 @@ else ifeq ($(BR2_FORTIFY_SOURCE_2),y) > > TARGET_HARDENED += -D_FORTIFY_SOURCE=2 > > endif > > > -TARGET_CPPFLAGS += -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 > > +TARGET_CPPFLAGS += -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64 I noticed that glibc 2.34 stop the build if _TIME_BITS is set without _FILE_OFFSET_BITS. What if something (build system) unset _FILE_OFFSET_BITS ? There is something weird with libzlib package. I suggest to apply for next first and backport it latter to the stable branch. Best regards, Romain > > TARGET_CFLAGS = $(TARGET_CPPFLAGS) $(TARGET_ABI) $(TARGET_OPTIMIZATION) $(TARGET_DEBUGGING) $(TARGET_HARDENED) > > TARGET_CXXFLAGS = $(TARGET_CFLAGS) > > TARGET_FCFLAGS = $(TARGET_ABI) $(TARGET_OPTIMIZATION) $(TARGET_DEBUGGING) > > -- > > > 2.35.1 > > > _______________________________________________ > > buildroot mailing list > > buildroot@buildroot.org > > https://lists.buildroot.org/mailman/listinfo/buildroot > >
On 07/03/2022 22:49, Romain Naour wrote: > Hello Peter, > > Le 07/03/2022 à 20:54, Peter Korsgaard a écrit : >>>>>>> "Romain" == Romain Naour <romain.naour@gmail.com> writes: >> >> > To use time_t 64-bit for glibc >= 2.34 toolchains we have to set both >> > _FILE_OFFSET_BITS=64 and _TIME_BITS=64 for glibc toolchains. Buildroot >> > already define _FILE_OFFSET_BITS=64 since 2008 [1] before the first >> > release tag 2009.02. >> >> > _TIME_BITS is not needed for musl libc since it already year2038 >> > ready [2]. >> >> > The uclibc-ng libc only support time_t 32-bit (long int) so it will be >> > affected by the year2038 issue [3]. >> >> > Fixes (in French, chapter Buildroot 2022 and GlibC): >> > https://www.blaess.fr/christophe/2038 >> >> > Runtime tested with qemu_arm_vexpress_defconfig and the Bootlin glibc >> > bleeding-edge 2021.11-1 toolchain. >> >> > Before: >> > # date >> > Tue Jan 19 03:14:07 UTC 2038 >> > # date >> > Thu Jan 1 00:00:00 UTC 1970 >> >> > After: >> > # date >> > Tue Jan 19 03:14:07 UTC 2038 >> > # date >> > Tue Jan 19 03:14:08 UTC 2038 >> > # date >> > Tue Jan 19 03:14:09 UTC 2038 >> >> Ahh, good catch. Maybe something to add a runtime test for? >> >> Committed, thanks. > > Sorry but I guess this patch needs more testing. > >> >> > [1] 60b5eee76edfa153ef118d2788c74ac8da1497a0 >> > [2] https://git.musl-libc.org/cgit/musl/tree/include/alltypes.h.in?h=v1.2.2#n3 >> > [3] https://cgit.uclibc-ng.org/cgi/cgit/uclibc-ng.git/tree/include/time.h?h=v1.0.40#n75 >> > https://cgit.uclibc-ng.org/cgi/cgit/uclibc-ng.git/tree/libc/sysdeps/linux/common/bits/types.h?h=v1.0.40#n106 >> >> > Signed-off-by: Romain Naour <romain.naour@gmail.com> >> > Cc: Christophe Blaess <christophe.blaess@logilin.fr> >> > --- >> > package/Makefile.in | 2 +- >> > 1 file changed, 1 insertion(+), 1 deletion(-) >> >> > diff --git a/package/Makefile.in b/package/Makefile.in >> > index 508ea7c366..cde050ca82 100644 >> > --- a/package/Makefile.in >> > +++ b/package/Makefile.in >> > @@ -167,7 +167,7 @@ else ifeq ($(BR2_FORTIFY_SOURCE_2),y) >> > TARGET_HARDENED += -D_FORTIFY_SOURCE=2 >> > endif >> >> > -TARGET_CPPFLAGS += -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 >> > +TARGET_CPPFLAGS += -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64 > > I noticed that glibc 2.34 stop the build if _TIME_BITS is set without > _FILE_OFFSET_BITS. > What if something (build system) unset _FILE_OFFSET_BITS ? Then there's something wrong with that package and it needs to be fixed. > There is something weird with libzlib package. gzguts.h has this: #ifdef _LARGEFILE64_SOURCE # ifndef _LARGEFILE_SOURCE # define _LARGEFILE_SOURCE 1 # endif # ifdef _FILE_OFFSET_BITS # undef _FILE_OFFSET_BITS # endif #endif Why, I have no idea... Regards, Arnout > > I suggest to apply for next first and backport it latter to the stable branch. > > Best regards, > Romain > > >> > TARGET_CFLAGS = $(TARGET_CPPFLAGS) $(TARGET_ABI) $(TARGET_OPTIMIZATION) $(TARGET_DEBUGGING) $(TARGET_HARDENED) >> > TARGET_CXXFLAGS = $(TARGET_CFLAGS) >> > TARGET_FCFLAGS = $(TARGET_ABI) $(TARGET_OPTIMIZATION) $(TARGET_DEBUGGING) >> > -- >> >> > 2.35.1 >> >> > _______________________________________________ >> > buildroot mailing list >> > buildroot@buildroot.org >> > https://lists.buildroot.org/mailman/listinfo/buildroot >> >> > > _______________________________________________ > buildroot mailing list > buildroot@buildroot.org > https://lists.buildroot.org/mailman/listinfo/buildroot
>>>>> "Arnout" == Arnout Vandecappelle <arnout@mind.be> writes: Hi, >> What if something (build system) unset _FILE_OFFSET_BITS ? > Then there's something wrong with that package and it needs to be fixed. >> There is something weird with libzlib package. > gzguts.h has this: > #ifdef _LARGEFILE64_SOURCE > # ifndef _LARGEFILE_SOURCE > # define _LARGEFILE_SOURCE 1 > # endif > # ifdef _FILE_OFFSET_BITS > # undef _FILE_OFFSET_BITS > # endif > #endif > Why, I have no idea... Me neither. It seems to have been added when the file was added to zlib 10 years ago, but given that there is no real public VCS for zlib it is hard to know why: https://github.com/madler/zlib/commit/d004b047838a7e803818b4973a2e39e0ff8c1fa2 We're not the only ones running into the issue: https://unix.stackexchange.com/questions/692377/relationship-between-flags-d-file-offset-bits-and-d-largefile64-source I agree that it simply looks like a bug in zlib, but maybe the best bet is indeed to revert for (the overdue) 2022.02 release? I hesitated when applying it given how late it is, but it indeed fixes a real bug.
>>>>> "Johannes" == Johannes Agricola <marvin@0x53a.de> writes: > Good Day! > This seems to break the build of gcc-10.3 w/ glibc > 2.34-110. `libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp` > contains: >> #if SANITIZER_LINUX || SANITIZER_MAC >> // Tests in this file assume that off_t-dependent data structures match the >> // libc ABI. For example, struct dirent here is what readdir() function (as >> // exported from libc) returns, and not the user-facing "dirent", which >> // depends on _FILE_OFFSET_BITS setting. >> // To get this "true" dirent definition, we undefine _FILE_OFFSET_BITS below. >> #ifdef _FILE_OFFSET_BITS >> #undef _FILE_OFFSET_BITS >> #endif Yes, we'll revert it for now and get it sorted out for 2022.05 instead.
diff --git a/package/Makefile.in b/package/Makefile.in index 508ea7c366..cde050ca82 100644 --- a/package/Makefile.in +++ b/package/Makefile.in @@ -167,7 +167,7 @@ else ifeq ($(BR2_FORTIFY_SOURCE_2),y) TARGET_HARDENED += -D_FORTIFY_SOURCE=2 endif -TARGET_CPPFLAGS += -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 +TARGET_CPPFLAGS += -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64 TARGET_CFLAGS = $(TARGET_CPPFLAGS) $(TARGET_ABI) $(TARGET_OPTIMIZATION) $(TARGET_DEBUGGING) $(TARGET_HARDENED) TARGET_CXXFLAGS = $(TARGET_CFLAGS) TARGET_FCFLAGS = $(TARGET_ABI) $(TARGET_OPTIMIZATION) $(TARGET_DEBUGGING)
To use time_t 64-bit for glibc >= 2.34 toolchains we have to set both _FILE_OFFSET_BITS=64 and _TIME_BITS=64 for glibc toolchains. Buildroot already define _FILE_OFFSET_BITS=64 since 2008 [1] before the first release tag 2009.02. _TIME_BITS is not needed for musl libc since it already year2038 ready [2]. The uclibc-ng libc only support time_t 32-bit (long int) so it will be affected by the year2038 issue [3]. Fixes (in French, chapter Buildroot 2022 and GlibC): https://www.blaess.fr/christophe/2038 Runtime tested with qemu_arm_vexpress_defconfig and the Bootlin glibc bleeding-edge 2021.11-1 toolchain. Before: # date Tue Jan 19 03:14:07 UTC 2038 # date Thu Jan 1 00:00:00 UTC 1970 After: # date Tue Jan 19 03:14:07 UTC 2038 # date Tue Jan 19 03:14:08 UTC 2038 # date Tue Jan 19 03:14:09 UTC 2038 [1] 60b5eee76edfa153ef118d2788c74ac8da1497a0 [2] https://git.musl-libc.org/cgit/musl/tree/include/alltypes.h.in?h=v1.2.2#n3 [3] https://cgit.uclibc-ng.org/cgi/cgit/uclibc-ng.git/tree/include/time.h?h=v1.0.40#n75 https://cgit.uclibc-ng.org/cgi/cgit/uclibc-ng.git/tree/libc/sysdeps/linux/common/bits/types.h?h=v1.0.40#n106 Signed-off-by: Romain Naour <romain.naour@gmail.com> Cc: Christophe Blaess <christophe.blaess@logilin.fr> --- package/Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)