ML-dev-crypto opened a new pull request, #19464:
URL: https://github.com/apache/nuttx/pull/19464

   ## Summary
   
   The CMake build generates an internal entry-point symbol by concatenating 
`NAME` with `_main`. If `NAME` contains `-` (for example, `hello-world`), the 
generated symbol (`hello-world_main`) is not a valid C identifier, causing the 
build to fail.
   
   This can be reproduced by setting 
`CONFIG_EXAMPLES_HELLO_PROGNAME="hello-world"` and rebuilding with CMake.
   
   ## Impact
   
   Introduce `NAME_SYM`, a sanitized copy of `NAME` with `-` replaced by `_`, 
and use it only where an internal C identifier is required.
   
   - Use `NAME_SYM` for the `main=` compile definition.
   - Use `NAME_SYM` for the `APP_MAIN` target property used during builtin list 
generation.
   - Keep `NAME` unchanged for the CMake target name, output name, and the 
`APP_NAME` property so applications continue to be invoked using their 
configured program name.
   
   The standalone and loadable executable path (`MODULE`/`DYNLIB`/kernel build) 
does not rename `main()` and therefore does not require any sanitization.
   
   This mirrors the Make-based fix already merged in `apache/nuttx-apps#3647`.
   
   ## Issues
   
   Fixes #19447
   
   ## Testing
   
   **Host:** WSL2 Ubuntu 24.04 x86_64
   
   **Configuration:** `sim/nsh`
   
   Configured the hello example with a hyphenated program name:
   
   - Set `CONFIG_EXAMPLES_HELLO_PROGNAME="hello-world"`.
   - Reconfigured the build with CMake.
   - Rebuilt the project.
   
   Before this change, the build failed because `hello-world_main` is not a 
valid C identifier.
   
   After applying this change, the build completed successfully.
   
   Verified the application from NSH:
   
   ```text
   nsh> hello-world
   Hello, World!!
   ```
   
   Regression test:
   
   - Changed `CONFIG_EXAMPLES_HELLO_PROGNAME` back to `"hello"`.
   - Reconfigured the build with `cmake -S .. -B .`.
   - Rebuilt in the same build directory.
   
   Verified the default configuration still works:
   
   ```text
   nsh> hello
   Hello, World!!
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to