rui314 / 8cc

A Small C Compiler

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error in Make Test!

QuestionPython opened this issue · comments

guest@Base:~/Gits/c-andrewchambers$ make test

make clean
make[1]: Entering directory '/home/guest/Gits/c-andrewchambers'
rm -rf src/panic.o src/cc/cpp.o src/cc/lex.o src/cc/parse.o src/cc/types.o src/cc/foldexpr.o src/cc/error.o src/mem/mem.o src/ds/list.o src/ds/map.o src/ds/vec.o src/ds/strset.o src/cmd/cpp/main.o  src/cmd/6c/emit.o src/cmd/6c/frontend.o src/cmd/6c/main.o  src/cmd/abifuzz/main.o lib bin
make[1]: Leaving directory '/home/guest/Gits/c-andrewchambers'
make all
make[1]: Entering directory '/home/guest/Gits/c-andrewchambers'
cc -std=c89 -g -Wfatal-errors -Wno-unused-parameter -Wall -Wextra -D_DEFAULT_SOURCE -Isrc/ -o src/cmd/6c/emit.o -c src/cmd/6c/emit.c
cc -std=c89 -g -Wfatal-errors -Wno-unused-parameter -Wall -Wextra -D_DEFAULT_SOURCE -Isrc/ -o src/cmd/6c/frontend.o -c src/cmd/6c/frontend.c
cc -std=c89 -g -Wfatal-errors -Wno-unused-parameter -Wall -Wextra -D_DEFAULT_SOURCE -Isrc/ -o src/cmd/6c/main.o -c src/cmd/6c/main.c
cc -std=c89 -g -Wfatal-errors -Wno-unused-parameter -Wall -Wextra -D_DEFAULT_SOURCE -Isrc/ -o src/panic.o -c src/panic.c
cc -std=c89 -g -Wfatal-errors -Wno-unused-parameter -Wall -Wextra -D_DEFAULT_SOURCE -Isrc/ -o src/cc/cpp.o -c src/cc/cpp.c
cc -std=c89 -g -Wfatal-errors -Wno-unused-parameter -Wall -Wextra -D_DEFAULT_SOURCE -Isrc/ -o src/cc/lex.o -c src/cc/lex.c
cc -std=c89 -g -Wfatal-errors -Wno-unused-parameter -Wall -Wextra -D_DEFAULT_SOURCE -Isrc/ -o src/cc/parse.o -c src/cc/parse.c
cc -std=c89 -g -Wfatal-errors -Wno-unused-parameter -Wall -Wextra -D_DEFAULT_SOURCE -Isrc/ -o src/cc/types.o -c src/cc/types.c
cc -std=c89 -g -Wfatal-errors -Wno-unused-parameter -Wall -Wextra -D_DEFAULT_SOURCE -Isrc/ -o src/cc/foldexpr.o -c src/cc/foldexpr.c
cc -std=c89 -g -Wfatal-errors -Wno-unused-parameter -Wall -Wextra -D_DEFAULT_SOURCE -Isrc/ -o src/cc/error.o -c src/cc/error.c
cc -std=c89 -g -Wfatal-errors -Wno-unused-parameter -Wall -Wextra -D_DEFAULT_SOURCE -Isrc/ -o src/mem/mem.o -c src/mem/mem.c
cc -std=c89 -g -Wfatal-errors -Wno-unused-parameter -Wall -Wextra -D_DEFAULT_SOURCE -Isrc/ -o src/ds/list.o -c src/ds/list.c
cc -std=c89 -g -Wfatal-errors -Wno-unused-parameter -Wall -Wextra -D_DEFAULT_SOURCE -Isrc/ -o src/ds/map.o -c src/ds/map.c
cc -std=c89 -g -Wfatal-errors -Wno-unused-parameter -Wall -Wextra -D_DEFAULT_SOURCE -Isrc/ -o src/ds/vec.o -c src/ds/vec.c
cc -std=c89 -g -Wfatal-errors -Wno-unused-parameter -Wall -Wextra -D_DEFAULT_SOURCE -Isrc/ -o src/ds/strset.o -c src/ds/strset.c
ar rcs lib/libcompiler.a src/panic.o src/cc/cpp.o src/cc/lex.o src/cc/parse.o src/cc/types.o src/cc/foldexpr.o src/cc/error.o src/mem/mem.o src/ds/list.o src/ds/map.o src/ds/vec.o src/ds/strset.o
cc  src/cmd/6c/emit.o src/cmd/6c/frontend.o src/cmd/6c/main.o  lib/libcompiler.a -o bin/6c
cc -std=c89 -g -Wfatal-errors -Wno-unused-parameter -Wall -Wextra -D_DEFAULT_SOURCE -Isrc/ -o src/cmd/cpp/main.o -c src/cmd/cpp/main.c
cc  src/cmd/cpp/main.o  lib/libcompiler.a -o bin/cpp
cc -std=c89 -g -Wfatal-errors -Wno-unused-parameter -Wall -Wextra -D_DEFAULT_SOURCE -Isrc/ -o src/cmd/abifuzz/main.o -c src/cmd/abifuzz/main.c
cc  src/cmd/abifuzz/main.o lib/libcompiler.a -o bin/abifuzz
make[1]: Leaving directory '/home/guest/Gits/c-andrewchambers'
./test.sh
test/execute/0001-sanity.c PASS
test/execute/0002-global1.c PASS
test/execute/0003-locals1.c PASS
test/execute/0004-operators1.c PASS
test/execute/0004-operators2.c PASS
test/execute/0004-operators3.c PASS
test/execute/0004-operators4.c PASS
test/execute/0004-operators5.c PASS
test/execute/0005-if1.c PASS
test/execute/0006-while1.c PASS
test/execute/0007-dowhile1.c PASS
test/execute/0008-for1.c PASS
test/execute/0009-breakcont1.c PASS
test/execute/0010-goto1.c PASS
test/execute/0011-switch1.c PASS
test/execute/0012-pointers1.c PASS
test/execute/0012-pointers2.c PASS
test/execute/0013-struct1.c PASS
test/execute/0013-struct2.c PASS
test/execute/0013-struct3.c PASS
test/execute/0013-struct4.c PASS
test/execute/0013-struct5.c PASS
test/execute/0013-struct6.c PASS
test/execute/0014-array1.c PASS
test/execute/0015-calls01.c PASS
test/execute/0015-calls02.c PASS
test/execute/0015-calls03.c PASS
test/execute/0015-calls04.c PASS
test/execute/0016-string1.c PASS
test/execute/0017-incdec1.c PASS
test/execute/0018-funcptr1.c PASS
test/execute/0019-condexpr1.c PASS
test/execute/0020-comma1.c PASS
test/execute/0020-comma2.c PASS
test/execute/0021-tentativedefs1.c PASS
test/execute/0022-namespaces1.c PASS
test/execute/0023-incomplete1.c PASS
test/execute/0024-enums1.c PASS
test/execute/0025-duff.c PASS
test/execute/0026-sizeof1.c PASS
test/execute/0027-structcopy.c PASS
test/execute/0028-inits01.c PASS
test/execute/0028-inits02.c PASS
test/execute/0028-inits03.c PASS
test/execute/0028-inits04.c PASS
test/execute/0028-inits05.c PASS
test/execute/0028-inits06.c PASS
test/execute/0028-inits07.c PASS
test/execute/0028-inits08.c PASS
test/execute/0028-inits09.c PASS
test/execute/0028-inits10.c PASS
test/execute/0028-inits11.c PASS
test/execute/0028-inits12.c PASS
test/execute/0028-inits13.c PASS
test/execute/0028-inits14.c PASS
test/execute/0028-inits15.c PASS
test/execute/0029-ptrarith1.c PASS
test/execute/0029-ptrarith2.c PASS
test/cpp/0001-define1.c PASS
test/cpp/0001-define2.c PASS
test/cpp/0001-define3.c PASS
test/bugs/0001.c PASS
test/bugs/0002.c PASS
test/bugs/0004.c PASS
test/bugs/0005.c PASS
test/bugs/0006.c PASS
test/bugs/0008.c PASS
/usr/bin/ld: test/bugs/0012.c.o: relocation R_X86_64_PC32 against symbol `abort@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
test/bugs/0012.c FAIL
Makefile:31: recipe for target 'test' failed
make: *** [test] Error 1
commented

I have the same problem:

make test output ->
./8cc -w -o test/builtin.o -c test/builtin.c
./8cc -w -o test/testmain.o -c test/testmain.c
cc -o test/builtin.bin test/builtin.o test/testmain.o
/usr/bin/ld: test/builtin.o: relocation R_X86_64_32S against `.text' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
Makefile:20: recipe for target 'test/builtin.bin' failed
make: *** [test/builtin.bin] Error 1
rm test/builtin.o test/testmain.o

This is what I get:

Ingwie@Ingwies-Macbook-Pro.local ~/W/g/8cc $ make
cc -Wall -Wno-strict-aliasing -std=gnu11 -g -I. -O0 -DBUILD_DIR='"/Users/Ingwie/Work/git/8cc"'   -c -o main.o main.c
cc -Wall -Wno-strict-aliasing -std=gnu11 -g -I. -O0 -DBUILD_DIR='"/Users/Ingwie/Work/git/8cc"'   -c -o cpp.o cpp.c
cc -Wall -Wno-strict-aliasing -std=gnu11 -g -I. -O0 -DBUILD_DIR='"/Users/Ingwie/Work/git/8cc"'   -c -o debug.o debug.c
cc -Wall -Wno-strict-aliasing -std=gnu11 -g -I. -O0 -DBUILD_DIR='"/Users/Ingwie/Work/git/8cc"'   -c -o dict.o dict.c
cc -Wall -Wno-strict-aliasing -std=gnu11 -g -I. -O0 -DBUILD_DIR='"/Users/Ingwie/Work/git/8cc"'   -c -o gen.o gen.c
cc -Wall -Wno-strict-aliasing -std=gnu11 -g -I. -O0 -DBUILD_DIR='"/Users/Ingwie/Work/git/8cc"'   -c -o lex.o lex.c
cc -Wall -Wno-strict-aliasing -std=gnu11 -g -I. -O0 -DBUILD_DIR='"/Users/Ingwie/Work/git/8cc"'   -c -o vector.o vector.c
cc -Wall -Wno-strict-aliasing -std=gnu11 -g -I. -O0 -DBUILD_DIR='"/Users/Ingwie/Work/git/8cc"'   -c -o parse.o parse.c
cc -Wall -Wno-strict-aliasing -std=gnu11 -g -I. -O0 -DBUILD_DIR='"/Users/Ingwie/Work/git/8cc"'   -c -o buffer.o buffer.c
cc -Wall -Wno-strict-aliasing -std=gnu11 -g -I. -O0 -DBUILD_DIR='"/Users/Ingwie/Work/git/8cc"'   -c -o map.o map.c
cc -Wall -Wno-strict-aliasing -std=gnu11 -g -I. -O0 -DBUILD_DIR='"/Users/Ingwie/Work/git/8cc"'   -c -o error.o error.c
cc -Wall -Wno-strict-aliasing -std=gnu11 -g -I. -O0 -DBUILD_DIR='"/Users/Ingwie/Work/git/8cc"'   -c -o path.o path.c
cc -Wall -Wno-strict-aliasing -std=gnu11 -g -I. -O0 -DBUILD_DIR='"/Users/Ingwie/Work/git/8cc"'   -c -o file.o file.c
cc -Wall -Wno-strict-aliasing -std=gnu11 -g -I. -O0 -DBUILD_DIR='"/Users/Ingwie/Work/git/8cc"'   -c -o set.o set.c
cc -Wall -Wno-strict-aliasing -std=gnu11 -g -I. -O0 -DBUILD_DIR='"/Users/Ingwie/Work/git/8cc"'   -c -o encoding.o encoding.c
cc -o 8cc main.o cpp.o debug.o dict.o gen.o lex.o vector.o parse.o buffer.o map.o error.o path.o file.o set.o encoding.o 
Ingwie@Ingwies-Macbook-Pro.local ~/W/g/8cc $ make test
./8cc -w -o test/align.o -c test/align.c
[ERROR] cpp.c:711: /Users/Ingwie/Work/Git/8cc/test/test.h:3:1: cannot find header file: stdio.h
make: *** [test/align.o] Error 1
Ingwie@Ingwies-Macbook-Pro.local ~/W/g/8cc $ sw_vers
ProductName:	Mac OS X
ProductVersion:	10.14.3
BuildVersion:	18D42

@QuestionPython Your bug is for my C compiler, this is the wrong repository.

@QuestionPython Your bug is for my C compiler, this is the wrong repository.

This is the right repository (8cc) afaik and I get the same linker error when runnning 'make test':

rob@ubuntu-dev:~/Source/github/8cc$ make test
./8cc -w -o test/line.o -c test/line.c
./8cc -w -o test/testmain.o -c test/testmain.c
cc -o test/line.bin test/line.o test/testmain.o 
./8cc -w -o test/decl.o -c test/decl.c
cc -o test/decl.bin test/decl.o test/testmain.o 
./8cc -w -o test/assign.o -c test/assign.c
cc -o test/assign.bin test/assign.o test/testmain.o 
./8cc -w -o test/oldstyle.o -c test/oldstyle.c
cc -o test/oldstyle.bin test/oldstyle.o test/testmain.o 
./8cc -w -o test/struct.o -c test/struct.c
cc -o test/struct.bin test/struct.o test/testmain.o 
./8cc -w -o test/control.o -c test/control.c
cc -o test/control.bin test/control.o test/testmain.o 
/usr/bin/ld: test/control.o: relocation R_X86_64_32S against `.text' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
Makefile:20: recipe for target 'test/control.bin' failed
make: *** [test/control.bin] Error 1
rm test/struct.o test/assign.o test/line.o test/control.o test/oldstyle.o test/decl.o test/testmain.o

I have this error on alpine.

$ make test
./8cc -w -o test/includeguard.o -c test/includeguard.c
[ERROR] parse.c:2196: /usr/include/bits/alltypes.h:6:27: ';' or ',' are expected, but got va_list
Makefile:17: recipe for target 'test/includeguard.o' failed
make: *** [test/includeguard.o] Error 1

This is my Dockerfile.

FROM alpine:3.3

RUN apk update

RUN apk add make

RUN apk add --no-cache gcc libc-dev

COPY ./ /home/working

WORKDIR /home/working/8cc

And this error happened on MacOS.

8cc git:(master) make test
./8cc -w -o test/align.o -c test/align.c
[ERROR] parse.c:2196: /usr/include/sys/cdefs.h:590:41: ';' or ',' are expected, but got __asm
make: *** [test/align.o] Error 1