2011-01-04 3 views
4

저는 LLVM으로 어떻게 작동하는지 알아 내려고 노력하고 있습니다. 나는 비트 코드와에 llcgcc을 실행하는 컴파일하면이 LLVM ASM을 어떻게 컴파일합니까?

% llvmc hello.ll 
ld: in /tmp/llvm_1291dX/hello.o, ObjectFileAddressSpace::mappedAddress(0x54) not in any section 
collect2: ld returned 1 exit status 

: 나는, 나는 다음과 같은 얻을 llvmc으로 컴파일하려고하면

;hello.ll 
@.LC0 = internal constant [4 x i8] c"%d\0A\00" 

declare i32 @printf(i8*, i32) 

define i32 @main() { 
     %cast210 = getelementptr [4 x i8]* @.LC0, i64 0, i64 0 
     %result = add i32 1, 4 
     call i32 @printf(i8* %cast210, i32 %result) 
     ret i32 0 
} 

: 나는 다음 코드를 컴파일하려고 해요 그것은, 내가 같은 것을 얻을 : 나는 lli 함께 JIT 경우, 그러나

% llc hello.ll 
% gcc -v hello.s 
Using built-in specs. 
Target: i686-apple-darwin10 
Configured with: /var/tmp/gcc/gcc-5664~89/src/configure --disable-checking --enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin10 --program-prefix=i686-apple-darwin10- --host=x86_64-apple-darwin10 --target=i686-apple-darwin10 --with-gxx-include-dir=/include/c++/4.2.1 
Thread model: posix 
gcc version 4.2.1 (Apple Inc. build 5664) 
/usr/libexec/gcc/i686-apple-darwin10/4.2.1/cc1 -E -lang-asm -quiet -v -imultilib x86_64 -D__DYNAMIC__ hello.s -fPIC -mmacosx-version-min=10.6.5 -m64 -mtune=core2 -o /var/folders/8g/8gcssc6aGyiiyOSGXHrLaU+++TI/-Tmp-//cc1qcw7g.s 
ignoring nonexistent directory "/usr/lib/gcc/i686-apple-darwin10/4.2.1/../../../../i686-apple-darwin10/include" 
#include "..." search starts here: 
#include <...> search starts here: 
/usr/local/include 
/usr/lib/gcc/i686-apple-darwin10/4.2.1/include 
/usr/include 
/System/Library/Frameworks (framework directory) 
/Library/Frameworks (framework directory) 
End of search list. 
/usr/libexec/gcc/i686-apple-darwin10/4.2.1/as -arch x86_64 -force_cpusubtype_ALL -o /var/folders/8g/8gcssc6aGyiiyOSGXHrLaU+++TI/-Tmp-//ccPlgnju.o /var/folders/8g/8gcssc6aGyiiyOSGXHrLaU+++TI/-Tmp-//cc1qcw7g.s 
/usr/libexec/gcc/i686-apple-darwin10/4.2.1/collect2 -dynamic -arch x86_64 -macosx_version_min 10.6.5 -weak_reference_mismatches non-weak -o a.out -lcrt1.10.6.o -L/usr/lib/gcc/i686-apple-darwin10/4.2.1/x86_64 -L/usr/lib/gcc/i686-apple-darwin10/4.2.1/x86_64 -L/usr/lib/i686-apple-darwin10/4.2.1 -L/usr/lib/gcc/i686-apple-darwin10/4.2.1 -L/usr/lib/gcc/i686-apple-darwin10/4.2.1 -L/usr/lib/gcc/i686-apple-darwin10/4.2.1/../../../i686-apple-darwin10/4.2.1 -L/usr/lib/gcc/i686-apple-darwin10/4.2.1/../../.. /var/folders/8g/8gcssc6aGyiiyOSGXHrLaU+++TI/-Tmp-//ccPlgnju.o -lSystem -lgcc -lSystem 
ld: in /var/folders/8g/8gcssc6aGyiiyOSGXHrLaU+++TI/-Tmp-//ccPlgnju.o, ObjectFileAddressSpace::mappedAddress(0x54) not in any section 
collect2: ld returned 1 exit status 

을, 그것을 작동 :

012 내가 잘못 뭐하는 거지 3,516,
% lli hello.bc 
5 

?

+0

분명히 gcc 빌드가 손상되었습니다. 'gcc -v'를 실행하여 현재 진행중인 작업을 확인하십시오. –

+0

@ SK-logic - 질문을'gcc -v'의 출력으로 업데이트했습니다. –

답변

2

내가 32 비트 LLVM 및 64 비트 GCC를 실행 해요 것으로 나타났다. gcc과 같이 실행하면 다음과 같이 작동합니다.

gcc -m32 hello.s -o hello 
관련 문제