nlsandler / writing-a-c-compiler-tests

Test cases for Writing a C Compiler
https://nostarch.com/writing-c-compiler
Other
172 stars 25 forks source link

"OK" despite linker errors?` #76

Closed xqb64 closed 2 months ago

xqb64 commented 2 months ago
alex@smartalex-pc:~/Repositories/ucc$ tests/test_compiler target/release/ucc --chapter 9
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x1b): undefined reference to `main'
collect2: error: ld returned 1 exit status

/usr/bin/ld: /tmp/cc3i33zB.o: in function `main':
(.text+0x13): undefined reference to `add'
collect2: error: ld returned 1 exit status

/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x1b): undefined reference to `main'
collect2: error: ld returned 1 exit status

/usr/bin/ld: /tmp/cc90kQ1F.o: in function `main':
(.text+0xe): undefined reference to `fib'
/usr/bin/ld: (.text+0x2a): undefined reference to `fib'
/usr/bin/ld: (.text+0x60): undefined reference to `multiply_many_args'
collect2: error: ld returned 1 exit status

/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x1b): undefined reference to `main'
collect2: error: ld returned 1 exit status

/usr/bin/ld: /tmp/ccr2aRCV.o: in function `main':
(.text+0x1d): undefined reference to `f'
collect2: error: ld returned 1 exit status

/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x1b): undefined reference to `main'
collect2: error: ld returned 1 exit status

/usr/bin/ld: /tmp/ccEwbcdy.o: in function `main':
(.text+0x57): undefined reference to `f'
collect2: error: ld returned 1 exit status

/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x1b): undefined reference to `main'
collect2: error: ld returned 1 exit status

/usr/bin/ld: /tmp/ccuRMnvH.o: in function `main':
(.text+0xe): undefined reference to `incr_and_print'
collect2: error: ld returned 1 exit status

/usr/bin/ld: /tmp/cclbzWSV.o: in function `main':
(.text+0x34): undefined reference to `even_arguments'
/usr/bin/ld: (.text+0x6a): undefined reference to `odd_arguments'
collect2: error: ld returned 1 exit status

----------------------------------------------------------------------
Ran 298 tests in 16.551s

OK
alex@smartalex-pc:~/Repositories/ucc$

I'd appreciate some help. Emitting @PLT doesn't seem to make a difference.

xqb64 commented 2 months ago

So what happened was that, in my compiler driver, I had reversed the order of -c and final executable. Sorry for the false alert.