drh / lcc

The lcc retargetable ANSI C compiler
https://drh.github.io/lcc/
2.03k stars 442 forks source link

Invalid main declaration && Missing input files #53

Open JohnAlexCO opened 3 months ago

JohnAlexCO commented 3 months ago

The declaration of main:74 is missing a type entirely. I set this to int and proceeded.

Trying to run make lcc gives me an error about not having permission to write the .o files, so I sudo to give the process permission and proceeded.

Compilation then failed because /lburg/gram.c uses free but <stdlib.h> hasn't been included and no definition is given for free, so I include it at the top of the file and try to proceed again.

But at this stage, regardless of what C-compiler I try to build with (clang, gcc, tcc, chibicc, ...) I get variations of the same problem -- lots of files don't want to build because of implicit function use (which is possible to get past, but I still end up with missing output files, regardless) or because I'm missing .o objects or whatever

# sudo make lcc CC=gcc
cc -g -c -o /host.o 
cc: fatal error: no input files
compilation terminated.
make: *** [makefile:128: /host.o] Error 1

So okay, let's try just running each of the make commands on their own.

sudo make cpp
sudo make bprint
sudo make liblcc
sudo make lburg
sudo make rcc
make: Nothing to be done for 'cpp'.
make: Nothing to be done for 'bprint'.
make: Nothing to be done for 'liblcc'.
make: Nothing to be done for 'lburg'.
make: Nothing to be done for 'rcc'.

so those ones seem to work, but no matter what order I do the rest in, compilation fails, and the outputs generally look like

sudo make triple
cc -g -c -o /host.o 
cc: fatal error: no input files
compilation terminated.
make: *** [makefile:128: /host.o] Error 1

How am I supposed to build this? because make all doesn't work either

cpp/getopt.c:21:3: warning: add explicit braces to avoid dangling else [-Wdangling-else]
   21 |                 else if (strcmp(argv[optind], "--") == 0) {
      |                 ^
1 warning generated.
clang -g -c -Icpp -o /unix.o cpp/unix.c
clang -g  -o /cpp /cpp.o /lexer.o /nlist.o /tokens.o /macro.o /eval.o /include.o /hideset.o /getopt.o /unix.o 
clang -g -c -o /host.o 
clang: error: no input files
make: *** [makefile:128: /host.o] Error 1
Azzydon commented 3 months ago

I'm away from a system at the moment, however, from what I recall you need to set environment values to tell the build system where the files will be located before invoking make.

Clearly host.o will not be located in the root of the filesystem.

cc -g -c -o /host.o

Take a look at the statements at the top of the makefile.

-Vince

On Mon, Aug 12, 2024 at 11:50 PM John Alex @.***> wrote:

The declaration of main:74 https://github.com/drh/lcc/blob/9bd428949f53b34980d194b1b4a2be921a85b5b4/etc/lcc.c#L74 is missing a type entirely. I set this to int and proceeded.

Trying to run make lcc gives me an error about not having permission to write the .o files, so I sudo to give the process permission and proceeded.

Compilation then failed because /lburg/gram.c uses free but hasn't been included and no definition is given for free, so I include it at the top of the file and try to proceed again.

But at this stage, regardless of what C-compiler I try to build with (clang, gcc, tcc, chibicc, ...) I get variations of the same problem -- lots of files don't want to build because of implicit function use (which is possible to get past by manually setting the standard to std=c89 or overriding with the right -W flag but I still end up with the result being that we're missing output files, see below) or because I'm missing .o objects or whatever

sudo make lcc CC=gcc

cc -g -c -o /host.o cc: fatal error: no input files compilation terminated. make: *** [makefile:128: /host.o] Error 1

sudo make all CC=clang

cpp/getopt.c:21:3: warning: add explicit braces to avoid dangling else [-Wdangling-else] 21 | else if (strcmp(argv[optind], "--") == 0) { | ^ 1 warning generated. clang -g -c -Icpp -o /unix.o cpp/unix.c clang -g -o /cpp /cpp.o /lexer.o /nlist.o /tokens.o /macro.o /eval.o /include.o /hideset.o /getopt.o /unix.o clang -g -c -o /host.o clang: error: no input files make: *** [makefile:128: /host.o] Error 1

So okay, let's try just running each of the make commands on their own.

sudo make cpp sudo make bprint sudo make liblcc sudo make lburg sudo make rcc make: Nothing to be done for 'cpp'. make: Nothing to be done for 'bprint'. make: Nothing to be done for 'liblcc'. make: Nothing to be done for 'lburg'. make: Nothing to be done for 'rcc'.

so those ones seem to work, but no matter what order I do the rest in, compilation fails, and the outputs generally look like

sudo make triple cc -g -c -o /host.o cc: fatal error: no input files compilation terminated. make: *** [makefile:128: /host.o] Error 1

How am I supposed to build this? because make all doesn't work either

cpp/getopt.c:21:3: warning: add explicit braces to avoid dangling else [-Wdangling-else] 21 | else if (strcmp(argv[optind], "--") == 0) { | ^ 1 warning generated. clang -g -c -Icpp -o /unix.o cpp/unix.c clang -g -o /cpp /cpp.o /lexer.o /nlist.o /tokens.o /macro.o /eval.o /include.o /hideset.o /getopt.o /unix.o clang -g -c -o /host.o clang: error: no input files make: *** [makefile:128: /host.o] Error 1

— Reply to this email directly, view it on GitHub https://github.com/drh/lcc/issues/53, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGSORE5IPL4SNI2H7DGHMHLZRF67NAVCNFSM6AAAAABMNLWF5SVHI2DSMVQWIX3LMV43ASLTON2WKOZSGQ3DEMZSGY2TGMQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

zqxyus commented 1 week ago

Even setting environment variables still has error: cc -g -c -o /host.o cc: fatal error: no input files compilation terminated. make: *** [makefile:128: /host.o] Error 1