Compiling NuttX with system stdlib instead of custom stdlib

2024-08-02 Thread Ritvik Tanksalkar
Hello,

I'm working on a project where I need to compile the NuttX kernel to use
the system's standard library (stdlib) instead of its custom
implementation. My goal is to have NuttX use the host system's stdlib
functions rather than the ones provided with the kernel.

Currently, I'm compiling the Nuttx kernel for "sim:posix_spawn" which
guarantees native linux support.

I'd appreciate any guidance on how to achieve this. Specifically:

1. What configuration changes are needed to disable NuttX's built-in libc?
2. Are there any known issues or challenges in making this change?

Any insights in this regard would be greatly appreciated.

Regards,
Ritvik


Re: Compiling NuttX with system stdlib instead of custom stdlib

2024-08-02 Thread Ritvik Tanksalkar
Hi,

Thank you so much for the valuable insights Gregory and Alan. I kind of
understood the pitfalls but nevertheless wanted to confirm.

Regards,
Ritvik



On Fri, Aug 2, 2024 at 3:49 PM Gregory Nutt  wrote:

> On 8/2/2024 12:06 PM, Ritvik Tanksalkar wrote:
> > Hello,
> >
> > I'm working on a project where I need to compile the NuttX kernel to use
> > the system's standard library (stdlib) instead of its custom
> > implementation. My goal is to have NuttX use the host system's stdlib
> > functions rather than the ones provided with the kernel.
> >
> > Currently, I'm compiling the Nuttx kernel for "sim:posix_spawn" which
> > guarantees native linux support.
> >
> > I'd appreciate any guidance on how to achieve this. Specifically:
> >
> > 1. What configuration changes are needed to disable NuttX's built-in
> libc?
> > 2. Are there any known issues or challenges in making this change?
> >
> > Any insights in this regard would be greatly appreciated.
> >
> > Regards,
> > Ritvik
> >
> Almost nothing is impossible given enough effort.  But if you are
> thinking in terms of a simple effort, the simple answer is that
> replacing the NuttX-specific libc with a Linux-specific libc is
> impossible.  That is because the NuttX libc uses the NuttX OS system
> calls and the Linux libc uses the Linux system calls.  They are not the
> same.  In order to make this work, you would have to change the OS
> interface used in GLIBC to use the NuttX OS interface.  That would be an
> enormous job!
>
> GLIBC uses the Linux-specific header files that you will find under
> /usr/include/sys.  Those would all have to be replaced with
> NuttX-specific header files.  The exported NuttX header files are the
> ones you find in nuttx/include/nuttx.  Most of the header file required
> by GLIBC don't even exist in NuttX and would have to be created to
> satisfy GLIBC.  That is another enormous job.
>
> Alan's suggestion works fine for a few, specific, leaf functions in
> GLIBC but will not work in general.  That is because many non-leaf GLIBC
> header files will draw in other header files that are not compatible
> with NuttX.  It would be yet another enormous job to make that work.
>
> My recommendatioin:  Don't waste your time.
>
>
>


Help need to understand Nuttx build process

2024-09-05 Thread Ritvik Tanksalkar
Hi,

I'm trying to understand the build process of the nuttx kernel using the
configuration for *sim:posix_spawn*. I see that the *sim* architecture has
a *nuttx-names.in * which the linker uses and likely
creates the *nuttx-names.dat* during the build process.

The symbols I see in this file make it seem like the linker is redirecting
some of them to host stdlib whenever available (ex - *pthread_sigmask* has
a custom stdlib implementation at *sched/pthread_sigmask.c*) but the
simulator uses host stdlib's pthread_sigmask (*pthread_sigmask@GLIBC_2.32*
).

There are some functions which get redirected to their custom
implementations and some that get redirected towards host stdlib. My
question is, when and how is this symbol redirection decided, specifically,
how does the linker understand which symbols to redirect to custom stdlib
and which ones to redirect towards host stdlib?

Regards,
Ritvik


Re: Help need to understand Nuttx build process

2024-09-05 Thread Ritvik Tanksalkar
Hi Gregory,

Thanks alot for pointing me to the correct documentation, just what I
needed!.

Warm Regards,
Ritvik Tanksalkar



On Thu, Sep 5, 2024 at 6:35 PM Gregory Nutt  wrote:

> See https://cwiki.apache.org/confluence/display/NUTTX/NuttX+Simulation
>
> On 9/5/2024 1:47 PM, Ritvik Tanksalkar wrote:
> > Hi,
> >
> > I'm trying to understand the build process of the nuttx kernel using the
> > configuration for *sim:posix_spawn*. I see that the *sim* architecture
> has
> > a *nuttx-names.in <http://nuttx-names.in>* which the linker uses and
> likely
> > creates the *nuttx-names.dat* during the build process.
> >
> > The symbols I see in this file make it seem like the linker is
> redirecting
> > some of them to host stdlib whenever available (ex - *pthread_sigmask*
> has
> > a custom stdlib implementation at *sched/pthread_sigmask.c*) but the
> > simulator uses host stdlib's pthread_sigmask (*pthread_sigmask@GLIBC_2.32
> *
> > ).
> >
> > There are some functions which get redirected to their custom
> > implementations and some that get redirected towards host stdlib. My
> > question is, when and how is this symbol redirection decided,
> specifically,
> > how does the linker understand which symbols to redirect to custom stdlib
> > and which ones to redirect towards host stdlib?
> >
> > Regards,
> > Ritvik
> >
>