LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1086|回复: 13

LFS 6.2 调整工具链时的疑问 Chapter 5.7

[复制链接]
发表于 2007-3-1 20:50:40 | 显示全部楼层 |阅读模式
第一个问题
按照LFS 6.2的文档来看, youbest 大作
http://www.linuxsir.cn/bbs/showthread.php?t=244052提到的
  1. [color="Red"]cd binutils-build
  2. make -C ld install
  3. cd ..
  4. rm -rf binutils-build
  5. rm -rf binutils-2.15.94.0.2.2[/color]
  6. SPECFILE=$(gcc --print-file specs) &&
  7. sed 's@ /lib/ld-linux.so.2@ /tools/lib/ld-linux.so.2@g' $SPECFILE > tempspecfile &&
  8. mv -f tempspecfile $SPECFILE &&
  9. unset SPECFILE
  10. rm -vf /tools/lib/gcc/*/*/include/{pthread.h,bits/sigthread.h}
复制代码

红色标记出的并没有在 5.7节中提到.
5.7里是这样的:

  1. 5.7. Adjusting the Toolchain
  2. Now that the temporary C libraries have been installed, all tools compiled in the rest of this chapter should be
  3. linked against these libraries. In order to accomplish this, the linker and the compiler's specs file need to be
  4. adjusted.
  5. The linker, adjusted at the end of the first pass of Binutils, needs to be renamed so that it can be properly found
  6. and used. First, backup the original linker, then replace it with the adjusted linker. We'll also create a link to its
  7. counterpart in /tools/$(gcc -dumpmachine)/bin
  8. mv -v /tools/bin/{ld,ld-old}
  9. mv -v /tools/$(gcc -dumpmachine)/bin/{ld,ld-old}
  10. mv -v /tools/bin/{ld-new,ld}
  11. ln -sv /tools/bin/ld /tools/$(gcc -dumpmachine)/bin/ld
  12. From this point onwards, everything will link only against the libraries in /tools/lib.
  13. The next task is to point GCC to the new dynamic linker. This is done by dumping GCC's “specs” file to a
  14. location where GCC will look for it by default. A simple sed substitution then alters the dynamic linker that
  15. GCC will use:
  16. SPECFILE=`dirname $(gcc -print-libgcc-file-name)`/specs &&
  17. gcc -dumpspecs > $SPECFILE &&
  18. sed 's@^/lib/ld-linux.so.2@/tools&@g' $SPECFILE > tempspecfile &&
  19. mv -vf tempspecfile $SPECFILE &&
  20. unset SPECFILE
复制代码

不知红色部分的命令是否要执行?

第二个问题
LFS 6.2  Chapter 5.7中提到
  1. mv -v /tools/bin/{ld,ld-old}
  2. mv -v /tools/$(gcc -dumpmachine)/bin/{ld,ld-old}
  3. mv -v /tools/bin/{ld-new,ld}
  4. ln -sv /tools/bin/ld /tools/$(gcc -dumpmachine)/bin/ld
复制代码

第三条命令我很疑惑, 即
  1. mv -v /tools/bin/{ld-new,ld}
复制代码

/tools/bin/ld-new 是如何得到的?
因为我执行后出现了错误.如下:
  1. lfs:/mnt/lfs/sources$ mv -v /tools/bin/{ld,ld-old}
  2. `/tools/bin/ld' -> `/tools/bin/ld-old'
  3. lfs:/mnt/lfs/sources$ mv -v /tools/$(gcc -dumpmachine)/bin/{ld,ld-old}
  4. `/tools/i686-pc-linux-gnu/bin/ld' -> `/tools/i686-pc-linux-gnu/bin/ld-old'
  5. lfs:/mnt/lfs/sources$ mv -v /tools/bin/{ld-new,ld}
  6. [color="Red"]mv: cannot stat `/tools/bin/ld-new': No such file or directory[/color]
  7. lfs:/mnt/lfs/sources$ ln -sv /tools/bin/ld /tools/$(gcc -dumpmachine)/bin/ld
  8. create symbolic link `/tools/i686-pc-linux-gnu/bin/ld' to `/tools/bin/ld'
  9. lfs:/mnt/lfs/sources$ echo $?
  10. 0
复制代码

请问这是为什么?
万分感谢!!
 楼主| 发表于 2007-3-1 20:59:13 | 显示全部楼层
我所做的步骤是
  1. cd binutils-build
  2. make -C ld install
  3. cd ..
  4. rm -rf binutils-build
  5. rm -rf binutils-2.15.94.0.2.2
复制代码

  1. mv -v /tools/bin/{ld,ld-old}
  2. mv -v /tools/$(gcc -dumpmachine)/bin/{ld,ld-old}
  3. [color="Red"]mv -v /tools/bin/{ld-new,ld}[/color]
  4. ln -sv /tools/bin/ld /tools/$(gcc -dumpmachine)/bin/ld
复制代码

当然红色的那句命令出错了.

  1. SPECFILE=`dirname $(gcc -print-libgcc-file-name)`/specs &&
  2. gcc -dumpspecs > $SPECFILE &&
  3. sed 's@^/lib/ld-linux.so.2@/tools&@g' $SPECFILE > tempspecfile &&
  4. mv -vf tempspecfile $SPECFILE &&
  5. unset SPECFILE
复制代码

这是5.7中的.

  1. GCC_INCLUDEDIR=`dirname $(gcc -print-libgcc-file-name)`/include &&
  2. find ${GCC_INCLUDEDIR}/* -maxdepth 0 -xtype d -exec rm -rvf '{}' \; &&
  3. rm -vf `grep -l "DO NOT EDIT THIS FILE" ${GCC_INCLUDEDIR}/*` &&
  4. unset GCC_INCLUDEDIR
复制代码

这也是5.7中的.

  1. echo 'main(){}' > dummy.c
  2. cc dummy.c
  3. readelf -l a.out | grep ': /tools'
复制代码

结果是
  1. lfs:/mnt/lfs/sources$ readelf -l a.out | grep ': /tools'
  2.       [Requesting program interpreter: /tools/lib/ld-linux.so.2]
  3. lfs:/mnt/lfs/sources$ rm -v dummy.c a.out
  4. removed `dummy.c'
  5. removed `a.out'
复制代码

这样我可以继续LFS吗?
请指点.
回复 支持 反对

使用道具 举报

发表于 2007-3-1 22:05:32 | 显示全部楼层
你把 6.1.1 与 6.2 两个版本搞混在一起了
而你碰到的这个问题真是这两个版本的主要差异之一
回复 支持 反对

使用道具 举报

发表于 2007-3-1 22:46:27 | 显示全部楼层
我刚才看了一下LFS 6.1.1的文档,的确如csfrank所说
6.1.1 在5.7调整工具链使用了make -C ld install
6.2 在5.3 Binutils生成时cp -v ld/ld-new /tools/bin,在5.7调整工具链做了mv的操作
在make -C ld LIB_PATH=/tools/lib生成的可执行程序名就是ld-new,在make install时被自动改成了ld
6.2做改进可能是因为有些人习惯生成一个软件包就删除一个源代码目录,这样按6.1.1的做法,在5.7步时,就无法make -C ld install,只能重新编译一遍。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-3-2 08:37:07 | 显示全部楼层
  1. 6.2做改进可能是因为有些人习惯生成一个软件包就删除一个源代码目录,这样按6.1.1的做法,在5.7步时,就无法make -C ld install,只能重新编译一遍。
复制代码

我编译完5.3 binutils后并没有删除binutils的编译目录和原代码目录. 所以在5.7时, 可以执行
make -C ld install

两位的意思是不是在lfs 6.2中, 5.7时不需要作在binutil里做make -C ld install, 而是应该按照LFS book上的作法?

谢谢!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-3-2 08:40:40 | 显示全部楼层
另, 在6.2中, 编译完5.3中的binutils包, 即做完 cp -v ld/ld-new /tools/bin 后就把binutils的原代码目录和编译目录删除吗?

请指教, 谢谢!
回复 支持 反对

使用道具 举报

发表于 2007-3-2 08:54:30 | 显示全部楼层
binutils的源代码可以不删,因为5.3和5.12都没有改动源代码,编译目录最好删掉

但对于有些在源代码中加入“特殊”补丁的,后面需要再做一次,最好把原来的源代码也删除,否则就会出现各种奇怪现象。

还有,做完第五章后,最好把源代码全部删除,第六章时重新解压
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-3-2 09:02:33 | 显示全部楼层
还有一个:confused: :confused: 问题, 在5.7中还要在binutils的目录里做make -C ld install 吗?
谢谢.
回复 支持 反对

使用道具 举报

发表于 2007-3-2 09:12:04 | 显示全部楼层
为什么不认真看看两本book啊,你这些问题把两本book看仔细了都不是问题,
再搞不明白就再看一次,仔细对比这看,一定会看出差别的
回复 支持 反对

使用道具 举报

发表于 2007-3-2 09:16:01 | 显示全部楼层
Post by future_god

我编译完5.3 binutils后并没有删除binutils的编译目录和原代码目录. 所以在5.7时, 可以执行
make -C ld install

两位的意思是不是在lfs 6.2中, 5.7时不需要作在binutil里做make -C ld install, 而是[color="DarkRed"]应该按照LFS book上的作法?

谢谢!

如果你是新手,建议你[color="DarkRed"]严格按照书上的指引做一遍,特别是你不甚明白的时候
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表