nba2kol二次疾风步:crosstool编译过程中gcc版本问题

来源:百度文库 编辑:偶看新闻 时间:2024/05/01 13:23:07
crosstool编译过程中gcc版本问题   
    在使用crosstool构建工具链的过程中,出现了如下问题,导致arm-linux-gcc没有生成:
   
    > checking version of gcc... 4.0.0, bad
    > checking for gnumake... no
    > checking for gmake... gmake
    > checking version of gmake... 3.80, ok
    > configure: error:
    > *** These critical programs are missing or too old: gcc
    > *** Check the INSTALL file for required versions.

    察看crosstool目录中的contrib/inbox.txt文件,有关于这个问题的邮件描述:

> checking build system type... i686-pc-linux-gnu
> checking host system type... mipsel-unknown-linux-gnu
> checking sysdep dirs... sysdeps/mips/elf sysdeps/unix/sysv/linux/mips
> sysdeps/unix/sysv/linux sysdeps/gnu sysdeps/unix/common
> sysdeps/unix/mman sysdeps/unix/inet sysdeps/unix/sysv sysdeps/unix/mips
> sysdeps/unix sysdeps/posix sysdeps/mips/mipsel sysdeps/mips/fpu
> sysdeps/mips sysdeps/wordsize-32 sysdeps/ieee754/flt-32
> sysdeps/ieee754/dbl-64 sysdeps/ieee754 sysdeps/generic/elf sysdeps/generic
> checking for a BSD-compatible install... /usr/bin/install -c
> checking whether ln -s works... yes
> checking for pwd... /bin/pwd
> checking for mipsel-unknown-linux-gnu-gcc... gcc
> checking version of gcc... 4.0.0, bad
> checking for gnumake... no
> checking for gmake... gmake
> checking version of gmake... 3.80, ok
> configure: error:
> *** These critical programs are missing or too old: gcc
> *** Check the INSTALL file for required versions.
>
I have had the same problem. What I found was that the glibc configure
script was testing for a version of gcc 3.2.* or later. It does not test
for a major number above 3 so the test fails. I do not know where this
test is initiated, but once you have reached that point you can patch
the configure script and run demo-*.sh with the --nounpack option added
to your desired toolchain build.

This patch worked for me:

--- configure.orig      2005-09-19 21:31:45.000000000 -0400
+++ configure   2005-09-19 21:32:13.000000000 -0400
@@ -2274,6 +2274,8 @@
     '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
     3.[2-9]*)
        ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
+    4.*)
+       ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
     *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
 
   esac

I hope that this helps. Good Luck.
-Mike Joyce

    其意思就是说,在glibc的configure脚本里会检查gcc的版本,当不是需要的版本就保错, glibc的configure中有如下检查:

if test -z "$CC"; then
  ac_verc_fail=yes
else
  # Found it, now check the version.
  echo "$as_me:$LINENO: checking version of $CC" >&5
echo $ECHO_N "checking version of $CC... $ECHO_C" >&6
  ac_prog_version=`$CC -v 2>&1 | sed -n 's/^.*version \([egcygnustpi-]*[0-9.]*\).*$/\1/p'`
  case $ac_prog_version in
    '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
    3.[2-9]*)
       ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
    *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;

  esac
  echo "$as_me:$LINENO: result: $ac_prog_version" >&5
echo "${ECHO_T}$ac_prog_version" >&6
fi
if test $ac_verc_fail = yes; then
  critic_missing="$critic_missing gcc"
fi

    在上面的gcc版本检查中,只使用了模式3.[2-9]*即只支持3.xxx版本的gcc,在crosstool自己的patches目录下有一个patch:patches/glibc-2.3.3-allow-gcc-4.0-configure.patch,他会在编译glic-2.3.2的时候给这个configure文件先打补丁,那个补丁来修复这个bug,但是这个补丁文件也不是很好,其内容是:


--- glibc-2.3.3/configure.old    Mon Mar 14 12:01:10 2005
+++ glibc-2.3.3/configure    Mon Mar 14 12:02:03 2005
@@ -3899,7 +3899,7 @@
   ac_prog_version=`$CC -v 2>&1 | sed -n 's/^.*version \([egcygnustpi-]*[0-9.]*\).*$/\1/p'`
   case $ac_prog_version in
     '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
-    3.[2-9]*)
+    3.[2-9]*|4.[01]*)
        ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
     *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
     即,它只是增加了对4.0xxx或者4.1xxx的支持,还是不够,我现在用的是4.2.1因此还是会出错,因此,修改这个patch,改为3.[2-9]*|4.*)就可以过去了。

    总之,在编译glibc的时候,其configure脚本对gcc的限定是比较严格的,而且并没有将后来的较新的版本考虑在内,这种严格的检查是我们在configure是出了错。但是如果我们直接修改glibc原码中的configure文件,又会造成crosstool在用他自己的patches给glibc的configure打补丁的时候出错,呵呵,还是去修改crosstool的补丁文件吧,glibc就留着不要动了。