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

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


The following commit(s) were added to refs/heads/master by this push:
     new 574fc64ab9d sim: Fix linker support and macOS host build issues
574fc64ab9d is described below

commit 574fc64ab9d139ac7eea6d36691131cec44dcf19
Author: Aditya Yadav <[email protected]>
AuthorDate: Wed Mar 4 21:33:59 2026 +0000

    sim: Fix linker support and macOS host build issues
    
    Update SIM configuration and CMake toolchain to resolve
    linker errors when building on macOS. Adjust POSIX host
    implementation to ensure successful compilation and
    proper behavior of the sim target.
    
    Modified:
    - arch/sim/Kconfig
    - arch/sim/src/cmake/Toolchain.cmake
    - arch/sim/src/sim/posix/sim_hostmisc.c
    
    Signed-off-by: Aditya Yadav 
<[email protected]>
---
 arch/sim/Kconfig                      | 1 +
 arch/sim/src/cmake/Toolchain.cmake    | 9 +++++++--
 arch/sim/src/sim/posix/sim_hostmisc.c | 1 +
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/arch/sim/Kconfig b/arch/sim/Kconfig
index e70425c7862..b8ace8699b9 100644
--- a/arch/sim/Kconfig
+++ b/arch/sim/Kconfig
@@ -37,6 +37,7 @@ config ARCH_CHIP
 
 choice
        prompt "Toolchain Selection"
+       default SIM_TOOLCHAIN_CLANG if HOST_MACOS
        default SIM_TOOLCHAIN_GCC
 
 config SIM_TOOLCHAIN_GCC
diff --git a/arch/sim/src/cmake/Toolchain.cmake 
b/arch/sim/src/cmake/Toolchain.cmake
index cf91d6f4cd2..3b21b25fbc8 100644
--- a/arch/sim/src/cmake/Toolchain.cmake
+++ b/arch/sim/src/cmake/Toolchain.cmake
@@ -20,7 +20,7 @@
 #
 # 
##############################################################################
 
-if(APPLE)
+if(APPLE AND CONFIG_SIM_TOOLCHAIN_GCC)
   find_program(CMAKE_C_ELF_COMPILER x86_64-elf-gcc)
   find_program(CMAKE_CXX_ELF_COMPILER x86_64-elf-g++)
 endif()
@@ -121,7 +121,12 @@ if(CONFIG_STACK_USAGE_WARNING)
 endif()
 
 if(CONFIG_COVERAGE_ALL)
-  add_compile_options(-fprofile-arcs -ftest-coverage -fno-inline)
+  if(CONFIG_ARCH_TOOLCHAIN_GCC)
+    add_compile_options(-fprofile-arcs -ftest-coverage -fno-inline)
+  elseif(CONFIG_ARCH_TOOLCHAIN_CLANG)
+    add_compile_options(-fprofile-instr-generate -fcoverage-mapping)
+    add_link_options(-fprofile-instr-generate)
+  endif()
 endif()
 
 if(CONFIG_PROFILE_ALL OR CONFIG_SIM_PROFILE)
diff --git a/arch/sim/src/sim/posix/sim_hostmisc.c 
b/arch/sim/src/sim/posix/sim_hostmisc.c
index 009005bff44..a2338ebbd16 100644
--- a/arch/sim/src/sim/posix/sim_hostmisc.c
+++ b/arch/sim/src/sim/posix/sim_hostmisc.c
@@ -24,6 +24,7 @@
  * Included Files
  ****************************************************************************/
 
+#include <signal.h>
 #include <errno.h>
 #include <limits.h>
 #include <stdio.h>

Reply via email to