rui314 / 8cc

A Small C Compiler
MIT License
6.13k stars 740 forks source link

missing setjmp.h or other libc headers #21

Closed mountain closed 9 years ago

mountain commented 9 years ago

Thanks for your contribution first. Recently I wanted to use 8cc to compile tinypy, a very tiny python interpreter, but failed due to the missing file of setjmp.h. I checked with the include directory of 8cc, and did not found setjmp.h.

I know a good compiler is not an easy work. But do you have any plan to fully support the standard c headers?

Or could I use another solution to build a libc implementation by 8cc? If it is yes, which one is a better choice?

rui314 commented 9 years ago

Yes, I have a plan to support setjmp/longjmp. It will take some time because even though these functions look like function, they are actually more like intrinsic to alter the control flow. But it shouldn't be that hard to support them.

andrewchambers commented 9 years ago

Inline assembly is sometimes helpful for implementing these sorts of functions. I'm not sure how difficult gcc style inline assembly is to handle correctly, but it would be nice to look at it. tcc does handle it, and 8cc needs to do less work than tcc because tcc needed to write an integrated assembler.

On Thu, Nov 27, 2014 at 6:06 AM, Rui Ueyama notifications@github.com wrote:

Yes, I have a plan to support setjmp/longjmp. It will take some time because even though these functions look like function, but they are actually more like intrinsic to alter the control flow. But it shouldn't be that hard to support them.

— Reply to this email directly or view it on GitHub https://github.com/rui314/8cc/issues/21#issuecomment-64677971.

mountain commented 9 years ago

Thanks for your answers. I will take another try in next months.

The reason I try to compile tiny-py is that I want to build a minimal-style toolchain from scratch, the gcc toolchain is too complicated for any newcomers. Some modern tools like ninja build is my favorite.

andrewchambers commented 9 years ago

I agree with you, getting a complete toolchain for pure C is hard. I wish for 8cc to work with a tiny assembler in the future too so gcc + binutils is not necessary for hobby operating systems.

On Thu, Nov 27, 2014 at 4:11 PM, Mingli Yuan notifications@github.com wrote:

Closed #21 https://github.com/rui314/8cc/issues/21.

— Reply to this email directly or view it on GitHub https://github.com/rui314/8cc/issues/21#event-199330421.

andrewchambers commented 9 years ago

@mountain You could also consider using lcc, pcc, or tcc - all of which are more complete. tcc does not even require an assembler.

mountain commented 9 years ago

Thanks for you information, Andrew. I will take tcc a try.

andrewchambers commented 9 years ago

http://bellard.org/tcc/

Here is the link to the website, the version on github don't seem to be official.

On Thu, Nov 27, 2014 at 8:01 PM, Mingli Yuan notifications@github.com wrote:

Thanks for you information, Andrew. I will take tcc a try.

— Reply to this email directly or view it on GitHub https://github.com/rui314/8cc/issues/21#issuecomment-64752936.