Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

include/stdlib.h: define system()'s prototype for the flat build #15756

Merged
merged 1 commit into from
Feb 7, 2025

Conversation

tmedicci
Copy link
Contributor

@tmedicci tmedicci commented Feb 4, 2025

Summary

  • include/stdlib.h: define system()'s prototype for the flat build

The $(APPDIR) folder is added to the $(KERNDEPDIRS) when CONFIG_BUILD_KERNEL=y. The depend phase iterates over the $(KERNDEPDIRS) folders and executes the depend recipe of these folders (including the apps' recipes) with the __KERNEL__ macro defined, which prevents system()'s prototype from being declared.

Impact

Impact architectures that build App's dependencies (the depend recipe) with CONFIG_SYSTEM_SYSTEM=y. This is the case, for instance, when building Python's library with support to the system() function.

This PR closes #15721

Testing

Internal CI testing + rv-virt:python with system() support:

make -j distclean && ./tools/configure.sh rv-virt:python && kconfig-tweak -e SYSTEM_SYSTEM && kconfig-tweak -e EXAMPLES_SYSTEM && make olddefconfig && make

Before this PR, it failed with:

/home/tiago/Documents/work/espressif/projects/nuttx/nuttxspace_alfa/apps/interpreters/python/Python/Modules/posixmodule.c:6026:14: error: implicit declaration of function 'system' [-Werror=implicit-function-declaration]
 6026 |     result = system(bytes);
      |              ^~~~~~
cc1: some warnings being treated as errors

The `$(APPDIR)` folder is added to the `$(KERNDEPDIRS)` when
`CONFIG_BUILD_KERNEL=y`. The `depend` phase iterates over the
`$(KERNDEPDIRS)` folders and executes the `depend` recipe of these
folders (including the apps' recipes) with the `__KERNEL__` macro
defined, which prevents `system()`'s prototype from being declared.
@github-actions github-actions bot added Area: OS Components OS Components issues Size: XS The size of the change in this PR is very small labels Feb 4, 2025
@tmedicci tmedicci requested review from anchao and lupyuen February 6, 2025 19:34
@lupyuen
Copy link
Member

lupyuen commented Feb 6, 2025

@nuttxpr test milkv_duos:nsh

@apache apache deleted a comment from nuttxpr Feb 6, 2025
@nuttxpr
Copy link

nuttxpr commented Feb 6, 2025

[Experimental Bot, please feedback here]

Build and Test Successful (milkv_duos:nsh)
https://gitlab.com/lupyuen/nuttx-build-log/-/snippets/4803688

$ git clone https://github.com/tmedicci/incubator-nuttx nuttx --branch bugfix/system_system
$ git clone https://github.com/apache/nuttx-apps apps --branch master
$ pushd nuttx
$ git reset --hard HEAD
HEAD is now at d33f654011 include/stdlib.h: define system()'s prototype for the flat build
$ popd
$ pushd apps
$ git reset --hard HEAD
HEAD is now at f139e56cd testing/libc/wcstombs: Add testing application for wcstombs
$ popd
NuttX Source: https://github.com/apache/nuttx/tree/d33f6540113b8a5a4392f8a69b1a8b6258669f64
NuttX Apps: https://github.com/apache/nuttx-apps/tree/f139e56cd62a30d6edcd7207c7e4cbc6e9b8b7d1
$ cd nuttx
$ tools/configure.sh milkv_duos:nsh
$ make -j
$ make -j export
$ pushd ../apps
$ ./tools/mkimport.sh -z -x ../nuttx/nuttx-export-10.3.0.tar.gz
$ make -j import
$ popd
$ genromfs -f initrd -d ../apps/bin -V NuttXBootVol
$ head -c 65536 /dev/zero
$ cat nuttx.bin /tmp/nuttx.pad initrd
$ scp Image tftpserver:/tftpboot/Image-sg2000
$ ssh tftpserver ls -l /tftpboot/Image-sg2000
$ cd /home/luppy/nuttx-build-farm
$ ssh tftpserver
OpenSBI v0.9
nsh> uname -a
NuttX 10.3.0 d33f654011 Feb  7 2025 06:49:26 risc-v milkv_duos
nsh> ostest
arena       81000    81000
ordblks         2        3
mxordblk    7cff8    78ff8
uordblks     2660     4570
fordblks    7e9a0    7ca90
user_main: Exiting
ostest_main: Exiting with status 0
nsh> Now running https://github.com/lupyuen/nuttx-build-farm/blob/main/oz64-power.sh off
----- Power off Oz64
[]

Copy link
Member

@lupyuen lupyuen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested OK on real hardware: Oz64 SG2000 RISC-V SBC. Thanks :-)

@anchao anchao merged commit 2ebdd72 into apache:master Feb 7, 2025
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: OS Components OS Components issues Size: XS The size of the change in this PR is very small
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] stdlib.h: system prototype
6 participants