diff --git a/libs/libbuiltin/compiler-rt/CMakeLists.txt b/libs/libbuiltin/compiler-rt/CMakeLists.txt index a235425c0c2..d1fa3f444fc 100644 --- a/libs/libbuiltin/compiler-rt/CMakeLists.txt +++ b/libs/libbuiltin/compiler-rt/CMakeLists.txt @@ -137,6 +137,10 @@ if(CONFIG_COVERAGE_COMPILER_RT) target_compile_options(rt.profile PRIVATE -DCOMPILER_RT_HAS_UNAME -Wno-undef -Wno-strict-prototypes -Wno-shadow) + if(APPLE) + target_compile_options(rt.profile PRIVATE -D__APPLE__) + endif() + set(SRCSTMP) set(RT_PROFILE_SRCS InstrProfilingPlatform.c) diff --git a/libs/libbuiltin/compiler-rt/InstrProfilingPlatform.c b/libs/libbuiltin/compiler-rt/InstrProfilingPlatform.c index 3de393c1bf2..4e7ba885699 100644 --- a/libs/libbuiltin/compiler-rt/InstrProfilingPlatform.c +++ b/libs/libbuiltin/compiler-rt/InstrProfilingPlatform.c @@ -32,12 +32,27 @@ * Public Data ****************************************************************************/ +#ifdef __APPLE__ +extern char __start__llvm_prf_names[] + __asm("section$start$__DATA$__llvm_prf_names"); +extern char __end__llvm_prf_names[] + __asm("section$end$__DATA$__llvm_prf_names"); +extern char __start__llvm_prf_data[] + __asm("section$start$__DATA$__llvm_prf_data"); +extern char __end__llvm_prf_data[] + __asm("section$end$__DATA$__llvm_prf_data"); +extern char __start__llvm_prf_cnts[] + __asm("section$start$__DATA$__llvm_prf_cnts"); +extern char __end__llvm_prf_cnts[] + __asm("section$end$__DATA$__llvm_prf_cnts"); +#else extern char __start__llvm_prf_names[]; extern char __end__llvm_prf_names[]; extern char __start__llvm_prf_data[]; extern char __end__llvm_prf_data[]; extern char __start__llvm_prf_cnts[]; extern char __end__llvm_prf_cnts[]; +#endif COMPILER_RT_VISIBILITY ValueProfNode *CurrentVNode = 0; COMPILER_RT_VISIBILITY ValueProfNode *EndVNode = 0; diff --git a/libs/libbuiltin/compiler-rt/Make.defs b/libs/libbuiltin/compiler-rt/Make.defs index d269024533a..3530d0b8f96 100644 --- a/libs/libbuiltin/compiler-rt/Make.defs +++ b/libs/libbuiltin/compiler-rt/Make.defs @@ -114,6 +114,10 @@ FLAGS += -fno-profile-instr-generate -fno-coverage-mapping FLAGS += -Wno-undef -Wno-strict-prototypes -Wno-shadow FLAGS += -DCOMPILER_RT_HAS_UNAME +ifeq ($(CONFIG_HOST_MACOS),y) +FLAGS += -D__APPLE__ +endif + CSRCS += $(wildcard compiler-rt/compiler-rt/lib/profile/*.c) CPPSRCS += $(wildcard compiler-rt/compiler-rt/lib/profile/*.cpp) CSRCS += InstrProfilingPlatform.c