Closed Quuxplusone closed 14 years ago
Bugzilla Link | PR689 |
Status | RESOLVED FIXED |
Importance | P normal |
Reported by | Mycroft Holmes (hp48gx@gmail.com) |
Reported on | 2006-01-12 03:39:31 -0800 |
Last modified on | 2010-03-06 13:59:19 -0800 |
Version | 1.6 |
Hardware | Macintosh MacOS X |
CC | llvm-bugs@lists.llvm.org, martin@mpa-garching.mpg.de |
Fixed by commit(s) | |
Attachments | |
Blocks | |
Blocked by | |
See also |
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
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?
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
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
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!
:)
ok, sounds fair.
-Chris
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?
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...)
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.
run llvm-gcc4 -v. Does it print the string "LLVM"? If not, you have a native GCC, not an LLVM GCC.
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)
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.
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
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<char> >& std::operator<<
<std::char_traits<char> >
(std::basic_ostream<char, std::char_traits<char> >&, char const*)
collect2: ld returned 1 exit status
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 -D__DYNAMIC__ 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"
#include "..." search starts here:
#include <...> search starts here:
/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 ; <int> [#uses=0]
br label %return
return: ; preds = %entry
%retval = load int* %retval ; <int> [#uses=1]
ret 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 -D__DYNAMIC__
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"
#include "..." search starts here:
#include <...> search starts here:
/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<char> >" = type { "struct.std::ios_base",
"struct.std::basic_ostream<char,std::char_traits<char> >"*, sbyte, uint,
"struct.std::basic_streambuf<char,std::char_traits<char> >"*,
"struct.std::ctype<char>"*,
"struct.std::num_get<char,std::istreambuf_iterator<char, std::char_traits<char>
> >"*,
"struct.std::num_get<char,std::istreambuf_iterator<char, std::char_traits<char>
> >"* }
"struct.std::basic_ostream<char,std::char_traits<char> >" = type { int (...)**,
"struct.std::basic_ios<char,std::char_traits<char> >" }
"struct.std::basic_streambuf<char,std::char_traits<char> >" = type { int (...)**, sbyte*, sbyte*,
sbyte*, sbyte*, sbyte*, sbyte*, "struct.std::locale" }
"struct.std::ctype<char>" = type { "struct.std::locale::facet", int*, uint, int*, int*, uint*, sbyte, [256
x sbyte], [256 x sbyte], sbyte }
"struct.std::ctype_base" = type { ubyte }
"struct.std::ios_base" = type { int (...)**, int, int, uint, uint, uint,
"struct.std::ios_base::_Callback_list"*, "struct.std::ios_base::_Words", [8 x
"struct.std::ios_base::_Words"],
int, "struct.std::ios_base::_Words"*, "struct.std::locale" }
"struct.std::ios_base::Init" = type { ubyte }
"struct.std::ios_base::_Callback_list" = type { "struct.std::ios_base::_Callback_list"*, void (uint,
"struct.std::ios_base"*, int)*, int, int }
"struct.std::ios_base::_Words" = type { sbyte*, int }
"struct.std::locale" = type { "struct.std::locale::_Impl"* }
"struct.std::locale::_Impl" = type { int, "struct.std::locale::facet"**, uint, "struct.std::locale::facet"**,
sbyte** }
"struct.std::locale::facet" = type { int (...)**, int }
"struct.std::num_get<char,std::istreambuf_iterator<char, std::char_traits<char> > >" = type
{ "struct.std::locale::facet" }
"struct.std::num_put<char,std::ostreambuf_iterator<char, std::char_traits<char> > >" = type
{ "struct.std::locale::facet" }
%_ZSt8__ioinit = internal global "struct.std::ctype_base" zeroinitializer
;
<"struct.std::ctype_base"*> [#uses=2]
%_ZSt4cout = external global
"struct.std::basic_ostream<char,std::char_traits<char> >" ;
<"struct.std::basic_ostream<char,std::char_traits<char> >"*> [#uses=1]
%str = internal constant [13 x sbyte] c"hello world\0A\00" ; <[13
x sbyte]*> [#uses=1]
%llvm.global_ctors = appending global [1 x { int, void ()* }] [ { int, void ()*
} { int 65535, void ()* %
_GLOBAL__I_main } ] ; <[1 x { int, void ()* }]*> [#uses=0]
%llvm.global_dtors = appending global [1 x { int, void ()* }] [ { int, void ()*
} { int 65535, void ()* %
_GLOBAL__D_main } ] ; <[1 x { int, void ()* }]*> [#uses=0]
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 ; <int> [#uses=0]
%tmp = getelementptr [13 x sbyte]* %str, int 0, uint 0 ; <sbyte*> [#uses=1]
%tmp = call "struct.std::basic_ostream<char,std::char_traits<char> >"* %
_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
( "struct.std::basic_ostream<char,std::char_traits<char> >"* %_ZSt4cout, sbyte*
%tmp ) ;
<"struct.std::basic_ostream<char,std::char_traits<char> >"*> [#uses=0]
store int 0, int* %tmp
%tmp = load int* %tmp ; <int> [#uses=1]
store int %tmp, int* %retval
br label %return
; No predecessors!
store int 0, int* %tmp
%tmp1 = load int* %tmp ; <int> [#uses=1]
store int %tmp1, int* %retval
br label %return
return: ; preds = %0, %entry
%retval = load int* %retval ; <int> [#uses=1]
ret 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<char> >"* %
_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
("struct.std::basic_ostream<char,std::char_traits<char> >"*, sbyte*)
internal void %_Z41__static_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 ; <int> [#uses=0]
store int %__initialize_p, int* %__initialize_p_addr
store int %__priority, int* %__priority_addr
%tmp = load int* %__priority_addr ; <int> [#uses=1]
%tmp = seteq int %tmp, 65535 ; <bool> [#uses=2]
%tmp = cast bool %tmp to uint ; <uint> [#uses=0]
br bool %tmp, label %cond_true, label %cond_false4
cond_true: ; preds = %entry
%tmp1 = load int* %__initialize_p_addr ; <int> [#uses=1]
%tmp2 = seteq int %tmp1, 1 ; <bool> [#uses=2]
%tmp2 = cast bool %tmp2 to uint ; <uint> [#uses=0]
br bool %tmp2, label %cond_true3, label %cond_false
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 ; <int> [#uses=1]
%tmp7 = seteq int %tmp6, 65535 ; <bool> [#uses=2]
%tmp7 = cast bool %tmp7 to uint ; <uint> [#uses=0]
br bool %tmp7, label %cond_true8, label %cond_false14
cond_true8: ; preds = %cond_next5
%tmp9 = load int* %__initialize_p_addr ; <int> [#uses=1]
%tmp10 = seteq int %tmp9, 0 ; <bool> [#uses=2]
%tmp10 = cast bool %tmp10 to uint ; <uint> [#uses=0]
br bool %tmp10, label %cond_true11, label %cond_false12
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"*)
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
This is fixed in recent drops of llvm-gcc4.
-Chris