I am new to LLVM. I built LLVM and Clang on windows by GnuStep yesterday.
LLVM+CLang:3.2
GCC:4.6.1(GnuStep)
OS:Win7 64
I can compile Objective-c source file to both bitcode and exe. The exe works, but when I tried to execute the bitcode, I got this error:
LLVM ERROR: Could not resolve external global address:
_OBJC_CLASS_NSConstantString
Questions:
How can I load dll or lib files in llvm?
How can I link lib files(ex: libobjc.dll.a) to bitcode? Is that possible?
hello.m
#import <Foundation/Foundation.h>
int main(int argc, char**argv)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSLog(@"Hello Objective-C\n");
[pool release];
return 0;
}
Makefile
CC=gcc
CCFLAGS=-fconstant-string-class=NSConstantString -ID:/GNUstep/GNUstep/System/Library/Headers
LDFLAGS=-LD:/GNUstep/GNUstep/System/Library/Libraries/ -lobjc -lgnustep-base
CLANG=clang
CLANG_FLAG=-c -fobjc-runtime=gcc -emit-llvm
LLC=llc
LLI=lli
LLI_FLAG=-load=D:\GNUstep\GNUstep\System\Tools\objc-4.dll -load=D:\GNUstep\GNUstep\System\Tools\gnustep-base-1_24.dll
#LLI_FLAG=-load=D:\GNUstep\GNUstep\System\Library\Libraries\libgnustep-base.dll.a -load=D:\GNUstep\GNUstep\System\Library\Libraries\libobjc.dll.a
all:hello.obj hello1.exe
hello.exe: hello.o
$(CC) -o hello.exe hello.o $(LDFLAGS)
hello.obj: hello.bc
$(LLC) -filetype=obj hello.bc
hello.bc:hello.m
$(CLANG) -o hello.bc hello.m $(CLANG_FLAG) $(CCFLAGS)
hello1.exe: hello.m
$(CLANG) hello.m -o hello1.exe $(CCFLAGS) $(LDFLAGS)
run:
#Err
$(LLI) $(LLI_FLAG) -force-interpreter=false hello.bc
#OK
hello.exe
#OK
hello1.exe
clean:
rm *.o
rm *.exe
rm *.bc