Total Pageviews

Monday 18 November 2019

编译crosstool-ng

从3.1.0开始,udns换成了libc-ares

fedora 26上试验编译crosstool-ng 1.21.0
  • 1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    In file included from zconf.tab.c:213:0:
    zconf.hash.c:170:1: error: conflicting types for ‘kconf_id_lookup’
     kconf_id_lookup (register const char *str, register size_t len)
     ^~~~~~~~~~~~~~~
    zconf.hash.c:41:25: note: previous declaration of ‘kconf_id_lookup’ was here
     static struct kconf_id *kconf_id_lookup(register const char *str, register unsigned int len);
                             ^~~~~~~~~~~~~~~
    make[2]: *** [Makefile:96: zconf.tab.o] Error 1
    make[1]: *** [Makefile:166: build-lib-kconfig] Error 2
    make: *** [Makefile:126: build] Error 2
    这是由于gperf太新导致,需要3.0.4,所以最好还是在docker镜像或者虚拟机里搞好,或者脑残法,直接装个旧版
    1
    2
    3
    4
    5
    6
    wget https://ftp.gnu.org/pub/gnu/gperf/gperf-3.0.4.tar.gz
    tar xvf gperf-3.0.4
    cd gperf-3.0.4
    ./configure --prefix=/usr
    make
    make install
  • 1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    INFO ]  Performing some trivial sanity checks
    [INFO ]  Build started 20170924.112011
    [INFO ]  Building environment variables
    [ERROR]    collect2: error: ld returned 1 exit status
    [ERROR]  
    [ERROR]  >>
    [ERROR]  >>  Build failed in step 'Checking that gcc can compile a trivial statically linked program (CT_WANTS_STATIC_LINK)'
    [ERROR]  >>        called in step '(top-level)'
    [ERROR]  >>
    [ERROR]  >>  Error happened in: CT_DoExecLog[scripts/functions@257]
    [ERROR]  >>        called from: main[scripts/crosstool-NG.sh@546]
    [ERROR]  >>
    [ERROR]  >>  For more info on this error, look at the file: 'build.log'
    [ERROR]  >>  There is a list of known issues, some with workarounds, in:
    [ERROR]  >>      '/usr/local/share/doc/crosstool-ng/ct-ng.1.21.0/B - Known issues.txt'
    [ERROR]  
    [ERROR]  (elapsed: 0:01.23)
    [00:01] / gmake[1]: *** [/usr/local/bin/ct-ng:147: build] Error 1
    gmake: *** [/usr/local/bin/ct-ng:150: build.4] Error 2

    1
    2
    dnf groupinstall "Development Tools"
    dnf install glibc-devel glibc-static libstdc++-static
  • 1
    2
    3
    4
    5
    6
    7
    8
    9
    [INFO ]  Installing final compiler
    [ERROR]    cfns.gperf:101:1: error: 'const char* libc_name_p(const char*, unsigned int)' redeclared inline with 'gnu_inline' attribute
    [ERROR]    gmake[4]: *** [Makefile:1058: cp/except.o] Error 1
    [ERROR]    gmake[3]: *** [Makefile:4118: all-gcc] Error 2
    [ERROR]    gmake[2]: *** [Makefile:874: all] Error 2
    [ERROR]  
    [ERROR]  >>
    [ERROR]  >>  Build failed in step 'Installing final compiler'
    [ERROR]  >>        called in step '(top-level)'
    这是因为gcc6以上编译旧版gcc 5.1.0,需要上游的patch, 虽然crosstool-ng有在新版本中带这个patch,可是需要的老版本的uclibc又没有了,所以还不如不要在自己系统里编译,用docker开个旧版系统应该方便些
    update 10/14/2017: lz试了下gcc 5.5.0,似乎不会出错,只需要改一下ctng.config文件里的gcc版本号即可,见这里
fedora 25 on docker
官方镜像里有25
1
2
3
4
5
6
7
8
9
sudo docker run -it --name fedora  docker.io/fedora:25 /bin/bash
dnf groupinstall "Development Tools"
dnf install automake gperf bison flex texinfo wget bzip2 libtool ncurses-devel
 
git clone https://github.com/crosstool-ng/crosstool-ng.git
cd crosstool-ng
git checkout tags/crosstool-ng-1.21.0
./bootstrap
./configure
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# make
  GEN    'config/configure.in'
  GEN    'paths.mk'
  GEN    'paths.sh'
  CC     'zconf.tab.o'
zconf.tab.c: In function 'zconfparse':
zconf.tab.c:1508:42: error: 'kconf_id_strings' undeclared (first use in this function)
  zconf_error("unexpected option \"%s\"", kconf_id_strings + (yyvsp[-2].id)->name);
                                          ^~~~~~~~~~~~~~~~
zconf.tab.c:1508:42: note: each undeclared identifier is reported only once for each function it appears in
zconf.tab.c:1629:24: warning: implicit declaration of function 'kconf_id_lookup' [-Wimplicit-function-declaration]
  struct kconf_id *id = kconf_id_lookup((yyvsp[-1].string), strlen((yyvsp[-1].string)));
                        ^~~~~~~~~~~~~~~
zconf.tab.c:1629:24: warning: initialization makes pointer from integer without a cast [-Wint-conversion]
zconf.tab.c: In function 'zconf_endtoken':
zconf.tab.c:2237:4: error: 'kconf_id_strings' undeclared (first use in this function)
    kconf_id_strings + id->name, zconf_tokenname(starttoken));
    ^~~~~~~~~~~~~~~~
In file included from zconf.tab.c:2429:0:
lex.zconf.c: In function 'zconflex':
lex.zconf.c:1117:25: warning: initialization makes pointer from integer without a cast [-Wint-conversion]
   struct kconf_id *id = kconf_id_lookup(zconftext, zconfleng);
                         ^~~~~~~~~~~~~~~
lex.zconf.c:1192:25: warning: initialization makes pointer from integer without a cast [-Wint-conversion]
   struct kconf_id *id = kconf_id_lookup(zconftext, zconfleng);
                         ^~~~~~~~~~~~~~~
Makefile:95: recipe for target 'zconf.tab.o' failed
make[2]: *** [zconf.tab.o] Error 1
Makefile:166: recipe for target 'build-lib-kconfig' failed
make[1]: *** [build-lib-kconfig] Error 2
Makefile:126: recipe for target 'build' failed
make: *** [build] Error 2
放弃,还是用更老的系统吧
lz用了travis的ubuntu docker镜像
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
make[5]: Entering directory `/home/travis/builds/tomato-arm/release/src-rt-6.x.4708/router/nano'
CDPATH="${ZSH_VERSION+.}:" && cd . && /bin/bash /home/travis/builds/tomato-arm/release/src-rt-6.x.4708/router/nano/missing aclocal-1.15 -I m4
configure.ac:27: error: Autoconf version 2.69 or higher is required
configure.ac:27: the top level
autom4te: /usr/bin/m4 failed with exit status: 63
aclocal-1.15: error: echo failed with exit status: 63
WARNING: 'aclocal-1.15' is probably too old.
         You should only need it if you modified 'acinclude.m4' or
         'configure.ac' or m4 files included by 'configure.ac'.
         The 'aclocal' program is part of the GNU Automake package:
         //www.gnu.org/software/automake>
         It also requires GNU Autoconf, GNU m4 and Perl in order to run:
         //www.gnu.org/software/autoconf>
         //www.gnu.org/software/m4/>
         //www.perl.org/>
make[5]: *** [aclocal.m4] Error 63
make[5]: Leaving directory `/home/travis/builds/tomato-arm/release/src-rt-6.x.4708/router/nano'
make[4]: *** [nano] Error 2
那就按他说的装2.69好了, 因为repo里只有2.68,可以用apt-cache policy autoconf查询
1
2
3
4
5
6
7
cd ~
wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz
tar xf autoconf-2.69.tar.gz
cd autoconf-2.69
sh configure --prefix /usr
make
sudo  make install
因为lz懒得一步一步试验需要装哪些,所以直接用了编译tomato固件时候需要的那些依赖,在此省略(其实就是把tomato-ci repo里的 .travis.sh 里的pre_build_prep运行了一下,装了一堆automake, autoconf, libtool等)
编译crosstool-ng 1.21工具链
准备工作,添加如下配置文件,不然wget没法从https网站下载文件
~/.wgetrc
1
check_certificate = off
1
2
3
4
5
6
7
8
sudo apt-get install gperf texinfo
 
mkdir -p /home/travis/src
 
# edit .config, modify uclibc config file path
ct-ng menuconfig
 
ct-ng build.4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
export PATH=/home/travis/x-tools/mipsel-unknown-linux-uclibc/bin:$PATH
 
sudo apt-get install asciidoc
 
. ./travis.sh
# then build install all dependencies
 
git clone git@github.com:oglops/shadowsocks-libev.git
 
cd shadowsocks-libev
git submodule update --init --recursive
 
./autogen.sh
 
CPPFLAGS="-I$HOME/cares-install/include -I$HOME/libev-install/include -I$HOME/zlib-install/include" LDFLAGS="-Wl,-rpath,/jffs/lib -L$HOME/cares-install/lib -L$HOME/libev-install/lib -L$HOME/zlib-install/lib" CC=mipsel-unknown-linux-uclibc-gcc CXX=mipsel-unknown-linux-uclibc-g++ AR=mipsel-unknown-linux-uclibc-ar RANLIB=mipsel-unknown-linux-uclibc-ranlib ./configure --disable-ssp --prefix=$HOME/ss-install --with-pcre=$HOME/pcre-install --with-sodium=$HOME/libsodium-install --with-mbedtls=$HOME/mbedtls-install --host=mipsel-uclibc-linux
 
make
make install
# Then possibly strip and upx the executable files
文件下载:
http://oglopss.github.io/ctng-ss-jekyll/
3.1.0之前的下载见repo的download文件夹,或者上面github pages页面底部的之前一遍blog里的mega网盘
参考:
Issue during make #39
Repositories on Docker Hub