gcc-4.6.1交叉编译时提示libiberty错误解决方法

GCC now requires the GMP, MPFR and MPC packages. As these packages may not be included in your host distribution, they will be built with GCC. Unpack each package into the GCC source directory and rename the resulting directories so the GCC build procedures will automatically use them:

tar -jxf ../mpfr-3.1.0.tar.bz2
mv -v mpfr-3.1.0 mpfr
tar -jxf ../gmp-5.0.2.tar.bz2
mv -v gmp-5.0.2 gmp
tar -zxf ../mpc-0.9.tar.gz
mv -v mpc-0.9 mpc

Apply a patch that will allow the building of the libiberty and zlib target libraries to be disabled as these do not build correctly in a cross-compiled environment:

patch -Np1 -i ../gcc-4.6.1-cross_compile-1.patch

The GCC documentation recommends building GCC outside of the source directory in a dedicated build directory:

mkdir -v ../gcc-build
cd ../gcc-build

Prepare GCC for compilation:

../gcc-4.6.1/configure \
    --target=$LFS_TGT --prefix=/tools \
    --disable-nls --disable-shared --disable-multilib \
    --disable-decimal-float --disable-threads \
    --disable-libmudflap --disable-libssp \
    --disable-libgomp --disable-libquadmath \
    --disable-target-libiberty --disable-target-zlib \
    --enable-languages=c --without-ppl --without-cloog \
    --with-mpfr-include=$(pwd)/../gcc-4.6.1/mpfr/src \
    --with-mpfr-lib=$(pwd)/mpfr/src/.libs

The meaning of the configure options:

--disable-shared

This switch forces GCC to link its internal libraries statically. We do this to avoid possible issues with the host system.

--disable-decimal-float, --disable-threads, --disable-libmudflap, --disable-libssp, --disable-libgomp, --disable-libquadmath --disable-target-libiberty --disable-target-zlib

These switches disable support for the decimal floating point extension, threading, libmudflap, libssp and libgomp, libquadmath, libiberty and zlib respectively. These features will fail to compile when building a cross-compiler and are not necessary for the task of cross-compiling the temporary libc.

--disable-multilib

On x86_64, LFS does not yet support a multilib configuration. This switch is harmless for x86.

--enable-languages=c

This option ensures that only the C compiler is built. This is the only language needed now.

--without-ppl, --without-cloog

These switches prevent GCC from building against the PPL and CLooG libraries which may be present on the host system, but will not be available in the chroot environment.

Compile GCC by running:

make

Compilation is now complete. At this point, the test suite would normally be run, but, as mentioned before, the test suite framework is not in place yet. The benefits of running the tests at this point are minimal since the programs from this first pass will soon be replaced.

Install the package:

make install

Using --disable-shared means that the libgcc_eh.a file isn't created and installed. The Glibc package depends on this library as it uses-lgcc_eh within its build system. This dependency can be satisfied by creating a symlink tolibgcc.a, since that file will end up containing the objects normally contained inlibgcc_eh.a:

ln -vs libgcc.a `$LFS_TGT-gcc -print-libgcc-file-name | \
    sed 's/libgcc/&_eh/'`

 

 

编译之后会出现

gtype-desc.c:8829:18: error: subscripted value is neither array nor pointer nor vector

 

修改

gcc/gengtype.c

static void

write_field_root (outf_p f, pair_p v, type_p type, const char *name,

          int has_length, struct fileloc *line, const char *if_marked,

          bool emit_pch, type_p field_type, const char *field_name)

{

  struct pair newv;// 修改这里

  /* If the field reference is relative to V, rather than to some

     subcomponent of V, we can mark any subarrays with a single stride.

     We're effectively treating the field as a global variable in its

     own right.  */

  if (v && type == v->type)

    {

      //struct pair newv;

 

      newv = *v;

      newv.type = field_type;

 

 

 

终于编译成功

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值