tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Tinycc-devel] Porting TinyCC to Jehanne


From: Giacomo Tesio
Subject: [Tinycc-devel] Porting TinyCC to Jehanne
Date: Sat, 10 Apr 2021 20:28:55 +0000

Hello hackers, my name is Giacomo

I created Jehanne http://jehanne.io a fork of Plan 9 operating system
that aims to stay simple (even simpler than the original).

In the last few years, I wasted a huge amount of my free time to port
GCC to Jehanne, but I've recently realized that it has been an error.
Recent issues emerged in GCC [1] made me decide for a simpler toolchain,
that a single person can understand and hack in a reasonable amount of
time.


So I'd like to adopt TinyCC to cross compile Jehanne from Linux and to
port it to Jehanne so that it becomes self-hosted.

As a Plan 9 fork, Jehanne has unusual conventions
- bind mounts turn the filesystem to a playfield where each process group can 
see a completely different organization
- no dynamic linking, static linking only
- 4k memory pages
- no mmap, ioctl, fctl or similar "modernities"
- no numeric signals, but non-reentrant notes (strings)
- no /usr/local
- /usr is what /home is in Linux's FHS
- /cfg is that /etc is in Linux's FHS
- /lib looks more or less like /share in Linux's FSF
- have a custom libc
- include files are in different places, according to their origin
  (either portable system includes, architecture specific or from
  external packages) and so on...

But even as a Plan 9 form, Jehanne is pretty heretic:
- commands are in /cmd instead of /bin
- it's designed to be little-endian and LP64 only
- it's based on elf64 and adopt the usual System V ABI calling
  conventions (for 64bit system)
- provides a posix environment based on newlib and an emulation
  library (enough to port mksh, binutils and gcc 9.2)

Currently it only runs on x86_64, but I'd like to port it to ARM64
too one day (but it's in no way a priority now)


So I'd like to know where should I start hacking TinyCC to first let it
target Jehanne so that I can cross compile the system (after fixing
compatibility issues) and then actually port it to Jehanne.

So far I've been able to cross compile a few simple user-space programs, but I 
still need 
to attack the kernel.


But given the peculiarity of Jehanne I have two ways to port TinyCC:
native port (which means using the Plan9-derived non-standard C lib) or
POSIX-based port (what I did with GCC).

Given the size of TinyCC, I'd prefer a native port (better performance, simpler 
debugging...), but this would mean different includes, different paths and
even additional functions to minimize the code changes to contribute upstream.


How would you suggest to proceed?
I've noticed that win32 has it's own directory with build scripts and so on...
I could follow a similar route, but I'd also have to change a few strings 
constants in 
the source code: should I introduce an fs_conventions.h that contains defines 
such 
as "/usr/local" "libc.a" and the like?

What about static linking: do you know any problem I should expect in this 
regard?

I don't intend to annoy you too much, but if you have some tips, documents or 
even 
commits to read that could put me on the right track, I would really appreciate 
your help.
I tried following the FreeBSD's port's breadcrumps but I'm having a hard time 
to 
understand figure out how I should proceed.
For example I've seen a FreeBSD_kernel define used somewhere and I wasn't able 
to 
get the whole picture of its usage.


So... sorry for this long mail and thanks a lot for any suggestion you will 
share!


Giacomo

[1] https://gcc.gnu.org/pipermail/gcc/2021-April/235285.html



reply via email to

[Prev in Thread] Current Thread [Next in Thread]