This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 31c7409d800455c6ad68ad8d592aa2139e197e6e
Author: bijunda <[email protected]>
AuthorDate: Tue May 12 22:07:10 2026 +0800

    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 <[email protected]>
---
 libs/libbuiltin/compiler-rt/CMakeLists.txt           |  4 ++++
 libs/libbuiltin/compiler-rt/InstrProfilingPlatform.c | 15 +++++++++++++++
 libs/libbuiltin/compiler-rt/Make.defs                |  4 ++++
 3 files changed, 23 insertions(+)

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

Reply via email to