Skip to content

Conversation

@adwait-godbole
Copy link
Contributor

@adwait-godbole adwait-godbole commented Feb 1, 2026

This PR fixes incorrect flag handling and string escaping in the make host_info diagnostic target.

The previous implementation passed compilation flags in a way that caused incorrect splitting and over-escaping, leading to malformed diagnostic output and incorrectly quoted configuration values.

The fixes ensure that:

  • CFLAGS, CXXFLAGS, and LDFLAGS are passed and parsed correctly
  • Configuration values are escaped exactly once when generating sysinfo.h
  • The parsed output accurately reflects the contents of the .config file

This is a diagnostic-only change and does not affect the NuttX build output.

Fixes #16696

image image

cc: @acassis

@github-actions github-actions bot added Area: Tooling Area: Build system Size: S The size of the change in this PR is small labels Feb 1, 2026
@acassis
Copy link
Contributor

acassis commented Feb 1, 2026

@adwait-godbole I don't know if you need to add quotes to every lines, my ideas was to fix just:

from:
CONFIG_ARCH_BOARD=\weact-stm32h743\

to:
CONFIG_ARCH_BOARD="weact-stm32h743"

@raiden00pl @xiaoxiang781216 what do you think?

@adwait-godbole
Copy link
Contributor Author

adwait-godbole commented Feb 2, 2026

Hi @acassis. Thanks for the quick feedback. From the screenshots I’ve attached in the PR description, I’ve already been able to achieve this:

before:

CONFIG_APPS_DIR=\../apps\

after (this PR):

“CONFIG_APPS_DIR=“../apps””

So removing those wrapping double quotes won’t be much of an issue. I’ll do that fix.

Just wanted to confirm one thing. Do we only want to do this (remove wrapping double quotes) for CONFIG_* options or for everything that is getting dumped on the terminal? I mean do we also want this:

My current PR changes:

NuttX LDFLAGS:
   “-Wl—gc-sections”

Your Requirement:

NuttX LDFLAGS:
   -Wl—gc-sections

? Let me know.

xiaoxiang781216
xiaoxiang781216 previously approved these changes Feb 2, 2026
@acassis
Copy link
Contributor

acassis commented Feb 2, 2026

   -Wl—gc-sections

Hi @adwait-godbole I think everything should have these double quote, only some strings after CONFIG_XXX..= should include "yyyy". So basically remote the initial and the ending quote of each line will fix the issue

@simbit18
Copy link
Contributor

simbit18 commented Feb 2, 2026

Hi @adwait-godbole please fix

====================================================================================

Configuration/Tool: esp32-devkitc/nxdiag
2026-02-01 20:19:24
------------------------------------------------------------------------------------
  Cleaning...
  Configuring...
  Building NuttX...
In file included from nxdiag.c:36:
Error: sysinfo.h:17:293: error: 'github' undeclared here (not in a function)
   17 |   "-fno-common -Wall -Wstrict-prototypes -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas -Wno-psabi -Os -fno-strict-aliasing -fomit-frame-pointer -ffunction-sections -fdata-sections -mlongcalls -isystem /github/workspace/sources/nuttx/include -D__NuttX__ -DNDEBUG -Wno-cpp -Werror -I "/github/workspace/sources/apps/include"",
      |                                                                                                                                                                                                                                                                                                     ^~~~~~
Error: sysinfo.h:17:300: error: 'workspace' undeclared here (not in a function)
   17 |   "-fno-common -Wall -Wstrict-prototypes -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas -Wno-psabi -Os -fno-strict-aliasing -fomit-frame-pointer -ffunction-sections -fdata-sections -mlongcalls -isystem /github/workspace/sources/nuttx/include -D__NuttX__ -DNDEBUG -Wno-cpp -Werror -I "/github/workspace/sources/apps/include"",
      |                                                                                                                                                                                                                                                                                                            ^~~~~~~~~
Error: sysinfo.h:17:310: error: 'sources' undeclared here (not in a function)
   17 |   "-fno-common -Wall -Wstrict-prototypes -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas -Wno-psabi -Os -fno-strict-aliasing -fomit-frame-pointer -ffunction-sections -fdata-sections -mlongcalls -isystem /github/workspace/sources/nuttx/include -D__NuttX__ -DNDEBUG -Wno-cpp -Werror -I "/github/workspace/sources/apps/include"",
      |                                                                                                                                                                                                                                                                                                                      ^~~~~~~
Error: sysinfo.h:17:318: error: 'apps' undeclared here (not in a function)
   17 |   "-fno-common -Wall -Wstrict-prototypes -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas -Wno-psabi -Os -fno-strict-aliasing -fomit-frame-pointer -ffunction-sections -fdata-sections -mlongcalls -isystem /github/workspace/sources/nuttx/include -D__NuttX__ -DNDEBUG -Wno-cpp -Werror -I "/github/workspace/sources/apps/include"",
      |                                                                                                                                                                                                                                                                                                                              ^~~~
Error: sysinfo.h:17:323: error: 'include' undeclared here (not in a function); did you mean 'inode'?
   17 |   "-fno-common -Wall -Wstrict-prototypes -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas -Wno-psabi -Os -fno-strict-aliasing -fomit-frame-pointer -ffunction-sections -fdata-sections -mlongcalls -isystem /github/workspace/sources/nuttx/include -D__NuttX__ -DNDEBUG -Wno-cpp -Werror -I "/github/workspace/sources/apps/include"",
      |                                                                                                                                                                                                                                                                                                                                   ^~~~~~~
      |                                                                                                                                                                                                                                                                                                                                   inode
Error: sysinfo.h:17:330: error: expected '}' before string constant
   17 |   "-fno-common -Wall -Wstrict-prototypes -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas -Wno-psabi -Os -fno-strict-aliasing -fomit-frame-pointer -ffunction-sections -fdata-sections -mlongcalls -isystem /github/workspace/sources/nuttx/include -D__NuttX__ -DNDEBUG -Wno-cpp -Werror -I "/github/workspace/sources/apps/include"",
      |                                                                                                                                                                                                                                                                                                                                          ^~
sysinfo.h:16:1: note: to match this '{'
   16 | {
      | ^
Error: sysinfo.h:23:105: error: expected '}' before 'gnu'
   23 |   "-fno-common -Wall -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas -nostdinc++ -Wno-psabi -std="gnu++17" -fno-exceptions -fcheck-new -fno-rtti -Os -fno-strict-aliasing -fomit-frame-pointer -ffunction-sections -fdata-sections -mlongcalls -isystem /github/workspace/sources/nuttx/include/cxx -isystem /github/workspace/sources/nuttx/include -D__NuttX__ -DNDEBUG -Wno-cpp -Werror -I "/github/workspace/sources/apps/include"",
      |                                                                                                         ^~~
sysinfo.h:22:1: note: to match this '{'
   22 | {
      | ^
make[2]: *** [/github/workspace/sources/apps/Application.mk:330: nxdiag.c.github.workspace.sources.apps.system.nxdiag.o] Error 1
make[2]: Target 'all' not remade because of errors.
make[1]: *** [Makefile:54: /github/workspace/sources/apps/system/nxdiag_all] Error 2
make[1]: Target 'all' not remade because of errors.
make: *** [tools/LibTargets.mk:248: /github/workspace/sources/apps/libapps.a] Error 2
make: Target 'all' not remade because of errors.
/github/workspace/sources/nuttx/tools/testbuild.sh: line 385: /github/workspace/sources/nuttx/../nuttx/nuttx.manifest: No such file or directory
  [1/1] Normalize esp32-devkitc/nxdiag
====================================================================================

@adwait-godbole
Copy link
Contributor Author

Hi @acassis @simbit18. Please re-review. Thanks :).

jerpelea
jerpelea previously approved these changes Feb 3, 2026
acassis
acassis previously approved these changes Feb 3, 2026
@adwait-godbole
Copy link
Contributor Author

@simbit18. Please let me know if you're still facing the same failure.

@simbit18
Copy link
Contributor

simbit18 commented Feb 3, 2026

Hi @adwait-godbole, you need to run the tests with this configuration esp32-devkitc:nxdiag

CC:  exec_builtin.c 
make[2]: Leaving directory '/github/workspace/sources/apps/builtin'
make[2]: Entering directory '/github/workspace/sources/apps/nshlib'
CC:  nsh_alias.c 
CC:  nsh_builtin.c 
CC:  nsh_command.c 
CC:  nsh_console.c 
CC:  nsh_consolemain.c 
CC:  nsh_dbgcmds.c 
CC:  nsh_envcmds.c 
CC:  nsh_fscmds.c 
CC:  nsh_fsutils.c 
CC:  nsh_init.c 
CC:  nsh_mmcmds.c 
CC:  nsh_mntcmds.c 
CC:  nsh_parse.c 
CC:  nsh_printf.c 
CC:  nsh_proccmds.c 
CC:  nsh_prompt.c 
CC:  nsh_script.c 
CC:  nsh_session.c 
CC:  nsh_syscmds.c 
CC:  nsh_system.c 
CC:  nsh_test.c 
CC:  nsh_timcmds.c 
CC:  nsh_wait.c 
make[2]: Leaving directory '/github/workspace/sources/apps/nshlib'
make[2]: Entering directory '/github/workspace/sources/apps/platform'
CC:  board/dummy.c 
make[2]: Leaving directory '/github/workspace/sources/apps/platform'
make[2]: Entering directory '/github/workspace/sources/apps/system/dd'
CC:  dd_main.c 
make[2]: Leaving directory '/github/workspace/sources/apps/system/dd'
make[2]: Entering directory '/github/workspace/sources/apps/system/nsh'
CC:  nsh_main.c 
CC:  sh_main.c 
make[2]: Leaving directory '/github/workspace/sources/apps/system/nsh'
make[2]: Entering directory '/github/workspace/sources/apps/system/nxdiag'
if ([ $? -ne 0 ]); then \
	echo "ERROR: Failed to generate sysinfo.h"; \
	exit 1; \
fi
CC:  nxdiag.c 
In file included from nxdiag.c:36:
Error: sysinfo.h:35:21: error: 'y' undeclared here (not in a function)
   35 |   CONFIG_HOST_LINUX=y,
      |                     ^
Error: sysinfo.h:36:18: error: assignment to expression with array type
   36 |   CONFIG_APPS_DIR="../apps",
      |                  ^
Error: sysinfo.h:37:24: error: assignment to expression with array type
   37 |   CONFIG_BASE_DEFCONFIG="esp32-devkitc:nxdiag",
      |                        ^
Error: sysinfo.h:44:24: error: lvalue required as left operand of assignment
   44 |   CONFIG_FORTIFY_SOURCE=0,
      |                        ^
Error: sysinfo.h:48:29: error: lvalue required as left operand of assignment
   48 |   CONFIG_STACK_USAGE_WARNING=0,
      |                             ^
Error: sysinfo.h:55:14: error: assignment to expression with array type
   55 |   CONFIG_ARCH="xtensa",
      |              ^
Error: sysinfo.h:56:19: error: assignment to expression with array type
   56 |   CONFIG_ARCH_CHIP="esp32",
      |                   ^
Error: sysinfo.h:57:31: error: assignment to expression with array type
   57 |   CONFIG_ESPRESSIF_CHIP_SERIES="esp32",
      |                               ^
Error: sysinfo.h:58:28: error: lvalue required as left operand of assignment
   58 |   CONFIG_ESPRESSIF_NUM_CPUS=2,
      |                            ^
Error: sysinfo.h:62:30: error: assignment to expression with array type
   62 |   CONFIG_ESPRESSIF_FLASH_FREQ="40m",
      |                              ^
Error: sysinfo.h:65:27: error: lvalue required as left operand of assignment
   65 |   CONFIG_XTENSA_CP_INITSET=0x0001,
      |                           ^
Error: sysinfo.h:74:36: error: lvalue required as left operand of assignment
   74 |   CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ=240,
      |                                    ^
Error: sysinfo.h:76:39: error: lvalue required as left operand of assignment
   76 |   CONFIG_ESP_PHY_IRQSTATE_FLAGS_NUMBER=3,
      |                                       ^
Error: sysinfo.h:80:31: error: lvalue required as left operand of assignment
   80 |   CONFIG_ESP32_BT_RESERVE_DRAM=0,
      |                               ^
Error: sysinfo.h:81:37: error: lvalue required as left operand of assignment
   81 |   CONFIG_ESP32_TRACEMEM_RESERVE_DRAM=0,
      |                                     ^
Error: sysinfo.h:82:38: error: lvalue required as left operand of assignment
   82 |   CONFIG_ESP32_ULP_COPROC_RESERVE_MEM=0,
      |                                      ^

@adwait-godbole
Copy link
Contributor Author

@simbit18 the esp32-devkitc:nxdiag test has now passed in the CI -> https://github.com/apache/nuttx/actions/runs/21633827066/job/62353972303?pr=18299. I hope everything else turns green as well :).

@adwait-godbole
Copy link
Contributor Author

@simbit18 good to go?

@simbit18
Copy link
Contributor

simbit18 commented Feb 4, 2026

@adwait-godbole Thank you so much !

Did @acassis resolve your request?

@fdcavalcanti @tmedicci @eren-terzioglu Is this acceptable for your internal tests?

@eren-terzioglu
Copy link
Contributor

@adwait-godbole Thank you so much !

Did @acassis resolve your request?

@fdcavalcanti @tmedicci @eren-terzioglu Is this acceptable for your internal tests?

Hi,
I am testing right now.

@eren-terzioglu
Copy link
Contributor

eren-terzioglu commented Feb 4, 2026

esp32-devkitc:nxdiag built fine but make host_info is giving this output. Is it happening on your machines too after the updates?

$ ./tools/configure.sh esp32-devkitc:nxdiag; make -j
...
Successfully created esp32 image.
Generated: nuttx.bin

$ make host_info
file sysinfo.h not exists
usage: host_info_dump.py [-h] [-m] [-k] [-p] [-c] [-f CFLAGS CXXFLAGS LDFLAGS]
                         [--verbose] [--target_info]
                         nuttx_path
host_info_dump.py: error: argument -f/--flags: expected 3 arguments
make: *** [tools/Unix.mk:644: host_info] Error 2

$ sudo make host_info
[sudo] password for eren: 
/usr/bin/bash: line 1: xtensa-esp32-elf-gcc: command not found
No matching array found.

@adwait-godbole
Copy link
Contributor Author

@eren-terzioglu I'll look into this. Thanks.

@github-actions github-actions bot added Area: CI Size: M The size of the change in this PR is medium labels Feb 4, 2026
@adwait-godbole adwait-godbole force-pushed the tools/host_info-fix branch 2 times, most recently from 92332e7 to 989238f Compare February 4, 2026 18:24
Fix incorrect flag handling and string escaping in the `make host_info`
diagnostic target.

Previously, CFLAGS, CXXFLAGS, and LDFLAGS were passed in a form that caused
improper splitting and quoting, which resulted in malformed output and
incorrectly escaped configuration values such as CONFIG_APPS_DIR.

This change ensures that:
- Compilation flags are passed as proper shell strings
- Flags are split correctly using shlex
- Configuration values are escaped exactly once when generating sysinfo.h
- Parsed output matches the contents of the .config file

This change affects diagnostic output only and does not modify the NuttX
build process or generated binaries.

Signed-off-by: Adwait Godbole <adwaitngodbole@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Build system Area: CI Area: Tooling Size: M The size of the change in this PR is medium Size: S The size of the change in this PR is small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] "make host_info" is generating config with messed double quote

6 participants