Skip to contentSkip to conversation

package/gcc: fix build with BR2_TIME_BITS_64=y

PATCH Applied Thomas Petazzoni via buildroot 2 participants 3 messages Jul 19, 2024 – Sep 2, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/gcc: fix build with BR2_TIME_BITS_64=y

On the architectures that supports libsanitizer (part of gcc), the build is currently failing with BR2_TIME_BITS_64=y. This is because some code in libsanitizer unsets _FILE_OFFSET_BITS, but building code with _FILE_OFFSET_BITS unset, but _TIME_BITS set isn't legal.

To fix this, this commit backports two changes:

- One change to also unset _TIME_BITS in sanitizer_platform_limits_posix.cpp. This change is upstream in LLVM, and already part of GCC 14.x, so we only bringing it to GCC 12.x and GCC 13.x.

- A second change doing the same modification, but in sanitizer_procmaps_solaris.cpp, which as crazy as it might sound, also gets compiled on Linux platforms (but to basically an empty file). This change has been submitted upstream to both LLVM and gcc.

Notes:

- the special PowerPC SPE version of GCC cannot be affected, as only uClibc-ng is used for this architecture, and uClibc-ng doesn't use _TIME_BITS=64 (but now default to 64-bit time_t on 32-bit architectures, like musl does).

- the special ARC version doesn't need patching because libsanitizer doesn't support the ARC architecture, so it doesn't get built

Fixes:

http://autobuild.buildroot.net/results/ff2dbfdabf0bb6a0d82ea8a80122ab97fd75bd3f/
https://gitlab.com/buildroot.org/buildroot/-/issues/16

---
 ...-along-with-_FILE_OFFSET_BITS-on-Lin.patch | 44 +++++++++++++++
 ...o-undef-_TIME_BITS-in-sanitizer_proc.patch | 53 +++++++++++++++++++
 ...-along-with-_FILE_OFFSET_BITS-on-Lin.patch | 44 +++++++++++++++
 ...o-undef-_TIME_BITS-in-sanitizer_proc.patch | 53 +++++++++++++++++++
 ...o-undef-_TIME_BITS-in-sanitizer_proc.patch | 53 +++++++++++++++++++
 5 files changed, 247 insertions(+)
 create mode 100644 package/gcc/12.4.0/0005-Undef-_TIME_BITS-along-with-_FILE_OFFSET_BITS-on-Lin.patch
 create mode 100644 package/gcc/12.4.0/0006-libsanitizer-also-undef-_TIME_BITS-in-sanitizer_proc.patch
 create mode 100644 package/gcc/13.3.0/0004-Undef-_TIME_BITS-along-with-_FILE_OFFSET_BITS-on-Lin.patch
 create mode 100644 package/gcc/13.3.0/0005-libsanitizer-also-undef-_TIME_BITS-in-sanitizer_proc.patch
 create mode 100644 package/gcc/14.1.0/0002-libsanitizer-also-undef-_TIME_BITS-in-sanitizer_proc.patch
package/gcc/12.4.0/0005-Undef-_TIME_BITS-along-with-_FILE_OFFSET_BITS-on-Lin.patch new file +44 -0
new file mode 100644
index 0000000000..386c9287f6
@@ -0,0 +1,44 @@
+From e45f12ecf703eed45515d451cf014fba32e7410b Mon Sep 17 00:00:00 2001
+From: Khem Raj <[email protected]>
+Date: Fri, 3 Feb 2023 11:48:35 -0800
+Subject: [PATCH] Undef _TIME_BITS along with _FILE_OFFSET_BITS on Linux
+
+On 32-bit glibc>=2.34 systems using 64bit time_t build fails because
+_FILE_OFFSET_BITS is undefined here but _TIME_BITS is still set to 64
+
+Fixes
+
+```
+/usr/include/features-time64.h:26:5: error: "_TIME_BITS=64 is allowed
+ only with _FILE_OFFSET_BITS=64"
+| #   error "_TIME_BITS=64 is allowed only with _FILE_OFFSET_BITS=64"
+|     ^
+| 1 error generated.
+```
+
+Reviewed By: thesamesam, MaskRay
+
+Differential Revision: https://reviews.llvm.org/D140812
+
+Upstream: https://github.com/llvm/llvm-project/commit/26800a2c7e7996dc773b4e990dd5cca41c45e1a9
+Upstream: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=d53b3d94aaf211ffb2159614f5aaaf03ceb861cc
+Signed-off-by: Thomas Petazzoni <[email protected]>
+---
+ .../sanitizer_common/sanitizer_platform_limits_posix.cpp         | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp
+index bfdccd5df07..4cedcbfb4bf 100644
+--- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp
++++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp
+@@ -18,6 +18,7 @@
+ // depends on _FILE_OFFSET_BITS setting.
+ // To get this "true" dirent definition, we undefine _FILE_OFFSET_BITS below.
+ #undef _FILE_OFFSET_BITS
++#undef _TIME_BITS
+ #endif
+ 
+ // Must go after undef _FILE_OFFSET_BITS.
+-- 
+2.45.2
+
package/gcc/12.4.0/0006-libsanitizer-also-undef-_TIME_BITS-in-sanitizer_proc.patch new file +53 -0

53 lines not on this page · raw message

package/gcc/13.3.0/0004-Undef-_TIME_BITS-along-with-_FILE_OFFSET_BITS-on-Lin.patch new file +44 -0

44 lines not on this page · raw message

package/gcc/13.3.0/0005-libsanitizer-also-undef-_TIME_BITS-in-sanitizer_proc.patch new file +53 -0

53 lines not on this page · raw message

package/gcc/14.1.0/0002-libsanitizer-also-undef-_TIME_BITS-in-sanitizer_proc.patch new file +53 -0

53 lines not on this page · raw message

Signature · 6 lines
2.45.2

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw
Quoted 33 lines · On Fri, 19 Jul 2024 23:03:24 +0200 Thomas Petazzoni via buildroot…

On the architectures that supports libsanitizer (part of gcc), the build is currently failing with BR2_TIME_BITS_64=y. This is because some code in libsanitizer unsets _FILE_OFFSET_BITS, but building code with _FILE_OFFSET_BITS unset, but _TIME_BITS set isn't legal.

To fix this, this commit backports two changes:

- One change to also unset _TIME_BITS in sanitizer_platform_limits_posix.cpp. This change is upstream in LLVM, and already part of GCC 14.x, so we only bringing it to GCC 12.x and GCC 13.x.

- A second change doing the same modification, but in sanitizer_procmaps_solaris.cpp, which as crazy as it might sound, also gets compiled on Linux platforms (but to basically an empty file). This change has been submitted upstream to both LLVM and gcc.

Notes:

- the special PowerPC SPE version of GCC cannot be affected, as only uClibc-ng is used for this architecture, and uClibc-ng doesn't use _TIME_BITS=64 (but now default to 64-bit time_t on 32-bit architectures, like musl does).

- the special ARC version doesn't need patching because libsanitizer doesn't support the ARC architecture, so it doesn't get built

Fixes:

http://autobuild.buildroot.net/results/ff2dbfdabf0bb6a0d82ea8a80122ab97fd75bd3f/
https://gitlab.com/buildroot.org/buildroot/-/issues/16

Quoted 12 lines
---
 ...-along-with-_FILE_OFFSET_BITS-on-Lin.patch | 44 +++++++++++++++
 ...o-undef-_TIME_BITS-in-sanitizer_proc.patch | 53 +++++++++++++++++++
 ...-along-with-_FILE_OFFSET_BITS-on-Lin.patch | 44 +++++++++++++++
 ...o-undef-_TIME_BITS-in-sanitizer_proc.patch | 53 +++++++++++++++++++
 ...o-undef-_TIME_BITS-in-sanitizer_proc.patch | 53 +++++++++++++++++++
 5 files changed, 247 insertions(+)
 create mode 100644 package/gcc/12.4.0/0005-Undef-_TIME_BITS-along-with-_FILE_OFFSET_BITS-on-Lin.patch
 create mode 100644 package/gcc/12.4.0/0006-libsanitizer-also-undef-_TIME_BITS-in-sanitizer_proc.patch
 create mode 100644 package/gcc/13.3.0/0004-Undef-_TIME_BITS-along-with-_FILE_OFFSET_BITS-on-Lin.patch
 create mode 100644 package/gcc/13.3.0/0005-libsanitizer-also-undef-_TIME_BITS-in-sanitizer_proc.patch
 create mode 100644 package/gcc/14.1.0/0002-libsanitizer-also-undef-_TIME_BITS-in-sanitizer_proc.patch

Applied to master, thanks.

Thomas

Signature · 7 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#2 lore raw
In reply to Thomas Petazzoni via buildroot
Quoted 29 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Thomas" == Thomas Petazzoni via buildroot <[email protected]> writes:

On the architectures that supports libsanitizer (part of gcc), the build is currently failing with BR2_TIME_BITS_64=y. This is because some code in libsanitizer unsets _FILE_OFFSET_BITS, but building code with _FILE_OFFSET_BITS unset, but _TIME_BITS set isn't legal.

To fix this, this commit backports two changes:

- One change to also unset _TIME_BITS in sanitizer_platform_limits_posix.cpp. This change is upstream in LLVM, and already part of GCC 14.x, so we only bringing it to GCC 12.x and GCC 13.x.

- A second change doing the same modification, but in sanitizer_procmaps_solaris.cpp, which as crazy as it might sound, also gets compiled on Linux platforms (but to basically an empty file). This change has been submitted upstream to both LLVM and gcc.

Notes:

- the special PowerPC SPE version of GCC cannot be affected, as only uClibc-ng is used for this architecture, and uClibc-ng doesn't use _TIME_BITS=64 (but now default to 64-bit time_t on 32-bit architectures, like musl does).

- the special ARC version doesn't need patching because libsanitizer doesn't support the ARC architecture, so it doesn't get built

Quoted 6 lines

Fixes:

http://autobuild.buildroot.net/results/ff2dbfdabf0bb6a0d82ea8a80122ab97fd75bd3f/
https://gitlab.com/buildroot.org/buildroot/-/issues/16

Committed to 2024.02.x and 2024.05.x, thanks.

Signature · 5 lines
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot