Openwrt实践过程-工具链-Internal/External Toolchain

Openwrt实践过程-工具链-Internal/External Toolchain

1.优势

external toolchain是预先编译好的工具链。openwrt在构建的时候,第一步是用本机(也就是pc,一般是x64或者x84_64的环境)编译一套交叉编译的工具链(toolchain),第二步才是用这个toolchain去交叉编译在目标机器(target)上运行的内核(kernel)和软件包(packages)。
相对于internal toolchain,external toolchain有如下优点:
a.省去编译toolchain的时间,加快编译速度
b.避免编译工具链时出错
c.可以同时保存多个不同的工具链,根据实际情况进行构建不同的固件或者多个项目共用一套 toolchain而不在需要重新编译

2.宏定义

internal toolchain配置如下,编出的toolchain为:staging_dir/toolchain-arm_gcc-4.8.0-linaro_uClibc-0.9.31目录

 [*] Advanced configuration options (for developers)  ---> 
 [*]   Toolchain Options  --->
 --- Toolchain Options                                                                               
[*]   Enable EABI support                                                                  
[ ]   Enable an extra toolchain target architecture  --->                     
 ---   Binary tools                                                                              
       Binutils Version (binutils 2.20.1)  --->                                               
()    Additional binutils configure options                                                         
 ---   Compiler                                                                               
       GCC compiler Version (gcc 4.8.x with Linaro enhancements)  --->                              
 ()    Additional gcc configure options                                                            
 [ ]   Enable Stack-Smashing Protection support                                                    
 [*]   Build/install c++ compiler and libstdc++?                                                    
 [ ]   Build/install java compiler and GNU classpath ?                                               
 ---   C Library                                                                              
       C Library implementation (Use uClibc)  --->                                                   
       uClibc Version (uClibc 0.9.31)  --->                                                      
 [ ]   Build with debug information                                                                
 ---   Debuggers                                                                                   
 [ ]   Build gdb                                                                                    
 [ ]   Build insight-gdb

由于每次checkout代码都需要重新编toolchain,耗时很长,为了节省这部分时间,决定将上面已经编好的toolchain作为一个独立的目录,只要放置于编译环境的固定目录,可使用的是external toolchain。

 [*] Advanced configuration options (for developers)  --->
 [*]   Use external toolchain  --->
--- Use external toolchain
[ ]   Use host's toolchain
(arm-unknown-linux-gnu) Target name
(arm-unknown-linux-gnu-) Toolchain prefix
(/opt/cross/arm-unknown-linux-gnu) Toolchain root
(./usr/bin ./bin) Toolchain program path
(./usr/include ./include) Toolchain include path
(./usr/lib ./lib) Toolchain library path
Toolchain version (Toolchain v1.0 gcc-5.3.0)  --->
(1.0) Code version
(http://rmm08064.ads.local/mirror/) Mirror url
[*]   EABI is supported

编译完在 .config 下可以见到以下变量的定义:

CONFIG_EXTERNAL_TOOLCHAIN=y
# CONFIG_NATIVE_TOOLCHAIN is not set
CONFIG_TARGET_NAME="arm-unknown-linux-gnu"
CONFIG_TOOLCHAIN_PREFIX="arm-unknown-linux-gnu-"
CONFIG_TOOLCHAIN_ROOT="/opt/cross/arm-unknown-linux-gnu"
CONFIG_TOOLCHAIN_BIN_PATH="./usr/bin ./bin"
CONFIG_TOOLCHAIN_INC_PATH="./usr/include ./include"
CONFIG_TOOLCHAIN_LIB_PATH="./usr/lib ./lib"
CONFIG_TOOLCHAIN_VERSION_1_0=y
# CONFIG_TOOLCHAIN_VERSION_2_0 is not set
CONFIG_TOOLCHAIN_VERSION="1.0"
CONFIG_CODE_VERSION="1.0"
CONFIG_TOOLCHAIN_MIRROR="http://rmm08064.ads.local/mirror/"
CONFIG_EABI_SUPPORT=y

温馨提示:
以上文章描述如有不清晰之处,欢迎在评论区评论,如有时间,会第一时间回复,谢谢!

猜你喜欢

转载自blog.csdn.net/qq_20677327/article/details/104550738