c2lang / c2c_native

C2 Compiler - written in C2
Apache License 2.0
24 stars 5 forks source link

No executables being generated #2

Closed tom-from-goss closed 1 year ago

tom-from-goss commented 1 year ago

UPDATE: Looking at the options for c2c I can workaround this issue by passing in the -c option and then building with then using the object file generated.

Dear Developers,

I'll start by saying I'm incredibly excited by c2.

Apologies if I'm doing something stupid but c2c doesn't appear to be generating executables apart from c2c itself.

Tried this on Ubuntu Server 22 LTS on an AWS EC2 instance and on WSL with ubuntu 22 and having the same issue.

In my home directory I have:

~/c2c_native ~/c2_libs

In the c2c_native directory I run

. ./env.sh 
make -C bootstrap

Output is

make: Entering directory '/home/<username>/c2c_native/bootstrap'
---- running (boostrapped) c2c ----
building c2c
parsing c2c
parsing took 8575 usec
analysis took 4762 usec
deps generation took 3997 usec
refs generation took 20671 usec
C generation took 3585 usec
C compilation took 3901451 usec
make: Leaving directory '/home/<username>/c2c_native/bootstrap'

As you can see the C generation and C compilation worked.

I have /home/<username/c2c_native/output/c2c added to my path.

When I run c2c in c2c_native (expecting it to build ctags and tester) I get the following output:

$ c2c
building c2c
parsing c2c
parsing took 7479 usec
analysis took 3696 usec
deps generation took 3844 usec
refs generation took 21229 usec
building c2tags
parsing c2tags
parsing took 286 usec
analysis took 473 usec
deps generation took 122 usec
refs generation took 611 usec
building tester
parsing tester
parsing took 544 usec
analysis took 615 usec
deps generation took 226 usec
refs generation took 995 usec

I can use c2c --created hello to create a project but again running c2c creates no output.

I've tried setting $CC to clang and gcc with no difference.

I'm very keen on trying this project so looking forward to discovering my mistake/getting the fix.

Tom

bvdberg commented 1 year ago

Hello Tom,

nice to hear you're also enthousiastic about C2!

C2 by default places all output in a directory called 'output/' tree output should show everything it has generated.

I think with the last command you typed: c2c --create hello (no --created). This will create a main.c2 and a recipe.txt in your current directory. Running c2c will then create an output/ directory output/ c2c tree output

└── hello ├── deps.xml └── refs

you can then run ./output/hello (although it wont do much). Then you can extend it to create everything you want :)

tom-from-goss commented 1 year ago

Hello Bas,

Thanks for your quick reply. I feel like an idiot here but for me hello is just a directory?

$ tree output
output
└── hello
    ├── deps.xml
    └── refs

1 directory, 2 files

Cheers,

Tom

bvdberg commented 1 year ago

Ahhh the c2c_native does not generate + compile C code by default yet. Use the -c flag to enable that. That should generate your hello binary. Good that you kept asking!

tom-from-goss commented 1 year ago

Excellent thanks, I actually figured that out just now!

Apologies to go off topic but as a final note, the reason why I'm excited about this project is that it's the only language I've come across that 'gets' what I think modern C programmers want out of a language. Zig, Odin, Hare, Vlang and even c3 claim to be C replacements but behave in totally un-C like ways that make them unpleasant to work in (hidden allocations, complex language models, over the top error handling to name a few sins).

I tweeted a very well known game developer called Casey Muratori about c2 and he said it looked very good. If you've come across Casey you'll know he can be scathing in his critiques of other languages, so that's high praise.

I believe c2 would be a great language for video games and so I would highly recommend thinking about doing more promotion of your incredible achievement and making things easier for Windows developers. Don't know if you've tried but I couldn't get it to build on cygwin despite an hour or so of trying to solve the link errors.

All the best and please keep up the good work.

Tom

bvdberg commented 1 year ago

Thanks for the big thumbs up! This indeed helps me pour more time into it and make it even better. I'm currently working on an SDL2 wrapper. This is already working (but not complete). C2 makes full program optimizations a lot easier.

One of the things I'm most proud of is the tool integration. It generates the best refs (that are used by the Vim plugin) and also the Deps generation that's used by my DSM (Dependency Structured Matrix) tool. This allows developers to see the structure of the whole program. I haven't seen this in other languages yes.

bvdberg commented 1 year ago

I've changed some cmdline arguments and recipe parsing. Now if the recipe states it should generate-C it will. The cmdline options are now more similar to the C++ c2c. For some cases, the C++ based compiler is still more advanced just so you know.