jacobly0 / llvm-project

This fork of the canonical git mirror of the LLVM subversion repository adds (e)Z80 targets. Please refer to the wiki for important build instructions.
https://github.com/jacobly0/llvm-project/wiki
123 stars 15 forks source link

Cannot compile simple example #13

Closed siraben closed 4 years ago

siraben commented 4 years ago

Using the latest macOS release binary linked in the wiki: https://jacobly.com/llvm/ez80-clang-macOSRelease.zip

hello.c

short square(short x) {
  return x * x;
}

int main() {
  short x = square(2);
  return x;
}
$ ez80-clang -O3 -o hello hello.c
/var/folders/s1/sm71lqk553d1_f8drd3tz_5r0000gn/T/hello-802185.s:1:no such instruction: `section .text,"ax",@progbits'
/var/folders/s1/sm71lqk553d1_f8drd3tz_5r0000gn/T/hello-802185.s:2:no such instruction: `assume adl =1'
/var/folders/s1/sm71lqk553d1_f8drd3tz_5r0000gn/T/hello-802185.s:3:no such instruction: `section .text,"ax",@progbits'
/var/folders/s1/sm71lqk553d1_f8drd3tz_5r0000gn/T/hello-802185.s:4:no such instruction: `public _square'
/var/folders/s1/sm71lqk553d1_f8drd3tz_5r0000gn/T/hello-802185.s:5:no such instruction: `private _square'
/var/folders/s1/sm71lqk553d1_f8drd3tz_5r0000gn/T/hello-802185.s:7:no such instruction: `ld iy, 0'
/var/folders/s1/sm71lqk553d1_f8drd3tz_5r0000gn/T/hello-802185.s:8:too many memory references for `add'
/var/folders/s1/sm71lqk553d1_f8drd3tz_5r0000gn/T/hello-802185.s:9:no such instruction: `ld bc, (iy+3)'
/var/folders/s1/sm71lqk553d1_f8drd3tz_5r0000gn/T/hello-802185.s:10:32-bit absolute addressing is not supported for x86-64
/var/folders/s1/sm71lqk553d1_f8drd3tz_5r0000gn/T/hello-802185.s:10:cannot do signed 4 byte relocation
/var/folders/s1/sm71lqk553d1_f8drd3tz_5r0000gn/T/hello-802185.s:11:32-bit absolute addressing is not supported for x86-64
/var/folders/s1/sm71lqk553d1_f8drd3tz_5r0000gn/T/hello-802185.s:11:cannot do signed 4 byte relocation
/var/folders/s1/sm71lqk553d1_f8drd3tz_5r0000gn/T/hello-802185.s:14:no such instruction: `section .text,"ax",@progbits'
/var/folders/s1/sm71lqk553d1_f8drd3tz_5r0000gn/T/hello-802185.s:16:no such instruction: `section .text,"ax",@progbits'
/var/folders/s1/sm71lqk553d1_f8drd3tz_5r0000gn/T/hello-802185.s:17:no such instruction: `public _main'
/var/folders/s1/sm71lqk553d1_f8drd3tz_5r0000gn/T/hello-802185.s:18:no such instruction: `private _main'
/var/folders/s1/sm71lqk553d1_f8drd3tz_5r0000gn/T/hello-802185.s:20:no such instruction: `ld hl, 4'
/var/folders/s1/sm71lqk553d1_f8drd3tz_5r0000gn/T/hello-802185.s:22:no such instruction: `section .text,"ax",@progbits'
/var/folders/s1/sm71lqk553d1_f8drd3tz_5r0000gn/T/hello-802185.s:24:no such instruction: `ident "clang version 12.0.0 (https://github.com/jacobly0/llvm-project 185536120e21b4d1407bfb888e2216423ef0e736)"'
/var/folders/s1/sm71lqk553d1_f8drd3tz_5r0000gn/T/hello-802185.s:25:no such instruction: `extern __Unwind_SjLj_Register'
/var/folders/s1/sm71lqk553d1_f8drd3tz_5r0000gn/T/hello-802185.s:26:no such instruction: `extern __Unwind_SjLj_Unregister'
/var/folders/s1/sm71lqk553d1_f8drd3tz_5r0000gn/T/hello-802185.s:27:no such instruction: `extern __imulu'
ez80-clang: error: assembler command failed with exit code 1 (use -v to see invocation)

It does generate assembly though, with the -S CLI option.

jacobly0 commented 4 years ago

Yes, I only use it for generating assembly, and link that with external tools, so none of the object emitting and assembler code is implemented yet. Also, that is calling your system assembler, so no surprise that it's so confused.

siraben commented 4 years ago

Which external tools do you use? And how do you properly resolve the call to __smulu?

jacobly0 commented 4 years ago

I use this for linking, but there's no documentation about the linker commands and such since it's only used by exactly one project. The name __smulu comes from the eZ80 ZDS toolchain, which was where the original c compiler/linker came from, but was abandoned due to the inability to fix bugs in closed source software, but which does include the C and assembly source for its runtime routines. Eventually, I intend to replace them all with manual implementations written by me or other assembly experts in the community.

siraben commented 4 years ago

Thanks, from the examples I've tried so far the quality of the Z80 output has been pretty high!