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

   ## Summary
   
   The build system generates an internal entry-point symbol by concatenating 
`PROGNAME` with `_main`. If `PROGNAME` 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 simply setting 
`CONFIG_EXAMPLES_HELLO_PROGNAME="hello-world"`.
   
   ## Changes
   
   Introduce `PROGSYM`, a sanitized copy of `PROGNAME` (`-` replaced with `_`), 
and use it only where an internal identifier is generated.
   
   Changes:
   
   - Use `PROGSYM` for the `-Dmain=` compiler define used by C/C++
   - Use `PROGSYM` in the Zig `RENAMEMAIN` path
   - Use `PROGSYM` for the builtin entry-point symbol passed to `REGISTER`
   
   The registered application name is unchanged, so applications continue to be 
invoked using their configured `PROGNAME`.
   
   ## Issues
   
   Fixes apache/nuttx#19447
   
   ## Test log
   
   Host: WSL2 Ubuntu 24.04 x86_64
   
   Configuration: `sim:nsh`
   
   Configured the hello example with a hyphenated program name:
   
   ```bash
   kconfig-tweak --enable CONFIG_EXAMPLES_HELLO
   kconfig-tweak --set-str CONFIG_EXAMPLES_HELLO_PROGNAME "hello-world"
   make olddefconfig
   make -j$(nproc)
   ```
   
   Before this change, the build failed because `hello-world_main` is not a 
valid C identifier.
   
   After applying this change, the build completed successfully:
   
   ```text
   Register: hello-world
   ...
   LD:  nuttx
   Pac SIM with dynamic libs..
   SIM elf with dynamic libs archive in nuttx.tgz
   ```
   
   Verified the application from NSH:
   
   ```text
   nsh> hello-world
   Hello, World!!
   ```
   
   Regression test:
   
   ```bash
   kconfig-tweak --set-str CONFIG_EXAMPLES_HELLO_PROGNAME "hello"
   make olddefconfig
   make clean
   make -j$(nproc)
   ```
   
   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