免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2481 | 回复: 2
打印 上一主题 下一主题

[其它] 构建工具链--glibc的问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2017-03-31 16:54 |只看该作者 |倒序浏览
本帖最后由 kallytin 于 2017-03-31 17:07 编辑

交叉编译:
编译平台:ubuntu(i386,32位)
目标平台:linux(arm,32位)

问题:
在“目标平台”是arm的情况下,glibc的编译语句该如何?

  1. 现在的编译语句如下:
  2. ../glibc-2.15/configure --prefix=/usr
  3.                   --host=$TARGET
  4.                   --enable-kernel=3.7.4
  5.                   --enable-add-ones
  6.                   --with-headers=$SYSROOT/usr/include
  7.                   libc_cv_forced_unwind=yes
  8.                   libc_cv_c_cleanup=yes
  9.                   libc_cv_ctors_header=yes

  10. make
  11. make install_root=$SYSROOT install
复制代码



注:
我也baidu了一下,但真没有找到有用的信息,希望曾经编译成功过的大师能分享一下他们的信息....

附:

编译过程:
  1. #-----------------------------------------------------------------
  2. #cp source
  3. #-----------------------------------------------------------------
  4. binutils-2.23.1.tar.bz2
  5. gcc-4.7.2.tar.bz2
  6. glibc-2.15-cpuid.patch
  7. glibc-2.15-s_frexp.patch
  8. glibc-2.15.tar.xz
  9. gmp-5.0.5.tar.bz2
  10. linux-3.7.4.tar.xz
  11. mpc-1.0.1.tar.gz
  12. mpfr-3.1.1.tar.bz2


  13. #-----------------------------------------------------------------
  14. #apt-get install
  15. #-----------------------------------------------------------------
  16. sudo apt-get -y install gawk
  17. sudo apt-get -y install libtool

  18. #-----------------------------------------------------------------
  19. # 第三步:定义环境变量
  20. #-----------------------------------------------------------------

  21. unset LANG
  22. export HOST=i686-pc-linux-gnu
  23. export BUILD=\$HOST
  24. export TARGET=arm-unknown-linux-gnueabi
  25. export CROSS_TOOL=/dest/cross-tool
  26. export CROSS_GCC_TMP=/dest/cross-gcc-tmp
  27. export SYSROOT=/dest/sysroot
  28. PATH=\$CROSS_TOOL/bin:\$CROSS_GCC_TMP/bin:/sbin:/usr/sbin:\$PATH


  29. #-----------------------------------------------------------------
  30. # 第五步:构建二进制工具
  31. #-----------------------------------------------------------------


  32. cd /dest/build
  33. tar xvf ../source/binutils-2.23.1.tar.bz2
  34. mkdir binutils-build
  35. cd binutils-build
  36. ../binutils-2.23.1/configure --prefix=$CROSS_TOOL --target=$TARGET --with-sysroot=$SYSROOT
  37. make
  38. make install

  39. #-----------------------------------------------------------------
  40. # 第六步:编译 freestanding 交叉编译器
  41. #-----------------------------------------------------------------

  42. #1、

  43. cd /dest/build
  44. tar xvf ../source/gcc-4.7.2.tar.bz2

  45. #2、

  46. cd /dest/build/gcc-4.7.2
  47. tar xvf ../../source/gmp-5.0.5.tar.bz2
  48. mv gmp-5.0.5/ gmp

  49. tar xvf ../../source/mpfr-3.1.1.tar.bz2
  50. mv mpfr-3.1.1/ mpfr

  51. tar xvf ../../source/mpc-1.0.1.tar.gz
  52. mv mpc-1.0.1/ mpc

  53. #3、

  54. cd /dest/build
  55. mkdir gcc-build
  56. cd gcc-build
  57. ../gcc-4.7.2/configure --prefix=$CROSS_GCC_TMP --target=$TARGET --with-sysroot=$SYSROOT --with-newlib --enable-languages=c --with-mpfr-include=/dest/build/gcc-4.7.2/mpfr/src --with-mpfr-lib=/dest/build/gcc-build/mpfr/src/.libs --disable-shared --disable-threads --disable-decimal-float --disable-libquadmath --disable-libmudflap --disable-libgomp --disable-nls --disable-libssp
  58. make
  59. make install

  60. #4、

  61. cd /dest/cross-gcc-tmp
  62. ln -s libgcc.a lib/gcc/arm-unknown-linux-gnueabi/4.7.2/libgcc_eh.a

  63. #-----------------------------------------------------------------
  64. # 第七步:安装内核头文件
  65. #-----------------------------------------------------------------


  66. cd /dest/build
  67. tar xvf ../source/linux-3.7.4.tar.xz
  68. cd linux-3.7.4
  69. make mrproper
  70. make ARCH=arm headers_check
  71. make ARCH=arm INSTALL_HDR_PATH=$SYSROOT/usr/ headers_install

  72. #-----------------------------------------------------------------
  73. # 第八步:安装目标系统 C库
  74. #-----------------------------------------------------------------


  75. #2、

  76. cd /dest/build
  77. tar xvf ../source/glibc-2.15.tar.xz
  78. cd glibc-2.15
  79. patch -p1 < ../../source/glibc-2.15-cpuid.patch
  80. patch -p1 < ../../source/glibc-2.15-s_frexp.patch

  81. #3、

  82. cd /dest/build
  83. mkdir glibc-build
  84. cd glibc-build
  85. ../glibc-2.15/configure --prefix=/usr --host=$TARGET --enable-kernel=3.7.4 --enable-add-ones --with-headers=$SYSROOT/usr/include libc_cv_forced_unwind=yes libc_cv_c_cleanup=yes libc_cv_ctors_header=yes
  86. make
  87. make install_root=$SYSROOT install

  88. #-----------------------------------------------------------------
  89. # 第九步:构建完整的交叉编译器
  90. #-----------------------------------------------------------------

  91. #1、

  92. cd /dest/build
  93. cd gcc-build
  94. rm -rf *
  95. ../gcc-4.7.2/configure --prefix=$CROSS_TOOL --target=$TARGET --with-sysroot=$SYSROOT --with-mpfr-include=/dest/build/gcc-4.7.2/mpfr/src --with-mpfr-lib=/dest/build/gcc-build/mpfr/src/.libs --enable-languages=c,c++ --enable-threads=posix
  96. make
  97. make install
复制代码


第9步(构建完整交叉编译器)报错,如下:
  1. ...........
  2. ...........
  3. ../../../gcc-4.7.2/libgcc/../gcc/tsystem.h:88:19: fatal error: stdio.h: No such file or directory
  4. compilation terminated.
  5. make[2]: *** [_muldi3.o] Error 1
  6. make[2]: Leaving directory `/dest/build/gcc-build/arm-none-linux-gnueabi/libgcc'
  7. make[1]: *** [all-target-libgcc] Error 2
  8. make[1]: Leaving directory `/dest/build/gcc-build'
  9. make: *** [all] Error 2
  10. ...........
  11. ..........
  12. /bin/bash: line 3: cd: arm-none-linux-gnueabi/libstdc++-v3: No such file or directory
  13. make[1]: *** [install-target-libstdc++-v3] Error 1
  14. make[1]: Leaving directory `/dest/build/gcc-build'
  15. make: *** [install] Error 2
复制代码

问题定位:
  1. 1、在第8步,编译 glibc的时候,

  2. ........
  3. ........
  4. configure: WARNING: if you wanted to set the --build type, don't use --host.
  5.     If a cross compiler is detected then cross compile mode will be used
  6. checking build system type... i686-pc-linux-gnu
  7. checking host system type... arm-unknown-linux-gnueabi
  8. checking for arm-unknown-linux-gnueabi-gcc... arm-unknown-linux-gnueabi-gcc
  9. checking for suffix of object files... configure: error: in `/dest/build/glibc-build':
  10. configure: error: cannot compute suffix of object files: cannot compile
  11. See `config.log' for more details
  12. make: *** No targets specified and no makefile found.  Stop.
  13. make: *** No rule to make target `install'.  Stop.
  14. ........
  15. .......

  16. 最终导致 /dest/build/glibc-build/ 下没有相应的文件生成,继而最终使 stdio.h 也没有生成(正常
  17. 的应该是 /dest/sysroot/usr/include/stdio.h)

  18. 2、因为按照上面的各个步骤,在“目标平台”也是i386(现在是arm)时,是一切正常的,因此估计是 glibc
  19. 的编译选项出了问题。
复制代码


论坛徽章:
0
2 [报告]
发表于 2017-03-31 20:34 |只看该作者
..................................

论坛徽章:
0
3 [报告]
发表于 2017-04-01 09:53 来自手机 |只看该作者
有人知道吗?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP