Skip to content

Fix Android debug build: Add HOST_ANDROID to timespec_get fallback#121425

Merged
steveisok merged 2 commits intomainfrom
copilot/fix-debug-compile-issue
Nov 7, 2025
Merged

Fix Android debug build: Add HOST_ANDROID to timespec_get fallback#121425
steveisok merged 2 commits intomainfrom
copilot/fix-debug-compile-issue

Conversation

Copy link
Contributor

Copilot AI commented Nov 6, 2025

timespec_get is not available on the Android API levels we target, causing compilation failures in debug builds of src/coreclr/utilcode/debug.cpp.

Changes

  • Added HOST_ANDROID to the existing preprocessor conditionals that select gettimeofday over timespec_get
  • Updated include guards for <sys/time.h> to include Android

Android now follows the same codepath as iOS, tvOS, and macCatalyst:

#if defined(HOST_IOS) || defined(HOST_TVOS) || defined(HOST_MACCATALYST) || defined(HOST_ANDROID)
    // timespec_get is only available on iOS 13.0+ and not supported on Android API levels we target
    struct timeval tv;
    gettimeofday(&tv, nullptr);
    ts.tv_sec = tv.tv_sec;
    ts.tv_nsec = tv.tv_usec * 1000;
#else
    int ret = timespec_get(&ts, TIME_UTC);
#endif
Original prompt

When built for Android in the debug configuration, src/coreclr/utilcode/debug.cpp fails to compile because timespec_get is not supported for the API level we target. HOST_ANDROID needs to be added to #define checks so that it will fall through the gettimeofday path.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: steveisok <471438+steveisok@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix debug compilation issue for Android due to timespec_get Fix Android debug build: Add HOST_ANDROID to timespec_get fallback Nov 6, 2025
Copilot AI requested a review from steveisok November 6, 2025 22:45
@steveisok steveisok marked this pull request as ready for review November 7, 2025 00:13
Copilot AI review requested due to automatic review settings November 7, 2025 00:13
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR extends platform support for time-related functionality by adding Android to the list of platforms that use gettimeofday() instead of timespec_get(). The change addresses compatibility issues on Android API levels that don't support timespec_get().

Key Changes

  • Added HOST_ANDROID to platform conditionals for time-related code
  • Updated comment to clarify Android API level compatibility
  • Ensures consistent time retrieval mechanism across mobile platforms

@steveisok steveisok requested a review from mdh1418 November 7, 2025 16:13
@steveisok steveisok enabled auto-merge (squash) November 7, 2025 17:39
@steveisok
Copy link
Member

/ba-g Unrelated helix timeout the job running on agent NetCore-Public 593 ran longer than the maximum time of 180 minutes

@steveisok steveisok merged commit 5668ab9 into main Nov 7, 2025
91 of 102 checks passed
@steveisok steveisok deleted the copilot/fix-debug-compile-issue branch November 7, 2025 17:41
@github-actions github-actions bot locked and limited conversation to collaborators Dec 8, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants