首页 文章

构建交叉编译64位GCC失败

提问于
浏览
4

我正在尝试创建一个工作的gcc交叉编译器,它存在于我的本地机器上[Darwin new-host-2.home 10.7.4 Darwin Kernel Version 10.7.4:Mon Apr 18 21:24:17 PDT 2011; root:xnu-1504.14.12~3 / RELEASE_X86_64 x86_64]并以FreeBSD 8.2 x86_64(FreeBSD中的AMD64)为目标 .

我正在编译gcc 4.3.1,binutils 2.19,GMP 4.2.3,MPFR 2.3.2 .

我看到了一些可能出错的事情,但它们可能是红色的鲱鱼 . 为了它的 Value ,我正在使用已知的工作脚本来构建交叉编译器,并且只是尝试让它们为x86_64架构工作,所以我知道我不在左边的领域 .

我正在使用gcc编译器目标"x86_64-pc-freebsd7",这似乎是正确的 . 我使用的编译器标志: compilerConfigureFlags="--enable-version-specific-runtime-libs --enable-shared --enable-threads=posix --disable-checking --disable-libunwind-exceptions --with-system-zlib --enable-__cxa_atexit" 并使用 "--enable-64-bit-bfd" 配置binutils

在我最后的错误;引起我注意的是'-m32',我的"incompatible"文件 /Developer/Cocotron/1.0/FreeBSD/x86_64/gcc-4.3.1/x86_64-pc-freebsd7/lib/libc.a when searching for -lc . 当我从FreeBSD框中的libc.a和libc.so上运行 file 时,我得到:

sh-3.2#file /Developer/Cocotron/1.0/FreeBSD/x86_64/gcc-4.3.1/x86_64-pc-freebsd7/lib/libc.a/Developer/Cocotron/1.0/FreeBSD/x86_64/gcc-4.3.1 /x86_64-pc-freebsd7/lib/libc.a:urrent ar archive

sh-3.2#file /Developer/Cocotron/1.0/FreeBSD/x86_64/gcc-4.3.1/x86_64-pc-freebsd7/lib/libc.so/Developer/Cocotron/1.0/FreeBSD/x86_64/gcc-4.3.1 /x86_64-pc-freebsd7/lib/libc.so:ELF 64位LSB共享对象,x86-64,版本1(FreeBSD),动态链接,剥离

最后一行我的构建死了:

/Developer/Cocotron/1.0/build/FreeBSD/x86_64/gcc-4.3.1/./gcc/xgcc -B / Developer / Cocotron / 1.0 / build / FreeBSD / x86_64 / gcc-4.3.1 /./ gcc / -B / Developer / Cocotron / 1.0 / FreeBSD / x86_64 / gcc-4.3.1 / x86_64-pc-freebsd7 / bin / -B / Developer / Cocotron / 1.0 / FreeBSD / x86_64 / gcc-4.3.1 / x86_64-pc- freebsd7 / lib / -isystem /Developer/Cocotron/1.0/FreeBSD/x86_64/gcc-4.3.1/x86_64-pc-freebsd7/include -isystem /Developer/Cocotron/1.0/FreeBSD/x86_64/gcc-4.3.1/x86_64 -pc-freebsd7 / sys-include -O2 -O2 -g -m32 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE -DNATIVE_CROSS -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -isystem ./include - fPIC -pthread -g -DHAVE_GTHR_DEFAULT -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED -shared -nodefaultlibs -Wl, - soname = libgcc_s.so.1 -Wl, - version-script = libgcc.map -o ./libgcc_s.so.1.tmp -O2 -g -m32 -B./ _muldi3_s.o _negdi2_s.o _lshrdi3_s.o _ashldi3_s.o _ashrdi3_s.o _cmpdi2_s.o _ucmpdi2_s.o _clear_cache_s.o _enable_execute_stack_s.o _trampoline_s.o __main_s.o _absvsi2_s.o _absvdi2_s.o _addvsi3_s.o _addvdi3_s.o _subvsi3_s.o _subvdi3_s.o _mulvsi3_s.o _mulvdi3_s.o _negvsi2_s.o _negvdi2_s.o _ctors_s.o _ffssi2_s.o _ffsdi2_s.o _clz_s.o _clzsi2_s.o _clzdi2_s.o _ctzsi2_s.o _ctzdi2_s . o _popcount_tab_s.o _popcountsi2_s.o _popcountdi2_s.o _paritysi2_s.o _paritydi2_s.o _powisf2_s.o _powidf2_s.o _powixf2_s.o _powitf2_s.o _mulsc3_s.o _muldc3_s.o _mulxc3_s.o _multc3_s.o _divsc3_s.o _divdc3_s.o _divxc3_s.o _divtc3_s .o _bswapsi2_s.o _bswapdi2_s.o _fixunssfsi_s.o _fixunsdfsi_s.o _fixunsxfsi_s.o _fixsfdi_s.o _fixdfdi_s.o _fixxfdi_s.o _fixtfdi_s.o _fixunssfdi_s.o _fixunsdfdi_s.o _fixunsxfdi_s.o _fixunstfdi_s.o _floatdisf_s.o _floatdidf_s.o _floatdixf_s.o _floatditf_s.o _floatundisf_s.o _floatundidf_s.o _floatundixf_s.o _floatunditf_s.o _divdi3_s.o _moddi3_s.o _udivdi3_s.o _umoddi3_s.o _udiv_w_sdiv_s.o _udivmoddi4_s.o unwind-dw2_s.o unwind-dw2-fde_s.o unwind-sjlj_s.o gthr-gnat_s.o unwind-c_s.o emutls_s.o -lc && rm -f ./libgcc_s.so&& if [-f ./libgcc_s.so.1];然后是mv -f ./libgcc_s.so.1 ./libgcc_s.so.1.backup;否则是真的; fi && mv ./libgcc_s.so.1.tmp ./libgcc_s.so.1&& ln -s libgcc_s.so.1 ./libgcc_s.so /Developer/Cocotron/1.0/FreeBSD/x86_64/gcc-4.3.1/ x86_64-pc-freebsd7 / bin / ld:在搜索-lc / Developer / Cocotron时跳过不兼容的/Developer/Cocotron/1.0/FreeBSD/x86_64/gcc-4.3.1/x86_64-pc-freebsd7/lib//libc.so /1.0/FreeBSD/x86_64/gcc-4.3.1/x86_64-pc-freebsd7/bin/ld:跳过不兼容/Developer/Cocotron/1.0/FreeBSD/x86_64/gcc-4.3.1/x86_64-pc-freebsd7/lib/ libc.a搜索-lc /Developer/Cocotron/1.0/FreeBSD/x86_64/gcc-4.3.1/x86_64-pc-freebsd7/bin/ld时:找不到-lc collect2:ld返回1退出状态make [2] :*** [libgcc_s.so]错误1 make [1]:*** [all-target-libgcc]错误2 make:*** [all]错误2

我很惊讶ld无法处理它,因为当我运行这个版本的'ld'时,我得到了followig输出:

/Developer/Cocotron/1.0/FreeBSD/x86_64/gcc-4.3.1/x86_64-pc-freebsd7/bin/ld:支持的目标:elf64-x86-64-freebsd elf32-i386-freebsd coff-i386 efi-app-ia32 efi-bsdrv-ia32 efi-rtdrv-ia32 efi-app-x86_64 efi-bsdrv-x86_64 efi-rtdrv-x86_64 elf32-i386 elf64- x86-64 elf64-little elf64-big elf32-little elf32-big srec symbolsrec tekhex binary ihex /Developer/Cocotron/1.0/FreeBSD/x86_64/gcc-4.3.1/x86_64-pc-freebsd7/bin/ld:支持仿真: elf_x86_64_fbsd elf_i386_fbsd elf_x86_64 elf_i386 /Developer/Cocotron/1.0/FreeBSD/x86_64/gcc-4.3.1/x86_64-pc-freebsd7/bin/ld:仿真特定选项:elf_x86_64_fbsd:

这告诉我,我已经正确构建了binutils ..但是无法处理一个ELF 64位x86-64 FreeBSD共享对象的库?

从一开始就讲述故事 - 编译binutils看起来完美无瑕 .

编译GMP和MPFR都给了我一些令我担心的ranlib问题,尝试 Build 一个.a库,但.o文件没有符号..这可能是正常但我不知道?

GMP:

/ usr / bin / ranlib:file:.libs / libprintf.a(obprintf.o)没有符号
/ usr / bin / ranlib:file:.libs / libprintf.a(obvprintf.o)没有符号
/ usr / bin / ranlib:file:.libs / libprintf.a(obprntffuns.o)没有符号
/ usr / bin / ranlib:file:.libs / libprintf.a(repl-vsnprintf.o)没有符号
ranlib .libs / libprintf.a
ranlib:file:.libs / libprintf.a(obprintf.o)没有符号
ranlib:file:.libs / libprintf.a(obvprintf.o)没有符号
ranlib:file:.libs / libprintf.a(obprntffuns.o)没有符号
ranlib:file:.libs / libprintf.a(repl-vsnprintf.o)没有符号

而且我还有更多的东西......

ranlib /Developer/Cocotron/1.0/FreeBSD/x86_64/gcc-4.3.1/lib/libgmp.a
ranlib:file:/Developer/Cocotron/1.0/FreeBSD/x86_64/gcc-4.3.1/lib/libgmp.a(mp_clz_tab.o)没有符号
ranlib:file:/Developer/Cocotron/1.0/FreeBSD/x86_64/gcc-4.3.1/lib/libgmp.a(obprintf.o)没有符号
ranlib:file:/Developer/Cocotron/1.0/FreeBSD/x86_64/gcc-4.3.1/lib/libgmp.a(obvprintf.o)没有符号
ranlib:file:/Developer/Cocotron/1.0/FreeBSD/x86_64/gcc-4.3.1/lib/libgmp.a(obprntffuns.o)没有符号
ranlib:file:/Developer/Cocotron/1.0/FreeBSD/x86_64/gcc-4.3.1/lib/libgmp.a(repl-vsnprintf.o)没有符号

MPFR:

类似的交易:

/usr/bin/ranlib: file: .libs/libmpfr.a(volatile.o) has no symbols
/usr/bin/ranlib: file: .libs/libmpfr.a(mp_clz_tab.o) has no symbols
/usr/bin/ranlib: file: .libs/libmpfr.a(logging.o) has no symbols
/usr/bin/ranlib: file: .libs/libmpfr.a(set_d64.o) has no symbols
/usr/bin/ranlib: file: .libs/libmpfr.a(get_d64.o) has no symbols
ranlib .libs/libmpfr.a
ranlib: file: .libs/libmpfr.a(volatile.o) has no symbols
ranlib: file: .libs/libmpfr.a(mp_clz_tab.o) has no symbols
ranlib: file: .libs/libmpfr.a(logging.o) has no symbols
ranlib: file: .libs/libmpfr.a(set_d64.o) has no symbols
ranlib: file: .libs/libmpfr.a(get_d64.o) has no symbols
creating libmpfr.la

还有一点......

ranlib /Developer/Cocotron/1.0/FreeBSD/x86_64/gcc-4.3.1/lib/libmpfr.a
ranlib: file: /Developer/Cocotron/1.0/FreeBSD/x86_64/gcc-4.3.1/lib/libmpfr.a(volatile.o) has no symbols
ranlib: file: /Developer/Cocotron/1.0/FreeBSD/x86_64/gcc-4.3.1/lib/libmpfr.a(mp_clz_tab.o) has no symbols
ranlib: file: /Developer/Cocotron/1.0/FreeBSD/x86_64/gcc-4.3.1/lib/libmpfr.a(logging.o) has no symbols
ranlib: file: /Developer/Cocotron/1.0/FreeBSD/x86_64/gcc-4.3.1/lib/libmpfr.a(set_d64.o) has no symbols
ranlib: file: /Developer/Cocotron/1.0/FreeBSD/x86_64/gcc-4.3.1/lib/libmpfr.a(get_d64.o) has no symbols

然后我们接受GCC,大概是有很好的binutils,GMP和MPFR ......但最后在构建gcc(特别是libgcc)时我得到了ld链接失败 .


一些更多的支持信息:

我用以下方法编译binutils:

CFLAGS="-m32 -Wformat=0 -Wno-error=deprecated-declarations" $sourceFolder/binutils-$binutilsVersion/configure --prefix="$resultFolder" --target=$compilerTarget $binutilsConfigureFlags

但是,如果我切换到-m64,我会遇到同样的问题..

CFLAGS="-m64 -Wformat=0 -Wno-error=deprecated-declarations" $sourceFolder/binutils-$binutilsVersion/configure --prefix="$resultFolder" --target=$compilerTarget $binutilsConfigureFlags

我使用以下方法编译GMP和MPFR:

ABI=32 $sourceFolder/gmp-$gmpVersion/configure --prefix="$resultFolder"

我用以下方法编译GCC:

CFLAGS="-m32" $sourceFolder/gcc-$gccVersion/configure -v --prefix="$resultFolder" --target=$compilerTarget \
                --with-gnu-as --with-gnu-ld --with-headers=$resultFolder/$compilerTarget/include \
                --without-newlib --disable-multilib --disable-libssp --disable-nls --enable-languages="$enableLanguages" \
                --with-gmp=$buildFolder/gmp-$gmpVersion --enable-decimal-float --with-mpfr=$resultFolder --enable-checking=release \
                --enable-objc-gc \ 
                $compilerConfigureFlags

对于所有这些,我正在使用:

compilerTarget=x86_64-pc-freebsd7
compilerConfigureFlags="--enable-version-specific-runtime-libs --enable-shared --enable-threads=posix --disable-checking --disable-libunwind-exceptions --with-system-zlib --enable-__cxa_atexit"
binutilsConfigureFlags="--enable-64-bit-bfd"

在我的目标FreeBSD系统上,顺便说一句是标准的FreeBSD 8.2 RELEASE amd64,ld表示我的交叉编译功能非常相似 . 事实上,似乎我的交叉编译环境的ld处理了实际目标的ld处理的超集 - 让我觉得我应该能够处理任何文件而没有我看到的不兼容性

ld: supported targets: elf64-x86-64 efi-app-ia32 elf32-i386-freebsd srec symbolsrec tekhex binary ihex
ld: supported emulations: elf_i386_fbsd elf_x86_64_fbsd
ld: emulation specific options:
elf_i386_fbsd:

1 回答

  • 2

    64位库只能链接到64位目标代码 . 您需要 -m64 来构建64位目标代码, -m32 确实产生32位目标代码 .

相关问题