【问题】
折腾:
【记录】编译配置好的xscale版本的crosstool-ng-1.18.0
期间,后来还是出错了:
[ALL ] `/home/CLi/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-xscale-linux-gnueabi/buildtools/bin/arm-xscale-linux-gnueabi-cc.exe’ -> `arm-xscale-linux-gnueabi-gcc.exe’ |
【解决过程】
1.很明显,此处是,
在编译完毕arm-xscale-linux-gnueabi工具链之后,然后在安装kernel headers出错的
[INFO ] Installing kernel headers |
所以,貌似,至少对于交叉编译器工具链来说,是已经编译完成了。
但是此处,为何在编译期间,就会调用交叉编译器去install kernel headers,也还是有点奇怪。
2.看到:
Problems to gererate a C toolchain for a custom Linux 2.6.18
其遇到和我类似的问题:
编译mips的,用的是linux-custom,结果也是最后调用
|
然后出错的。但是目前也是无解。
3.此处仔细看了看错误,貌似由于是,在编译期间,用了:
‘make’ ‘-C’ ‘xxx/.build/src/linux-custom’ ‘O=xxx/.build/arm-xscale-linux-gnueabi/build/build-kernel-headers’ ‘ARCH=arm’ ‘INSTALL_HDR_PATH=xxx/arm-xscale-linux-gnueabi/sysroot/usr’ ‘V=0’ ‘headers_install’ |
的命令,即,在make时,给了ARCH=arm,所以会去找
arm-xscale-linux-gnu-gcc
但是结果却由于本身就没有
arm-xscale-linux-gnu-gcc
当然报错找不到。
但是问题在于:
(1)在crosstoo-ng编译期间,本身就不应该调用,目标平台的的编译器,此处由于是ARCH=arm所以调用的是:
arm-xscale-linux-gnu-gcc
(2)即使要调用,也应该是,我此处的编译目标:arm-xscale-linux-gnueabi-gcc,才对。
4.考虑到:
此处目标是为了编译交叉工具链,即使不去做所谓的install kernel headers,也无所谓,所以,暂时去取消此设置。
取消之前,看看其解释:
.config – crosstool-NG 1.18.0 Configuration Check installed headers CT_KERNEL_LINUX_INSTALL_CHECK: here to have an extra check passed onto the headers. Type : boolean Depends on: KERNEL_linux [=y] && !KERNEL_LINUX_USE_CUSTOM_HEADERS [=n] Location: -> Operating System |
然后再去取消此选择:
5.然后再去重新编译ct-ng build,看看结果:
错误依旧:
CLi@PC-CLI-1 ~/develop/crosstool-ng/crosstool-ng-1.18.0_build [INFO ] Performing some trivial sanity checks [INFO ] Build started 20130731.140328 [INFO ] Building environment variables [EXTRA] Preparing working directories [EXTRA] Installing user-supplied crosstool-NG configuration [EXTRA] ================================================================= [EXTRA] Dumping internal crosstool-NG configuration [EXTRA] Building a toolchain for: [EXTRA] build = i686-pc-cygwin [EXTRA] host = i686-pc-cygwin [EXTRA] target = arm-xscale-linux-gnueabi [EXTRA] Dumping internal crosstool-NG configuration: done in 0.90s (at 00:54) [INFO ] ================================================================= [INFO ] Retrieving needed toolchain components’ tarballs [EXTRA] Using ‘linux-custom’ from custom location [INFO ] Retrieving needed toolchain components’ tarballs: done in 3.15s (at 00:57) [INFO ] ================================================================= [INFO ] Extracting and patching toolchain components [INFO ] Extracting and patching toolchain components: done in 8.45s (at 01:06) [EXTRA] Saving state to restart at step ‘libc_check_config’… [EXTRA] Saving state to restart at step ‘companion_libs_for_build’… [EXTRA] Saving state to restart at step ‘binutils_for_build’… [EXTRA] Saving state to restart at step ‘companion_libs_for_host’… [INFO ] ================================================================= [INFO ] Installing GMP for host [EXTRA] Configuring GMP [EXTRA] Building GMP [EXTRA] Installing GMP [INFO ] Installing GMP for host: done in 501.29s (at 09:32) [INFO ] ================================================================= [INFO ] Installing MPFR for host [EXTRA] Configuring MPFR [EXTRA] Building MPFR [EXTRA] Installing MPFR [INFO ] Installing MPFR for host: done in 236.76s (at 13:29) [INFO ] ================================================================= [INFO ] Installing MPC for host [EXTRA] Configuring MPC [EXTRA] Building MPC [EXTRA] Installing MPC [INFO ] Installing MPC for host: done in 121.25s (at 15:31) [EXTRA] Saving state to restart at step ‘binutils_for_host’… [INFO ] ================================================================= [INFO ] Installing binutils for host [EXTRA] Configuring binutils [EXTRA] Building binutils [EXTRA] Installing binutils [INFO ] Installing binutils for host: done in 654.77s (at 26:27) [EXTRA] Saving state to restart at step ‘cc_core_pass_1’… [INFO ] ================================================================= [INFO ] Installing pass-1 core C compiler [EXTRA] Configuring gcc [EXTRA] Building gcc [EXTRA] Installing gcc [INFO ] Installing pass-1 core C compiler: done in 978.00s (at 42:49) [EXTRA] Saving state to restart at step ‘kernel_headers’… [INFO ] ================================================================= [INFO ] Installing kernel headers [EXTRA] Installing kernel headers [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] ‘make’ ‘-C’ ‘/home/CLi/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/src/linux-custom’ ‘O=/home/CLi/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-xscale-linux-gnueabi/build/build-kernel-headers’ ‘ARCH=arm’ ‘INSTALL_HDR_PATH=/home/CLi/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> |
即,此处没有取消掉安装kernel头文件。
6.然后再去找对应的脚本的路径:
D:\tmp\tmp_dev_root\cgwin\home\CLi\develop\crosstool-ng\crosstool-ng-1.18.0\scripts\build\kernel\linux.sh
中的112行前后的内容是:
# Install kernel headers using headers_install from kernel sources. do_kernel_install() { local kernel_path CT_DoLog DEBUG "Using kernel's headers_install" mkdir -p "${CT_BUILD_DIR}/build-kernel-headers" kernel_path="${CT_SRC_DIR}/linux-${CT_KERNEL_VERSION}" if [ "${CT_KERNEL_LINUX_CUSTOM}" = "y" ]; then kernel_path="${CT_SRC_DIR}/linux-custom" fi V_OPT="V=${CT_KERNEL_LINUX_VERBOSE_LEVEL}" CT_DoLog EXTRA "Installing kernel headers" CT_DoExecLog ALL \ make -C "${kernel_path}" \ O="${CT_BUILD_DIR}/build-kernel-headers" \ ARCH=${CT_ARCH} \ INSTALL_HDR_PATH="${CT_SYSROOT_DIR}/usr" \ ${V_OPT} \ headers_install if [ "${CT_KERNEL_LINUX_INSTALL_CHECK}" = "y" ]; then CT_DoLog EXTRA "Checking installed headers" CT_DoExecLog ALL \ make -C "${kernel_path}" \ O="${CT_BUILD_DIR}/build-kernel-headers" \ ARCH=${CT_ARCH} \ INSTALL_HDR_PATH="${CT_SYSROOT_DIR}/usr" \ ${V_OPT} \ headers_check fi
很明显,此处的log的:
[DEBUG] ==> Executing: ‘make’ ‘-C’ ‘/home/CLi/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/src/linux-custom’ ‘O=/home/CLi/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-xscale-linux-gnueabi/build/build-kernel-headers’ ‘ARCH=arm’ ‘INSTALL_HDR_PATH=/home/CLi/develop/crosstool-ng/x-tools/arm-xscale-linux-gnueabi/arm-xscale-linux-gnueabi/sysroot/usr’ ‘V=0’ ‘headers_install’ |
是对应的:
make -C "${kernel_path}" \ O="${CT_BUILD_DIR}/build-kernel-headers" \ ARCH=${CT_ARCH} \ INSTALL_HDR_PATH="${CT_SYSROOT_DIR}/usr" \ ${V_OPT} \ headers_install
产生的。
但是由于ARCH=arm而使得调用了arm-xscale-linux-gnu的gcc,结果找不到,而报错。
7.参考:
去找到log是:
[INFO ] Installing kernel headers [EXTRA] Installing kernel headers [DEBUG] ==> Executing: ‘make’ ‘-C’ ‘/home/CLi/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/src/linux-custom’ ‘O=/home/CLi/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-xscale-linux-gnueabi/build/build-kernel-headers’ ‘ARCH=arm’ ‘INSTALL_HDR_PATH=/home/CLi/develop/crosstool-ng/x-tools/arm-xscale-linux-gnueabi/arm-xscale-linux-gnueabi/sysroot/usr’ ‘V=0’ ‘headers_install’ [ALL ] make[1]: Entering directory `/home/CLi/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/src/linux-custom’ [ALL ] make[2]: arm-xscale-linux-gnu-gcc: Command not found [ALL ] /home/CLi/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/src/linux-custom/Makefile:1444: *** mixed implicit and normal rules. Stop. |
然后找到对应的Makefile:
D:\tmp\tmp_dev_root\cgwin\home\CLi\develop\crosstool-ng\crosstool-ng-1.18.0_build\.build\src\linux-custom\Makefile
中的1444行:
# Modules / %/: prepare scripts FORCE $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ $(build)=$(build-dir)
换为:
# Modules #/ %/: prepare scripts FORCE %/: prepare scripts FORCE $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ $(build)=$(build-dir)
再去编译试试。
8.后来,好像看到了此处问题的根本原因和解决办法:
实际上错误是:
mixed implicit and normal rules
然后对此,已经有人:
Build Failure for PPC405 using crosstool-ng 1.9.2
和
fedora14下利用crosstool-ng-1.18.0创建arm-linux交叉编译环境
给出解决办法是:
把make从当前3.82换成旧的3.81
Maybe build 3.81 and install it to ${HOME}/make export PATH="${HOME}/make/bin:$PATH" |
等上面编译再次出错的话,再去这么换make。
9.后来,再搜:
crosstool-ng mixed implicit and normal rules. Stop. |
时,都找到了crosstool-ng的官网的patch和解释了:
docs/known-issues: add the infamous "mixed implicit and normal rules"
此处专门去确认了一下当前cygwin下使用的make:
CLi@PC-CLI-1 ~/develop/crosstool-ng/crosstool-ng-1.18.0_build $ make -v GNU Make 3.82.90 Built for i686-pc-cygwin Copyright (C) 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
的确是3.82的。
此问题的解决办法是:
方法1:
针对此项编译,指定crosstool-ng使用3.81的make,即选上:
Paths and misc options —> Companion tools —> [*] Build some companion tools [*] make |
方法2:
如前所述,手动安装3.81的make。
暂时还是那句:
等上述编译完毕看看是否出错,如果出错再去选上上面的选项。
如果已经解决了,那么就暂时,通过修改makefile,没有换make而解决问题。
10。再后来,其实看到了,之前就看到的,这里:
[ALL ] Makefile:245: *** mixed implicit and normal rules. Stop.
的讨论,也说明了此问题的原因和解决办法,和上面的官网人家提交的patch,是一样的,都是换make。
另外,这里也有个类似的讨论:
11.后来参考:
而找到本地的1.18.0的:
D:\tmp\tmp_dev_root\cgwin\home\CLi\develop\crosstool-ng\crosstool-ng-1.18.0\docs\B – Known issues.txt
也看到对应的解释了:
——————————– glibc start files and headers fail with: [/usr/include/limits.h] Error 1 Explanations: Status: Fix: Workaround: 1- ask crosstool-NG to build make-3.81 just for this build session: Select the following options: Paths and misc options —> [*] Try features marked as EXPERIMENTAL Companion tools —> [*] Build some companion tools [*] make 2- manually install make-3.81 to take precedence over the system make. ——————————– The build fails with "mixed implicit and normal rules. Stop." Explanations: Status: Fix: Workaround: |
结果编译了半天,终于解决此处的错误了。
【总结】
在crosstool-ng的Installing kernel headers阶段,出现:
[DEBUG] ==> Executing: ‘make’ ‘-C’ ‘/home/CLi/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/src/linux-custom’ ‘O=/home/CLi/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-xscale-linux-gnueabi/build/build-kernel-headers’ ‘ARCH=arm’ ‘INSTALL_HDR_PATH=/home/CLi/develop/crosstool-ng/x-tools/arm-xscale-linux-gnueabi/arm-xscale-linux-gnueabi/sysroot/usr’ ‘V=0’ ‘headers_install’ [ALL ] make[2]: arm-xscale-linux-gnu-gcc: Command not found [ALL ] /home/CLi/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/src/linux-custom/Makefile:1444: *** mixed implicit and normal rules. Stop. [ALL ] Makefile:119: recipe for target `headers_install’ failed |
的错误时,实际上:
arm-xscale-linux-gnu-gcc: Command not found |
的错误,不影响继续编译的。
而真正影响编译,而停止的,是:
mixed implicit and normal rules. Stop. |
的错误。
其根本原因是:
make,是新版3.82,不支持如下的语法:
# Modules %/: prepare scripts FORCE $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ $(build)=$(build-dir)
中的:
/ %/: prepare scripts FORCE
前者/的是显式(explicit)的,而后者%/是隐式(implicit)的,而3.82版的make不支持显式和隐式混用。
而之前的3.81版本的make是支持的。
所以解决办法是:
方法1:
直接手动改makefile里面的对应的代码。
比如我这里的,把:
# Modules %/: prepare scripts FORCE $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ $(build)=$(build-dir)
改为:
# Modules #/ %/: prepare scripts FORCE %/: prepare scripts FORCE $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ $(build)=$(build-dir)
即可。
方法2:
让crosstool-ng用3.81版本的make去编译,做法是:
编译选项里面,选上:
Paths and misc options —> Companion tools —> [*] Build some companion tools [*] make |
方法3:
自己手动编译一个3.81的make,然后替换掉当前的3.82的make。
比如:
编译一个3.81的make后,去:
export PATH="${HOME}/make/bin:$PATH" |
而使得之后(crosstool-ng编译的时候,调用系统的make的时候)优先找到的是你的自己的那个3.81的make。
此处解决了此问题,但是后来编译又出现别的错误:
转载请注明:在路上 » 【已解决】编译crosstool-ng在Installing kernel headers时出错:/home/CLi/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/src/linux-custom/Makefile:1444: *** mixed implicit and normal rules. Stop.