Skip to content

fix(time): correct timegm on arm32 with 64-bit time_t (#1204) - #3

Open
azkrishpy wants to merge 1 commit into
mainfrom
fix/arm32-gcc15-timegm-1204
Open

fix(time): correct timegm on arm32 with 64-bit time_t (#1204)#3
azkrishpy wants to merge 1 commit into
mainfrom
fix/arm32-gcc15-timegm-1204

Conversation

@azkrishpy

Copy link
Copy Markdown
Owner

Problem

Issue awslabs#1204: on arm32 + gcc15 (Yocto master), all rfc822/iso8601 date-time parsing tests fail; arm64 and x86-64 pass.

Root cause

source/posix/time.c declared its own prototype extern time_t timegm(struct tm *);. On 32-bit platforms built with _TIME_BITS=64 (the Yocto default on arm32), glibc's <time.h> normally redirects timegm to __timegm64 via __REDIRECT. The hand-rolled prototype bypasses that redirect, so the code links the legacy 32-bit timegm and the 64-bit time_t return value is truncated → wrong timestamps → every parse-then-compare test fails. arm64/x86-64 have native 64-bit time_t and no redirect, so they were unaffected.

Fix

Define _GNU_SOURCE before includes so <time.h> declares timegm with the correct _TIME_BITS=64 redirect, and remove the buggy manual prototype.

Testing

Built locally and ran the date_time parsing suite (ctest -R parsing): 14/14 pass. Confirms no regression on native 64-bit platforms.

The manual 'extern time_t timegm(struct tm *);' prototype bypassed glibc's
timegm -> __timegm64 redirect used on 32-bit platforms built with _TIME_BITS=64
(the Yocto default on arm32). This truncated the returned time_t, causing every
rfc822/iso8601 date parsing test to fail on arm32 + gcc15 while arm64/x86-64
(native 64-bit time_t) passed. Define _GNU_SOURCE before includes so <time.h>
declares timegm with the correct redirect, and drop the hand-rolled prototype.

Fixes awslabs#1204
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant