3.3.1.2. 从之前错误的那一步恢复继续编译

示例配置:


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. 从出错的那一步恢复重新继续编译

比如,我之前折腾:

【已解决】crosstool-ng在Installing C library headers & start files期间出错:Makefile:240: *** mixed implicit and normal rules. Stop.

期间,当时出错的输出信息是:


=================================================================
[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

[小心]此处不是ct-ng last_fail_step+

此处,之前不熟悉此功能的用法,结果去用:

ct-ng last_fail_step+

的方法,即用:

ct-ng cc_core_pass_1+

想要回复错误,继续执行,结果就出现:

[ERROR]  The previous build did not reach the point where it could be restarted at xxx

之类的错误了。

详见:

【已解决】crosstool-ng在Installing C library headers & start files期间出错:Makefile:240: *** mixed implicit and normal rules. Stop.

[提示]RESTART=step的参数估计也可以实现同样的从错误那步恢复继续编译的效果

从之前的第 3.1.1 节 “用ct-ng help查看所拥有的功能”中可以看出

估计在build的时候,指定对应的RESTART=step

ct-ng build RESTART=last_successful_step

应该也可以实现类似的效果的。

有空的话,可以去试试。