选项详解
BUILD= 是指在什么平台上编译源代码,这个肯定是主机了,x86
HOST= 是指编译出来的可执行文件在什么平台上运行,这个对binutils个gcc来说是 x86, 对libc来说是arm
TARGET= 是指用编译出来的交叉编译器编译其它代码生成的可执行文件在什么平台运行, arm
-without-headers
--with-newlib \
--with-float=soft \
--with-cpu=arm920t \
--with-tune=arm9tdmi \
--with-gnu-as \
--with-gnu-ld \
--disable-decimal-float \
--disable-libgomp \
--disable-multilib \
--disable-libmudflap \
--disable-libssp \
--disable-shared \
--disable-threads \
--disable-libmudflap \
--disable-libstdcxx-pch \
--disable-libffi \
--disable-shared
Disables the creation of the shared libraries.
--disable-threads
This will prevent GCC from looking for the multi-thread include files, since they haven't been created for this architecture yet. GCC will be able to find the multi-thread information after the Glibc headers are created.
--enable-languages=c
This option ensures that only the C compiler is built.
注意: 将这GMP和MPFR软件包解压到GCC源码树的根目录下,并分别命名为"gmp"和"mpfr",那么GCC的编译程
序将自动将两者与GCC一起编译。这样做了后,不需要加 --with-gmp 和with-mpfr 选项,加了反而会出错:
configure: error: in `/home/hongwang/mktoolchain/build/gcc-4.4.0/mpfr':
configure: error: Do not use --with-gmp-build and other --with-gmp options simultaneously.
See `config.log' for more details.
make: *** [configure-mpfr] 错误 1
make install_root=${TARGET_PREFIX} prefix="" install
选项详解
BUILD_CC="gcc"
Glibc在编译过程中需要先创建一些工具,这些工具需要用主机上的GCC来编译。
CC=${TARGET}-gcc
告诉Glibc使用我们在上一步为ARM目标平台创建的交叉编译器GCC来编译C库。
AR=${TARGET}-ar \
告诉Glibc使用我们在上一步为ARM目标平台创建的ar来汇编C库。
RANLIB=${TARGET}-ranlib
告诉Glibc使用我们在上一步为ARM目标平台创建的ranlib
-with-headers=${TARGET_PREFIX}/include \
--with-binutils=${RESULT_DIR}/bin
This tells Glibc to use the Binutils that are specific to our target architecture.
--with-tls
This tells Glibc to use Thread Local Storage.
--with-__thread
This tells Glibc to use use the __thread for libc and libpthread builds.
--enable-sim \
--enable-nptl \
--enable-add-ons
This tells Glibc to utilize all add-ons that are available.
--enable-kernel=2.6.29 \
--disable-profile
This builds the libraries without profiling information. Omit this option if profiling on the temporary tools is necessary.
--without-gd \
--without-cvs \
--cache-file=config.cache
This tells Glibc to utilize a premade cache file.
对 prefix 的解释
对 libc.so 的修正·
rm ${TARGET_PREFIX}/lib/libc.so
cat > ${TARGET_PREFIX}/lib/libc.so << "EOF"
/* GNU ld script
Use the shared library, but some functions are only in
the static library, so try that secondarily. */
OUTPUT_FORMAT(elf32-littlearm)
GROUP ( libc.so.6 libc_nonshared.a AS_NEEDED ( ld-linux.so.3 ) )
EOF
make install 后得到的文件:(待完善)
第五步 编译GCC(第二次)
需要时间大概为:1小时
配置选项
这次是编译完整的GCC,因此第一次disable的一些选项这次可以enable了。
${SOURCE_DIR}/${PACKAGE_GCC}/configure \
--build=${HOST} \
--host=${HOST} \
--target=${TARGET} \
--prefix=${RESULT_DIR} \
--with-float=soft \
--with-cpu=arm920t \
--with-tune=arm9tdmi \
--enable-languages=c,c++ \
--enable-threads=posix \
--enable-c99 \
--enable-long-long \
--enable-shared \
--enable-__cxa_atexit \
--enable-nls \
--disable-libgomp
make && make install
选项详解
-enable-languages=c,c++
This option ensures that only the C and C++ compilers are built.
--enable-__cxa_atexit
This option allows use of __cxa_atexit, rather than atexit, to register C++ destructors for local statics and global objects and is essential for fully standards-compliant handling of destructors. It also affects the C++ ABI and therefore results in C++ shared libraries and C++ programs that are interoperable with other Linux distributions.
--enable-c99
Enable C99 support for C programs.
--enable-long-long
Enables long long support in the compiler.
--enable-threads=posix
This enables C++ exception handling for multi-threaded code.