Closed llvmbot closed 14 years ago
This is fixed in recent drops of llvm-gcc4.
-Chris
From your transcript, it looks like everything is working perfectly. To build .bc files with llvm-gcc4 use either:
llvm-gcc file.c -c -emit-llvm -o file.bc -O3
or: llvm-gcc file.c -S -emit-llvm -o file.ll -O3 llvm-as file.ll -o file.bc
-Chris
still the same: no bytecode. here's the gcc4 directory (it's in the path)
powerbookg4:/llvm/llvm-gcc/bin mycroft$ ls -l total 97864 -rwxr-xr-x 4 mycroft admin 5586284 Jun 22 07:25 c++ -rwxr-xr-x 1 mycroft admin 5585780 Jun 22 07:25 cpp -rwxr-xr-x 4 mycroft admin 5586284 Jun 22 07:25 g++ -rwxr-xr-x 3 mycroft admin 5584860 Jun 22 07:25 gcc -rwxr-xr-x 1 mycroft admin 15728 Jun 22 07:25 gccbug -rwxr-xr-x 1 mycroft admin 5367872 Jun 22 07:25 gcov lrwxr-xr-x 1 mycroft admin 3 Jun 27 09:58 llvm-c++ -> c++ lrwxr-xr-x 1 mycroft admin 3 Jun 27 09:58 llvm-cpp -> cpp lrwxr-xr-x 1 mycroft admin 3 Jun 27 09:58 llvm-g++ -> g++ lrwxr-xr-x 1 mycroft admin 3 Jun 27 09:58 llvm-gcc -> gcc lrwxr-xr-x 1 mycroft admin 6 Jun 27 09:58 llvm-gccbug -> gccbug lrwxr-xr-x 1 mycroft admin 4 Jun 27 09:58 llvm-gcov -> gcov -rwxr-xr-x 4 mycroft admin 5586284 Jun 22 07:25 powerpc-apple-darwin8.6.0-c++ -rwxr-xr-x 4 mycroft admin 5586284 Jun 22 07:25 powerpc-apple-darwin8.6.0-g++ -rwxr-xr-x 3 mycroft admin 5584860 Jun 22 07:25 powerpc-apple-darwin8.6.0-gcc -rwxr-xr-x 3 mycroft admin 5584860 Jun 22 07:25 powerpc-apple-darwin8.6.0-gcc-4.0.1
powerbookg4:/llvm/test mycroft$ ls hello.cpp test.c
powerbookg4:/llvm/test mycroft$ llvm-gcc hello.cpp
/usr/bin/ld: Undefined symbols:
std::ios_base::Init::Init()
std::ios_base::Init::~Init()
std::cout
std::basic_ostream<char, std::char_traits
powerbookg4:/llvm/test mycroft$ llvm-g++ hello.cpp powerbookg4:/llvm/test mycroft$ ls a.out hello.cpp test.c powerbookg4:/llvm/test mycroft$ ./a.out hello world
powerbookg4:/llvm/test mycroft$ llvm-gcc test.c -S -o - -emit-llvm -v Using built-in specs. Target: powerpc-apple-darwin8.6.0 Configured with: ../gccsrc/configure --prefix=/llvm/llvm-gcc -enable-llvm=/llvm/llvmobj --enable- languages=c,c++,objc,obj-c++ Thread model: posix gcc version 4.0.1 LLVM (Apple Computer, Inc. build 5400) /llvm/llvm-gcc/libexec/gcc/powerpc-apple-darwin8.6.0/4.0.1/cc1 -quiet -v -DDYNAMIC test.c - emit-llvm -fPIC -quiet -dumpbase test.c -auxbase-strip - -version -o - ignoring nonexistent directory "/llvm/llvm-gcc/lib/gcc/powerpc-apple-darwin8.6.0/4.0.1/../../../../ powerpc-apple-darwin8.6.0/include"
/usr/local/include /llvm/llvm-gcc/include /llvm/llvm-gcc/lib/gcc/powerpc-apple-darwin8.6.0/4.0.1/include /usr/include /System/Library/Frameworks /Library/Frameworks End of search list. GNU C version 4.0.1 LLVM (Apple Computer, Inc. build 5400) (powerpc-apple-darwin8.6.0) compiled by GNU C version 4.0.1 (Apple Computer, Inc. build 5341). GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: 552bb8881767f70d3bc8f89513fbe650 ; ModuleID = 'test.c' target endian = big target pointersize = 32 target triple = "powerpc-apple-darwin8.6.0"
implementation ; Functions:
int %foo() {
entry:
%retval = alloca int, align 4 ; <int*> [#uses=1]
"alloca point" = cast int 0 to int ;
return: ; preds = %entry
%retval = load int* %retval ;
if you are interested:
powerbookg4:/llvm/test mycroft$ llvm-gcc hello.cpp -S -o - -emit-llvm -v Using built-in specs. Target: powerpc-apple-darwin8.6.0 Configured with: ../gccsrc/configure --prefix=/llvm/llvm-gcc -enable-llvm=/llvm/llvmobj --enable- languages=c,c++,objc,obj-c++ Thread model: posix gcc version 4.0.1 LLVM (Apple Computer, Inc. build 5400) /llvm/llvm-gcc/libexec/gcc/powerpc-apple-darwin8.6.0/4.0.1/cc1plus -quiet -v -DDYNAMIC hello.cpp -emit-llvm -fPIC -quiet -dumpbase hello.cpp -auxbase-strip - -version -o - - D__private_extern__=extern ignoring nonexistent directory "/llvm/llvm-gcc/lib/gcc/powerpc-apple-darwin8.6.0/4.0.1/../../../../ powerpc-apple-darwin8.6.0/include"
/llvm/llvm-gcc/lib/gcc/powerpc-apple-darwin8.6.0/4.0.1/../../../../include/c++/4.0.1
/llvm/llvm-gcc/lib/gcc/powerpc-apple-darwin8.6.0/4.0.1/../../../../include/c++/4.0.1/powerpc-
apple-darwin8.6.0
/llvm/llvm-gcc/lib/gcc/powerpc-apple-darwin8.6.0/4.0.1/../../../../include/c++/4.0.1/backward
/usr/local/include
/llvm/llvm-gcc/include
/llvm/llvm-gcc/lib/gcc/powerpc-apple-darwin8.6.0/4.0.1/include
/usr/include
/System/Library/Frameworks
/Library/Frameworks
End of search list.
GNU C++ version 4.0.1 LLVM (Apple Computer, Inc. build 5400) (powerpc-apple-darwin8.6.0)
compiled by GNU C version 4.0.1 (Apple Computer, Inc. build 5341).
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 099f891e5e9b8ccebf1bf8512c58370d
; ModuleID = 'hello.cpp'
target endian = big
target pointersize = 32
target triple = "powerpc-apple-darwin8.6.0"
"struct.std::basic_ios<char,std::char_traits
implementation ; Functions:
int %main() {
entry:
%retval = alloca int, align 4 ; <int> [#uses=3]
%tmp = alloca int, align 4 ; <int> [#uses=4]
"alloca point" = cast int 0 to int ;
return: ; preds = %0, %entry
%retval = load int* %retval ;
internal void %_GLOBAL__I_main() section "TEXT,StaticInit,regular,pure_instructions" { entry: call void %_Z41__static_initialization_and_destruction_0ii( int 1, int 65535 ) br label %return
return: ; preds = %entry ret void }
internal void %_GLOBAL__D_main() section "TEXT,StaticInit,regular,pure_instructions" { entry: call void %_Z41__static_initialization_and_destruction_0ii( int 0, int 65535 ) br label %return
return: ; preds = %entry ret void }
declare "struct.std::basic_ostream<char,std::char_traits
internal void %_Z41static_initialization_and_destruction_0ii(int %initialize_p, int %priority) section
"TEXT,StaticInit,regular,pure_instructions" {
entry:
%initialize_p_addr = alloca int ; <int*> [#uses=3]
%priority_addr = alloca int ; <int*> [#uses=3]
"alloca point" = cast int 0 to int ;
cond_true: ; preds = %entry
%tmp1 = load int* %__initialize_p_addr ;
cond_true3: ; preds = %cond_true call void %_ZNSt8ios_base4InitC1Ev( "struct.std::ctype_base"* %_ZSt8__ioinit ) br label %cond_next
cond_false: ; preds = %cond_true br label %cond_next
cond_next: ; preds = %cond_false, %cond_true3 br label %cond_next5
cond_false4: ; preds = %entry br label %cond_next5
cond_next5: ; preds = %cond_false4, %cond_next
%tmp6 = load int* %__priority_addr ;
cond_true8: ; preds = %cond_next5
%tmp9 = load int* %__initialize_p_addr ;
cond_true11: ; preds = %cond_true8 call void %_ZNSt8ios_base4InitD1Ev( "struct.std::ctype_base"* %_ZSt8__ioinit ) br label %cond_next13
cond_false12: ; preds = %cond_true8 br label %cond_next13
cond_next13: ; preds = %cond_false12, %cond_true11 br label %cond_next15
cond_false14: ; preds = %cond_next5 br label %cond_next15
cond_next15: ; preds = %cond_false14, %cond_next13 br label %return
return: ; preds = %cond_next15 ret void }
declare void %_ZNSt8ios_base4InitC1Ev("struct.std::ctype_base"*)
declare void %_ZNSt8ios_base4InitD1Ev("struct.std::ctype_base"*)
I'm not that stupid... ;) It's the first thing I checked.
No insult intended. Often the most obvious cause is the right one :)
If I had to guess, I would guess it's because you renamed the executables. Please try naming them "gcc" and using a symlink from llvm-gcc to gcc. GCC is funny about how it finds parts like "cc1".
If that doesn't help, please try a simple example, e.g.:
echo "int foo(){}" > test.c llvm-gcc test.c -S -o - -emit-llvm -v
and include the output.
Thanks,
-Chris
I forgot to mention: this is the version I recompiled, however the binaries you distribute have a similar version dump. (the filename is originally gcc and not llvm-gcc, but I renamed it)
I'm not that stupid... ;) It's the first thing I checked.
powerbookg4:/llvm/llvm-gcc4/bin mycroft$ ./llvm-gcc -v Using built-in specs. Target: powerpc-apple-darwin8.6.0 Configured with: ../gccsrc/configure --prefix=/llvm/llvm-gcc -enable-llvm=/llvm/llvmobj --enable- languages=c,c++,objc,obj-c++ Thread model: posix gcc version 4.0.1 LLVM (Apple Computer, Inc. build 5400)
run llvm-gcc4 -v. Does it print the string "LLVM"? If not, you have a native GCC, not an LLVM GCC.
recompiling the gcc4 frontend partially fixes: the new gcc4 does compile the "hello world" c++ sample, it will NOT produce bytecode, but at least the binary file works.
Hi,
the bug reappeared with llvm 1.7, and it's much worse:
I'm working on a powerbook g4, with 10.4.6 I use the binary version of llvm-gcc v3.4 from the download section on the website. I configure llvm with "--enable-optimized --enable-jit"
llvm compiles fine, but now BOTH llvm-gcc and llvm-g++ produce an identical bytecode (and segmentation fault...)
if I use llvm-gcc4 (powerpc) binaries I get a bizarre result: first, in the archive, the executables don't have the llvm- prefix. If I rename them and compile llvm as above, when I compile something I don't get bytecode, but a native executable, which however does not run (it says: invalid CPU...)
please, tell me what's happening (hint: please, provide a BINARY setup...)
I'm observing the same behaviour on i386 with LLVM 1.7. Whenever I compile a C++ code that tries to write to cout I get a segmentation fault as soon as I run it. I tried to compile the frontend from SVN sources but failed so far.
Anyway, since it appears to work fine for most other users, I expect that I must have made a simple mistake during my LLVM setup. Any idea what this could be?
ok, sounds fair.
-Chris
thanks, I've only a 56k dial-up connection here, so I won't try to checkout llvm-gcc... If you prefer, close this bug. I'll open a new one if necessary (I hope not to! :)
Were you able to reproduce this problem with a CVS llvm-gcc? If you can't check, I'm going to have to close this as "works for me".
Thanks,
-Chris
when you link with 'gcc', it uses the system libstdc++ library. When you link with g++, it uses the LLVM version.
BTW, note that compiling a program like that invokes the JIT when you run a.out.
-Chris
yes, it's the released 1.6 binary package downloaded from website. I run fixheader with MacOS 10.4.3 but now it's running in 10.4.4
I'll have some more check and let you know, but why gcc works when g++ does not?
This implies that llvm-g++'s libstdc++ is corrupt. Where did you get your llvmgcc? Is it llvm-gcc 1.6 or something earlier? If it is 1.6, please try updating it to the latest CVS version: it works fine for me on OS X 10.4.4.
-Chris
Extended Description
It looks like there's a bug in llvm-g++: a very simple c++ source code compiled by llvm-gcc produces a working bytecode, but the same file compiled by llvm-g++ generates a smaller and non working output:
PowerBookG4:/llvm/test mycroft$ cat hello.cpp
include
int main() { std::cout << "hello world\n"; return 0; }
PowerBookG4:/llvm/test mycroft$ llvm-gcc hello.cpp PowerBookG4:/llvm/test mycroft$ ls -l total 440 -rwxr-xr-x 1 mycroft admin 64 Jan 12 00:03 a.out -rwxr-xr-x 1 mycroft admin 216923 Jan 12 00:03 a.out.bc -rw-r--r-- 1 mycroft admin 95 Jan 12 00:00 hello.cpp PowerBookG4:/llvm/test mycroft$ ./a.out hello world
PowerBookG4:/llvm/test mycroft$ rm a.*
PowerBookG4:/llvm/test mycroft$ llvm-g++ hello.cpp PowerBookG4:/llvm/test mycroft$ ls -l total 112 -rwxr-xr-x 1 mycroft admin 64 Jan 12 00:04 a.out -rwxr-xr-x 1 mycroft admin 47320 Jan 12 00:04 a.out.bc -rw-r--r-- 1 mycroft admin 95 Jan 12 00:00 hello.cpp PowerBookG4:/llvm/test mycroft$ ./a.out Segmentation fault