Discussion:
cross compiler gcc 4.2.3 for FreeBSD 10
a***@gmail.com
2014-10-16 11:30:39 UTC
Permalink
Hello!
I have compiled cross compiler gcc 4.2.3 for FreeBSD using
binutils-2.17.50. To compiler that compiler I used gcc 4.4.3 compiler.

Before that I patched files removing freebsd1* and freebsd[1... and
freebsd[[1 if/case. It is well known problem which I found in
Changelog of gcc 4.6.3

binutils-2.17.5/ld/configure
binutils-2.17.5/gas/configure
binutils-2.17.5/gprof/configure
binutils-2.17.5/opcodes/configure
binutils-2.17.5/configure
binutils-2.17.5/binutils/configure
binutils-2.17.5/bfd/configure
binutils-2.17.5/config.rpath
binutils-2.17.5/libtool.m4
binutils-2.17.5/ld/configure.host
binutils-2.17.5/ld/configure.tgt
binutils-2.17.5/bfd/config.bfd
binutils-2.17.5/bfd/configure

gcc-4.2.3/boehm-gc/configure
gcc-4.2.3/configure
gcc-4.2.3/fixincludes/configure
gcc-4.2.3/gcc/configure
gcc-4.2.3/gnattools/configure
gcc-4.2.3/intl/configure
gcc-4.2.3/libada/configure
gcc-4.2.3/libcpp/configure
gcc-4.2.3/libdecnumber/configure
gcc-4.2.3/libffi/configure
gcc-4.2.3/libgfortran/configure
gcc-4.2.3/libgomp/configure
gcc-4.2.3/libiberty/configure
gcc-4.2.3/libjava/classpath/configure
gcc-4.2.3/libjava/configure
gcc-4.2.3/libjava/libltdl/configure
gcc-4.2.3/libmudflap/configure
gcc-4.2.3/libobjc/configure
gcc-4.2.3/libssp/configure
gcc-4.2.3/libstdc++-v3/configure
gcc-4.2.3/zlib/configure
gcc compiler built with no errors.

Next I tried to compile a simple example of c++ code

int main()
{
try
{
throw 10;
}
catch(...)
{
return 1;
}

return 0;
}
But I got a coredump

root@:~ # ./42.out
Abort (core dumped)
root@:~ # ldd ./42.out
./42.out:
libstdc++.so.6 => /root/4.2/libstdc++.so.6 (0x28069000)
libm.so.5 => /lib/libm.so.5 (0x28155000)
libgcc_s.so.1 => /root/4.2/libgcc_s.so.1 (0x28177000)
libc.so.7 => /lib/libc.so.7 (0x28185000)

root@:~ # gdb 42.out 42.out.core
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-marcel-freebsd"...(no debugging
symbols found)...
Attaching to program: /root/42.out, process 42
ptrace: No such process.
Core was generated by `42.out'.
Program terminated with signal 6, Aborted.
Reading symbols from /root/4.2/libstdc++.so.6...done.
Loaded symbols for /root/4.2/libstdc++.so.6
Reading symbols from /lib/libm.so.5...done.
Loaded symbols for /lib/libm.so.5
Reading symbols from /root/4.2/libgcc_s.so.1...done.
Loaded symbols for /root/4.2/libgcc_s.so.1
Reading symbols from /lib/libc.so.7...done.
Loaded symbols for /lib/libc.so.7
Reading symbols from /libexec/ld-elf.so.1...done.
Loaded symbols for /libexec/ld-elf.so.1
#0 0x282afed7 in kill () from /lib/libc.so.7
(gdb) bt
#0 0x282afed7 in kill () from /lib/libc.so.7
#1 0x282afe67 in raise () from /lib/libc.so.7
#2 0x282ae8a6 in abort () from /lib/libc.so.7
#3 0x28180078 in uw_init_context_1 (context=0xbfbfdb68,
outer_cfa=0xbfbfdc10, outer_ra=0x281214f1) at
../../gcc/unwind-dw2.c:1413
#4 0x281804e2 in _Unwind_RaiseException (exc=0x28803070) at unwind.inc:92
#5 0x281214f1 in __cxa_throw (obj=0x28803090, tinfo=0x80499a0,
dest=0) at ../../../../libstdc++-v3/libsupc++/eh_throw.cc:71
#6 0x08048770 in main ()

part of gcc/unwind-dw2.c:1413
...
code = uw_frame_state_for (context, &fs);
gcc_assert (code == _URC_NO_REASON); <--- line 14, here I got code
== _URC_END_OF_STACK
...

Then I linked libgcc and libstdc++ statically

root@:~ # ldd 42.out
42.out:
libm.so.5 => /lib/libm.so.5 (0x2807c000)
libc.so.7 => /lib/libc.so.7 (0x2809e000)

But the problem was reproducted again

root@:~ # ./42.out
Abort (core dumped)

With the same stack trace

root@:~ # gdb 42.out 42.out.core
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-marcel-freebsd"...
Attaching to program: /root/42.out, process 42
ptrace: No such process.
Core was generated by `42.out'.
Program terminated with signal 6, Aborted.
Reading symbols from /lib/libm.so.5...done.
Loaded symbols for /lib/libm.so.5
Reading symbols from /lib/libc.so.7...done.
Loaded symbols for /lib/libc.so.7
Reading symbols from /libexec/ld-elf.so.1...done.
Loaded symbols for /libexec/ld-elf.so.1
#0 0x281c8ed7 in kill () from /lib/libc.so.7
(gdb) bt
#0 0x281c8ed7 in kill () from /lib/libc.so.7
#1 0x281c8e67 in raise () from /lib/libc.so.7
#2 0x281c78a6 in abort () from /lib/libc.so.7
#3 0x08056268 in uw_init_context_1 (context=0xbfbfdb68,
outer_cfa=0xbfbfdc10, outer_ra=0x804d537) at
../../gcc/unwind-dw2.c:1413
#4 0x080566d2 in _Unwind_RaiseException (exc=0x28803070) at unwind.inc:92
#5 0x0804d537 in __cxa_throw (obj=0x28803090, tinfo=0x805c480,
dest=0) at ../../../../libstdc++-v3/libsupc++/eh_throw.cc:71
#6 0x080492c0 in main ()

Can you please tell me where to dig to get workable compiler?
--
/BR, Alexander
a***@gmail.com
2014-10-16 12:47:45 UTC
Permalink
Hello!
If I build toolchain based on gcc 4.6.3 compiler it works fine and
catching exceptions does not lead to abort() call.
Post by a***@gmail.com
Hello!
I have compiled cross compiler gcc 4.2.3 for FreeBSD using
binutils-2.17.50. To compiler that compiler I used gcc 4.4.3 compiler.
Before that I patched files removing freebsd1* and freebsd[1... and
freebsd[[1 if/case. It is well known problem which I found in
Changelog of gcc 4.6.3
binutils-2.17.5/ld/configure
binutils-2.17.5/gas/configure
binutils-2.17.5/gprof/configure
binutils-2.17.5/opcodes/configure
binutils-2.17.5/configure
binutils-2.17.5/binutils/configure
binutils-2.17.5/bfd/configure
binutils-2.17.5/config.rpath
binutils-2.17.5/libtool.m4
binutils-2.17.5/ld/configure.host
binutils-2.17.5/ld/configure.tgt
binutils-2.17.5/bfd/config.bfd
binutils-2.17.5/bfd/configure
gcc-4.2.3/boehm-gc/configure
gcc-4.2.3/configure
gcc-4.2.3/fixincludes/configure
gcc-4.2.3/gcc/configure
gcc-4.2.3/gnattools/configure
gcc-4.2.3/intl/configure
gcc-4.2.3/libada/configure
gcc-4.2.3/libcpp/configure
gcc-4.2.3/libdecnumber/configure
gcc-4.2.3/libffi/configure
gcc-4.2.3/libgfortran/configure
gcc-4.2.3/libgomp/configure
gcc-4.2.3/libiberty/configure
gcc-4.2.3/libjava/classpath/configure
gcc-4.2.3/libjava/configure
gcc-4.2.3/libjava/libltdl/configure
gcc-4.2.3/libmudflap/configure
gcc-4.2.3/libobjc/configure
gcc-4.2.3/libssp/configure
gcc-4.2.3/libstdc++-v3/configure
gcc-4.2.3/zlib/configure
gcc compiler built with no errors.
Next I tried to compile a simple example of c++ code
int main()
{
try
{
throw 10;
}
catch(...)
{
return 1;
}
return 0;
}
But I got a coredump
Abort (core dumped)
libstdc++.so.6 => /root/4.2/libstdc++.so.6 (0x28069000)
libm.so.5 => /lib/libm.so.5 (0x28155000)
libgcc_s.so.1 => /root/4.2/libgcc_s.so.1 (0x28177000)
libc.so.7 => /lib/libc.so.7 (0x28185000)
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-marcel-freebsd"...(no debugging
symbols found)...
Attaching to program: /root/42.out, process 42
ptrace: No such process.
Core was generated by `42.out'.
Program terminated with signal 6, Aborted.
Reading symbols from /root/4.2/libstdc++.so.6...done.
Loaded symbols for /root/4.2/libstdc++.so.6
Reading symbols from /lib/libm.so.5...done.
Loaded symbols for /lib/libm.so.5
Reading symbols from /root/4.2/libgcc_s.so.1...done.
Loaded symbols for /root/4.2/libgcc_s.so.1
Reading symbols from /lib/libc.so.7...done.
Loaded symbols for /lib/libc.so.7
Reading symbols from /libexec/ld-elf.so.1...done.
Loaded symbols for /libexec/ld-elf.so.1
#0 0x282afed7 in kill () from /lib/libc.so.7
(gdb) bt
#0 0x282afed7 in kill () from /lib/libc.so.7
#1 0x282afe67 in raise () from /lib/libc.so.7
#2 0x282ae8a6 in abort () from /lib/libc.so.7
#3 0x28180078 in uw_init_context_1 (context=0xbfbfdb68,
outer_cfa=0xbfbfdc10, outer_ra=0x281214f1) at
../../gcc/unwind-dw2.c:1413
#4 0x281804e2 in _Unwind_RaiseException (exc=0x28803070) at unwind.inc:92
#5 0x281214f1 in __cxa_throw (obj=0x28803090, tinfo=0x80499a0,
dest=0) at ../../../../libstdc++-v3/libsupc++/eh_throw.cc:71
#6 0x08048770 in main ()
part of gcc/unwind-dw2.c:1413
...
code = uw_frame_state_for (context, &fs);
gcc_assert (code == _URC_NO_REASON); <--- line 14, here I got code
== _URC_END_OF_STACK
...
Then I linked libgcc and libstdc++ statically
libm.so.5 => /lib/libm.so.5 (0x2807c000)
libc.so.7 => /lib/libc.so.7 (0x2809e000)
But the problem was reproducted again
Abort (core dumped)
With the same stack trace
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-marcel-freebsd"...
Attaching to program: /root/42.out, process 42
ptrace: No such process.
Core was generated by `42.out'.
Program terminated with signal 6, Aborted.
Reading symbols from /lib/libm.so.5...done.
Loaded symbols for /lib/libm.so.5
Reading symbols from /lib/libc.so.7...done.
Loaded symbols for /lib/libc.so.7
Reading symbols from /libexec/ld-elf.so.1...done.
Loaded symbols for /libexec/ld-elf.so.1
#0 0x281c8ed7 in kill () from /lib/libc.so.7
(gdb) bt
#0 0x281c8ed7 in kill () from /lib/libc.so.7
#1 0x281c8e67 in raise () from /lib/libc.so.7
#2 0x281c78a6 in abort () from /lib/libc.so.7
#3 0x08056268 in uw_init_context_1 (context=0xbfbfdb68,
outer_cfa=0xbfbfdc10, outer_ra=0x804d537) at
../../gcc/unwind-dw2.c:1413
#4 0x080566d2 in _Unwind_RaiseException (exc=0x28803070) at unwind.inc:92
#5 0x0804d537 in __cxa_throw (obj=0x28803090, tinfo=0x805c480,
dest=0) at ../../../../libstdc++-v3/libsupc++/eh_throw.cc:71
#6 0x080492c0 in main ()
Can you please tell me where to dig to get workable compiler?
--
/BR, Alexander
--
/BR, Alexander
a***@gmail.com
2014-10-16 17:09:40 UTC
Permalink
Can you help please to make compiler gcc 4.2 work?
Post by a***@gmail.com
Hello!
If I build toolchain based on gcc 4.6.3 compiler it works fine and
catching exceptions does not lead to abort() call.
Post by a***@gmail.com
Hello!
I have compiled cross compiler gcc 4.2.3 for FreeBSD using
binutils-2.17.50. To compiler that compiler I used gcc 4.4.3 compiler.
Before that I patched files removing freebsd1* and freebsd[1... and
freebsd[[1 if/case. It is well known problem which I found in
Changelog of gcc 4.6.3
binutils-2.17.5/ld/configure
binutils-2.17.5/gas/configure
binutils-2.17.5/gprof/configure
binutils-2.17.5/opcodes/configure
binutils-2.17.5/configure
binutils-2.17.5/binutils/configure
binutils-2.17.5/bfd/configure
binutils-2.17.5/config.rpath
binutils-2.17.5/libtool.m4
binutils-2.17.5/ld/configure.host
binutils-2.17.5/ld/configure.tgt
binutils-2.17.5/bfd/config.bfd
binutils-2.17.5/bfd/configure
gcc-4.2.3/boehm-gc/configure
gcc-4.2.3/configure
gcc-4.2.3/fixincludes/configure
gcc-4.2.3/gcc/configure
gcc-4.2.3/gnattools/configure
gcc-4.2.3/intl/configure
gcc-4.2.3/libada/configure
gcc-4.2.3/libcpp/configure
gcc-4.2.3/libdecnumber/configure
gcc-4.2.3/libffi/configure
gcc-4.2.3/libgfortran/configure
gcc-4.2.3/libgomp/configure
gcc-4.2.3/libiberty/configure
gcc-4.2.3/libjava/classpath/configure
gcc-4.2.3/libjava/configure
gcc-4.2.3/libjava/libltdl/configure
gcc-4.2.3/libmudflap/configure
gcc-4.2.3/libobjc/configure
gcc-4.2.3/libssp/configure
gcc-4.2.3/libstdc++-v3/configure
gcc-4.2.3/zlib/configure
gcc compiler built with no errors.
Next I tried to compile a simple example of c++ code
int main()
{
try
{
throw 10;
}
catch(...)
{
return 1;
}
return 0;
}
But I got a coredump
Abort (core dumped)
libstdc++.so.6 => /root/4.2/libstdc++.so.6 (0x28069000)
libm.so.5 => /lib/libm.so.5 (0x28155000)
libgcc_s.so.1 => /root/4.2/libgcc_s.so.1 (0x28177000)
libc.so.7 => /lib/libc.so.7 (0x28185000)
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-marcel-freebsd"...(no debugging
symbols found)...
Attaching to program: /root/42.out, process 42
ptrace: No such process.
Core was generated by `42.out'.
Program terminated with signal 6, Aborted.
Reading symbols from /root/4.2/libstdc++.so.6...done.
Loaded symbols for /root/4.2/libstdc++.so.6
Reading symbols from /lib/libm.so.5...done.
Loaded symbols for /lib/libm.so.5
Reading symbols from /root/4.2/libgcc_s.so.1...done.
Loaded symbols for /root/4.2/libgcc_s.so.1
Reading symbols from /lib/libc.so.7...done.
Loaded symbols for /lib/libc.so.7
Reading symbols from /libexec/ld-elf.so.1...done.
Loaded symbols for /libexec/ld-elf.so.1
#0 0x282afed7 in kill () from /lib/libc.so.7
(gdb) bt
#0 0x282afed7 in kill () from /lib/libc.so.7
#1 0x282afe67 in raise () from /lib/libc.so.7
#2 0x282ae8a6 in abort () from /lib/libc.so.7
#3 0x28180078 in uw_init_context_1 (context=0xbfbfdb68,
outer_cfa=0xbfbfdc10, outer_ra=0x281214f1) at
../../gcc/unwind-dw2.c:1413
#4 0x281804e2 in _Unwind_RaiseException (exc=0x28803070) at unwind.inc:92
#5 0x281214f1 in __cxa_throw (obj=0x28803090, tinfo=0x80499a0,
dest=0) at ../../../../libstdc++-v3/libsupc++/eh_throw.cc:71
#6 0x08048770 in main ()
part of gcc/unwind-dw2.c:1413
...
code = uw_frame_state_for (context, &fs);
gcc_assert (code == _URC_NO_REASON); <--- line 14, here I got code
== _URC_END_OF_STACK
...
Then I linked libgcc and libstdc++ statically
libm.so.5 => /lib/libm.so.5 (0x2807c000)
libc.so.7 => /lib/libc.so.7 (0x2809e000)
But the problem was reproducted again
Abort (core dumped)
With the same stack trace
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-marcel-freebsd"...
Attaching to program: /root/42.out, process 42
ptrace: No such process.
Core was generated by `42.out'.
Program terminated with signal 6, Aborted.
Reading symbols from /lib/libm.so.5...done.
Loaded symbols for /lib/libm.so.5
Reading symbols from /lib/libc.so.7...done.
Loaded symbols for /lib/libc.so.7
Reading symbols from /libexec/ld-elf.so.1...done.
Loaded symbols for /libexec/ld-elf.so.1
#0 0x281c8ed7 in kill () from /lib/libc.so.7
(gdb) bt
#0 0x281c8ed7 in kill () from /lib/libc.so.7
#1 0x281c8e67 in raise () from /lib/libc.so.7
#2 0x281c78a6 in abort () from /lib/libc.so.7
#3 0x08056268 in uw_init_context_1 (context=0xbfbfdb68,
outer_cfa=0xbfbfdc10, outer_ra=0x804d537) at
../../gcc/unwind-dw2.c:1413
#4 0x080566d2 in _Unwind_RaiseException (exc=0x28803070) at unwind.inc:92
#5 0x0804d537 in __cxa_throw (obj=0x28803090, tinfo=0x805c480,
dest=0) at ../../../../libstdc++-v3/libsupc++/eh_throw.cc:71
#6 0x080492c0 in main ()
Can you please tell me where to dig to get workable compiler?
--
/BR, Alexander
--
/BR, Alexander
--
/BR, Alexander
Andrew Haley
2014-10-16 17:20:19 UTC
Permalink
Post by a***@gmail.com
Can you help please to make compiler gcc 4.2 work?
Sorry, no. The last release of GCC 4.2 was in 2008. I don't know why
you want to try to make this obsolete version work, but it's unlikely
that it'd be of use to anyone else and in any case the release is
closed.

If you really need this compiler, you best bet is to look at the
ChangeLogs for BSD-specific changes. Other than that, you're just
going to have to debug it.

Andrew.
a***@gmail.com
2014-10-16 18:17:55 UTC
Permalink
Can you let me know which release of gcc is usually considered as obsolete?
Post by Andrew Haley
Post by a***@gmail.com
Can you help please to make compiler gcc 4.2 work?
Sorry, no. The last release of GCC 4.2 was in 2008. I don't know why
you want to try to make this obsolete version work, but it's unlikely
that it'd be of use to anyone else and in any case the release is
closed.
If you really need this compiler, you best bet is to look at the
ChangeLogs for BSD-specific changes. Other than that, you're just
going to have to debug it.
Andrew.
--
/BR, Alexander
Andrew Haley
2014-10-16 18:27:11 UTC
Permalink
Post by a***@gmail.com
Can you let me know which release of gcc is usually considered as obsolete?
Current versions are always at https://gcc.gnu.org/.
They are 4.8.3 and 4.9.1.

Andrew.
a***@gmail.com
2014-10-16 18:29:14 UTC
Permalink
Thank you.
Other ones are obsolete, right?
Post by Andrew Haley
Post by a***@gmail.com
Can you let me know which release of gcc is usually considered as obsolete?
Current versions are always at https://gcc.gnu.org/.
They are 4.8.3 and 4.9.1.
Andrew.
--
/BR, Alexander
Richard Earnshaw
2014-10-17 08:58:03 UTC
Permalink
Post by a***@gmail.com
Thank you.
Other ones are obsolete, right?
Post by Andrew Haley
Post by a***@gmail.com
Can you let me know which release of gcc is usually considered as obsolete?
Current versions are always at https://gcc.gnu.org/.
They are 4.8.3 and 4.9.1.
Andrew.
As a general rule the GCC Developers only maintain the two most recent
release branches. Other communities may maintain older releases, but
generally only for specific products. I'd be very surprised, though, if
anyone is still actively maintaining GCC 4.2.

R.

Loading...