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

[BUG] stdlib.h: system prototype #15721

Closed
1 task done
tmedicci opened this issue Jan 29, 2025 · 0 comments · Fixed by #15756
Closed
1 task done

[BUG] stdlib.h: system prototype #15721

tmedicci opened this issue Jan 29, 2025 · 0 comments · Fixed by #15756
Labels
Arch: all Issues that apply to all architectures Area: Kernel Kernel issues OS: Linux Issues related to Linux (building system, etc) Type: Bug Something isn't working

Comments

@tmedicci
Copy link
Contributor

Description / Steps to reproduce the issue

The Error

While trying to build Python with system function during the pass2dep phase, it triggers the following warning (that may be treated as an error):

/home/tiago/Documents/work/espressif/projects/nuttx/nuttxspace_alfa/apps/interpreters/python/Python/Modules/posixmodule.c:6026:14: warning: implicit declaration of function 'system' [-Wimplicit-function-declaration]
 6026 |     result = system(bytes);

Although the source includes stdlib.h, it fails because __KERNEL__ is defined and, thus, the system prototype is not defined.

Why?

There is a "trap" here:
__KERNEL__ (with $(KDEFINE)) is defined in the following snippet:

pass2dep: context tools/mkdeps$(HOSTEXEEXT) tools/cnvwindeps$(HOSTEXEEXT)
	$(Q) for dir in $(KERNDEPDIRS) ; do \
		$(MAKE) -C $$dir EXTRAFLAGS="$(KDEFINE) $(EXTRAFLAGS)" depend || exit; \
	done

$(KERNDEPDIRS) includes the $(APPDIR) folder here for flat build:

ifeq ($(CONFIG_BUILD_PROTECTED),y)
USERDEPDIRS += $(APPDIR)
else ifneq ($(CONFIG_BUILD_KERNEL),y)
KERNDEPDIRS += $(APPDIR)
else
CLEANDIRS += $(APPDIR)
endif

Proposed Fixes

We should either 1) remove $(APPDIR) from $(KERNDEPDIRS) (adding it to $(USERDEPDIRS) for both PROTECTED and FLAT BUILD or 2) define the prototype at nuttx/include/stdlib.h with the following if clause (which particularly I prefer):

#if !defined(__KERNEL__) || defined(CONFIG_BUILD_FLAT)
int       system(FAR const char *cmd);
#endif

Any thoughts about it?

On which OS does this issue occur?

[OS: Linux]

What is the version of your OS?

Manjaro

NuttX Version

master

Issue Architecture

[Arch: all]

Issue Area

[Area: Kernel]

Host information

No response

Verification

  • I have verified before submitting the report.
@tmedicci tmedicci added the Type: Bug Something isn't working label Jan 29, 2025
@github-actions github-actions bot added Arch: all Issues that apply to all architectures Area: Kernel Kernel issues OS: Linux Issues related to Linux (building system, etc) labels Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Arch: all Issues that apply to all architectures Area: Kernel Kernel issues OS: Linux Issues related to Linux (building system, etc) Type: Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant