关于编译过程中--build、--host、--target的疑惑
时间:2009-05-16
来源:互联网
在autoconf.pdf中,可以看到:
If you mean to override the result of config.guess, use ‘--build’, not ‘--host’, since the latter enables cross-compilation. For historical reasons, whenever you specify ‘--host’, be sure to specify ‘--build’ too; this will be fixed in the future. |
Chapter 5. Constructing Cross-Compile Tools
5.6. Cross Binutils-2.18 --host=${CLFS_HOST} --target=${CLFS_TARGET} |
5.7. Cross GCC-4.2.4 - Static --host=${CLFS_HOST} --target=${CLFS_TARGET} |
5.9. Cross GCC-4.2.4 - Final --target=${CLFS_TARGET} --host=${CLFS_HOST} |
5.8. Glibc-2.7 --host=${CLFS_TARGET} --build=${CLFS_HOST} |
Chapter 6. Constructing a Temporary System
6.3.1. Installation of Binutils --build=${CLFS_HOST} --host=${CLFS_TARGET} --target=${CLFS_TARGET} |
6.4.1. Installation of GCC --build=${CLFS_HOST} --host=${CLFS_TARGET} --target=${CLFS_TARGET} |
上面两个引用中为什么还要添加上--target呢,不是没有指定--target时,其值为--host的值得么?
而下面的引用中就没有添加上--target,这有什么区别的呢?
6.5. Ncurses-5.6 --build=${CLFS_HOST} --host=${CLFS_TARGET} |
6.6. Bash-3.2 --build=${CLFS_HOST} --host=${CLFS_TARGET} |
6.8. Coreutils-6.9 --build=${CLFS_HOST} --host=${CLFS_TARGET} 6.9. Diffutils-2.8.7 6.10. Findutils-4.2.32 6.12. File-4.23 6.13. Gawk-3.1.6 也是同样如此 |
作者: lofeng 发布时间: 2009-05-16
还有clfs是不是只做两次即可,即在编译时添加上--host --target参数即可?
譬如先在i686上编译出--host=i686 --target=ppc的toolchain,然后用该toolchain来编译各种工具(包括toolchain in ppc)
这样两次就可以做到i686>>ppc等
————————————————————————————————————————————————————————————————————
做一次是不是也可以的,用i686上的toolchain,编译时添加上--host=ppc,是不是即可?
这两种方法哪种比较好点?哪种用的比较多?
gcc在编译时,生成的二进制文件命名是否会参照--build --host --target参数的值得?给人的感觉是生成的二进制文件的名会添加前缀,但是具体的规则是怎样的?还请大侠来讲讲。先行谢过了~~
作者: lofeng 发布时间: 2009-05-16
貌似在用arm-gcc来编译程序时,会去寻找arm-cpp arm-cc1 arm-ld arm-as等程序
而gcc在编译时生成的程序在安装时会添加上个prefix,这个具体的规则是怎样的呢?
作者: lofeng 发布时间: 2009-05-16
为什么上面三个引用中更改了--host而没有带上--build? |
您换 gcc-4.3.x 还省略 --build 就会出问题了。
build 会自动设置,虽然自动设置的值不一定总是合适的。
上面的引用中为什么--host就是${CLFS_TARGET}了呢? |
上面两个引用中为什么还要添加上--target呢,不是没有指定--target时,其值为--host的值得么? 而下面的引用中就没有添加上--target,这有什么区别的呢? |
只有工具链部分才会出现 --build --host --target 均不同的情况,虽然一般用不到。
其它工具使用普通的交叉编译即可。
作者: 聚焦深空 发布时间: 2009-05-17
binutils gcc 是 工具链 的 一部分,要保证绝对的正确安装。 只有工具链部分才会出现 --build --host --target 均不同的情况,虽然一般用不到。 其它工具使用普通的交叉编译即可。 |
但是我提到的
6.3.1. Installation of Binutils --build=${CLFS_HOST} --host=${CLFS_TARGET} --target=${CLFS_TARGET} 6.4.1. Installation of GCC --build=${CLFS_HOST} --host=${CLFS_TARGET} --target=${CLFS_TARGET} |
作者: lofeng 发布时间: 2009-05-17
--build=${CLFS_HOST} --host=${CLFS_TARGET} --target=${CLFS_TARGET}
表示在宿主机构建,运行于目标机,用来生成目标机二进制代码的 工具链。
在宿主机构建:构建过程中有些中间程序需要运行于宿主,需要宿主自己的工具链来编译。
运行于目标机:构建生成的程序是目标机上的可执行程序。
用来生成目标机二进制代码:构建生成的程序是目标机上的本地编译工具链。
为什么需要 --build?
您可以使用 i486-linux-gnu 的系统,但使用 i686 甚至 x86_64 的内核,这种情况您就必须手工指定正确的参数,否则 autotool 会自作主张,有可能给出错误值。
为什么需要 --target?
您必须告诉配置系统工具链生成的目标代码类型,不要想当然。
还有问题,请自己动手验证,您会发现动一次手,几乎能解决您所有问题。
作者: 聚焦深空 发布时间: 2009-05-17
所参考的过程中有的只有--build参数,而有的只有--target参数
而对这三个参数又不是很理解,所以会有这些问题
为什么需要 --build? 您可以使用 i486-linux-gnu 的系统,但使用 i686 甚至 x86_64 的内核,这种情况您就必须手工指定正确的参数,否则 autotool 会自作主张,有可能给出错误值。 |
而--build需要的属性是系统的值还是内核的值呢?
为什么需要 --target? 您必须告诉配置系统工具链生成的目标代码类型,不要想当然。 |
作者: lofeng 发布时间: 2009-05-17
您真要一意孤行,也应该用cygwin。
msys+mingw 缺少很多构建工具链必须的 gnu 工具程序。
--build 使用系统值,对应宿主工具链。
不同 autotool 版本给出的默认值有出入,最明显的是 gcc-4.2.x gcc-4.3.x 的区别。(autotool 是自包含的,与宿主 autotool 版本无关)
再次提醒您不要想当然,存在的东西自有存在的理由,那是很多人多年经验的积淀。
不明白可以先记下来,随着您经验积累,您慢慢会明白为什么要那样,甚至您有可能提出更合理的解决方案。
作者: 聚焦深空 发布时间: 2009-05-17
http://www.linuxsir.org/bbs/showthre...ht=host+target --build = 软件在什么平台下编译 --host = 软件在什么平台下运行 --target = 软件为什么平台服务(仅限开发工具链) host= 后面的参数是四个部分: 架构-厂商-内核-标准库 例如 arm-generic-linux-gnu 表示 arm 架构,generic 厂商,linux内核,gnu glibc 标准库。 |
http://www.linuxsir.org/bbs/showthre...ht=host+target 你需要搞清楚 --build --host --target 三个参数的含义,一般来说,同时指定这三个参数,正常configure的概率最高。 |
作者: lofeng 发布时间: 2009-05-17
lofeng@HDU002 /build/binutils-2.19.1 $ ./configure checking build system type... i686-pc-mingw32 checking host system type... i686-pc-mingw32 checking target system type... i686-pc-mingw32 checking for a BSD-compatible install... /bin/install -c checking whether ln works... yes checking whether ln -s works... yes checking for gcc... gcc checking for C compiler default output file name... a.exe checking where to find the target ar... just compiled checking where to find the target as... just compiled checking where to find the target cc... host tool checking where to find the target c++... host tool checking where to find the target c++ for libstdc++... host tool checking where to find the target dlltool... just compiled checking where to find the target gcc... host tool checking where to find the target gcj... host tool checking where to find the target gfortran... host tool checking where to find the target ld... just compiled checking where to find the target lipo... host tool checking where to find the target nm... just compiled checking where to find the target objdump... just compiled checking where to find the target ranlib... just compiled checking where to find the target strip... just compiled checking where to find the target windres... just compiled checking where to find the target windmc... just compiled |
跟$ gcc -dumpmachine出来的结果一致
$ gcc -dumpmachine
i686-pc-mingw32
还有编译链接时使用的ld为什么是just compiled?生成ld的过程不是也是需要host ld的么?
lofeng@HDU002 /build/binutils-2.19.1 $ ./configure --build=mingw32 checking build system type... i386-pc-mingw32 checking host system type... i386-pc-mingw32 checking target system type... i386-pc-mingw32 checking for a BSD-compatible install... /bin/install -c checking whether ln works... yes checking whether ln -s works... yes checking for gcc... gcc checking for C compiler default output file name... a.exe checking whether the C compiler works... yes checking whether we are cross compiling... no |
lofeng@HDU002 /build/binutils-2.19.1 $ ./configure --target=mingw32 checking build system type... i686-pc-mingw32 checking host system type... i686-pc-mingw32 checking target system type... i386-pc-mingw32 checking for a BSD-compatible install... /bin/install -c checking whether ln works... yes checking whether ln -s works... yes checking for gcc... gcc |
lofeng@HDU002 /build/binutils-2.19.1 $ ./configure --target=arm checking build system type... i686-pc-mingw32 checking host system type... i686-pc-mingw32 checking target system type... arm-unknown-none checking for a BSD-compatible install... /bin/install -c checking whether ln works... yes checking whether ln -s works... yes checking for gcc... gcc |
lofeng@HDU002 /build/binutils-2.19.1 $ ./configure --build=arm checking build system type... arm-unknown-none checking host system type... arm-unknown-none checking target system type... arm-unknown-none checking for a BSD-compatible install... /bin/install -c checking whether ln works... yes checking whether ln -s works... yes checking for gcc... gcc |
lofeng@HDU002 /build/binutils-2.19.1 $ ./configure --host=i686 configure: WARNING: If you wanted to set the --build type, don't use --host. If a cross compiler is detected then cross compile mode will be used. checking build system type... i686-pc-mingw32 checking host system type... i686-pc-none checking target system type... i686-pc-none checking for a BSD-compatible install... /bin/install -c checking whether ln works... yes checking whether ln -s works... yes checking for i686-gcc... no checking for gcc... gcc checking for C compiler default output file name... a.exe checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... .exe 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 ANSI C... none needed checking for i686-g++... no checking for i686-c++... no checking for i686-gpp... no checking for i686-aCC... no checking for i686-CC... no checking for i686-cxx... no checking for i686-cc++... no checking for i686-cl... no checking for i686-FCC... no checking for i686-KCC... no checking for i686-RCC... no checking for i686-xlC_r... no checking for i686-xlC... no checking for g++... g++ checking whether we are using the GNU C++ compiler... yes checking whether g++ accepts -g... yes checking for i686-gnatbind... no checking for gnatbind... no checking for i686-gnatmake... no checking for gnatmake... no |
i686-g++
i686-c++
等工具,而这些工具的名称,又是怎样保证他们会有这个i686这个前缀的呢?
作者: lofeng 发布时间: 2009-05-17
刚开始还是老老实实用主流系统吧,msys+mingw 可是绝对的非主流。 您真要一意孤行,也应该用cygwin。 msys+mingw 缺少很多构建工具链必须的 gnu 工具程序。 |
--build 使用系统值,对应宿主工具链。 不同 autotool 版本给出的默认值有出入,最明显的是 gcc-4.2.x gcc-4.3.x 的区别。(autotool 是自包含的,与宿主 autotool 版本无关) |
再次提醒您不要想当然,存在的东西自有存在的理由,那是很多人多年经验的积淀。 不明白可以先记下来,随着您经验积累,您慢慢会明白为什么要那样,甚至您有可能提出更合理的解决方案。 |
作者: lofeng 发布时间: 2009-05-17
自己实力、经验不够,硬啃骨头 也是 大忌。
非主流的问题 想得到 满意的答案,您自己认为可能性有多大?
使用 MinGW,合理的找答案的地方是 MinGW 的 maillist。
如果是工作原因,偶看不到您自己编译 工具链 的 必要性,windows 相对 *nix-like 系统 基本不存在定制性,全世界的 windows 版本也就那么几个,MinGW、Cygwin 完全可以照顾好的。
如果是研究目的,不想装 *nix-like 系统到物理机器,安装一个虚拟机如何,很简单的,也会节省您大半浪费的时间。
作者: 聚焦深空 发布时间: 2009-05-17
作者: lofeng 发布时间: 2009-05-18
作者: lofeng
需要使用mingw,但是官方给出的只是gcc3.4.3这个版本的,而gcc4.x只有tdm提供,所以也想自己来编译mingw。为了编译mingw,才使用上msys的。呵呵~~
|
您自己再看看,上面的问题 和 您的标题相距多么遥远。
这种问题 是 非主流中的非主流。
下面是您需要明白的:
1、MinGW 是 GNU 工具链 的 windows 移植,和 普通的工具链不同,LFS/CLFS 的方法不适用。
2、windows 上用 MinGW 编译 gcc 属于本地编译,不需要给出 --build --host --target。
再次重复,您这种问题应该到 MinGW maillist 寻找答案。
祝好运。
作者: 聚焦深空 发布时间: 2009-05-18
这些参数,不管是在mingw的编译中,还是在clfs中,都会碰上,我只是想彻底明白这些,而不是仅仅解决mingw的编译问题。
而我觉得lfs这个分论坛,肯定有很多大虾,对这些问题有个非常清晰地理解,所以才有这几贴。
作者: lofeng 发布时间: 2009-05-18
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28