This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] Include <sys/time.h> in posix_compat.h
ClosedPublic

Authored by phosek on Jun 20 2023, 3:42 PM.

Details

Summary

posix_compat.h uses struct timeval which is defined in <sys/time.h>
but it doesn't include it. On most POSIX platforms like Linux or macOS,
that headers is transitively included by other headers like <sys/stat.h>,
but there are other platforms where this is not the case.

Diff Detail

Event Timeline

phosek created this revision.Jun 20 2023, 3:42 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 20 2023, 3:42 PM
phosek requested review of this revision.Jun 20 2023, 3:42 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 20 2023, 3:42 PM
Herald added a reviewer: Restricted Project. · View Herald Transcript

We noticed this in our downstream CI after D152377 landed where we started getting build errors like these:

In file included from /b/s/w/ir/x/w/llvm-llvm-project/libcxx/src/filesystem/directory_entry.cpp:16:
/b/s/w/ir/x/w/llvm-llvm-project/libcxx/src/filesystem/time_utils.h:263:16: error: incomplete result type 'TimeVal' (aka 'std::filesystem::detail::(anonymous namespace)::timeval') in function definition
  263 | inline TimeVal make_timeval(TimeSpec const& ts) {
      |                ^
zibi accepted this revision.Jun 21 2023, 7:09 AM
zibi added a subscriber: zibi.

LGTM,

this fixes exact same issue on z/OS. Thank you for a quick fix.

This revision was not accepted when it landed; it landed in state Needs Review.Jun 21 2023, 9:10 AM
This revision was automatically updated to reflect the committed changes.

LGTM post-commit.