如上,借用已有的配置后,接下来就是去:
ct-ng menuconfig
然后针对里面的配置选项,去根据自己的需要,去修改了。
由于crosstool-ng的功能太多,配置选项太多,
所以,此处,也不太可能,针对每个参数都详细解释其含义。
不过,对于一些核心参数,是我们必须要了解清楚的,
所以,下面就针对,一些核心参数,比较有用的参数,来详细解释解释:
crosstool-ng中,有不少有用的参数,是和,crosstool-ng这个工具本身,有关的
其目的在于,在为你使用此工具时,提供使用上的便利
比如设置多线程,以加快编译速度,节省编译时间,
之前编译在某步出错,然后重新重头编译又需要耗费大量的无谓的时间,而提供了从之前错误的某步中恢复,继续编译,从而节省你的时间
在编译出错时,不退出,而提供机会给你修复错误,修复后,然后可以继续编译
如此等等的参数,目的就一个:
让制作交叉编译器,这个费事费力的活,变得尽可能的省时省力
下面,就来介绍一下这些参数,如何配置,以及详细的含义和用法。
直接给出示例配置:
Paths and misc options (4) Number of parallel jobs
其help的说明为:
┌────────────────────────── Number of parallel jobs ───────────────────────────┐ │ CT_PARALLEL_JOBS: │ │ │ │ Number of jobs make will be allowed to run concurently. │ │ Set this higher than the number of processors you have, but not too high. │ │ A good rule of thumb is twice the number of processors you have. │ │ │ │ Enter 1 to have only one job at a time. │ │ │ │ Enter 0 to set automatically based on how many processors the host has. │ │ │ │ Symbol: PARALLEL_JOBS [=4] │ │ Type : integer │ │ Prompt: Number of parallel jobs │ │ Defined at config/global/build-behave.in:8 │ │ Depends on: !BACKEND [=n] │ │ Location: │ │ -> Paths and misc options │
此处,设置为4,意思是:
同时运行4个进程(去执行crosstool-ng的编译过程)
很明显,多线程去编译的话,会大大缩短整个的编译时间。
此数字的设置,当然,不能随便胡乱设置。
比较常见的做法是:
CPU内核数 x 2
比如,你的是Intel的双核的CPU,那么此值就是:
2 x 2 =4
了。
不用去ct-ng build.N | |
---|---|
此处,设置好此参数后,后续直接去build: ct-ng build 即可自动以对应的多线程去编译了。 无需后续手动再在build上参数,即无需: ct-ng build.4 |
示例配置:
Paths and misc options [*] Debug crosstool-NG [*] Save intermediate steps
Save intermediate steps的help的说明为:
┌────────────────────────── Save intermediate steps ───────────────────────────┐ │ CT_DEBUG_CT_SAVE_STEPS: │ │ │ │ If you say 'y' here, then you will be able to restart crosstool-NG at │ │ any step. │ │ │ │ It is not currently possible to restart at any of the debug facilities. │ │ They are treated as a whole. │ │ │ │ To get the full list os steps, run: ct-ng list-steps │ │ │ │ Symbol: DEBUG_CT_SAVE_STEPS [=y] │ │ Type : boolean │ │ Prompt: Save intermediate steps │ │ Defined at config/global/ct-behave.in:79 │ │ Depends on: DEBUG_CT [=y] │ │ Location: │ │ -> Paths and misc options │ │ -> Debug crosstool-NG (DEBUG_CT [=y]) │
此处,先要选上:Debug crosstool-NG
表示,使用crosstoo-ng的调试方面的功能
再去选上:Save intermediate steps
意思是:
编译完毕每一步之后,都会保存对应的状态
如此,就可以实现对应的,从之前出错的步骤恢复而继续编译的效果了。
当然,实现此效果的前提是,你参考之前的第 3.1.2 节 “用ct-ng list-steps查看本身的build过程分成哪几步”,而搞清楚了,crosstool-ng的编译,其本身分了哪些步骤。
然后直到自己是在哪一步出的错,然后才可以实现回复出错的步骤,而继续编译。
总的逻辑是:
找到之前编译,最后成功的那一步(last successful step)。
然后去执行:
ct-ng last_successful_step+
就可以继续恢复继续编译了。
例 3.1. 从出错的那一步恢复重新继续编译
比如,我之前折腾:
期间,当时出错的输出信息是:
================================================================= [INFO ] Installing MPC for host [EXTRA] Configuring MPC [EXTRA] Building MPC [EXTRA] Installing MPC [INFO ] Installing MPC for host: done in 182.22s (at 27:10) [EXTRA] Saving state to restart at step 'binutils_for_host'... [INFO ] ================================================================= [INFO ] Installing binutils for host [EXTRA] Configuring binutils [ERROR] configure: error: cannot create configure.lineno; rerun with a POSIX shell [ERROR] [ERROR] >> [ERROR] >> Build failed in step 'Installing binutils for host' [ERROR] >> called in step '(top-level)' [ERROR] >> [ERROR] >> Error happened in: CT_DoExecLog[scripts/functions@257] [ERROR] >> called from: do_binutils_backend[scripts/build/binutils/binutils.sh@205] [ERROR] >> called from: do_binutils_for_host[scripts/build/binutils/binutils.sh@92] [ERROR] >> called from: main[scripts/crosstool-NG.sh@632] Current command: 'CFLAGS=-O2 -g -pipe ' 'CXXFLAGS=-O2 -g -pipe ' 'LDFLAGS= ' '/home/CLi/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/src/binutils-2.22/configure' '--build=i686-build_pc-cygwin' '--host=i686-build_pc-cygwin' '--target=arm-xscale-linux-gnueabi' '--prefix=/home/CLi/develop/crosstool-ng/x-tools/arm-xscale-linux-gnueabi' '--disable-werror' '--enable-ld=yes' '--enable-gold=no' '--with-pkgversion=crosstool-NG 1.18.0' '--disable-multilib' '--disable-nls' '--with-float=softfp' '--with-sysroot=/home/CLi/develop/crosstool-ng/x-tools/arm-xscale-linux-gnueabi/arm-xscale-linux-gnueabi/sysroot' exited with error code: 1 Please fix it up and finish by exiting the shell with one of these values: 1 fixed, continue with next build command 2 repeat this build command 3 abort build ct-ng:~/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-xscale-linux-gnueabi/build/build-binutils-host-i686-build_pc-cygwin>
此处,我们能看到的是,在当前的:
[INFO ] Installing binutils for host
而出错了,而对应的,在此之前的,最后一个正确编译的阶段,是对应着有输出:
[EXTRA] Saving state to restart at step 'binutils_for_host'...
的那一步,即:
binutils_for_host
此时,你就可以用:
ct-ng binutils_for_host+
而实现:
(给定,之前最后正常执行的那一步(last successful step),往后,)从上述出错的那一步,继续正常编译的效果了。
即,所谓的:restore from fail step
RESTART=step的参数估计也可以实现同样的从错误那步恢复继续编译的效果 | |
---|---|
从之前的第 3.1.1 节 “用ct-ng help查看所拥有的功能”中可以看出 估计在build的时候,指定对应的RESTART=step ct-ng build RESTART=last_successful_step 应该也可以实现类似的效果的。 有空的话,可以去试试。 |
说实话,对于上面的那个:第 3.3.1.2 节 “从之前错误的那一步恢复继续编译”的功能,已经很强大了
而crosstool-ng,工具做的就是好。
因为,除此之外,又进一步的支持这个,出错时不立刻退出,的功能。
配置如下:
Paths and misc options [*] Debug crosstool-NG [*] Interactive shell on failed commands
Interactive shell on failed commands的help的说明为:
┌─────────────────── Interactive shell on failed commands ────────────────────┐ │ CT_DEBUG_INTERACTIVE: │ │ │ │ If you say 'y' here, then an interactive shell will be spawned for │ │ each failed command. │ │ │ │ This shell will have the same environment that the failed command │ │ was run with, and the working directory will be set to the directory │ │ the failed command was run in. │ │ │ │ After you fix the issue, you can exit the interactive shell with any │ │ of these exit codes: │ │ 1 the issue was fixed, continue the build with the next command │ │ 2 the issue was fixed, re-run the failed command │ │ 3 abort the build │ │ │ │ Note: '2' is only possible for commands run via CT_DoExecLog, though. │ │ │ │ Symbol: DEBUG_INTERACTIVE [=y] │ │ Type : boolean │ │ Prompt: Interactive shell on failed commands │ │ Defined at config/global/ct-behave.in:121 │ │ Depends on: DEBUG_CT [=y] │ │ Location: │ │ -> Paths and misc options │ │ -> Debug crosstool-NG (DEBUG_CT [=y]) │
此处,参数Interactive shell on failed commands的含义是:
直译为:当编译(命令)出错时,提供交互式的shell
其具体实际效果是:
正常情况下,当编译出错,会直接退出crosstool-ng的编译环境,回到当前的命令行。
而设置了此参数后,当编译失败时,不是直接退出编译
而是提供一个交互式的shell
然后你可以(另开一个终端)去修复你的问题
然后修复问题后,再通过
exit N
实现对应的返回N的值,达到对应的效果:
(不重新执行,之前错误的那个命令)
而接着直接继续编译
重新执行之前错误的那个命令
然后接着继续执行
常用于:
当某个.c文件编译出错了,然后你另起一个终端,去修改了该.c文件,解决了错误。
然后就可以通过
exit 2
而使得,重新执行命令,重新编译该.c文件,而使得可以正常编译,继续编译。
直接退出编译
相当于,直接按Ctrl+C,而中断编译
例 3.2. 如何在编译失败后,修复错误,然后继续接着编译
比如,我之前折腾
【记录】crosstool为xscale编译(ct-ng build)过程
时,遇到编译出错后,就回到当前命令行了:
================================================================= [INFO ] Installing static core C compiler [EXTRA] Configuring static core C compiler [EXTRA] Building static core C compiler [EXTRA] Installing static core C compiler [INFO ] Installing static core C compiler: done in 1282.54s (at 67:22) [EXTRA] Saving state to restart at step 'libc_headers'... [INFO ] ================================================================= [INFO ] Installing C library headers [EXTRA] Configuring C library [EXTRA] Installing C library headers [ERROR] make[3]: *** [/home/CLi/develop/crosstool-ng/x-tools/arm-xscale-linux-gnueabi/arm-xscale-linux-gnueabi//sys-root/usr/include/sys/uio.h] Error 1 [ERROR] make[2]: *** [misc/install-headers] Error 2 [ERROR] make[1]: *** [install-headers] Error 2 [ERROR] Build failed in step 'Installing C library headers' [ERROR] Error happened in '/opt/crosstool-ng/lib/ct-ng-1.9.3/scripts/functions' in function 'CT_DoExecLog' (line unknown, sorry) [ERROR] called from '/opt/crosstool-ng/lib/ct-ng-1.9.3/scripts/build/libc/glibc.sh' at line # 175 in function 'do_libc_headers' [ERROR] called from '/opt/crosstool-ng/lib/ct-ng-1.9.3/scripts/crosstool-NG.sh' at line # 597 in function 'main' [ERROR] Look at '/home/CLi/develop/crosstool-ng/x-tools/arm-xscale-linux-gnueabi/build.log' for more info on this error. [ERROR] (elapsed: 76:07.10) [76:12] / /opt/crosstool-ng/bin/ct-ng:143: recipe for target `build' failed make: *** [build] Error 2 CLi@PC-CLI-1 ~/develop/crosstool-ng/crosstool-ng-1.9.3_build $
没有给你机会去修复错误,然后继续编译。
而你能做的,做节省时间的方式,也最多只是,参考:第 3.3.1.2 节 “从之前错误的那一步恢复继续编译”去,在解决了问题之后,去:
ct-ng libc_headers+
从而达到,从出错的步骤,恢复后继续编译的效果,不再重复之前的已经成功编译的那些步骤。
但是,即便是这样,对于编译最开始的部分:
CLi@PC-CLI-1 ~/develop/crosstool-ng/crosstool-ng-1.9.3_build $ ct-ng build [INFO ] Performing some trivial sanity checks [INFO ] Build started 20130724.093552 [INFO ] Building environment variables [EXTRA] Preparing working directories
等步骤,还是需要花点时间的,还是有点重复浪费的感觉。
所以,此处,选中了上面所说的那个"Interactive shell on failed commands"选项后,
当编译出错后,会出现类似于:
【已解决】Ubuntu中crosstool-ng编译出错:scripts/unifdef.c:209:25: error: conflicting types for ‘getline’
中的这样的效果:
[INFO ] ================================================================= [INFO ] Installing kernel headers [EXTRA] Installing kernel headers [ERROR] /home/crifan/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/src/linux-custom/scripts/unifdef.c:209:25: error: conflicting types for 'getline' [ERROR] make[3]: *** [scripts/unifdef] Error 1 [ERROR] make[2]: *** [headers_install] Error 2 [ERROR] make[1]: *** [headers_install] Error 2 [ERROR] [ERROR] >> [ERROR] >> Build failed in step 'Installing kernel headers' [ERROR] >> called in step '(top-level)' [ERROR] >> [ERROR] >> Error happened in: CT_DoExecLog[scripts/functions@257] [ERROR] >> called from: do_kernel_install[scripts/build/kernel/linux.sh@112] [ERROR] >> called from: do_kernel_headers[scripts/build/kernel/linux.sh@91] [ERROR] >> called from: main[scripts/crosstool-NG.sh@632] Current command: 'make' '-C' '/home/crifan/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/src/linux-custom' 'O=/home/crifan/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-xscale-linux-gnueabi/build/build-kernel-headers' 'ARCH=arm' 'INSTALL_HDR_PATH=/home/crifan/develop/crosstool-ng/x-tools/arm-xscale-linux-gnueabi/arm-xscale-linux-gnueabi/sysroot/usr' 'V=0' 'headers_install' exited with error code: 2 Please fix it up and finish by exiting the shell with one of these values: 1 fixed, continue with next build command 2 repeat this build command 3 abort build ct-ng:~/develop/crosstool-ng/crosstool-ng-1.18.0_build>
即,有对应的
Please fix it up and finish by exiting the shell with one of these values
那些信息。
然后,当你去解决了对应的问题后:
此处,只是去修改对应的.build/src/linux-custom/scripts/unifdef.c
,即可。
然后,就可以通过输入:
exit 2
就可以实现:
重新执行此处刚才出错的命令,然后继续重新去编译刚才出错的那个.build/src/linux-custom/scripts/unifdef.c
文件,
从而实现:
当编译出错时,也不立刻退出crosstool-ng的编译,
允许你去修复对应的问题,然后修复完毕后,可以接着继续编译。
因而实现了:
避免重复的,之前的各个步骤,包括最开始的环境检查等等的时间
真正的,彻底的,最大程度上的,节省你的时间和精力。
crosstool-ng中有很多配置参数。
其中一些核心参数,是交叉编码方面,比如搞清楚,和配置正确的参数。
下面就来详细解释这些参数的含义和说明如何配置。
此处介绍,和crosstool-ng,为了交叉编译,作为工具本身方面的一些常见的,重要的参数的配置。
常见配置如下:
Paths and misc options (${HOME}/develop/crosstool-ng/src) Local tarballs directory
Local tarballs directory的help的说明为:
┌───────────────────────── Local tarballs directory ──────────────────────────┐ │ CT_LOCAL_TARBALLS_DIR: │ │ │ │ If you have previously downloaded the tarballs, enter the PATH where │ │ you stored them here. │ │ │ │ Symbol: LOCAL_TARBALLS_DIR [=${HOME}/develop/crosstool-ng/src] │ │ Type : string │ │ Prompt: Local tarballs directory │ │ Defined at config/global/paths.in:5 │ │ Depends on: !BACKEND [=n] │ │ Location: │ │ -> Paths and misc options │
即,你之前配置好的各种模块,包括C库,GCC,binutils等等所有的东西,下载下来,都放在此文件夹中。
所有的东西,都放在其下,包括:
一般使用默认配置,如下:
Paths and misc options (${CT_TOP_DIR}/.build) Working directory
Working directory的help的说明为:
┌───────────────────────────── Working directory ─────────────────────────────┐ │ CT_WORK_DIR: │ │ │ │ Set this to the directory where all build actions will be done. │ │ │ │ The default is "${CT_TOP_DIR}/.build", and leaving this option │ │ empty will also use the default. │ │ │ │ You should not need to change that, except in one very peculiar │ │ setup: │ │ - your crosstool-NG source directory is on the network │ │ - you configured crosstool-NG with --local │ │ This kind of setup is a pain, as any action involving source file │ │ access would have to go through the wire. In this case, you should │ │ set CT_WORK_DIR to point to a path local to your machine, to avoid │ │ any network overhead. │ │ │ │ Do *NOT* change it if you don't know better. │ │ │ │ Symbol: WORK_DIR [=${CT_TOP_DIR}/.build] │ │ Type : string │ │ Prompt: Working directory │ │ Defined at config/global/paths.in:31 │ │ Depends on: !BACKEND [=n] │ │ Location: │ │ -> Paths and misc options │
改为你自己的,对应的x-tools/${CT_TARGET}的路径:
Paths and misc options (${HOME}/develop/crosstool-ng/x-tools/${CT_TARGET}) Prefix directory
Prefix directory的help的说明为:
┌────────────────────────────── Prefix directory ──────────────────────────────┐ │ CT_PREFIX_DIR: │ │ │ │ This is the path the toolchain will run from. │ │ │ │ Symbol: PREFIX_DIR [=${HOME}/develop/crosstool-ng/x-tools/${CT_TARGET}] │ │ Type : string │ │ Prompt: Prefix directory │ │ Defined at config/global/paths.in:52 │ │ Depends on: !BACKEND [=n] │ │ Location: │ │ -> Paths and misc options │
crosstool-ng中的Architecture level, Emit assembly for CPU, Tune for CPU,分别对应的是gcc中的-march=xxx, -mcpu=xxx, -mtune=xxx
而这几个参数,是相对最最核心的,最最重要的配置了。
例 3.3. 举例说明Architecture level, Emit assembly for CPU, Tune for CPU如何去配置
比如,我之前的折腾:
中的:
以及后来的折腾:
【整理】crosstool-ng中的Architecture level,Emit assembly for CPU,Tune for CPU对于TQ2440的S3C2440的ARM920T填写何值
而搞清楚了自己的xscale的CPU所对应的配置是:
以及,后来的折腾:
【记录】Cygwin下为arm920t配置crosstool-ng
中的:
【整理】crosstool-ng中的Architecture level,Emit assembly for CPU,Tune for CPU对于TQ2440的S3C2440的ARM920T填写何值
去搞懂了,S3C2440的对应的配置是:
crosstool-ng中,对于MMU的配置,此处如下:
Target options [*] Use the MMU
Use the MMU的help的说明为:
┌──────────────────────────────── Use the MMU ─────────────────────────────────┐ │ CT_ARCH_USE_MMU: │ │ │ │ If your architecture has an MMU and you want to use it, │ │ say 'Y' here. │ │ │ │ OTOH, if you don't want to use the MMU, or your arch │ │ lacks an MMU, say 'N' here. │ │ │ │ Note that some architectures (eg. ARM) has variants that │ │ lacks an MMU (eg. ARM Cortex-M3), while other variants │ │ have one (eg. ARM Cortex-A8). │ │ │ │ Symbol: ARCH_USE_MMU [=y] │ │ Type : boolean │ │ Prompt: Use the MMU │ │ Defined at config/target.in:87 │ │ Depends on: ARCH_SUPPORTS_BOTH_MMU [=y] │ │ Location: │ │ -> Target options │ │ Selected by: ARCH_alpha [=n] && GEN_CHOICE_ARCH [=y] && \ │ │ ARCH_alpha_AVAILABLE [=y] || ARCH_s390 [=n] && GEN_CHOICE_ARCH [=y] && \ │ │ ARCH_s390_AVAILABLE [=y] || ARCH_powerpc [=n] && GEN_CHOICE_ARCH [=y] && \ │ │ ARCH_powerpc_AVAILABLE [=y] || ARCH_sparc [=n] && GEN_CHOICE_ARCH [=y] && \ │ │ ARCH_sparc_AVAILABLE [=y] || ARCH_mips [=n] && GEN_CHOICE_ARCH [=y] && \ │ │ ARCH_mips_AVAILABLE [=y] || ARCH_avr32 [=n] && GEN_CHOICE_ARCH [=y] && \ │ │ ARCH_avr32_AVAILABLE [=y] || ARCH_sh [=n] && GEN_CHOICE_ARCH [=y] && \ │ │ ARCH_sh_AVAILABLE [=y] || ARCH_x86 [=n] && GEN_CHOICE_ARCH [=y] && \ │ │ ARCH_x86_AVAILABLE [=y] │
此处,已经选上了MMU,是因为之前对于CPU部分,是在:
设置为xscale的,而xscale的CPU,全都是有MMU的。
所以,此处,crosstool-ng(根据内部已经实现好的依赖关系),已经自动帮你选上MMU了。
需要了解的是,现在多数的CPU,都是已经支持MMU的。
只有之前的很老的CPU,有的才不支持MMU。
crosstool-ng中,对于MMU的配置,此处如下:
Target options Endianness: (Little endian) --->
Endianness的help的说明为:
┌──────────────────────────────── Endianness: ─────────────────────────────────┐ │ There is no help available for this option. │ │ Prompt: Endianness: │ │ Defined at config/target.in:112 │ │ Depends on: ARCH_SUPPORTS_BOTH_ENDIAN [=y] │ │ Location: │ │ -> Target options │ │ Selected by: ARCH_SUPPORTS_BOTH_ENDIAN [=y] && m │
此处,将Endianness设置为小端(Little endian)
一般,多数情况下,都是小端。
不论设置大端(Big Endian)还是小端(Little endian)
都要确保本身CPU是支持此种模式的。
比如,之前,也是经过确认,才知道,xscale,本身是,既支持大端,也支持小端的:
所以,此处设置小端,也才是确保,CPU本身是支持的。
关于大端和小端的区别的,不熟悉的可参考:
crosstool-ng中的配置中,同样会涉及到,当前的CPU,是否有FPU,浮点处理单元。
一般来说,多数CPU都是没有的。
比如,我之前的折腾:
【记录】Cygwin下为arm920t配置crosstool-ng
就发现,当然的S3C2440dearm920t的话,是不支持FPU的。
所以,此处,就设置为对应的,软件浮点了:
Target options () Use specific FPU Floating point: (softfp (FPU)) --->
Use specific FPU的help的说明为:
┌────────────────────────────── Use specific FPU ──────────────────────────────┐ │ CT_ARCH_FPU: │ │ │ │ On some targets (eg. ARM), you can specify the kind of FPU to emit │ │ code for. │ │ │ │ This is the configuration flag --with-fpu=XXX, and the runtime flag │ │ -mfpu=XXX. │ │ │ │ See below wether to actually emit FP opcodes, or to emulate them. │ │ │ │ Pick a value from the gcc manual for your choosen gcc version and your │ │ target CPU. │ │ │ │ Leave blank if you don't know, or if your target architecture does not │ │ offer this option. │ │ │ │ Symbol: ARCH_FPU [=] │ │ Type : string │ │ Prompt: Use specific FPU │ │ Defined at config/target.in:274 │ │ Depends on: ARCH_SUPPORTS_WITH_FPU [=y] │ │ Location: │ │ -> Target options │
Floating point的help的说明为:
┌────────────────────────────── Floating point: ───────────────────────────────┐ │ There is no help available for this option. │ │ Prompt: Floating point: │ │ Defined at config/target.in:294 │ │ Depends on: ARCH_SUPPORTS_WITH_FLOAT [=y] │ │ Location: │ │ -> Target options │ │ Selected by: ARCH_SUPPORTS_WITH_FLOAT [=y] && m │
可见,此处的FPU,就是对应着gcc中的参数:-mfpu=XXX
对应的,如果是你:
中所举例的Cortex-A9 with NEON的CPU的话,那么此处的设置就是:
Target options (neon) Use specific FPU Floating point: (hardware (FPU)) --->
了,而此时,你也可以看到,配置选择中,又多了个,关于后缀hf的选项,你也可以选择该项:
Target options [*] append 'hf' to the tuple (EXPERIMENTAL)
append 'hf' to the tuple的help的说明为:
┌───────────────── append 'hf' to the tuple (EXPERIMENTAL) ─────────────────┐ │ CT_ARCH_ARM_TUPLE_USE_EABIHF: │ │ │ │ Is you say 'y' here, then the tuple for the toolchain will end │ │ up with *eabihf, instead of the usual *eabi. │ │ │ │ *eabihf is used to denote that the toolchain *is* using the │ │ hard-float ABI, while *eabi is just an indication of using the │ │ soft-float ABI. │ │ │ │ Ie. all one can say is: *eabihf hard-float ABI │ │ │ │ Saying 'n' here does *not* impact the ability of the toolchain to │ │ generate hard-float instructions with the hard-float ABI. It is a │ │ purely cosmetic thing, used by distros to differentiate their │ │ hard-float-ABI-using ports from their soft-float-ABI-using ports. │ │ (eg. Debian Wheezy and above). │ │ │ │ This is an option, as not all versions of gcc/binutils do support │ │ such tuple, and fail to build with *eabihf. Stock gcc version up │ │ to, and including 4.7.2 have an issue or another with *eabihf. │ │ │ │ This option is here for the future. │ │ │ │ Say 'n', unless you are trying to fix gcc to properly recognise │ │ the *eabihf tuples. │ │ │ │ Symbol: ARCH_ARM_TUPLE_USE_EABIHF [=y] │ │ Type : boolean │ │ Prompt: append 'hf' to the tuple (EXPERIMENTAL) │ │ Defined at config/arch/arm.in.2:64 │ │ Depends on: ARCH_arm [=y] && ARCH_FLOAT_HW [=y] && ARCH_ARM_EABI [=y]\ │ │ && EXPERIMENTAL [=y] │ │ Location: │ │ -> Target options │ │ -> Use EABI (ARCH_ARM_EABI [=y]) │
crosstool-ng中,支持设置对应的CFLAGS参数,以传递给底层的gcc的。
经过之前的调查:
【整理】crosstool中Target CFLAGS参数的含义和如何设置
结论是:
一般设置为-O,即可。
Target options (-O) Target CFLAGS
Target CFLAGS的help的说明为:
┌────────────────────────────── Target CFLAGS ──────────────────────────────┐ │ CT_TARGET_CFLAGS: │ │ │ │ Used to add specific options when compiling libraries of the toolchain, │ │ that will run on the target (eg. libc.so). │ │ │ │ Note that the options above for ARCH, ABI, CPU, TUNE and FPU will be │ │ automatically used. You don't need to specify them here. │ │ │ │ Leave blank if you don't know better. │ │ │ │ Symbol: TARGET_CFLAGS [=-O] │ │ Type : string │ │ Prompt: Target CFLAGS │ │ Defined at config/target.in:341 │ │ Location: │ │ -> Target options │
目前我的理解是:
对于你进行嵌入式开发时,所选择的对应的Linux版本,应该和此处交叉编译器配置的Linux内核版本要一致。
比如,我之前折腾:
【记录】重试使用最新版本1.18.0的crosstool-ng去配置和编译xscale的交叉编译器
时,去选择了,自定义版本的Linux内核:linux-2.6.19.1.tar.bz2
所以,此处,就先去把对应的,自己的linux-2.6.19.1.tar.bz2
,放到对应的路径下:
Cygwin下面的:
/home/CLi/develop/crosstool-ng/src/linux-2.6.19.1.tar.bz2
而当前自己的HOME路径是:
/home/CLi
所以就可以去设置为:
Operating System Linux kernel version (custom tarball or directory) ---> custom tarball or directory (${HOME}/develop/crosstool-ng/src/linux-2.6.19.1.tar.bz2) Path to custom source, tarball or directory
Path to custom source, tarball or directory的help的说明为:
┌─────────────────────────── Path to custom source, tarball or directory ───────────────────────────┐ │ CT_KERNEL_LINUX_CUSTOM_LOCATION: │ │ │ │ Enter here the path to the tarball of your full kernel tree or │ │ kernel directory │ │ │ │ Symbol: KERNEL_LINUX_CUSTOM_LOCATION [=${HOME}/develop/crosstool-ng/src/linux-2.6.19.1.tar.bz2] │ │ Type : string │ │ Prompt: Path to custom source, tarball or directory │ │ Defined at config/kernel/linux.in:148 │ │ Depends on: <choice> && KERNEL_LINUX_CUSTOM [=y] │ │ Location: │ │ -> Operating System │ │ -> Linux kernel version (<choice> [=y]) │ │ -> custom tarball or directory (KERNEL_LINUX_CUSTOM [=y]) │
如此,之后编译的时候,就可以找到你自己设置的Linux内核,并解压,去加载对应的头文件等内容了。
binutils,是编译交叉编译器时,一个比较重要的组件。
对应的版本的选择,一般还是按照之前使用示例配置时,选择的为准。
如果后期编译出错,实在解决不了的时候,再考虑换个其他的版本试试。
我目前的配置,供参考:
Binary utilities binutils version (2.22) --->
binutils version的help的说明为:
┌─────────────────────── binutils version ────────────────────────┐ │ There is no help available for this option. │ │ Prompt: binutils version │ │ Defined at config/binutils/binutils.in:5 │ │ Depends on: BINUTILS_binutils [=y] │ │ Location: │ │ -> Binary utilities │ │ Selected by: BINUTILS_binutils [=y] && m │
crosstool-ng中的gcc的版本选择,也是属于极其重要的参数。
此处我的gcc版本的选择,还是按照之前的逻辑,选用示例配置中的gcc的版本的,此处是4.6.0版本的:
并且,对应着,此处,如果没有特殊需求,则只是选择C++的,即可。
即,剩余那些语言:Fortran,Java,ADA,Objective-C,Objective-C++等,都无需选择。
我此处的配置如下,供参考:
C compiler C compiler (gcc) ---> gcc version (4.6.0) ---> [*] C++ [ ] Fortran [ ] Java [ ] ADA (EXPERIMENTAL) [ ] Objective-C (EXPERIMENTAL) [ ] Objective-C++ (EXPERIMENTAL) () Other languages (EXPERIMENTAL)
crosstool-ng中,关于C库的选择,也是个重要的问题。
常见的有三种C库:glibc,eglibc,uclibc
不了解的,可参考:【整理】uclibc,eglibc,glibc之间的区别和联系
一般选择glibc或者是eglibc。
我此处,选择的是glibc,对应的版本选择,也是使用之前示例配置中的2.9
配置如下:
C-library C library (glibc) ---> glibc version (2.9) --->
线程模型主要分两种:linuxThreads和nptl
相关区别,可参考这个帖子:Linux 线程模型的比较:LinuxThreads 和 NPTL
现在多数都选择,默认的nptl
配置如下:
C-library Threading implementation to use: (nptl) --->