-
Notifications
You must be signed in to change notification settings - Fork 14
Home
Jump right into Getting Started page. It contains the basics about prerequisites, code review system and accessing files.
First of all, you must remember that APEX is a work in progress. We're adding/fixing things while porting Unix/Linux software. Seeing what must be changed or updated and what does not matter.
When Plan 9 was made at Bell Labs, its authors made a minimal ANSI/POSIX environment to test native Plan 9 software in a simulated Unix environment. Main purpose was porting Plan 9 programs to Unix.
But life has weird ways sometimes, and APE ended up being the way to port Unix programs to Plan 9. If you don't know anything about that, you should read first this paper in order to understand better next paragraph.
APE originally had a bunch of libs wrapping native Plan 9 libs, but now Harvey is using GCC as its toolchain (for now, remember, we want Clang), then there are only needed a couple of libs: ap and bsd. There's no enough information about why some implementations where separated in a library referring BSD code, and soon libbsd will be into libap (ansi/posix) as a dir, like stdio, multibyte, stdlib and rest. It has no sense to keep apart because every time you would need to link it manually in this actual sequence: -lbsd -lap -lc (a work in progress, do you remember?).
As you can see, and in "Getting Started" page, it's needed the "-lc" for libc. Well, native toolchain will do for you, but for now we are compiling in Linux and running in Harvey, do you remember?.
Well, Plan 9 APE was built like a bunch of wrappers for native syscalls and related functions (see malloc.c) thinking in build ANSI libc over this "translators". In those days, it was slow and under certain point of view, a leak in runtime. But we're in 2016, and now we have better hardware. And APE was being implemented/fixed in any ways.
We implemented APEX from APE with Musl libc code, to bring up an ANSI/POSIX environment more compatible and in line with the times. Because original Plan 9 APE was purely C89, and in Harvey we have needs and projects that were claiming for a better implementation. It keeps main wrappers, but updated, and uses native syscall API: tha means, it has only 7 wrappers for syscalls that are implemented in a different way in Unix, or their corresponding functions are based on a Harvey's syscall with the same name. I mean, APEX has wait(int status) -for example- based on native Waitmsg* wait(void), so its definition and prototype were incompatible. A way to avoid this situation was, from original APE, wrapping up the syscall in its corresponding name in uppercase with underscores. For example, open as _OPEN. Avoiding the collision if ANSI open calls _OPEN syscall inside it. Main prupose of wrapping case. Harvey APEX allow this because we're using the same compiler across all the system. Plan 9 used its own toolchain and an ANSI wrapper for it called pcc (do not confuse with Portable C Compiler) wrapping entire syscall collection. Harvey uses the same GCC/Clang for all, so there's no need to wrapp entire syscall API, just only those what could collide with ANSI functions.
This way provides as well that Harvey only needs libap (with code from libbsd inside) to build ANSI/POSIX programs, because rest of the old APE libs were made thinking in using a wrapped compiler (Plan 9 8c/6c/etc.. -> pcc) what had its own way and subworld into the system. Harvey has APEX as a submodule, you can put or retire it just adding/removing its dir, and uses same compiler and all of rest of the system environment. So now with the same toolchain, you can merge code in your programs between native Harvey's library and APEX subsystem, so you are not obligated to use printf, you can have a source including u.h and libc.h and use fmt functions like print, vfprint, etc... from native system into an ANSI/POSIX program, usually ported from Unix/Linux world.
Harvey inherited a libStdio from Plan 9. It's not clear why it exist, because it's the same implementation as lib/ap/stdio in APEX. So if you merge things from both environments, ensure you're not using libStdio or Stdio.h (note the uppercase).
About porting earthling software to Harvey, check Porting programs from Unix or Linux to Harvey.