fix(sim): fix compiler-rt build on macOS

Added the missing __APPLE__ which was undefined by sim globally.
Added missing linker flags.

Signed-off-by: bijunda <bijunda@bytedance.com>
This commit is contained in:
bijunda 2026-05-12 22:07:10 +08:00 committed by Alan C. Assis
parent d701340cb6
commit 31c7409d80
3 changed files with 23 additions and 0 deletions

View file

@ -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)

View file

@ -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;

View file

@ -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