]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
gcc: Undef _TIME_BITS in sanitizer_procmaps_solaris.cpp
authorJiaying Song <jiaying.song.cn@windriver.com>
Wed, 9 Apr 2025 02:51:10 +0000 (10:51 +0800)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 10 Apr 2025 09:40:39 +0000 (10:40 +0100)
gcc-sanitizers fail to build when both -D_TIME_BITS=64 and
-D_FILE_OFFSET_BITS=64  are defined. This is because
sanitizer_procmaps_solaris.cpp explicitly undefines  _FILE_OFFSET_BITS
before including any headers, which causes _TIME_BITS=64 to  violate the
requirement in glibc:

/usr/include/features-time64.h:26:5: error:  "_TIME_BITS=64 is allowed
only with _FILE_OFFSET_BITS=64"

Fixes a build failure on 32-bit Linux platforms when using both
-D_TIME_BITS=64 and -D_FILE_OFFSET_BITS=64.

Signed-off-by: Jiaying Song <jiaying.song.cn@windriver.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/recipes-devtools/gcc/gcc-14.2.inc
meta/recipes-devtools/gcc/gcc/0028-libsanitizer-undef-_TIME_BITS-in-solaris-procmaps.patch [new file with mode: 0644]

index 3d65bed92a031ec5514504f659a8d1496bb2f8df..ae2f8c06380468c0e468b632f48f5184a4396d26 100644 (file)
@@ -71,6 +71,7 @@ SRC_URI = "${BASEURI} \
           file://0026-gcc-Fix-c-tweak-for-Wrange-loop-construct.patch \
            file://0027-gcc-backport-patch-to-fix-data-relocation-to-ENDBR-s.patch \
            file://gcc.git-ab884fffe3fc82a710bea66ad651720d71c938b8.patch \
+           file://0028-libsanitizer-undef-_TIME_BITS-in-solaris-procmaps.patch \
 "
 
 S = "${TMPDIR}/work-shared/gcc-${PV}-${PR}/${SOURCEDIR}"
diff --git a/meta/recipes-devtools/gcc/gcc/0028-libsanitizer-undef-_TIME_BITS-in-solaris-procmaps.patch b/meta/recipes-devtools/gcc/gcc/0028-libsanitizer-undef-_TIME_BITS-in-solaris-procmaps.patch
new file mode 100644 (file)
index 0000000..9426f5d
--- /dev/null
@@ -0,0 +1,62 @@
+From 883d5549dc959b736e3cb61b989272a9e6a42565 Mon Sep 17 00:00:00 2001
+From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
+Date: Thu, 3 Apr 2025 17:09:22 +0800
+Subject: [PATCH] libsanitizer: also undef _TIME_BITS in sanitizer_procmaps_solaris.cpp
+
+Upstream commit
+https://github.com/llvm/llvm-project/commit/26800a2c7e7996dc773b4e990dd5cca41c45e1a9
+of LLVM added a #undef _TIME_BITS in
+libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp to
+fix the build on 32-bit Linux platforms that have enabled 64-bit
+time_t using _TIME_BITS=64.
+
+Indeed, _TIME_BITS=64 can only be used when _FILE_OFFSET_BITS=64, but
+sanitizer_platform_limits_posix.cpp undefines _FILE_OFFSET_BITS before
+including any header file. To fix this, the upstream fix was to also
+undef _TIME_BITS.
+
+This commit simply does the same in sanitizer_procmaps_solaris.cpp,
+which also gets compiled under Linux (despite what the file name
+says). In practice on Linux hosts (where _TIME_BITS=64 matters),
+sanitizer_procmaps_solaris.cpp will expand to nothing, as pretty much
+the rest of the file is inside a #ifdef SANITIZER_SOLARIS...#endif. So
+the #undef _FILE_OFFSET_BITS and #undef _TIME_BITS are only here
+before including sanitizer_platform.h, which will set the
+SANITIZER_LINUX/SANITIZER_SOLARIS define depending on the platform.
+
+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.
+```
+Upstream-Status: Backport [https://github.com/gcc-mirror/gcc/commit/fa321004f3f6288d3ee2eefa6b02177131882dca]
+
+Signed-off-by: Jiaying Song <jiaying.song.cn@windriver.com>
+---
+ libsanitizer/sanitizer_common/sanitizer_procmaps_solaris.cpp | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libsanitizer/sanitizer_common/sanitizer_procmaps_solaris.cpp b/libsanitizer/sanitizer_common/sanitizer_procmaps_solaris.cpp
+index eeb49e2af..f78558bed 100644
+--- a/libsanitizer/sanitizer_common/sanitizer_procmaps_solaris.cpp
++++ b/libsanitizer/sanitizer_common/sanitizer_procmaps_solaris.cpp
+@@ -10,7 +10,12 @@
+ //===----------------------------------------------------------------------===//
+ // Before Solaris 11.4, <procfs.h> doesn't work in a largefile environment.
++
+ #undef _FILE_OFFSET_BITS
++
++// Avoid conflict between `_TIME_BITS` defined vs. `_FILE_OFFSET_BITS`
++// undefined in some Linux configurations.
++#undef _TIME_BITS
+ #include "sanitizer_platform.h"
+ #if SANITIZER_SOLARIS
+ #  include <fcntl.h>
+-- 
+2.34.1
+