cmake: Fix SIM_TOOLCHAIN using CMake on macOS.#18957
Merged
Merged
Conversation
Fix an issue where `SIM_TOOLCHAIN_GCC` was incorrectly set when configuring `sim:nsh` using CMake on macOS. Ensure that `nuttx_sethost()` is called before `nuttx_olddefconfig()`. Signed-off-by: Shoji Tokunaga <toku@mac.com>
xiaoxiang781216
approved these changes
May 25, 2026
lupyuen
approved these changes
May 25, 2026
Member
lupyuen
left a comment
There was a problem hiding this comment.
Tested OK on macOS 26.4.1 25E253 arm64 thanks :-)
https://gist.github.com/lupyuen/6016cbcd5ca7068b59e0e6008d04b7b0
$ git clone https://github.com/toku-mac/nuttx --branch fix_cmake_sim_toolchain
$ git clone https://github.com/apache/nuttx-apps apps
$ cd nuttx ; cmake -S . -B build-debug -DBOARD_CONFIG=sim:nsh -GNinja -DCMAKE_MAKE_PROGRAM=/opt/homebrew/bin/ninja
...
$ cmake --build build-debug -t olddefconfig
$ cmake --build build-debug
$ build-debug/nuttx
NuttShell (NSH)
nsh> uname -a
NuttX 0.0.0 db6ec219d1 May 25 2026 18:10:35 sim sim
nsh> hello
Hello, World!!
jerpelea
approved these changes
May 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Set host-specific Kconfig values before the initial
olddefconfigstep in the CMake build, and clarify the helper arguments used for that setup.On macOS,
sim:nshneedsHOST_MACOS=yto be present before the sim toolchain choice is resolved. Without that, the firstolddefconfigmay select the default GCC toolchain instead of the macOS-specific Clang default.As a result, you encounter the error
ld: library not found for -lgcov.This PR updates the CMake initialization flow so
nuttx_sethost()can apply host settings to the temporary.config.compressedbefore the firstolddefconfig.The helper functions were also refactored to use named arguments:
Impact
CONFIG_SIM_TOOLCHAIN_CLANG=yis enabled, which resolves linker errors.Testing
I confirm that changes are verified on local setup and works as intended:
Configuration:
Testing logs before change:
Testing logs after change:
PR verification Self-Check