fix(time): correct timegm on arm32 with 64-bit time_t (#1204) - #3
Open
azkrishpy wants to merge 1 commit into
Open
fix(time): correct timegm on arm32 with 64-bit time_t (#1204)#3azkrishpy wants to merge 1 commit into
azkrishpy wants to merge 1 commit into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.cdeclared its own prototypeextern time_t timegm(struct tm *);. On 32-bit platforms built with_TIME_BITS=64(the Yocto default on arm32), glibc's<time.h>normally redirectstimegmto__timegm64via__REDIRECT. The hand-rolled prototype bypasses that redirect, so the code links the legacy 32-bittimegmand the 64-bittime_treturn 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_SOURCEbefore includes so<time.h>declarestimegmwith the correct_TIME_BITS=64redirect, 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.