diff mbox series

gcc: Undef _TIME_BITS along with _FILE_OFFSET_BITS on Linux

Message ID 20250403094223.2339348-1-jiaying.song.cn@windriver.com
State New
Headers show
Series gcc: Undef _TIME_BITS along with _FILE_OFFSET_BITS on Linux | expand

Commit Message

Song, Jiaying (CN) April 3, 2025, 9:42 a.m. UTC
From: Jiaying Song <jiaying.song.cn@windriver.com>

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.
```

Signed-off-by: Jiaying Song <jiaying.song.cn@windriver.com>
---
 meta/recipes-devtools/gcc/gcc-14.2.inc        |  1 +
 ...-along-with-_FILE_OFFSET_BITS-on-Lin.patch | 44 +++++++++++++++++++
 2 files changed, 45 insertions(+)
 create mode 100644 meta/recipes-devtools/gcc/gcc/0028-Undef-_TIME_BITS-along-with-_FILE_OFFSET_BITS-on-Lin.patch

Comments

Alexander Kanavin April 3, 2025, 10:05 a.m. UTC | #1
Thanks for the patch. The correct mailing list is openembedded-core.

Just a quick note: if the aim is to address issues on Linux, why is
the patch changing things in solaris code?

Alex

On Thu, 3 Apr 2025 at 11:42, Song, Jiaying (CN) via
lists.openembedded.org
<Jiaying.Song.CN=windriver.com@lists.openembedded.org> wrote:
>
> From: Jiaying Song <jiaying.song.cn@windriver.com>
>
> 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.
> ```
>
> Signed-off-by: Jiaying Song <jiaying.song.cn@windriver.com>
> ---
>  meta/recipes-devtools/gcc/gcc-14.2.inc        |  1 +
>  ...-along-with-_FILE_OFFSET_BITS-on-Lin.patch | 44 +++++++++++++++++++
>  2 files changed, 45 insertions(+)
>  create mode 100644 meta/recipes-devtools/gcc/gcc/0028-Undef-_TIME_BITS-along-with-_FILE_OFFSET_BITS-on-Lin.patch
>
> diff --git a/meta/recipes-devtools/gcc/gcc-14.2.inc b/meta/recipes-devtools/gcc/gcc-14.2.inc
> index 3d65bed92a..0ed6f1875b 100644
> --- a/meta/recipes-devtools/gcc/gcc-14.2.inc
> +++ b/meta/recipes-devtools/gcc/gcc-14.2.inc
> @@ -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-Undef-_TIME_BITS-along-with-_FILE_OFFSET_BITS-on-Lin.patch \
>  "
>
>  S = "${TMPDIR}/work-shared/gcc-${PV}-${PR}/${SOURCEDIR}"
> diff --git a/meta/recipes-devtools/gcc/gcc/0028-Undef-_TIME_BITS-along-with-_FILE_OFFSET_BITS-on-Lin.patch b/meta/recipes-devtools/gcc/gcc/0028-Undef-_TIME_BITS-along-with-_FILE_OFFSET_BITS-on-Lin.patch
> new file mode 100644
> index 0000000000..06c24cdff5
> --- /dev/null
> +++ b/meta/recipes-devtools/gcc/gcc/0028-Undef-_TIME_BITS-along-with-_FILE_OFFSET_BITS-on-Lin.patch
> @@ -0,0 +1,44 @@
> +From 883d5549dc959b736e3cb61b989272a9e6a42565 Mon Sep 17 00:00:00 2001
> +From: Khem Raj <raj.khem@gmail.com>
> +Date: Thu, 3 Apr 2025 17:09:22 +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.
> +```
> +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
> +
> --
> 2.34.1
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#116538): https://lists.openembedded.org/g/openembedded-devel/message/116538
> Mute This Topic: https://lists.openembedded.org/mt/112062601/1686489
> Group Owner: openembedded-devel+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [alex.kanavin@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Song, Jiaying (CN) April 9, 2025, 3:01 a.m. UTC | #2
Hello Alex,

Thank you for your feedback. I have already sent the more comprehensive commit message to the correct mailing list. 

The patch modifies sanitizer_procmaps_solaris.cpp because this file is compiled on Linux as well, despite its name suggesting it is specific to Solaris.   The issue arises when both _TIME_BITS=64 and _FILE_OFFSET_BITS=64 are defined on 32-bit Linux platforms, causing a build failure due to the conflicting requirements in glibc.

To resolve this, the patch ensures that _TIME_BITS is also undefined in sanitizer_procmaps_solaris.cpp.

This change is necessary to avoid build errors in Linux environments when dealing with 64-bit time support, even though the file is named for Solaris.

Thanks,
Jiaying.

-----Original Message-----
From: Alexander Kanavin <alex.kanavin@gmail.com> 
Sent: Thursday, April 3, 2025 6:06 PM
To: Song, Jiaying (CN) <Jiaying.Song.CN@windriver.com>
Cc: openembedded-devel@lists.openembedded.org; Li, Changqing <Changqing.Li@windriver.com>
Subject: Re: [oe] [PATCH] gcc: Undef _TIME_BITS along with _FILE_OFFSET_BITS on Linux

CAUTION: This email comes from a non Wind River email account!
Do not click links or open attachments unless you recognize the sender and know the content is safe.

Thanks for the patch. The correct mailing list is openembedded-core.

Just a quick note: if the aim is to address issues on Linux, why is the patch changing things in solaris code?

Alex

On Thu, 3 Apr 2025 at 11:42, Song, Jiaying (CN) via lists.openembedded.org <Jiaying.Song.CN=windriver.com@lists.openembedded.org> wrote:
>
> From: Jiaying Song <jiaying.song.cn@windriver.com>
>
> 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.
> ```
>
> Signed-off-by: Jiaying Song <jiaying.song.cn@windriver.com>
> ---
>  meta/recipes-devtools/gcc/gcc-14.2.inc        |  1 +
>  ...-along-with-_FILE_OFFSET_BITS-on-Lin.patch | 44 
> +++++++++++++++++++
>  2 files changed, 45 insertions(+)
>  create mode 100644 
> meta/recipes-devtools/gcc/gcc/0028-Undef-_TIME_BITS-along-with-_FILE_O
> FFSET_BITS-on-Lin.patch
>
> diff --git a/meta/recipes-devtools/gcc/gcc-14.2.inc 
> b/meta/recipes-devtools/gcc/gcc-14.2.inc
> index 3d65bed92a..0ed6f1875b 100644
> --- a/meta/recipes-devtools/gcc/gcc-14.2.inc
> +++ b/meta/recipes-devtools/gcc/gcc-14.2.inc
> @@ -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-Undef-_TIME_BITS-along-with-_FILE_OFFSET_BITS-on-Lin.pat
> + ch \
>  "
>
>  S = "${TMPDIR}/work-shared/gcc-${PV}-${PR}/${SOURCEDIR}"
> diff --git 
> a/meta/recipes-devtools/gcc/gcc/0028-Undef-_TIME_BITS-along-with-_FILE
> _OFFSET_BITS-on-Lin.patch 
> b/meta/recipes-devtools/gcc/gcc/0028-Undef-_TIME_BITS-along-with-_FILE
> _OFFSET_BITS-on-Lin.patch
> new file mode 100644
> index 0000000000..06c24cdff5
> --- /dev/null
> +++ b/meta/recipes-devtools/gcc/gcc/0028-Undef-_TIME_BITS-along-with-_
> +++ FILE_OFFSET_BITS-on-Lin.patch
> @@ -0,0 +1,44 @@
> +From 883d5549dc959b736e3cb61b989272a9e6a42565 Mon Sep 17 00:00:00 
> +2001
> +From: Khem Raj <raj.khem@gmail.com>
> +Date: Thu, 3 Apr 2025 17:09:22 +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.
> +```
> +Upstream-Status: Backport 
> +[https://github.com/gcc-mirror/gcc/commit/fa321004f3f6288d3ee2eefa6b0
> +2177131882dca]
> +
> +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
> +
> --
> 2.34.1
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#116538): 
> https://lists.openembedded.org/g/openembedded-devel/message/116538
> Mute This Topic: https://lists.openembedded.org/mt/112062601/1686489
> Group Owner: openembedded-devel+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub 
> [alex.kanavin@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
diff mbox series

Patch

diff --git a/meta/recipes-devtools/gcc/gcc-14.2.inc b/meta/recipes-devtools/gcc/gcc-14.2.inc
index 3d65bed92a..0ed6f1875b 100644
--- a/meta/recipes-devtools/gcc/gcc-14.2.inc
+++ b/meta/recipes-devtools/gcc/gcc-14.2.inc
@@ -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-Undef-_TIME_BITS-along-with-_FILE_OFFSET_BITS-on-Lin.patch \
 "
 
 S = "${TMPDIR}/work-shared/gcc-${PV}-${PR}/${SOURCEDIR}"
diff --git a/meta/recipes-devtools/gcc/gcc/0028-Undef-_TIME_BITS-along-with-_FILE_OFFSET_BITS-on-Lin.patch b/meta/recipes-devtools/gcc/gcc/0028-Undef-_TIME_BITS-along-with-_FILE_OFFSET_BITS-on-Lin.patch
new file mode 100644
index 0000000000..06c24cdff5
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc/0028-Undef-_TIME_BITS-along-with-_FILE_OFFSET_BITS-on-Lin.patch
@@ -0,0 +1,44 @@ 
+From 883d5549dc959b736e3cb61b989272a9e6a42565 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Thu, 3 Apr 2025 17:09:22 +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.
+```
+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
+