This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: freebsd gcc cross compiler creates binaries that crash when using c++ exceptions


> On 01/12/2012 07:25 PM, Markus Henschel wrote:
> >> On 01/12/2012 06:55 PM, Markus Henschel wrote:
> >>> Is there some flaw in the way I built this toolchain? Where could I
> >> try to start looking for the source of the problem? I can add all
> >> sorts of other outputs from the created toolchains if it helps.
> >>
> >> I wouldn't put the installed compiler (i.e. the prefix=) into the
> >> same directory as the sysroot.  The sysroot should be a clean &
> >> pristine copy of the root directories on your target.  It isn't
> >> written to, only read from.  Once you have done your make install
> you
> >> should have a set of target libraries that work in your prefix/lib.
> >
> > I did this because I had problems building a relocatable toolchain.
> > When "prefix" was different from "sysroot" the compiler used an
> > absolute path to some files in sysroot.
> 
> Well, surely that's exactly what you want, otherwise how could it ever
> find sysroot?
> >> You can't mix the c++ and libgcc libraries you just built with the
> >> versions on your target system.  It should be possible to install
> the
> >> newly-created ones side by side with the versions on your target
> >> system.
> >
> > May be I should explain better:
> 
> > Usually I link libgcc and libstdc++ statically to not interfere with
> > whatever is installed on the target system.
> 
> This is a bad idea: statically-linked libgcc doesn't play well with any
> shared libraries.

In our case this is desired. We do not link any C++ libraries because the target systems OS (which is not under our control) is ancient as well as the default system compilers. So all we use is libc and some other libraries with C-API to be able to upgrade our compilers and dependencies as we like. But as far as I can see it isn't part of the problem. The simple test case only linked to libgcc and libstdc++ (and libc,libm).

> > Because I got these crashes I started playing around. I linked my
> test
> > app dynamically against libgcc.so and libstdc++.so. Then I copied my
> > test app to the target system and used the installed versions of
> these
> > libraries. This seems to work. I just did this by accident. This
> > brought me to my conclusion that something must be wrong with these
> > libs that I created while building the cross compiler.
> 
> Perhaps so.
> 
> > I should also mention that the versions of the compiler support
> > libraries on the target system come from gcc 4.2.1 so they are
> > "similar enough" to what my binaries needed.
> >
> > So I started to build my toolchain on the target system as a native
> > compiler with exactly the same configure switches. This also produced
> > working versions of libgcc and libstdc++.
> 
> As you'd expect.
> 
> Like I said, you've got to break out the debugger to find out what is
> wrong.
> 
> Andrew.

What I did so far was attaching gdb and seeing that it crashes in libgcc in __cxa_end_catch. I guess I'll have to build libgcc with debug symbols then.

Thanks for the tips so far. Any further input is welcome.

Markus.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]