This is an archive of the discontinued LLVM Phabricator instance.

[libc] Add global stdout and stderr objects.
ClosedPublic

Authored by sivachandra on May 24 2022, 2:12 PM.

Details

Summary

They are added as entrypoint object targets. The header-gen
infrastructure has been extended to enable handling standard required
global objects. The libc-api-test has also been extended to verify the
global object declarations.

Diff Detail

Event Timeline

sivachandra created this revision.May 24 2022, 2:12 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptMay 24 2022, 2:12 PM
sivachandra requested review of this revision.May 24 2022, 2:12 PM
lntue accepted this revision.May 24 2022, 5:09 PM
lntue added inline comments.
libc/utils/HdrGen/PublicAPICommand.cpp
119

const auto &Name?

This revision is now accepted and ready to land.May 24 2022, 5:09 PM
abrachet added inline comments.
libc/src/__support/File/linux_file.cpp
169–170

These should probably be static

175
176

I don't know what values are ok for buffer_mode but stderr would logically have a different buffer mode from stdout because of no line buffering.

Why does stderr have OpenMode::WRITE and stdout has OpenMode::APPEND

Address comments.

sivachandra marked an inline comment as done.

Address one more comment missed in the previous update.

sivachandra marked an inline comment as done.May 24 2022, 10:58 PM
sivachandra added inline comments.
libc/src/__support/File/linux_file.cpp
169–170

Yes, fixed!

176

About buffering mode, we do not have line buffering support yet so I just left the value at 0. I have added a TODO to update that when we add line buffering support.

About WRITE vs APPEND, My intention was to put APPEND on both but I was playing with WRITE on one of them but forgot to put it back to APPEND. I have updated both to APPEND now.

Overall, this is a total case of copy-paste oversight. Sorry about that.

This revision was automatically updated to reflect the committed changes.