Pyromancer
Pyromancer

Reputation: 133

How to resolve '__tls_get_addr@@GLIBC_2.3' error on compiling GCC itself?

The Background: A client has a set of legacy SuSE servers which require glibc updating to patch the 'Ghost' vulnerability. These machines have never been updated and are running old versions of gcc and glibc from about 2005. Attempting to compile current glibc gives errors that a more up to date gcc is required, so I am attempting to upgrade gcc.

The problem: A very long way through the make for gcc, it fails with the following error (short version - longer version further down post):

undefined reference to symbol '__tls_get_addr@@GLIBC_2.3'
/lib64/ld-linux-x86-64.so.2: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

Research and investigations already tried:

From Googling I know this is a linker issue. The gcc infrastructure systems, including ld, have all been upgraded successfully to binutils-2.25

I've tried changing LDFLAGS = to LDFLAGS = -lz in the Makefile, which is suggested as a fix for similar problems affecting Oracle installs, but this makes no difference.

I've tried installing a slightly older gcc (4.8 instead of 4.92), gives the same error at the same place.

Unfortunately trying to search for issues relating to compiling gcc itself tends to produce lots of results about using gcc to compile other things, making searches difficult.

Detailed background and error message:

Installing gcc has many prerequisites, before I could get this install under way I had to upgrade gmp, mpfr, and mpc. Gmp and mpfr installed successfully, but it was only possible to get mpc to compile by adding --disable-shared to the ./configure command.

A full list of what has been installed:

binutils-2.25, gmp-4.3.2, mpfr-2.4.2, mpc-0.8.1

Configuration command (running from an adjacent build directory as recommended by the gcc team):

../gcc-4.9.2/configure --with-gmp=/usr/local --with-mpfr=/usr/local --with-mpc=/usr/local

The full error message:

make[3]: Entering directory /usr/local/src/gcc-4.9.2-build/gcc' /usr/local/src/gcc-4.9.2-build/./prev-gcc/xg++ -B/usr/local/src/gcc-4.9.2-build/./prev-gcc/ -B/usr/local/x86_64-unknown-linux-gnu/bin/ -nostdinc++ -B/usr/local/src/gcc-4.9.2-build/prev-x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs -B/usr/local/src/gcc-4.9.2-build/prev-x86_64-unknown-linux-gnu/libstdc++-v3/libsupc++/.libs -I/usr/local/src/gcc-4.9.2-build/prev-x86_64-unknown-linux-gnu/libstdc++-v3/include/x86_64-unknown-linux-gnu -I/usr/local/src/gcc-4.9.2-build/prev-x86_64-unknown-linux-gnu/libstdc++-v3/include -I/usr/local/src/gcc-4.9.2/libstdc++-v3/libsupc++ -L/usr/local/src/gcc-4.9.2-build/prev-x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs -L/usr/local/src/gcc-4.9.2-build/prev-x86_64-unknown-linux-gnu/libstdc++-v3/libsupc++/.libs -g -O2 -gtoggle -DIN_GCC -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -DHAVE_CONFIG_H -static-libstdc++ -static-libgcc -o cc1 c/c-lang.o c-family/stub-objc.o attribs.o c/c-errors.o c/c-decl.o c/c-typeck.o c/c-convert.o c/c-aux-info.o c/c-objc-common.o c/c-parser.o c/c-array-notation.o c-family/c-common.o c-family/c-cppbuiltin.o c-family/c-dump.o c-family/c-format.o c-family/c-gimplify.o c-family/c-lex.o c-family/c-omp.o c-family/c-opts.o c-family/c-pch.o c-family/c-ppoutput.o c-family/c-pragma.o c-family/c-pretty-print.o c-family/c-semantics.o c-family/c-ada-spec.o c-family/c-cilkplus.o c-family/array-notation-common.o c-family/cilk.o c-family/c-ubsan.o i386-c.o glibc-c.o \ cc1-checksum.o libbackend.a main.o libcommon-target.a libcommon.a ../libcpp/libcpp.a ../libdecnumber/libdecnumber.a libcommon.a ../libcpp/libcpp.a
../libbacktrace/.libs/libbacktrace.a ../libiberty/libiberty.a ../libdecnumber/libdecnumber.a -L/usr/local/lib -L/usr/local/lib -L/usr/local/lib -lmpc -lmpfr -lgmp -rdynamic -ldl -L../zlib -lz /usr/local/x86_64-unknown-linux-gnu/bin/ld: /usr/local/src/gcc-4.9.2-build/prev-x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs/libstdc++.a(eh_globals.o): undefined reference to symbol '__tls_get_addr@@GLIBC_2.3' /lib64/ld-linux-x86-64.so.2: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status make[3]: *** [cc1] Error 1 make[3]: Leaving directory
/usr/local/src/gcc-4.9.2-build/gcc' make[2]: * [all-stage2-gcc] Error 2 make[2]: Leaving directory /usr/local/src/gcc-4.9.2-build' make[1]: *** [stage2-bubble] Error 2 make[1]: Leaving directory /usr/local/src/gcc-4.9.2-build' make: * [all] Error 2

Upvotes: 5

Views: 10225

Answers (3)

nicolas xu
nicolas xu

Reputation: 1

I met the same issue when building QT5.3 or greater QT versions from source code.

my system background:

the OS : Linux iaschn 2.6.9-89.0.25.ELsmp #1 SMP Thu May 6 12:33:40 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux

the gcc: Using built-in specs. COLLECT_GCC=./gcc COLLECT_LTO_WRAPPER=/rapid/rapid_tools/REL_4.7/x86_64/gcc-5.3.0/libexec/gcc/x86_64-unknown-linux-gnu/5.3.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ../../src/gcc-5.3.0/configure CC=gcc4 CXX=g++4 --enable-languages=c,c++ --prefix=/rapid/rapid_tools/REL_4.7/x86_64/gcc-5.3.0 Thread model: posix gcc version 5.3.0 (GCC)

the binutils are: GNU ld version 2.26.20160125 Copyright (C) 2015 Free Software Foundation, Inc. This program is free software; you may redistribute it under the terms of the GNU General Public License version 3 or (at your option) a later version. This program has absolutely no warranty.

while, I have been struggling on this issue for a long time, searched info on Google and **google said: manually add dynamical link at the end of command line:

-L/lib64 -l:ld-linux-x86-64.so.2

It passed above issue, while the compiled binary doesn't work at all.

I later checked out minimal requirements for QT5.3 or greater versions. checked out that glibc needs to be greater than 2.8.3 , So, I am afaid that you might have the same issue on glibc.

so, the solution might be:

upgrade glibc

Upvotes: 0

zbeekman
zbeekman

Reputation: 678

I ran into a similar issue building a code on a Cray xc40/50 system. My issue was that, since Cray has to change every last thing from a default, you have to pass an extra flag to the compiler wrappers. (The compiler wrappers are cc, CC and ftn for C, C++, and Fortran.) The flag you need to pass, -dynamic is documented in the man page for the wrappers. You can tell the underlying compiler to link statically or dynamically but without passing this flag to the wrapper you're out of luck.

Upvotes: 1

Tushar
Tushar

Reputation: 11

I had a similar issue after I upgrade binutils to 2.26 on a Centos 4.9 machine. The newer linkers need /lib64/ld-linux-x86-64.so.2 to be included, but they need to be included at the end of the DSO list win option --as-needed

To get it right, invoke the linker via the compiler and add the stuff in bold following to /usr/lib64/libc.so

/* GNU ld script Use the shared library, but some functions are only in the static library, so try that secondarily. */ OUTPUT_FORMAT(elf64-x86-64) GROUP ( /lib64/libc.so.6 /usr/lib64/libc_nonshared.a AS_NEEDED ( /lib64/ld-linux-x86-64.so.2 ) )

This worked for me

Upvotes: 1

Related Questions