Porting newlib without execve

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
brain
Member
Member
Posts: 234
Joined: Thu Nov 05, 2009 5:04 pm
Location: UK
Contact:

Porting newlib without execve

Post by brain »

Hi,

I am planning when i am far enough into OS development to port newlib to my OS then from there use that to compile gcc and binutils for my OS. However, i am unsure as to what will happen if i do not implement execve() in newlib, would this break any possibility of running gcc?

It seems gcc is pretty much tied to unix style schemantics, and i do not want to implement execve() in my OS, i am going to be going for a more CreateProcess style function instead. exec however has special behaviour in that it replaces the text portion of the code and leaves the environment, file handles etc intact, and causes the actual caller to be *replaced* (e.g. it never actually returns) where createprocess would return, and spawn a second process much like fork() and exec() combined.

So in short, can i get away with not implementing execve() and still be able to port gcc?
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Re: Porting newlib without execve

Post by pcmattman »

Simply put, no.

Vanilla ports of GCC (no patching) use execve several times during a conventional run (at least once to run "cc1" or "cc1plus", and once more to run "as", and then "collect2" and "ld" if you don't specify "-c"). If you want to port applications which depend on POSIX semantics, you can't get around it.

In my OS, I have a POSIX subsystem which will be separate from the native OS-specific native API, which means it's possible to run POSIX applications alongside native applications. In your case, this would mean a set of POSIX system calls with POSIX semantics (exec and so on), and a set of native system calls with your semantics (CreateProcess).
Last edited by pcmattman on Fri Nov 20, 2009 3:14 am, edited 1 time in total.
Kevin
Member
Member
Posts: 1071
Joined: Sun Feb 01, 2009 6:11 am
Location: Germany
Contact:

Re: Porting newlib without execve

Post by Kevin »

If patching gcc (or rather libiberty) is an option for you, it's quite possible to run gcc without separate fork/exec functions. Internally it uses an abstraction on your CreateProcess level, so we implemented pex_tyndur_exec_child and were happy. Of course, with the next POSIX program expecting fork/exec, you need to patch again...
Developer of tyndur - community OS of Lowlevel (German)
Post Reply