This is an archive of the discontinued LLVM Phabricator instance.

[builtins] Allow compiling the builtins without libc headers
ClosedPublic

Authored by arichardson on Jun 8 2021, 1:50 AM.

Details

Summary

When compiled with -ffreestanding, we should not assume that headers
declaring functions such as abort() are available. While the compiler may
still emit calls to those functions [1], we should not require the headers
to build compiler-rt since that can result in a cyclic dependency graph:
The compiler-rt functions might be required to build libc.so, but the libc
headers such as stdlib.h might only be available once libc has been built.

[1] From https://gcc.gnu.org/onlinedocs/gcc/Standards.html:
GCC requires the freestanding environment provide memcpy, memmove,
memset and memcmp. Finally, if __builtin_trap is used, and the target
does not implement the trap pattern, then GCC emits a call to abort.

Diff Detail

Event Timeline

arichardson created this revision.Jun 8 2021, 1:50 AM
arichardson requested review of this revision.Jun 8 2021, 1:50 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 8 2021, 1:50 AM
Herald added a subscriber: Restricted Project. · View Herald Transcript
phosek accepted this revision.Jun 14 2021, 12:42 AM

LGTM

This revision is now accepted and ready to land.Jun 14 2021, 12:42 AM