【已解决】cygwin中编译crosstool-ng在eglibc 2.17中的rpc_parse.c出错:rpc/types.h:73:18: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘u_char’

【问题】

折腾:

【记录】cygwin下在针对arm920t去ct-ng menuconfig配置后去ct-ng build去编译

期间,编译出错:

[INFO ]  =================================================================
[INFO ]  Installing C library headers & start files
[EXTRA]    Configuring C library
[EXTRA]    Installing C library headers
[ERROR]    rpc/types.h:73:18: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'u_char'
[ERROR]    rpc/types.h:74:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'u_short'
[ERROR]    rpc/types.h:75:17: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'u_int'
[ERROR]    rpc/types.h:76:18: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'u_long'
[ERROR]    rpc/types.h:77:18: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'quad_t'
[ERROR]    rpc/types.h:78:20: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'u_quad_t'
[ERROR]    rpc/types.h:79:18: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'fsid_t'
[ERROR]    rpc/types.h:83:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'daddr_t'
[ERROR]    rpc/types.h:84:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'caddr_t'
[ERROR]    make[3]: *** [/home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/build/build-libc-startfiles/sunrpc/cross-rpc_parse.o] Error 1
[ERROR]    make[2]: *** [sunrpc/install-headers] Error 2
[ERROR]    make[1]: *** [install-headers] Error 2
[ERROR]
[ERROR]  >>
[ERROR]  >>  Build failed in step 'Installing C library headers & start files'
[ERROR]  >>        called in step '(top-level)'
[ERROR]  >>
[ERROR]  >>  Error happened in: CT_DoExecLog[scripts/functions@257]
[ERROR]  >>        called from: do_libc_backend_once[scripts/build/libc/glibc-eglibc.sh-common@380]
[ERROR]  >>        called from: do_libc_backend[scripts/build/libc/glibc-eglibc.sh-common@143]
[ERROR]  >>        called from: do_libc_start_files[scripts/build/libc/glibc-eglibc.sh-common@60]
[ERROR]  >>        called from: main[scripts/crosstool-NG.sh@632]


Current command:
  'make' '-j4' '-l' 'install_root=/home/develop/crosstool-ng/x-tools/arm-arm920t-linux-gnueabi/arm-arm920t-linux-gnueabi/sysroot' 'install-bootstrap-headers=yes' 'install-headers'
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:/home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/build/build-libc-startfiles>

如图:

rpc types.h error expected asm or attribute before u_char

即:

[ERROR]    rpc/types.h:73:18: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘u_char’

对应的build.log:

E:\dev_install_root\cygwin\home\develop\crosstool-ng\crosstool-ng-1.18.0_build\build.log

相关内容为:

[ALL  ]    mkdir /home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/build/build-libc-startfiles/sunrpc
[ALL  ]    touch /home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/build/build-libc-startfiles/libc-abis.stamp
[ALL  ]    i686-build_pc-cygwin-gcc   -D_RPC_THREAD_SAFE_ -D_GNU_SOURCE -DIS_IN_build -include /home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/build/build-libc-startfiles/config.h rpc_main.c 		-o /home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/build/build-libc-startfiles/sunrpc/cross-rpc_main.o -MMD -MP -MF /home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/build/build-libc-startfiles/sunrpc/cross-rpc_main.o.dt -MT /home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/build/build-libc-startfiles/sunrpc/cross-rpc_main.o -c
[ALL  ]    i686-build_pc-cygwin-gcc   -D_RPC_THREAD_SAFE_ -D_GNU_SOURCE -DIS_IN_build -include /home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/build/build-libc-startfiles/config.h rpc_hout.c 		-o /home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/build/build-libc-startfiles/sunrpc/cross-rpc_hout.o -MMD -MP -MF /home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/build/build-libc-startfiles/sunrpc/cross-rpc_hout.o.dt -MT /home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/build/build-libc-startfiles/sunrpc/cross-rpc_hout.o -c
[ALL  ]    mkdir /home/develop/crosstool-ng/x-tools/arm-arm920t-linux-gnueabi/arm-arm920t-linux-gnueabi/sysroot/usr/include/nfs
[ALL  ]    i686-build_pc-cygwin-gcc   -D_RPC_THREAD_SAFE_ -D_GNU_SOURCE -DIS_IN_build -include /home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/build/build-libc-startfiles/config.h rpc_cout.c 		-o /home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/build/build-libc-startfiles/sunrpc/cross-rpc_cout.o -MMD -MP -MF /home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/build/build-libc-startfiles/sunrpc/cross-rpc_cout.o.dt -MT /home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/build/build-libc-startfiles/sunrpc/cross-rpc_cout.o -c
[ALL  ]    /home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/tools/bin/install -c -m 644 ../sysdeps/unix/sysv/linux/nfs/nfs.h /home/develop/crosstool-ng/x-tools/arm-arm920t-linux-gnueabi/arm-arm920t-linux-gnueabi/sysroot/usr/include/nfs/nfs.h
[ALL  ]    i686-build_pc-cygwin-gcc   -D_RPC_THREAD_SAFE_ -D_GNU_SOURCE -DIS_IN_build -include /home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/build/build-libc-startfiles/config.h rpc_parse.c 		-o /home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/build/build-libc-startfiles/sunrpc/cross-rpc_parse.o -MMD -MP -MF /home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/build/build-libc-startfiles/sunrpc/cross-rpc_parse.o.dt -MT /home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/build/build-libc-startfiles/sunrpc/cross-rpc_parse.o -c
[ALL  ]    i686-build_pc-cygwin-gcc   -D_RPC_THREAD_SAFE_ -D_GNU_SOURCE -DIS_IN_build -include /home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/build/build-libc-startfiles/config.h rpc_scan.c 		-o /home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/build/build-libc-startfiles/sunrpc/cross-rpc_scan.o -MMD -MP -MF /home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/build/build-libc-startfiles/sunrpc/cross-rpc_scan.o.dt -MT /home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/build/build-libc-startfiles/sunrpc/cross-rpc_scan.o -c
[ALL  ]    i686-build_pc-cygwin-gcc   -D_RPC_THREAD_SAFE_ -D_GNU_SOURCE -DIS_IN_build -include /home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/build/build-libc-startfiles/config.h rpc_util.c 		-o /home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/build/build-libc-startfiles/sunrpc/cross-rpc_util.o -MMD -MP -MF /home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/build/build-libc-startfiles/sunrpc/cross-rpc_util.o.dt -MT /home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/build/build-libc-startfiles/sunrpc/cross-rpc_util.o -c
[ALL  ]    In file included from rpc_parse.c:39:0:
[ERROR]    rpc/types.h:73:18: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'u_char'
[ERROR]    rpc/types.h:74:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'u_short'
[ERROR]    rpc/types.h:75:17: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'u_int'
[ERROR]    rpc/types.h:76:18: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'u_long'
[ERROR]    rpc/types.h:77:18: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'quad_t'
[ERROR]    rpc/types.h:78:20: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'u_quad_t'
[ERROR]    rpc/types.h:79:18: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'fsid_t'
[ERROR]    rpc/types.h:83:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'daddr_t'
[ERROR]    rpc/types.h:84:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'caddr_t'
[ERROR]    make[3]: *** [/home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/build/build-libc-startfiles/sunrpc/cross-rpc_parse.o] Error 1
[ALL  ]    make[3]: *** Waiting for unfinished jobs....
[ALL  ]    make[3]: Leaving directory `/home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/src/eglibc-2_17/sunrpc'
[ERROR]    make[2]: *** [sunrpc/install-headers] Error 2
[ALL  ]    make[2]: Leaving directory `/home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/src/eglibc-2_17'
[ERROR]    make[1]: *** [install-headers] Error 2
[ALL  ]    make[1]: Leaving directory `/home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/build/build-libc-startfiles'
[ERROR]  
[ERROR]  >>
[ERROR]  >>  Build failed in step 'Installing C library headers & start files'
[ERROR]  >>        called in step '(top-level)'
[ERROR]  >>
[ERROR]  >>  Error happened in: CT_DoExecLog[scripts/functions@257]
[ERROR]  >>        called from: do_libc_backend_once[scripts/build/libc/glibc-eglibc.sh-common@380]
[ERROR]  >>        called from: do_libc_backend[scripts/build/libc/glibc-eglibc.sh-common@143]
[ERROR]  >>        called from: do_libc_start_files[scripts/build/libc/glibc-eglibc.sh-common@60]
[ERROR]  >>        called from: main[scripts/crosstool-NG.sh@632]

【解决过程】

1.参考:

Re: [PATCH 2 of 2] libc/eglibc: [OS X] Don’t Redefine Already Defined Types in rpc/types.h

然后另外找到有patch的帖子:

Patchwork [2,of,2] libc/eglibc: [OS X] Don’t Redefine Already Defined Types in rpc/types.h

去在对应位置,新建了patch文件:

E:\dev_install_root\cygwin\home\develop\crosstool-ng\crosstool-ng-1.18.0\patches\eglibc\2_17\osx_do_not_redefine_types_sunrpc.patch

内容为:

diff -r fcdf7fc7fd1c -r 0926f7ff958a patches/eglibc/2_17/osx_do_not_redefine_types_sunrpc.patch
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/eglibc/2_17/osx_do_not_redefine_types_sunrpc.patch	Tue Mar 26 14:28:49 2013 +0200
@@ -0,0 +1,39 @@ 
+Apple already defines the u_char, u_short, etc. types in <sys/types.h>.
+However, those are defined directly, without using the __u_char types.
+
+diff -Naur eglibc-2_17-old/sunrpc/rpc/types.h eglibc-2_17-new/sunrpc/rpc/types.h
+--- eglibc-2_17-old/sunrpc/rpc/types.h	2010-08-19 23:32:31.000000000 +0300
++++ eglibc-2_17-new/sunrpc/rpc/types.h	2013-03-26 01:16:16.000000000 +0200
+@@ -69,7 +69,11 @@
+ #include <sys/types.h>
+ #endif
+ 
+-#ifndef __u_char_defined
++/*
++ * OS X already has these <sys/types.h>
++ */
++#ifndef __APPLE__
++# ifndef __u_char_defined
+ typedef __u_char u_char;
+ typedef __u_short u_short;
+ typedef __u_int u_int;
+@@ -77,13 +81,14 @@
+ typedef __quad_t quad_t;
+ typedef __u_quad_t u_quad_t;
+ typedef __fsid_t fsid_t;
+-# define __u_char_defined
+-#endif
+-#ifndef __daddr_t_defined
++#  define __u_char_defined
++# endif
++# ifndef __daddr_t_defined
+ typedef __daddr_t daddr_t;
+ typedef __caddr_t caddr_t;
+-# define __daddr_t_defined
+-#endif
++#  define __daddr_t_defined
++# endif
++#endif /* __APPLE__ */
+ 
+ #include <sys/time.h>
+ #include <sys/param.h>

然后再去编译,看看是否能生效:

结果错误依旧:

Administrator@PC-20130611GART /home/develop/crosstool-ng/crosstool-ng-1.18.0_build
$ ct-ng build RESTART=libc_start_files
[INFO ]  Performing some trivial sanity checks
[INFO ]  Build started 20131006.221555
[INFO ]  Building environment variables
[EXTRA]  Preparing working directories
[EXTRA]  Restoring state at step 'libc_start_files', as requested.
[INFO ]  =================================================================
[INFO ]  Installing C library headers & start files
[EXTRA]    Configuring C library
[EXTRA]    Installing C library headers
[ERROR]    rpc/types.h:73:18: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'u_char'
[ERROR]    rpc/types.h:74:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'u_short'
[ERROR]    rpc/types.h:75:17: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'u_int'
[ERROR]    rpc/types.h:76:18: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'u_long'
[ERROR]    rpc/types.h:77:18: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'quad_t'
[ERROR]    rpc/types.h:78:20: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'u_quad_t'
[ERROR]    rpc/types.h:79:18: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'fsid_t'
[ERROR]    rpc/types.h:83:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'daddr_t'
[ERROR]    rpc/types.h:84:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'caddr_t'
[ERROR]    make[3]: *** [/home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/build/build-libc-startfiles/sunrpc/cross-rpc_parse.o] Error 1
[ERROR]    make[2]: *** [sunrpc/install-headers] Error 2
[ERROR]    make[1]: *** [install-headers] Error 2
[ERROR]
[ERROR]  >>
[ERROR]  >>  Build failed in step 'Installing C library headers & start files'
[ERROR]  >>        called in step '(top-level)'
[ERROR]  >>
[ERROR]  >>  Error happened in: CT_DoExecLog[scripts/functions@257]
[ERROR]  >>        called from: do_libc_backend_once[scripts/build/libc/glibc-eglibc.sh-common@380]
[ERROR]  >>        called from: do_libc_backend[scripts/build/libc/glibc-eglibc.sh-common@143]
[ERROR]  >>        called from: do_libc_start_files[scripts/build/libc/glibc-eglibc.sh-common@60]
[ERROR]  >>        called from: main[scripts/crosstool-NG.sh@632]


Current command:
  'make' '-j4' '-l' 'install_root=/home/develop/crosstool-ng/x-tools/arm-arm920t-linux-gnueabi/arm-arm920t-linux-gnueabi/sysroot' 'install-bootstrap-headers=yes' 'install-headers'
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:/home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/build/build-libc-startfiles>

2.感觉或许是由于此处的eglibc已经解压过了,没法再去打上刚才那个patch。

所以无法生效。所以打算删除

E:\dev_install_root\cygwin\home\develop\crosstool-ng\crosstool-ng-1.18.0_build\.build\src\eglibc-2_17

之前,先去参考一下:

E:\dev_install_root\cygwin\home\develop\crosstool-ng\crosstool-ng-1.18.0\patches\eglibc

别的版本的patch,发现其他版本的patch,都是

001-xxx.patch

或是:

100-xxx.patch

所以此处也去改名为:

E:\dev_install_root\cygwin\home\develop\crosstool-ng\crosstool-ng-1.18.0\patches\eglibc\2_17\001-osx_do_not_redefine_types_sunrpc.patch

然后再去删除:

E:\dev_install_root\cygwin\home\develop\crosstool-ng\crosstool-ng-1.18.0_build\.build\src\eglibc-2_17

然后再去

ct-ng build RESTART=libc_start_files

看看结果。

3.结果这样是不行的,会说找不到configure的:

[INFO ]  =================================================================
[INFO ]  Installing C library headers & start files
[EXTRA]    Configuring C library
[DEBUG]    Using gcc for target    : '/home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/buildtools/bin/arm-arm920t-linux-gnueabi-gcc'
[DEBUG]    Configuring with addons : 'nptl,ports'
[DEBUG]    Extra config args passed: '--enable-obsolete-rpc --enable-kernel=2.6.30 --with-__thread --with-tls --enable-shared --without-fp --enable-add-ons=nptl,ports --with-pkgversion=crosstool-NG 1.18.0'
[DEBUG]    Extra CC args passed    : ' -U_FORTIFY_SOURCE  -mlittle-endian -march=armv4t   -mtune=arm920t  -msoft-float -O -O2 '
[DEBUG]    Extra flags (multilib)  : ''
[DEBUG]    ==> Executing: 'BUILD_CC=i686-build_pc-cygwin-gcc' 'CFLAGS= -U_FORTIFY_SOURCE  -mlittle-endian -march=armv4t   -mtune=arm920t  -msoft-float -O -O2 ' 'CC=arm-arm920t-linux-gnueabi-gcc    ' 'AR=arm-arm920t-linux-gnueabi-ar' 'RANLIB=arm-arm920t-linux-gnueabi-ranlib' '/usr/bin/bash' '/home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/src/eglibc-2_17/configure' '--prefix=/usr' '--build=i686-build_pc-cygwin' '--host=arm-arm920t-linux-gnueabi' '--cache-file=/home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/build/build-libc-startfiles/config.cache' '--without-cvs' '--disable-profile' '--without-gd' '--with-headers=/home/develop/crosstool-ng/x-tools/arm-arm920t-linux-gnueabi/arm-arm920t-linux-gnueabi/sysroot/usr/include' '--enable-obsolete-rpc' '--enable-kernel=2.6.30' '--with-__thread' '--with-tls' '--enable-shared' '--without-fp' '--enable-add-ons=nptl,ports' '--with-pkgversion=crosstool-NG 1.18.0' 
[CFG  ]    /usr/bin/bash: /home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/src/eglibc-2_17/configure: No such file or directory
[ERROR]  
[ERROR]  >>
[ERROR]  >>  Build failed in step 'Installing C library headers & start files'
[ERROR]  >>        called in step '(top-level)'
[ERROR]  >>
[ERROR]  >>  Error happened in: CT_DoExecLog[scripts/functions@257]
[ERROR]  >>        called from: do_libc_backend_once[scripts/build/libc/glibc-eglibc.sh-common@347]
[ERROR]  >>        called from: do_libc_backend[scripts/build/libc/glibc-eglibc.sh-common@143]
[ERROR]  >>        called from: do_libc_start_files[scripts/build/libc/glibc-eglibc.sh-common@60]
[ERROR]  >>        called from: main[scripts/crosstool-NG.sh@632]

所以,还是重头编译一遍。。。

4.结果是由于patch不对,而导致出错:

[INFO ]  =================================================================
[INFO ]  Extracting and patching toolchain components
[DEBUG]    Already extracted 'gmp-4.3.2'
[DEBUG]    Already patched 'gmp-4.3.2'
[DEBUG]    Already extracted 'mpfr-2.4.2'
[DEBUG]    Already patched 'mpfr-2.4.2'
[DEBUG]    Already extracted 'libelf-0.8.13'
[DEBUG]    Already patched 'libelf-0.8.13'
[DEBUG]    Already extracted 'binutils-2.20.1a'
[DEBUG]    Already patched 'binutils-2.20.1a'
[DEBUG]    Already extracted 'gcc-4.3.2'
[DEBUG]    Already patched 'gcc-4.3.2'
[DEBUG]    Already extracted 'eglibc-2_17'
[ERROR]  
[ERROR]  >>
[ERROR]  >>  Build failed in step 'Extracting and patching toolchain components'
[ERROR]  >>        called in step '(top-level)'
[ERROR]  >>
[ERROR]  >>  Error happened in: CT_Pushd[scripts/functions@417]
[ERROR]  >>        called from: do_libc_extract[scripts/build/libc/glibc-eglibc.sh-common@9]
[ERROR]  >>        called from: main[scripts/crosstool-NG.sh@603]

5.然后去把:

E:\dev_install_root\cygwin\home\develop\crosstool-ng\crosstool-ng-1.18.0\patches\eglibc\2_17\001-osx_do_not_redefine_types_sunrpc.patch

改为:

Apple already defines the u_char, u_short, etc. types in <sys/types.h>.
However, those are defined directly, without using the __u_char types.

diff -Naur eglibc-2_17-old/sunrpc/rpc/types.h eglibc-2_17-new/sunrpc/rpc/types.h
--- eglibc-2_17-old/sunrpc/rpc/types.h	2010-08-19 23:32:31.000000000 +0300
+++ eglibc-2_17-new/sunrpc/rpc/types.h	2013-03-26 01:16:16.000000000 +0200
@@ -69,7 +69,11 @@
 #include <sys/types.h>
 #endif
 
-#ifndef __u_char_defined
+/*
+ * OS X already has these <sys/types.h>
+ */
+#ifndef __APPLE__
+# ifndef __u_char_defined
 typedef __u_char u_char;
 typedef __u_short u_short;
 typedef __u_int u_int;
@@ -77,13 +81,14 @@
 typedef __quad_t quad_t;
 typedef __u_quad_t u_quad_t;
 typedef __fsid_t fsid_t;
-# define __u_char_defined
-#endif
-#ifndef __daddr_t_defined
+#  define __u_char_defined
+# endif
+# ifndef __daddr_t_defined
 typedef __daddr_t daddr_t;
 typedef __caddr_t caddr_t;
-# define __daddr_t_defined
-#endif
+#  define __daddr_t_defined
+# endif
+#endif /* __APPLE__ */
 
 #include <sys/time.h>
 #include <sys/param.h>

然后再去运行试试,

结果错误依旧。

6.删除掉

001-osx_do_not_redefine_types_sunrpc.patch.bak

再删除掉:

E:\dev_install_root\cygwin\home\develop\crosstool-ng\crosstool-ng-1.18.0_build\.build\src\.eglibc-2_17.patched

E:\dev_install_root\cygwin\home\develop\crosstool-ng\crosstool-ng-1.18.0_build\.build\src\.eglibc-2_17.extracted

再重新编译试试:

然后对于eglic 2.17去打补丁,就正常了:

但是最终错误依旧:

Administrator@PC-20130611GART /home/develop/crosstool-ng/crosstool-ng-1.18.0_build
$ ct-ng build
[INFO ]  Performing some trivial sanity checks
[INFO ]  Build started 20131006.225417
[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-arm920t-linux-gnueabi
[EXTRA]  Dumping internal crosstool-NG configuration: done in 0.77s (at 00:31)
[INFO ]  =================================================================
[INFO ]  Retrieving needed toolchain components' tarballs
[EXTRA]    Using 'linux-custom' from custom location
[INFO ]  Retrieving needed toolchain components' tarballs: done in 2.40s (at 00:34)
[INFO ]  =================================================================
[INFO ]  Extracting, patching and installing companion tools
[EXTRA]    =================================================================
[EXTRA]    Installing make
[EXTRA]    Installing make: done in 161.84s (at 03:16)
[INFO ]  Extracting, patching and installing companion tools: done in 162.59s (at 03:17)
[INFO ]  =================================================================
[INFO ]  Extracting and patching toolchain components
[EXTRA]    Extracting 'eglibc-2_17'
[EXTRA]    Patching 'eglibc-2_17'
[INFO ]  Extracting and patching toolchain components: done in 27.25s (at 03:44)
[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 1404.95s (at 27:14)
[INFO ]  =================================================================
[INFO ]  Installing MPFR for host
[EXTRA]    Configuring MPFR
[EXTRA]    Building MPFR
[EXTRA]    Installing MPFR
[INFO ]  Installing MPFR for host: done in 229.11s (at 31:03)
[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 669.95s (at 42:14)
[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 1037.75s (at 59:36)
[EXTRA]  Saving state to restart at step 'kernel_headers'...
[INFO ]  =================================================================
[INFO ]  Installing kernel headers
[EXTRA]    Installing kernel headers
[EXTRA]    Checking installed headers
[INFO ]  Installing kernel headers: done in 72.82s (at 60:55)
[EXTRA]  Saving state to restart at step 'libc_start_files'...
[INFO ]  =================================================================
[INFO ]  Installing C library headers & start files
[EXTRA]    Configuring C library
[EXTRA]    Installing C library headers
[ERROR]    rpc/types.h:73:18: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'u_char'
[ERROR]    rpc/types.h:74:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'u_short'
[ERROR]    rpc/types.h:75:17: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'u_int'
[ERROR]    rpc/types.h:76:18: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'u_long'
[ERROR]    rpc/types.h:77:18: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'quad_t'
[ERROR]    rpc/types.h:78:20: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'u_quad_t'
[ERROR]    rpc/types.h:79:18: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'fsid_t'
[ERROR]    rpc/types.h:83:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'daddr_t'
[ERROR]    rpc/types.h:84:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'caddr_t'
[ERROR]    make[3]: *** [/home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/build/build-libc-startfiles/sunrpc/cross-rpc_parse.o] Error 1
[ERROR]    make[2]: *** [sunrpc/install-headers] Error 2
[ERROR]    make[1]: *** [install-headers] Error 2
[ERROR]
[ERROR]  >>
[ERROR]  >>  Build failed in step 'Installing C library headers & start files'
[ERROR]  >>        called in step '(top-level)'
[ERROR]  >>
[ERROR]  >>  Error happened in: CT_DoExecLog[scripts/functions@257]
[ERROR]  >>        called from: do_libc_backend_once[scripts/build/libc/glibc-eglibc.sh-common@380]
[ERROR]  >>        called from: do_libc_backend[scripts/build/libc/glibc-eglibc.sh-common@143]
[ERROR]  >>        called from: do_libc_start_files[scripts/build/libc/glibc-eglibc.sh-common@60]
[ERROR]  >>        called from: main[scripts/crosstool-NG.sh@632]


Current command:
  'make' '-j4' '-l' 'install_root=/home/develop/crosstool-ng/x-tools/arm-arm920t-linux-gnueabi/arm-arm920t-linux-gnueabi/sysroot' 'install-bootstrap-headers=yes' 'install-headers'
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:/home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/build/build-libc-startfiles>

所以,还是先去看看,文件是否真的打了补丁:

结果发现:

E:\dev_install_root\cygwin\home\develop\crosstool-ng\crosstool-ng-1.18.0_build\.build\src\eglibc-2_17\sunrpc\rpc\types.h

中是:

#ifndef makedev /* ie, we haven't already included it */
#include <sys/types.h>
#endif

#ifndef __u_char_defined
typedef __u_char u_char;
typedef __u_short u_short;
typedef __u_int u_int;
typedef __u_long u_long;
typedef __quad_t quad_t;
typedef __u_quad_t u_quad_t;
typedef __fsid_t fsid_t;
# define __u_char_defined
#endif
#ifndef __daddr_t_defined
typedef __daddr_t daddr_t;
typedef __caddr_t caddr_t;
# define __daddr_t_defined
#endif

#include <sys/time.h>
#include <sys/param.h>

即,根本没有打补丁。

7.然后手动改为:

//#ifndef __u_char_defined
/*
 * OS X and Cygwin already has these <sys/types.h>
 */
#ifndef __APPLE__
# ifndef __u_char_defined
typedef __u_char u_char;
typedef __u_short u_short;
typedef __u_int u_int;
typedef __u_long u_long;
typedef __quad_t quad_t;
typedef __u_quad_t u_quad_t;
typedef __fsid_t fsid_t;
//# define __u_char_defined
//#endif
#  define __u_char_defined
# endif

#ifndef __daddr_t_defined
typedef __daddr_t daddr_t;
typedef __caddr_t caddr_t;
//# define __daddr_t_defined
//#endif
#  define __daddr_t_defined
# endif
#endif /* __APPLE__ */

其中暂时没考虑cygwin。

看看编译是否成功。

结果果然错误依旧。

8.再去添加cygwin的检查:

//#ifndef __u_char_defined
/*
 * OS X and Cygwin already has these <sys/types.h>
 */
#ifndef __CYGWIN__ //add for check for __CYGWIN__
#ifndef __APPLE__
# ifndef __u_char_defined
typedef __u_char u_char;
typedef __u_short u_short;
typedef __u_int u_int;
typedef __u_long u_long;
typedef __quad_t quad_t;
typedef __u_quad_t u_quad_t;
typedef __fsid_t fsid_t;
//# define __u_char_defined
//#endif
#  define __u_char_defined
# endif

#ifndef __daddr_t_defined
typedef __daddr_t daddr_t;
typedef __caddr_t caddr_t;
//# define __daddr_t_defined
//#endif
#  define __daddr_t_defined
# endif
#endif /* __APPLE__ */

#include <sys/time.h>
#include <sys/param.h>

#include <netinet/in.h>

#ifndef INADDR_LOOPBACK
#define       INADDR_LOOPBACK         (u_long)0x7F000001
#endif
#ifndef MAXHOSTNAMELEN
#define        MAXHOSTNAMELEN  64
#endif

#endif /* rpc/types.h */
#endif /* __CYGWIN__ */

用exit 2重新运行当前命令,结果是:

终于解决此问题,继续编译了:

[ERROR]  rpc/types.h:78:18: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'u_char'
[ERROR]  rpc/types.h:79:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'u_short'
[ERROR]  rpc/types.h:80:17: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'u_int'
[ERROR]  rpc/types.h:81:18: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'u_long'
[ERROR]  rpc/types.h:82:18: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'quad_t'
[ERROR]  rpc/types.h:83:20: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'u_quad_t'
[ERROR]  rpc/types.h:84:18: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'fsid_t'
[ERROR]  rpc/types.h:91:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'daddr_t'
[ERROR]  rpc/types.h:92:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'caddr_t'
[ERROR]  rpc/types.h:78:18: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'u_char'
[ERROR]  rpc/types.h:79:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'u_short'
[ERROR]  rpc/types.h:80:17: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'u_int'
[ERROR]  rpc/types.h:81:18: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'u_long'
[ERROR]  rpc/types.h:82:18: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'quad_t'
[ERROR]  rpc/types.h:83:20: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'u_quad_t'
[ERROR]  rpc/types.h:84:18: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'fsid_t'
[ERROR]  rpc/types.h:91:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'daddr_t'
[ERROR]  rpc/types.h:92:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'caddr_t'
[ERROR]  make[3]: *** [/home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/build/build-libc-startfiles/sunrpc/cross-rpc_clntout.o] Error 1
[ERROR]  make[3]: *** [/home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/build/build-libc-startfiles/sunrpc/cross-rpc_parse.o] Error 1
[ERROR]  make[2]: *** [sunrpc/install-headers] Error 2
[ERROR]  make[1]: *** [install-headers] Error 2
[ERROR]
[ERROR]  >>
[ERROR]  >>  Build failed in step '(top-level)'
[ERROR]  >>
[ERROR]  >>  Error happened in: CT_DoExecLog[scripts/functions@257]
[ERROR]  >>        called from: do_libc_backend_once[scripts/build/libc/glibc-eglibc.sh-common@380]
[ERROR]  >>        called from: do_libc_backend[scripts/build/libc/glibc-eglibc.sh-common@143]
[ERROR]  >>        called from: do_libc_start_files[scripts/build/libc/glibc-eglibc.sh-common@60]
[ERROR]  >>        called from: main[scripts/crosstool-NG.sh@632]


Current command:
  'make' '-j4' '-l' 'install_root=/home/develop/crosstool-ng/x-tools/arm-arm920t-linux-gnueabi/arm-arm920t-linux-gnueabi/sysroot' 'install-bootstrap-headers=yes' 'install-headers'
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:/home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/build/build-libc-startfiles> exit 2
exit

Re-trying last command.

[EXTRA]    Installing C library start files
[INFO ]  Installing C library headers & start files: done in 1586.60s (at 87:28)
[EXTRA]  Saving state to restart at step 'cc_core_pass_2'...
[INFO ]  =================================================================
[INFO ]  Installing pass-2 core C compiler
[EXTRA]    Configuring gcc
[88:06] \

 

【总结】

此处,错误原因很简单,就是重定义了。

但是,此处通过添加patch到对应的

E:\dev_install_root\cygwin\home\develop\crosstool-ng\crosstool-ng-1.18.0\patches\eglibc\2_17\001-osx_do_not_redefine_types_sunrpc.patch

结果却没有真正生效:

对应的eglibc-2.17的sunrpc/rpc/types.h没有被修改。

后来还是手动修改的,结果还是不行。

最终是,添加了cygwin的判断才可以的。

即:

修改:

E:\dev_install_root\cygwin\home\develop\crosstool-ng\crosstool-ng-1.18.0_build\.build\src\eglibc-2_17\sunrpc\rpc\types.h

从:

#ifndef __u_char_defined
typedef __u_char u_char;
typedef __u_short u_short;
typedef __u_int u_int;
typedef __u_long u_long;
typedef __quad_t quad_t;
typedef __u_quad_t u_quad_t;
typedef __fsid_t fsid_t;
# define __u_char_defined
#endif
#ifndef __daddr_t_defined
typedef __daddr_t daddr_t;
typedef __caddr_t caddr_t;
# define __daddr_t_defined
#endif

#include <sys/time.h>
#include <sys/param.h>

改为:

//#ifndef __u_char_defined
/*
 * OS X and Cygwin already has these <sys/types.h>
 */
#ifndef __CYGWIN__ //add for check for __CYGWIN__
#ifndef __APPLE__
# ifndef __u_char_defined
typedef __u_char u_char;
typedef __u_short u_short;
typedef __u_int u_int;
typedef __u_long u_long;
typedef __quad_t quad_t;
typedef __u_quad_t u_quad_t;
typedef __fsid_t fsid_t;
//# define __u_char_defined
//#endif
#  define __u_char_defined
# endif

#ifndef __daddr_t_defined
typedef __daddr_t daddr_t;
typedef __caddr_t caddr_t;
//# define __daddr_t_defined
//#endif
#  define __daddr_t_defined
# endif
#endif /* __APPLE__ */

#include <sys/time.h>
#include <sys/param.h>

#include <netinet/in.h>

#ifndef INADDR_LOOPBACK
#define       INADDR_LOOPBACK         (u_long)0x7F000001
#endif
#ifndef MAXHOSTNAMELEN
#define        MAXHOSTNAMELEN  64
#endif

#endif /* rpc/types.h */
#endif /* __CYGWIN__ */

即可。



发表评论

电子邮件地址不会被公开。 必填项已用*标注

无觅相关文章插件,快速提升流量