diff --git a/compiler-rt/lib/builtins/atomic.c b/compiler-rt/lib/builtins/atomic.c --- a/compiler-rt/lib/builtins/atomic.c +++ b/compiler-rt/lib/builtins/atomic.c @@ -24,11 +24,15 @@ //===----------------------------------------------------------------------===// #include +#include #include -#include #include "assembly.h" +// We use __builtin_mem* here to avoid dependencies on libc-provided headers. +#define memcpy __builtin_memcpy +#define memcmp __builtin_memcmp + // Clang objects if you redefine a builtin. This little hack allows us to // define a function with the same name as an intrinsic. #pragma redefine_extname __atomic_load_c SYMBOL_NAME(__atomic_load) diff --git a/compiler-rt/lib/builtins/clear_cache.c b/compiler-rt/lib/builtins/clear_cache.c --- a/compiler-rt/lib/builtins/clear_cache.c +++ b/compiler-rt/lib/builtins/clear_cache.c @@ -7,7 +7,9 @@ //===----------------------------------------------------------------------===// #include "int_lib.h" +#if defined(__linux__) #include +#endif #include #if __APPLE__ diff --git a/compiler-rt/lib/builtins/int_util.c b/compiler-rt/lib/builtins/int_util.c --- a/compiler-rt/lib/builtins/int_util.c +++ b/compiler-rt/lib/builtins/int_util.c @@ -33,35 +33,25 @@ NORETURN extern void __assert_rtn(const char *func, const char *file, int line, const char *message); -#ifndef _WIN32 __attribute__((weak)) __attribute__((visibility("hidden"))) -#endif void __compilerrt_abort_impl(const char *file, int line, const char *function) { __assert_rtn(function, file, line, "libcompiler_rt abort"); } -#elif __Fuchsia__ +#else #ifndef _WIN32 __attribute__((weak)) __attribute__((visibility("hidden"))) #endif void __compilerrt_abort_impl(const char *file, int line, const char *function) { +#if !__STDC_HOSTED__ + // Avoid depending on libc when compiling with -ffreestanding. __builtin_trap(); -} - #else - -// Get the system definition of abort() -#include - -#ifndef _WIN32 -__attribute__((weak)) -__attribute__((visibility("hidden"))) + __builtin_abort(); #endif -void __compilerrt_abort_impl(const char *file, int line, const char *function) { - abort(); } #endif