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

Andrew Haley aph@redhat.com
Fri Jan 13 15:34:00 GMT 2012


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.

> 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.




More information about the Gcc-help mailing list