Солярис - скомпилировать 64-битный GCC - ошибка класса эльфов - PullRequest
1 голос
/ 22 марта 2011

Я устанавливаю современную версию gcc на солярис. Я скомпилировал gmp, mpfr и mpc, они все 64-битные. Когда я пытаюсь настроить gcc следующим образом, я получаю сообщение об ошибке, в котором говорится, что mpc, mpfr и gmp - неправильный класс elf. Что дает?

./../gcc-4.5.1/configure --prefix=/opt/OurAppDir/gcc --with-gmp=/opt/OurAppDir/gmp --with-mpfr=/opt/OurAppDir/mpfr --with-gnu-as --with-gnu-ld --build=sparc-sun-solaris2.10
checking build system type... sparc-sun-solaris2.10
checking host system type... sparc-sun-solaris2.10
checking target system type... sparc-sun-solaris2.10
checking for a BSD-compatible install... ./../gcc-4.5.1/install-sh -c
checking whether ln works... yes
checking whether ln -s works... yes
checking for a sed that does not truncate output... /usr/bin/sed
checking for gawk... no
checking for mawk... no
checking for nawk... nawk
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking for gnatbind... no
checking for gnatmake... no
checking whether compiler driver understands Ada... no
checking how to compare bootstrapped objects... cmp $$f1 $$f2 16 16
checking for objdir... .libs
checking for the correct version of gmp.h... yes
checking for the correct version of mpfr.h... yes
checking for the correct version of mpc.h... yes
checking for the correct version of the gmp/mpfr/mpc libraries... no
configure: error: Building GCC requires GMP 4.2+, MPFR 2.3.1+ and MPC 0.8.0+.
Try the --with-gmp, --with-mpfr and/or --with-mpc options to specify
their locations.  Source code for these libraries can be found at
their respective hosting sites as well as at
ftp://gcc.gnu.org/pub/gcc/infrastructure/.  See also
http://gcc.gnu.org/install/prerequisites.html for additional info.  If
you obtained GMP, MPFR and/or MPC from a vendor distribution package,
make sure that you have installed both the libraries and the header
files.  They may be located in separate packages.

ошибки config.log

configure:5474: checking for the correct version of gmp.h
configure:5494: gcc -c -g -O2 -I/opt/OurAppDir/gmp/include -I/opt/OurAppDir/mpfr/include   conftest.c >&5
configure:5494: $? = 0
configure:5512: gcc -c -g -O2 -I/opt/OurAppDir/gmp/include -I/opt/OurAppDir/mpfr/include   conftest.c >&5
configure:5512: $? = 0
configure:5513: result: yes
configure:5529: checking for the correct version of mpfr.h
configure:5547: gcc -c -g -O2 -I/opt/OurAppDir/gmp/include -I/opt/OurAppDir/mpfr/include   conftest.c >&5
configure:5547: $? = 0
configure:5564: gcc -c -g -O2 -I/opt/OurAppDir/gmp/include -I/opt/OurAppDir/mpfr/include   conftest.c >&5
configure:5564: $? = 0
configure:5565: result: yes
configure:5582: checking for the correct version of mpc.h
configure:5599: gcc -c -g -O2 -I/opt/OurAppDir/gmp/include -I/opt/OurAppDir/mpfr/include   conftest.c >&5
configure:5599: $? = 0
configure:5615: gcc -c -g -O2 -I/opt/OurAppDir/gmp/include -I/opt/OurAppDir/mpfr/include   conftest.c >&5
configure:5615: $? = 0
configure:5616: result: yes
configure:5634: checking for the correct version of the gmp/mpfr/mpc libraries
configure:5665: gcc -o conftest -g -O2 -I/opt/OurAppDir/gmp/include -I/opt/OurAppDir/mpfr/include   -R/usr/sfw/lib/sparcv9 conftest.c  -L/opt/OurAppDir/gmp/lib -L/opt/OurAppDir/m
pfr/lib -lmpc -lmpfr -lgmp >&5
ld: fatal: file /opt/OurAppDir/mpfr/lib/libmpc.so: wrong ELF class: ELFCLASS64
ld: fatal: file /opt/OurAppDir/mpfr/lib/libmpfr.so: wrong ELF class: ELFCLASS64
ld: fatal: file /opt/OurAppDir/gmp/lib/libgmp.so: wrong ELF class: ELFCLASS64
ld: fatal: File processing errors. No output written to conftest

Ответы [ 2 ]

1 голос
/ 06 декабря 2011

Вам не нужны 64-битные двоичные файлы gcc для создания 64-битного приложения.Пакеты OpenCSW Solaris предоставляют 32-битный компилятор с 32-битными и 64-битными целевыми объектами.

Я предполагаю, что вы больше заботитесь о возможности генерировать 64-битные двоичные файлы из вашего gcc, и меньше о том, чтобы сам gcc был 64-bit.

Чтобы создать 32-битные и 64-битные цели, вам нужно собрать gmp два раза, один раз 32-битный и один раз 64-битный.Затем у вас есть следующий макет (пример взят из пакета pkgmap):

1 f none /opt/csw/include/gmp-32.h 0644 root bin 86213 38841 1316878625
1 f none /opt/csw/include/gmp-64.h 0644 root bin 86218 39139 1316879685
1 f none /opt/csw/include/gmp.h 0755 root bin 159 12880 1316879688
1 f none /opt/csw/include/gmpxx-32.h 0644 root bin 114646 51865 1316878625
1 f none /opt/csw/include/gmpxx-64.h 0644 root bin 114646 51865 1316879685
1 f none /opt/csw/include/gmpxx.h 0755 root bin 163 13360 1316879688
1 s none /opt/csw/lib/libgmp.so=libgmp.so.10.0.2
1 s none /opt/csw/lib/libgmpxx.so=libgmpxx.so.4.2.2
1 s none /opt/csw/lib/libgmp.so.10=libgmp.so.10.0.2
1 f none /opt/csw/lib/libgmp.so.10.0.2 0755 root bin 462552 51359 1316878625
1 s none /opt/csw/lib/sparcv9/libgmp.so.10=libgmp.so.10.0.2
1 f none /opt/csw/lib/sparcv9/libgmp.so.10.0.2 0755 root bin 503424 11223 1316879684

Система сборки GCC достаточно умна, чтобы знать, что такое /opt/csw/lib/sparcv9 для 64-битных библиотек и /opt/csw/lib для 32-битных библиотек.

Заголовочный файл gmp.h представляет собой оболочку, которая содержит оператор #ifdef, включая gmp-32.h или gmp-64.h в зависимости от запрошенного режима компиляции.

/* Allow 32 and 64 bit headers to coexist */
#if defined __amd64 || defined __x86_64 || defined __sparcv9
#include "gmp-64.h"
#else
#include "gmp-32.h"
#endif

Библиотека gmp является единственной, для которой требуется этот тип оболочки файла заголовка;библиотеки mpc, mpfr, ppl и cloog не меняют заголовочные файлы в зависимости от архитектуры / длины слова.

Когда вы компилируете gcc с 64-битными целями, вы получаете макет с двумя файлами crt1.o:

/opt/csw/lib/gcc/sparc-sun-solaris2.9/4.6.2/crt1.o
/opt/csw/lib/gcc/sparc-sun-solaris2.9/4.6.2/sparcv9/crt1.o

Таким образом, когда вы передаете -m64, gcc создаст 64-битный двоичный файл.

1 голос
/ 23 марта 2011

При использовании строки конфигурации по умолчанию GCC будет построен не как 64-разрядный двоичный файл, а как 32-разрядный.Таким образом, вам нужно перестроить GMP, MPFR и MPC в 32-битном режиме, принудительно задав configure ABI=32.

В качестве альтернативы, вы можете настроить GCC с помощью sparc64-sun-solarisX триплета сборки.В этом случае на веб-сайте GCC есть дополнительные инструкции .

...