最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】crosstool-ng在Installing kernel headers时出错:[ERROR] /xxx/crosstool-ng/crosstool-ng-1.18.0_build/.build/src/linux-custom/scripts/unifdef.c:209:25: error: conflicting types for ‘getline’

crosstool-ng crifan 3191浏览 0评论

【问题】

在折腾:

【记录】编译配置好的xscale版本的crosstool-ng-1.18.0

期间,解决了:

【已解决】编译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.

后,结果又出现另外的错误:

CLi@PC-CLI-1 ~/develop/crosstool-ng/crosstool-ng-1.18.0_build
$ ct-ng build
[INFO ]  Performing some trivial sanity checks
[INFO ]  Build started 20130731.151836
[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.89s (at 00:48)
[INFO ]  =================================================================
[INFO ]  Retrieving needed toolchain components' tarballs
[EXTRA]    Using 'linux-custom' from custom location
[INFO ]  Retrieving needed toolchain components' tarballs: done in 3.16s (at 00:51)
[INFO ]  =================================================================
[INFO ]  Extracting and patching toolchain components
[INFO ]  Extracting and patching toolchain components: done in 8.77s (at 01:00)
[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 487.49s (at 09:13)
[INFO ]  =================================================================
[INFO ]  Installing MPFR for host
[EXTRA]    Configuring MPFR
[EXTRA]    Building MPFR
[EXTRA]    Installing MPFR
[INFO ]  Installing MPFR for host: done in 227.55s (at 13:00)
[INFO ]  =================================================================
[INFO ]  Installing MPC for host
[EXTRA]    Configuring MPC
[EXTRA]    Building MPC
[EXTRA]    Installing MPC
[INFO ]  Installing MPC for host: done in 114.11s (at 14:55)
[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 626.43s (at 25:23)
[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 954.27s (at 41:21)
[EXTRA]  Saving state to restart at step 'kernel_headers'...
[INFO ]  =================================================================
[INFO ]  Installing kernel headers
[EXTRA]    Installing kernel headers
[ERROR]    /home/CLi/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/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>

对应的详细的log内容:

[INFO ]  =================================================================

[INFO ]  Installing kernel headers

[DEBUG]    Using kernel’s headers_install

[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  ]      CHK     include/linux/version.h

[ALL  ]      UPD     include/linux/version.h

[ALL  ]      HOSTCC  scripts/basic/fixdep

[ALL  ]    /home/CLi/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/src/linux-custom/scripts/basic/fixdep.c: In function ‘parse_config_file’:

[ALL  ]    /home/CLi/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/src/linux-custom/scripts/basic/fixdep.c:242:4: warning: array subscript has type ‘char’

[ALL  ]    /home/CLi/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/src/linux-custom/scripts/basic/fixdep.c: In function ‘parse_dep_file’:

[ALL  ]    /home/CLi/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/src/linux-custom/scripts/basic/fixdep.c:319:4: warning: array subscript has type ‘char’

[ALL  ]    /home/CLi/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/src/linux-custom/scripts/basic/fixdep.c: In function ‘traps’:

[ALL  ]    /home/CLi/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/src/linux-custom/scripts/basic/fixdep.c:371:2: warning: dereferencing type-punned pointer will break strict-aliasing rules

[ALL  ]    /home/CLi/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/src/linux-custom/scripts/basic/fixdep.c:373:4: warning: dereferencing type-punned pointer will break strict-aliasing rules

[ALL  ]      HOSTCC  scripts/basic/docproc

[ALL  ]    /home/CLi/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/src/linux-custom/scripts/basic/docproc.c: In function ‘find_export_symbols’:

[ALL  ]    /home/CLi/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/src/linux-custom/scripts/basic/docproc.c:188:5: warning: array subscript has type ‘char’

[ALL  ]    /home/CLi/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/src/linux-custom/scripts/basic/docproc.c:191:5: warning: array subscript has type ‘char’

[ALL  ]    /home/CLi/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/src/linux-custom/scripts/basic/docproc.c:197:5: warning: array subscript has type ‘char’

[ALL  ]    /home/CLi/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/src/linux-custom/scripts/basic/docproc.c:200:5: warning: array subscript has type ‘char’

[ALL  ]    /home/CLi/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/src/linux-custom/scripts/basic/docproc.c: In function ‘singfunc’:

[ALL  ]    /home/CLi/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/src/linux-custom/scripts/basic/docproc.c:267:17: warning: array subscript has type ‘char’

[ALL  ]    /home/CLi/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/src/linux-custom/scripts/basic/docproc.c: In function ‘parse_file’:

[ALL  ]    /home/CLi/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/src/linux-custom/scripts/basic/docproc.c:300:6: warning: array subscript has type ‘char’

[ALL  ]    /home/CLi/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/src/linux-custom/scripts/basic/docproc.c:305:6: warning: array subscript has type ‘char’

[ALL  ]    /home/CLi/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/src/linux-custom/scripts/basic/docproc.c:310:6: warning: array subscript has type ‘char’

[ALL  ]    /home/CLi/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/src/linux-custom/scripts/basic/docproc.c:316:6: warning: array subscript has type ‘char’

[ALL  ]    /home/CLi/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/src/linux-custom/scripts/basic/docproc.c:319:6: warning: array subscript has type ‘char’

[ALL  ]      HOSTCC  scripts/unifdef

[ERROR]    /home/CLi/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/src/linux-custom/scripts/unifdef.c:209:25: error: conflicting types for ‘getline’

[ALL  ]    /usr/include/sys/stdio.h:37:9: note: previous declaration of ‘getline’ was here

[ALL  ]    scripts/Makefile.host:118: recipe for target `scripts/unifdef’ failed

[ERROR]    make[3]: *** [scripts/unifdef] Error 1

[ALL  ]    /home/CLi/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/src/linux-custom/Makefile:941: recipe for target `headers_install’ failed

[ERROR]    make[2]: *** [headers_install] Error 2

[ALL  ]    Makefile:119: recipe for target `headers_install’ failed

[ERROR]    make[1]: *** [headers_install] Error 2

[ALL  ]    make[1]: Leaving directory `/home/CLi/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/src/linux-custom’

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

即:

[ERROR]    /home/CLi/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/src/linux-custom/scripts/unifdef.c:209:25: error: conflicting types for ‘getline’

[ALL  ]    /usr/include/sys/stdio.h:37:9: note: previous declaration of ‘getline’ was here

 

【解决过程】

1.很久很久之前,貌似就见过此问题。

2.参考:

libc/uClibc: fix building on system with recent glibc

去改个别的名字:

D:\tmp\tmp_dev_root\cgwin\home\CLi\develop\crosstool-ng\crosstool-ng-1.18.0_build\.build\src\linux-custom\scripts\unifdef.c

改为:

static void             flushline(bool);
//static Linetype         getline(void);
static Linetype         get_line(void);
static Linetype         ifeval(const char **);

......

/*
 * The driver for the state machine.
 */
static void
process(void)
{
	Linetype lineval;

	for (;;) {
		linenum++;
		//lineval = getline();
        lineval = get_line();
		trans_table[ifstate[depth]][lineval]();
		debug("process %s -> %s depth %d",
		    linetype_name[lineval],
		    ifstate_name[ifstate[depth]], depth);
	}
}

/*
 * Parse a line and determine its type. We keep the preprocessor line
 * parser state between calls in the global variable linestate, with
 * help from skipcomment().
 */
static Linetype
//getline(void)
get_line(void)
{

 

3.修改好之后,用exit 2去继续编译:

[INFO ]  =================================================================
[INFO ]  Installing kernel headers
[EXTRA]    Installing kernel headers
[ERROR]    /home/CLi/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/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> exit 2

然后就可以继续编译了。

 

【总结】

libc/uClibc: fix building on system with recent glibc

所述,getline的bug,是自从glibc 2.10就有了。

解决办法是:

把getline随便改个别的名字即可。比如get_line,或像:

Patchwork scripts/unifdef.c: rename getline symbol to something else

中去改为parseline等等,都可以。

 

注意:

文件中不止一处getline,注意要都修改了,不要漏了,才可以。

转载请注明:在路上 » 【已解决】crosstool-ng在Installing kernel headers时出错:[ERROR] /xxx/crosstool-ng/crosstool-ng-1.18.0_build/.build/src/linux-custom/scripts/unifdef.c:209:25: error: conflicting types for ‘getline’

与本文相关的文章

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
83 queries in 0.174 seconds, using 22.44MB memory