Skip to contentSkip to conversation

bfin c++ problem

Buildroot Waldemar Brodkorb 1 participant 3 messages Jul 21, 2016 – Jul 25, 2016 5 messages not in the archive

lore
Share & tools
lore
#0 lore raw

Hi,

recently Thomas Petazzoni reported an issue for the internal toolchain support in Buildroot targeting Blackfin to me.

It seem a simple c++ hello world program can't be compiled:
cat t.c
#include <iostream>
int main(void) { std::cout << "hello, world\n"; }

./output/host/usr/bin/bfin-buildroot-linux-uclibc-g++ -o t t.c /home/wbx/buildroot/output/host/usr/lib/gcc/bfin-buildroot-linux-uclibc/6.1.0/../../../../bfin-buildroot-linux-uclibc/bin/ld:
t: hidden symbol `___gtdf2' in /home/wbx/buildroot/output/host/usr/lib/gcc/bfin-buildroot-linux-uclibc/6.1.0/libgcc.a(_gt_df.o)
is referenced by DSO /home/wbx/buildroot/output/host/usr/lib/gcc/bfin-buildroot-linux-uclibc/6.1.0/../../../../bfin-buildroot-linux-uclibc/bin/ld:
final link failed: Bad value
collect2: error: ld returned 1 exit status

It seems not specific to ___gtdf2, I have seen other symbols in other buildsystems.

./output/host/usr/bin/bfin-buildroot-linux-uclibc-g++ -v
Using built-in specs. COLLECT_GCC=/home/wbx/buildroot/output/host/usr/bin/bfin-buildroot-linux-uclibc-g++.br_real COLLECT_LTO_WRAPPER=/home/wbx/buildroot/output/host/usr/libexec/gcc/bfin-buildroot-linux-uclibc/6.1.0/lto-wrapper
Target: bfin-buildroot-linux-uclibc
Configured with: ./configure
--prefix=/home/wbx/buildroot/output/host/usr
--sysconfdir=/home/wbx/buildroot/output/host/etc --enable-static --target=bfin-buildroot-linux-uclibc --with-sysroot=/home/wbx/buildroot/output/host/usr/bfin-buildroot-linux-uclibc/sysroot --disable-__cxa_atexit --with-gnu-ld --disable-libssp
--disable-multilib --with-gmp=/home/wbx/buildroot/output/host/usr --with-mpfr=/home/wbx/buildroot/output/host/usr
--with-pkgversion='Buildroot 2016.08-git-01367-gdf60d48' --with-bugurl=http://bugs.buildroot.net/ --disable-libquadmath
--disable-libsanitizer --disable-tls --disable-libmudflap
--enable-threads --with-mpc=/home/wbx/buildroot/output/host/usr
--without-isl --without-cloog --disable-decimal-float
--enable-languages=c,c++ --with-build-time-tools=/home/wbx/buildroot/output/host/usr/bfin-buildroot-linux-uclibc/bin --enable-shared --disable-libgomp
Thread model: posix
gcc version 6.1.0 (Buildroot 2016.08-git-01367-gdf60d48)

binutils 2.26.1, gcc 6.1.0 is used.

At least two patches are applied on top of gcc 6.1.0, one for Bug 68468 and one for Bug 71721.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68468
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71721

ADI GNU Toolchain 2014R1 can compile the test program.

Does anyone have an idea?

best regards
Waldemar

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): CAH6eHdRNcLv9iT8dKN_zneVp2=P=yakUH=p8wq5dz5q2gNL-xQ@mail.gmail.com

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): CAH6eHdT-H+4qUe3uU268uG8O_7KQLoOZchtsW3AdFAVaeuN6cg@mail.gmail.com

A message that is not in the archive (sent off-list or not yet received): [email protected]

#6 lore raw

Hi Oliver,
Oliver Kullmann wrote,

Quoted 9 lines · Jonathan Wakely
Quoted 8 lines · Oliver Kullmann
Quoted 7 lines · Jonathan Wakely
Quoted 6 lines · Oliver Kullmann
Quoted 3 lines

Hello,

a C++ compiler is not required to recognise "main(void)":

That's incorrect.

Thanks for any advice about correct usage of C++, but I am afraid it does not help in any way to fix my original problem. Please open up a new thread to discuss this. Thanks.

Anyway, even a simple C application does compile with gcc, but not with g++:

./output/host/usr/bin/bfin-buildroot-linux-uclibc-g++ -o t test.c /home/wbx/buildroot/output/host/usr/lib/gcc/bfin-buildroot-linux-uclibc/6.1.0/../../../../bfin-buildroot-linux-uclibc/bin/ld:
t: hidden symbol `___gtdf2' in /home/wbx/buildroot/output/host/usr/lib/gcc/bfin-buildroot-linux-uclibc/6.1.0/libgcc.a(_gt_df.o)
is referenced by DSO /home/wbx/buildroot/output/host/usr/lib/gcc/bfin-buildroot-linux-uclibc/6.1.0/../../../../bfin-buildroot-linux-uclibc/bin/ld:
final link failed: Bad value
collect2: error: ld returned 1 exit status

$ cat test.c
int main() {
 return(0);
}
$ ./output/host/usr/bin/bfin-buildroot-linux-uclibc-gcc -o t test.c
$ file t
t: ELF 32-bit LSB executable, Analog Devices Blackfin, version 1
(SYSV), dynamically linked (uses shared libs), not stripped
$ 

Any advice? Why does the hidden symbols in libgcc.a from the first-stage gcc, doesn't make it into libstdc++ shared library?

Buildroot first compiles gcc with --disable-shared and have then a libgcc.a. Afterwards the C library (uClibc-ng) is build. In the next step a full --enable-shared gcc including libstdc++ is build. This one is then somehow mislinked and then g++ can not compile a simple application.

It must be some architecture specific problem, because we are not seeing this kind of issues on any other architecture at the moment.

Thanks in advance
Waldemar

#7 lore raw

Hi,
Waldemar Brodkorb wrote,

Quoted 42 lines

Hi Oliver,
Oliver Kullmann wrote,

Quoted 9 lines · Jonathan Wakely
Quoted 8 lines · Oliver Kullmann
Quoted 7 lines · Jonathan Wakely
Quoted 6 lines · Oliver Kullmann
Quoted 3 lines

Hello,

a C++ compiler is not required to recognise "main(void)":

That's incorrect.

Thanks for any advice about correct usage of C++, but I am afraid it does not help in any way to fix my original problem. Please open up a new thread to discuss this. Thanks.

Anyway, even a simple C application does compile with gcc, but not with g++:

./output/host/usr/bin/bfin-buildroot-linux-uclibc-g++ -o t test.c /home/wbx/buildroot/output/host/usr/lib/gcc/bfin-buildroot-linux-uclibc/6.1.0/../../../../bfin-buildroot-linux-uclibc/bin/ld:
t: hidden symbol `___gtdf2' in /home/wbx/buildroot/output/host/usr/lib/gcc/bfin-buildroot-linux-uclibc/6.1.0/libgcc.a(_gt_df.o)
is referenced by DSO /home/wbx/buildroot/output/host/usr/lib/gcc/bfin-buildroot-linux-uclibc/6.1.0/../../../../bfin-buildroot-linux-uclibc/bin/ld:
final link failed: Bad value
collect2: error: ld returned 1 exit status

$ cat test.c
int main() {
 return(0);
}
$ ./output/host/usr/bin/bfin-buildroot-linux-uclibc-gcc -o t test.c
$ file t
t: ELF 32-bit LSB executable, Analog Devices Blackfin, version 1
(SYSV), dynamically linked (uses shared libs), not stripped
$ 

Any advice? Why does the hidden symbols in libgcc.a from the first-stage gcc, doesn't make it into libstdc++ shared library?

Quoted 8 lines

Buildroot first compiles gcc with --disable-shared and have then a libgcc.a. Afterwards the C library (uClibc-ng) is build. In the next step a full --enable-shared gcc including libstdc++ is build. This one is then somehow mislinked and then g++ can not compile a simple application.

It must be some architecture specific problem, because we are not seeing this kind of issues on any other architecture at the moment.

I think this might be solved by using a linker script for libgcc_so.so as described here:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=40134

But now I am fighting again with:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68468

How can the libgcc dwarf or sjlj execptions needed for C++ can be compiled for FDPIC toolchains?

best regards
Waldemar