[libc] Move the definitions of the standard IO streams to the platform
authorJoseph Huber <jhuber6@vols.utk.edu>
Wed, 14 Jun 2023 23:59:29 +0000 (18:59 -0500)
committerJoseph Huber <jhuber6@vols.utk.edu>
Thu, 15 Jun 2023 12:06:43 +0000 (07:06 -0500)
commita09bec6459331e7f949c2ed3df6102de52d25f5d
treeacbc5b35e61aa6a6b71e64e344acb8db38ee50ac
parent4e4bd29061de5e7790e47e78ec90e41e2ee7ee30
[libc] Move the definitions of the standard IO streams to the platform

This patch moves the definitions of the standard IO streams to the
platform file definition. This is necessary because previously we had a
level of indirection where the stream's `FILE *` was initialized based
on the pointer to the internal `__llvm_libc` version. This cannot be
resolved ahead of time by the linker because the address will not be
known until runtime. This caused the previous implementation to emit a
global constructor to initialize the pointer to the actual `FILE *`. By
moving these definitions so that we can bind their address to the
original file type we can avoid this global constructor.

This file keeps the entrypoints, but makes them empty files only
containing an external reference. This is so they still appear as
entrypoints and get emitted as declarations in the generated headers.

Reviewed By: lntue, sivachandra

Differential Revision: https://reviews.llvm.org/D152983
libc/src/__support/File/gpu/file.cpp
libc/src/__support/File/linux/file.cpp
libc/src/stdio/stderr.cpp
libc/src/stdio/stdin.cpp
libc/src/stdio/stdout.cpp