Search code examples
clangllvminline-assemblycpu-registersllvm-gcc

LLVM bug building synthetic CPU for nostalgic childhood game (register asm global variable)


I've been trying to compile syn64k--for use in Executor, to run System's Twilight (a game I played as a kid). I'm doing this on my macbook pro (lion 10.7.4 with the latest Xcode and command line tools). I mapped CC to gcc -m32 to fix a couple problems I was having, but I got the following:

Making all in native/i386
make[2]: Nothing to be done for `all'.
outgoing=;\
    gcc -m32 -maccumulate-outgoing-args -c -x c /dev/null 2> /dev/null && outgoing=-maccumulate-outgoing-args; \
    gcc -m32 -S -O2 -fomit-frame-pointer  -Wall -static -fno-defer-pop -Wno-unused\ -I./include -I./../include -I. -I../include $outgoing syn68k.c -o ./syn68k.s
syn68k.c: In function ‘s68k_handle_opcode_0x07A3’:
syn68k.c:52968: internal compiler error: in EmitLV_DECL, at llvm-convert.cpp:7475
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://developer.apple.com/bugreporter> for instructions.
make[2]: *** [syn68k.o] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all-recursive] Error 1

I went to URL, and it doesn't look like a place to really put a bug report about LLVM. I the file 'syn68k.c' is about 50k lines long after the preprocessor is done with it, so I really don't thing I can make a reproducible test case to show the bug.

Turns out this issue is already on the github project (it is the only issue listed, ha). MaddTheSane says that this happens because clang does not support global register variables (as I verified here).

I don't really have much more than a basic understanding of how compilation works after you type make, so is there a way I can skip clang or something like that? What do you suggest?


Solution

  • Unfortunately, you need to use gcc, not llvm-gcc to compile this program. The LLVM backend of llvm-gcc does not support global register variables. Switching to clang won't help because it too will choke on the global register variables, for the same reason.