Holger Schurig
2007-Aug-24 20:52 UTC
[LLVMdev] llvmc doesn't work for compilation nor linking
Is llvmc meant for compilation? $ llvmc -c a.c -o a.o /usr/src/llvm/dist/etc/llvm/c:55: Error: Expecting output type value /usr/src/llvm/dist/etc/llvm/c had 1 errors. Terminating. The offending line contains: optimizer.output = bytecode which doesn't seem to be understood by llvmc. If I uncomment this line, I get another error message: $ llvmc -c a.c -o a.o llvmc: Can't find program '%llvmcc1%' However, I can use it for linking: $ llvm-gcc --emit-llvm -c a.c -o a.o $ llvm-gcc -c main.c -o main.o $ llvmc a.o main.o -o main Wow, nice. Unfortunately, the result doesn't run: $ ./main 'main' function not found in module. That seems true, because llvm-dis doesn't find a main either: $ llvm-dis main.bc -o - ; ModuleID = 'main.bc' target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32" target triple = "i686-pc-linux-gnu" @i.b = internal global i1 false ; <i1*> [#uses=2] define void @foo2() { entry: store i1 true, i1* @i.b, align 1 ret void } declare void @foo4() define i32 @foo1() { entry: %tmp1.b = load i1* @i.b, align 1 ; <i1> [#uses=1] br i1 %tmp1.b, label %cond_true, label %return cond_true: ; preds = %entry call void @foo4( ) ret i32 52 return: ; preds = %entry ret i32 42 }
Tanya Lattner
2007-Aug-24 23:34 UTC
[LLVMdev] llvmc doesn't work for compilation nor linking
On Aug 24, 2007, at 1:52 PM, Holger Schurig wrote:> Is llvmc meant for compilation? >I'm not sure what the status of llvmc is (is anyone working on it?), but I don't believe it was ready for real use or was finished. If you would like to work on it, patches are welcomed! Thanks, Tanya> $ llvmc -c a.c -o a.o > /usr/src/llvm/dist/etc/llvm/c:55: Error: Expecting output type value > /usr/src/llvm/dist/etc/llvm/c had 1 errors. Terminating. > > > The offending line contains: > > optimizer.output = bytecode > > which doesn't seem to be understood by llvmc. If I uncomment this > line, I get another error message: > > $ llvmc -c a.c -o a.o > llvmc: Can't find program '%llvmcc1%' > > > > > However, I can use it for linking: > > $ llvm-gcc --emit-llvm -c a.c -o a.o > $ llvm-gcc -c main.c -o main.o > $ llvmc a.o main.o -o main > > Wow, nice. Unfortunately, the result doesn't run: > > $ ./main > 'main' function not found in module. > > > That seems true, because llvm-dis doesn't find a main either: > > $ llvm-dis main.bc -o - > ; ModuleID = 'main.bc' > target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32- > i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64- > f80:32:32" > target triple = "i686-pc-linux-gnu" > @i.b = internal global i1 false ; <i1*> [#uses=2] > > define void @foo2() { > entry: > store i1 true, i1* @i.b, align 1 > ret void > } > > declare void @foo4() > > define i32 @foo1() { > entry: > %tmp1.b = load i1* @i.b, align 1 ; <i1> > [#uses=1] > br i1 %tmp1.b, label %cond_true, label %return > > cond_true: ; preds = %entry > call void @foo4( ) > ret i32 52 > > return: ; preds = %entry > ret i32 42 > } > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Holger Schurig
2007-Aug-28 15:36 UTC
[LLVMdev] llvmc doesn't work for compilation nor linking
> If you would like to work on it, patches are welcomed!I think this problem space matched my capabilities, below is a patch. With this patch applied, the following worked: $ llvmc -verbose -native -lstdc++ -o hellocpp hello.cpp g++ -E hello.cpp -o /tmp/llvm_30nlL0/hello.E /usr/src/llvm/dist/libexec/gcc/i686-pc-linux-gnu/4.0.1/cc1plus -quiet -emit-llvm /tmp/llvm_30nlL0/hello.E -o /tmp/llvm_30nlL0/hello.trans -O1 llvm-as /tmp/llvm_30nlL0/hello.trans -o /tmp/llvm_30nlL0/hello.trans.bc /usr/src/llvm/dist/bin/opt /tmp/llvm_30nlL0/hello.trans.bc -std-compile-opts -f -o /tmp/llvm_30nlL0/hello.opt llvm-ld -O1 /tmp/llvm_30nlL0/hello.opt -lstdc++ -L%llvmgccdir%/lib -L%llvmgccdir%/lib -L/usr/local/lib/ -L/usr/X11R6/lib/ -L/usr/lib/ -L/lib/ -native -v -o hellocpp Linking bitcode file '/tmp/llvm_30nlL0/hello.opt' Linked in file '/tmp/llvm_30nlL0/hello.opt' Linking archive file '/usr/src/llvm/dist/lib/libstdc++.a' Generating Bitcode To hellocpp.bc Generating Assembly With: '/usr/src/llvm/dist/bin/llc' '-f' '-o' 'hellocpp.s' 'hellocpp.bc' Generating Native Executable With: '/usr/bin/gcc' '-fno-strict-aliasing' '-O3' '-o' 'hellocpp' 'hellocpp.s' '-L' '%llvmgccdir%/lib' '-L' '%llvmgccdir%/lib' '-L' '/usr/local/lib/' '-L' '/usr/X11R6/lib/' '-L' '/usr/lib/' '-L' '/lib/' '-lstdc++' $ llvmc -verbose -native -o helloc hello.c gcc -E hello.c -o /tmp/llvm_XpaR7m/hello.E /usr/src/llvm/dist/libexec/gcc/i686-pc-linux-gnu/4.0.1/cc1 -quiet -emit-llvm /tmp/llvm_XpaR7m/hello.E -o /tmp/llvm_XpaR7m/hello.trans -O1 llvm-as /tmp/llvm_XpaR7m/hello.trans -o /tmp/llvm_XpaR7m/hello.trans.bc /usr/src/llvm/dist/bin/opt /tmp/llvm_XpaR7m/hello.trans.bc -std-compile-opts -f -o /tmp/llvm_XpaR7m/hello.opt llvm-ld -O1 /tmp/llvm_XpaR7m/hello.opt -L%llvmgccdir%/lib -L%llvmgccdir%/lib -L/usr/local/lib/ -L/usr/X11R6/lib/ -L/usr/lib/ -L/lib/ -native -v -o helloc Linking bitcode file '/tmp/llvm_XpaR7m/hello.opt' Linked in file '/tmp/llvm_XpaR7m/hello.opt' Generating Bitcode To helloc.bc Generating Assembly With: '/usr/src/llvm/dist/bin/llc' '-f' '-o' 'helloc.s' 'helloc.bc' Generating Native Executable With: '/usr/bin/gcc' '-fno-strict-aliasing' '-O3' '-o' 'helloc' 'helloc.s' '-L' '%llvmgccdir%/lib' '-L' '%llvmgccdir%/lib' '-L' '/usr/local/lib/' '-L' '/usr/X11R6/lib/' '-L' '/usr/lib/' '-L' '/lib/' $ size helloc hellocpp text data bss dec hex filename 911 260 4 1175 497 helloc 1427 288 148 1863 747 hellocpp I'll look after the strange '-L' '%llvmgccdir%/lib' in a separate patch, but I guess that this has something to do with the configure call I made for LLVM. Now the patch: ------------------------------------------------------------------ Add "-emit-llvm" to the cc1 call so that cc1 to trigger usage of the llvm-framework Use "opt" instead of the deprecated "ggcas". For now, use "-std-compile-opts" just like the "gccas" shell script. Fix optimizer output, it was "bytecode" which was wrong: * the lexer knows "bitcode", but not "bytecode" * the optimizer produces human-readable code, so it must be assembly anyway Index: tools/llvmc/cpp ==================================================================--- tools/llvmc/cpp (revision 41536) +++ tools/llvmc/cpp (working copy) @@ -25,7 +25,7 @@ ########################################################## # To compile C++ source, just use llvm-g++'s cc1 - translator.command=%llvmcc1plus% -quiet %in% -o %out% \ + translator.command=%llvmcc1plus% -quiet -emit-llvm %in% -o %out% \ %opt% %incls% %defs% %WOpts% %fOpts% %MOpts% %args% \ -D_GNU_SOURCE @@ -42,18 +42,18 @@ # Optimizer definitions ########################################################## - # Use gccas to clean up the generated code - optimizer.command=%bindir%/gccas %in% -o %out% %args% + # Use opt to clean up the generated code + optimizer.command=%bindir%/opt %in% -std-compile-opts -f -o %out% %args% optimizer.required = true - # gccas doesn't translate + # opt doesn't translate optimizer.translates = false - # gccas doesn't preprocess + # opt doesn't preprocess optimizer.preprocesses=false - # gccas produces bytecode - optimizer.output = bytecode + # opt produces assembly + optimizer.output = assembly ########################################################## # Assembler definitions Index: tools/llvmc/c ==================================================================--- tools/llvmc/c (revision 41536) +++ tools/llvmc/c (working copy) @@ -24,7 +24,7 @@ ########################################################## # To compile C source, just use llvm-gcc's cc1 - translator.command=%llvmcc1% -quiet %in% -o %out% \ + translator.command=%llvmcc1% -quiet -emit-llvm %in% -o %out% \ %opt% %incls% %defs% %WOpts% %fOpts% %MOpts% %args% \ -D_GNU_SOURCE @@ -41,18 +41,18 @@ # Optimizer definitions ########################################################## - # Use gccas to clean up the generated code - optimizer.command=%bindir%/gccas %in% -o %out% %args% + # Use opt to clean up the generated code + optimizer.command=%bindir%/opt %in% -std-compile-opts -f -o %out% %args% optimizer.required = true - # gccas doesn't translate - optimizer.translates = false + # opt doesn't translate + optimizer.translates = true - # gccas doesn't preprocess + # opt doesn't preprocess optimizer.preprocesses=false - # gccas produces bytecode - optimizer.output = bytecode + # opt produces llvm assembly + optimizer.output = assembly ########################################################## # Assembler definitions Index: tools/llvmc/st ==================================================================--- tools/llvmc/st (revision 41536) +++ tools/llvmc/st (working copy) @@ -36,7 +36,7 @@ translator.required=false # stkrc doesn't handle the -On options - translator.output=bytecode + translator.output=bitcode ########################################################## # Optimizer definitions @@ -54,8 +54,8 @@ # opt doesn't preprocess optimizer.preprocesses=yes - # opt produces bytecode - optimizer.output = bc + # opt produces assembly + optimizer.output = assembly ########################################################## # Assembler definitions
Reasonably Related Threads
- [LLVMdev] llvmc doesn't work for compilation nor linking
- [LLVMdev] Problem with stock llvmc configuration for C
- [LLVMdev] Problem with stock llvmc configuration for C
- [LLVMdev] Problem with stock llvmc configuration for C
- [LLVMdev] Problems Cross Compiling for x86 and ia64