statically linked gcc binaries

Emmanuel BOUAZIZ ebouaziz@neotion.com
Mon Jul 9 16:34:00 GMT 2012


Hello,

I'm trying to build differents ARM gcc compiler suites for x86_64 linux host.

I'd like it to be linked statically to gmp, mpfr, mpc, libelf, ppl and cloog, so that it's easy to install and behaves
the same independently of the libraries versions installed on the host.

So, I build each library with the '--disable-shared' switch, and finally build GCC with 'LDFLAGS=-static'

In all cases, it fails at link time, stating that it cannot find the thousands of symbols from libppl. Those symbol
names appear however in the libppl.a file.

For example, for the 4.6.1 suite with gmp-5.0.2, mpfr-3.0.1, mpc-0.9, libelf-0.8.13, ppl-0.11.2, and cloog-ppl-0.15.11,
I would do the following :

(mkdir, cd, make etc have been removed of course)

#GMP
LDFLAGS=-static ../../src/gmp-$GMP_VER/configure --prefix=/home/$USER/compilos/$GCC_VER/libs/ \
--enable-cxx --disable-shared

#MPFR
LDFLAGS=-static ../../src/mpfr-3.0.1/configure --with-gmp=/home/$USER/compilos/$GCC_VER/libs \
--prefix=/home/$USER/compilos/$GCC_VER/libs --disable-shared --disable-dependency-tracking

#MPC
LDFLAGS=-static ../../src/mpc-0.9/configure --prefix=/home/$USER/compilos/$GCC_VER/libs \
--with-gmp=/home/$USER/compilos/$GCC_VER/libs --with-mpfr=/home/$USER/compilos/$GCC_VER/libs \
--disable-shared --disable-dependency-tracking

#LIBELF
LDFLAGS=-static ../../src/libelf-0.8.13/configure --prefix=/home/$USER/compilos/$GCC_VER/libs --disable-shared

#PPL
LDFLAGS="-static -L/home/$USER/compilos/$GCC_VER/libs/lib -lstdc++" ../../src/ppl-$PPL_VER/configure \
--prefix=/home/$USER/compilos/$GCC_VER/libs --with-gmp=/home/$USER/compilos/$GCC_VER/libs --disable-shared \
--enable-optimization=sspeed --enable-arch=x86-64

#CLOOG
LDFLAGS="-static -L/home/$USER/compilos/$GCC_VER/libs/lib -lstdc++" \
../../src/cloog-*-$CLOOG_VER/configure --prefix=/home/$USER/compilos/$GCC_VER/libs \
--with-ppl-prefix=/home/$USER/compilos/$GCC_VER/libs --with-gmp-prefix=/home/$USER/compilos/$GCC_VER/libs \
--disable-shared

#BINUTILS
LDFLAGS="-static -L/home/$USER/compilos/$GCC_VER/libs/lib -lstdc++" CFLAGS="-O2 -m64" \
../../src/binutils-2.21.1/configure --prefix=$PREFIX --target=$TARGET --enable-static --disable-shared \
--disable-plugins --disable-nls --enable-multilibs --enable-interwork --disable-werror --disable-debug \
--disable-lto --with-gmp=/home/$USER/compilos/$GCC_VER/libs --with-mpfr=/home/$USER/compilos/$GCC_VER/libs \
--with-mpc=/home/$USER/compilos/$GCC_VER/libs --with-ppl=/home/$USER/compilos/$GCC_VER/libs \
--with-cloog=/home/$USER/compilos/$GCC_VER/libs

Note that all previous `make check` are OK

#GCC
LDFLAGS="-static -L/home/$USER/compilos/$GCC_VER/libs/lib -lstdc++" CFLAGS_FOR_BUILD="-O2 -m64" \
CFLAGS_FOR_TARGET="-O2" CFLAGS="-O2 -m64" CXXFLAGS_FOR_BUILD="-O2 -m64" CXXFLAGS_FOR_TARGET="-O2" CXXFLAGS="-O2 -m64" \
../../src/gcc-$GCC_VER/configure --prefix=$PREFIX --target=$TARGET --enable-static --disable-shared \
--with-gxx-include-dir=$PREFIX/$TARGET/include --with-gnu-as --with-gnu-ld --with-newlib \
--with-float=soft --disable-bigendian --disable-fpu --disable-underscore --enable-multilibs --with-float=soft \
--enable-interwork --disable-lto --disable-plugin \
--with-multilib-list=interwork --with-abi=aapcs --enable-languages=c,c++ --disable-debug --disable-__cxa_atexit \
--with-gmp=/home/$USER/compilos/$GCC_VER/libs --with-mpfr=/home/$USER/compilos/$GCC_VER/libs \
--with-mpc=/home/$USER/compilos/$GCC_VER/libs \
--with-ppl=/home/$USER/compilos/$GCC_VER/libs --with-cloog=/home/$USER/compilos/$GCC_VER/libs \
--with-libelf=/home/$USER/compilos/$GCC_VER/libs

during make, I get these errors:

gcc   -O2 -m64 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE  -W -Wall -Wwrite-strings -Wcast-qual -Wstrict-prototypes
-Wmissing-prototypes -Wmissing-format-attribute -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings
-Wold-style-definition -Wc++-compat   -DHAVE_CONFIG_H -static -L/home/ebouaziz/compilos/4.6.1/libs/lib -lstdc++ -o cc1plus \
              cp/cp-lang.o c-family/stub-objc.o cp/call.o cp/decl.o cp/expr.o cp/pt.o cp/typeck2.o cp/class.o cp/decl2.o
cp/error.o cp/lex.o cp/parser.o cp/ptree.o cp/rtti.o cp/typeck.o cp/cvt.o cp/except.o cp/friend.o cp/init.o cp/method.o
cp/search.o cp/semantics.o cp/tree.o cp/repo.o cp/dump.o cp/optimize.o cp/mangle.o cp/cp-objcp-common.o cp/name-lookup.o
cp/cxx-pretty-print.o cp/cp-gimplify.o tree-mudflap.o attribs.o incpath.o prefix.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 arm-c.o cc1plus-checksum.o main.o  libbackend.a ../libcpp/libcpp.a
../libdecnumber/libdecnumber.a ../libcpp/libcpp.a   ../libiberty/libiberty.a ../libdecnumber/libdecnumber.a
-L/home/ebouaziz/compilos/4.6.1/libs/lib -lcloog -L/home/ebouaziz/compilos/4.6.1/libs/lib -lppl_c -lppl  -lgmpxx
-L/home/ebouaziz/compilos/4.6.1/libs/lib -L/home/ebouaziz/compilos/4.6.1/libs/lib
-L/home/ebouaziz/compilos/4.6.1/libs/lib -lmpc -lmpfr -lgmp   -L../zlib -lz
/home/ebouaziz/compilos/4.6.1/libs/lib/libppl_c.a(ppl_c_implementation_common.o): In function `std::basic_ios<char,
std::char_traits<char> >::setstate(std::_Ios_Iostate)':
/usr/include/c++/4.7/bits/basic_ios.h:150: undefined reference to `std::basic_ios<char, std::char_traits<char>
>::clear(std::_Ios_Iostate)'
/home/ebouaziz/compilos/4.6.1/libs/lib/libppl_c.a(ppl_c_implementation_common.o): In function
`Parma_Polyhedra_Library::Interfaces::C::reset_timeout()':
/home/ebouaziz/compilos/4.6.1/build/ppl/interfaces/C/../../../../src/ppl-0.11.2/interfaces/C/ppl_c_implementation_common.cc:113:
undefined reference to `operator delete(void*)'
/home/ebouaziz/compilos/4.6.1/libs/lib/libppl_c.a(ppl_c_implementation_common.o): In function `~Watchdog':
/home/ebouaziz/compilos/4.6.1/build/ppl/interfaces/C/../../Watchdog/src/pwl.hh:1452: undefined reference to
`Parma_Watchdog_Library::Watchdog::in_critical_section'
/home/ebouaziz/compilos/4.6.1/build/ppl/interfaces/C/../../Watchdog/src/pwl.hh:1453: undefined reference to
`Parma_Watchdog_Library::Watchdog::remove_watchdog_event(Parma_Watchdog_Library::EList_Iterator<Parma_Watchdog_Library::Pending_Element<Parma_Watchdog_Library::Time>
>)'
/home/ebouaziz/compilos/4.6.1/build/ppl/interfaces/C/../../Watchdog/src/pwl.hh:1454: undefined reference to
`Parma_Watchdog_Library::Watchdog::in_critical_section'
/home/ebouaziz/compilos/4.6.1/libs/lib/libppl_c.a(ppl_c_implementation_common.o): In function
`Parma_Polyhedra_Library::Interfaces::C::reset_deterministic_timeout()':
/home/ebouaziz/compilos/4.6.1/build/ppl/interfaces/C/../../../../src/ppl-0.11.2/interfaces/C/ppl_c_implementation_common.cc:124:
undefined reference to `operator delete(void*)'
/home/ebouaziz/compilos/4.6.1/libs/lib/libppl_c.a(ppl_c_implementation_common.o): In function `initialize':
/home/ebouaziz/compilos/4.6.1/build/ppl/interfaces/C/../../src/ppl.hh:3576: undefined reference to `operator
new(unsigned long)'
/home/ebouaziz/compilos/4.6.1/build/ppl/interfaces/C/../../src/ppl.hh:3576: undefined reference to `operator delete(void*)'
/home/ebouaziz/compilos/4.6.1/libs/lib/libppl_c.a(ppl_c_implementation_common.o): In function `ppl_initialize':
/home/ebouaziz/compilos/4.6.1/build/ppl/interfaces/C/../../../../src/ppl-0.11.2/interfaces/C/ppl_c_implementation_common.cc:240:
undefined reference to `__cxa_begin_catch'
/home/ebouaziz/compilos/4.6.1/build/ppl/interfaces/C/../../../../src/ppl-0.11.2/interfaces/C/ppl_c_implementation_common.cc:240:
undefined reference to `__cxa_end_catch'
and so on...

I tried dozens of other combinations of versions and options, the problem remains the same (we have different
combinations depending on our SDK version: once a SDK version is tagged, the compiler to use with it is frozen).

I also tried to replay this line manually, changing the order of -L and -l options without success.

I also don't understand the first error about std::basic_ios, as -lstdc++ is present and I also tried to add
-L/usr/lib/x86_64-linux-gnu where the lib is present.

What am I doing wrong ?

regards,

-- 
Emmanuel



More information about the Gcc-help mailing list