[all-commits] [llvm/llvm-project] 244601: [builtins] Allow compiling the builtins without li...

Alexander Richardson via All-commits all-commits at lists.llvm.org
Tue Jun 15 01:12:49 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 244601f4720d9cda6e81ea1908f3ce905a4bcb0e
      https://github.com/llvm/llvm-project/commit/244601f4720d9cda6e81ea1908f3ce905a4bcb0e
  Author: Alex Richardson <Alexander.Richardson at cl.cam.ac.uk>
  Date:   2021-06-15 (Tue, 15 Jun 2021)

  Changed paths:
    M compiler-rt/lib/builtins/atomic.c
    M compiler-rt/lib/builtins/clear_cache.c
    M compiler-rt/lib/builtins/int_util.c

  Log Message:
  -----------
  [builtins] Allow compiling the builtins without libc headers

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.

Reviewed By: phosek

Differential Revision: https://reviews.llvm.org/D103876




More information about the All-commits mailing list