TUD-OS / NRE

NOVA runtime environment (official branch)
GNU General Public License v2.0
33 stars 12 forks source link

A question about standard non-OS specific C/C++ headers #56

Closed lonnietc closed 3 years ago

lonnietc commented 3 years ago

Hi Nils,

I am slowly making good progress forward on things and am liking the NOVA+NRE combination very much now.

As I go forward to try to port in some applications of different types, I started to wonder what are the different NON-OS Specific C/C++ headers and libraries that maybe you ran across during the development of NRE as well as your porting some of the NUL stuff over to the NRE framework.

I do not really have an idea as to what standard headers might be usable from gcc in the existing libraries and did not want to spend large amounts of time re-inventing the wheel to make new ones, so to speak, if there were some of them that could be used directly with NRE to compile and port different applications.

Do you have any suggestions or guidance on this that might be helpful for me going forward?

Cheers and have a good weekend

Nils-TUD commented 3 years ago

I guess you mean libc and libstdc++? These are currently not supported. NRE has its own custom C++ API instead, which worked fine so far (e.g., for porting stuff from NUL).

So, if you want to port other libraries or applications, you probably want to have a libc at some point. As soon as you have that, porting libstdc++ or others should be rather straightforward. For example, you could port musl or newlib to get a libc.

However, keep in mind that NOVA+NRE don't provide most of the functionality that is expected by a libc. In particular, there is no filesystem, no network API, no processes in the POSIX sense etc. Therefore, the parts of the libc that are freestanding (string functions, ...) are trivial to support, but the parts that require an OS need much more work (or are simply not supported). Depending on the software you want to port these missing features might a problem or not.

lonnietc commented 3 years ago

Thanks for your input on this.

I am gearing up for a VMM port of Bhyve which seems to be the best available options in that is is supposed to have very minimal OS dependencies and also has a small TCB which is able to compile for x86_64 hosts and will support the running of 32-bit and 64-bit guests.

There is also the MAC OSX port of Bhyve called "Xhyve" that also further compartmentalizes the VMM away from the underlying OS so that may be useful along the way to see how some things are done.

After all of the review, this "seems" like the best approach, but I am sure that it will be a challenge as well.

Nils-TUD commented 3 years ago

Oh, btw, if you want to see how that can look like, you can find here the port of musl to M³. Certainly not finished and it will look different for NRE, but might still be helpful as an example.

lonnietc commented 3 years ago

Thanks for the link and I will definitely see what I can do with it.

Every bit of help counts to make things come together. Cheers and have a good weekend, my friend.

lonnietc commented 3 years ago

I was looking through various libraries and bare metal headers along the lines of clib libraries like "musl" and found:

Clib C-Header Related

MUSL LIBC
https://musl.libc.org/

uClib
https://www.uclibc.org/

C++ Relates

libsupcxx
https://github.com/daedaleanai/libsupcxx

Embedded Template Library (ELT)
https://www.etlcpp.com/home.html and https://github.com/ETLCPP/etl

From all of these, it seems, based upon my minimal experience so far that probably the MUSL (Clib) and ELT (C++) are the most useful and actively updated projects to work towards getting some standard C headers installed to work with NRE.

Of course, there is no single fix to make porting a few Linux (or FreeBSD) apps directly to NOVE + NRE while still keeping as small a footprint and TCB as possible, but my guess is that these might be a good start.

Any thoughts? Cheers

Nils-TUD commented 3 years ago

From all of these, it seems, based upon my minimal experience so far that probably the MUSL (Clib) and ELT (C++) are the most useful and actively updated projects to work towards getting some standard C headers installed to work with NRE.

musl is definitely useful, yes. libsupcxx probably not as NRE already uses the libsupc++ from GCC (as it relies on exceptions) and libsupcxx contains mostly the libsupc++ and some other stuff that NRE already has, as far as I can see.

I also don't think that ETL helps, because according to their website it does not replace the STL, but only complements it. So, if you want to port applications, this does not seem useful.

I would rather port musl and then port (which is probably just a compile when building the cross compiler) the libstdc++ from GCC.

Of course, there is no single fix to make porting a few Linux (or FreeBSD) apps directly to NOVE + NRE while still keeping as small a footprint and TCB as possible, but my guess is that these might be a good start.

True, this will still be difficult as NOVA+NRE will even with a full C and C++ standard library quite far away from being POSIX compliant. But this is definitely a first and good step in that direction.

lonnietc commented 3 years ago

Thanks for your input on my thoughts here.

My first and primary goal is to get a good VMM ported over and then hopefully be able to extend upon some of the needed libraries to post a few applications for the overall project.

Cheers and have a good weekend,

On Sun, Jul 11, 2021 at 10:26 AM Nils Asmussen @.***> wrote:

From all of these, it seems, based upon my minimal experience so far that probably the MUSL (Clib) and ELT (C++) are the most useful and actively updated projects to work towards getting some standard C headers installed to work with NRE.

musl is definitely useful, yes. libsupcxx probably not as NRE already uses the libsupc++ from GCC (as it relies on exceptions) and libsupcxx contains mostly the libsupc++ and some other stuff that NRE already has, as far as I can see.

I also don't think that ETL helps, because according to their website it does not replace the STL, but only complements it. So, if you want to port applications, this does not seem useful.

I would rather port musl and then port (which is probably just a compile when building the cross compiler) the libstdc++ from GCC.

Of course, there is no single fix to make porting a few Linux (or FreeBSD) apps directly to NOVE + NRE while still keeping as small a footprint and TCB as possible, but my guess is that these might be a good start.

True, this will still be difficult as NOVA+NRE will even with a full C and C++ standard library quite far away from being POSIX compliant. But this is definitely a first and good step in that direction.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/TUD-OS/NRE/issues/56#issuecomment-877809092, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADUOZIV5LXHQME55OIAGYZ3TXGSYLANCNFSM5ADTWVFA .