Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building tcc with pnut #63

Open
cosinusoidally opened this issue Aug 13, 2024 · 3 comments
Open

Building tcc with pnut #63

cosinusoidally opened this issue Aug 13, 2024 · 3 comments

Comments

@cosinusoidally
Copy link

In the readme file it indicates that pnut.exe is capable of building tcc. I can't seem to figure out how to actually do that though. Can you please advise whether this is possible? Simply passing --cc=pnut.exe to the tcc configure script won't work:

configure: error: 'pnut.exe' failed to compile conftest.c

If I try this (which works with gcc after the configure script has been run):

pnut.exe tcc.c

I get the following error:

codegen_glo_decl: unexpected declaration

I'm using a stock tcc 0.9.27 release from 2017 (rather than a random version of their mob branch). Same issue when i use the i386 backend.

@laurenthuberdeau
Copy link
Collaborator

laurenthuberdeau commented Aug 16, 2024

We're still working on TCC support. I'll update the README because pnut-exe is not yet able to compile TCC. I've updated the README.

@cosinusoidally
Copy link
Author

cosinusoidally commented Aug 24, 2024

Thanks, it's good to know that tcc is one of your aims. It will be good to have another C compiler that is capable of bootstrapping tcc.

Are you aware of the live-bootstrap project (https://github.com/fosslinux/live-bootstrap/)? They bootstrap from a couple of hundred bytes of commented machine code all the way up to modern versions of GCC. tcc is part of their bootstrap chain. They use a "bootstrapable" version of tcc 0.9.26 (https://gitlab.com/janneke/tinycc (mes-0.27 branch I think) which is actually closer to 0.9.27 than 26). This version of tcc can be built by mescc (which is a C compiler written in scheme). I mention this because their bootstrapable version can be built by simplified C compilers and is used as a stepping stone to a stock 2017 era tcc-0.9.27 release (and then on to modern versions of gcc).

Live Bootstrap actually goes through several C compilers on its way to tcc:

cc_x86 (a C compiler written in a simple macro assembly language. There are also other arch versions)
M2-Planet (a C compiler written in the cc_x86 dialect)
mescc (a C compiler written in scheme that is run in a scheme interpreter (mes.c) written in the M2-Planet dialect of C)

I have also been working on a means of bootstrapping tcc but replacing mescc with a chain of previous versions of tcc (plus some cut down versions of tcc). My project is very i386 specific, but it can bootstrap from nothing up to tcc 0.9.27 much more quickly than a stock live-bootstrap can. https://github.com/cosinusoidally/tcc_bootstrap_alt . The thing that got me interested in pnut is potentially allowing me to eliminate some intermediate versions of tcc from my project.

@feeley
Copy link
Member

feeley commented Aug 24, 2024

@cosinusoidally We should definitely talk some more about how we can combine our efforts. We see pnut as a more practical seed than used by live bootstrap (depends only on the shell, more maintainable source, and fewer steps to get TCC built). We could add more C language features to pnut as needed and you could simplify TCC to avoid "advanced" features.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants