一半君的总结纸

听话只听一半君

update: crosstool-ng 1.2.2 cross compile shadowsocks-libev 2.4.5 for 磊科q3 asus rt-n66u rt-n16

更新一下上一篇 update: crosstool-ng 1.2.2 cross compile shadowsocks-libev 2.4.1 for 磊科q3 asus rt-n66u rt-n16

本文的内容已过时,请参考这篇: crosstool-ng 1.22.0 and shadowsocks 2.4.5 备忘录,有编译好的版本下载.

因为之前的笔记本上还有编译出来的toolchain,所以直接从第4步开始
在compile shadowsocks的时候提示需要libssp,所以重新编译了工具链,在C compiler选项里选中compile libssp,配置文件在此,不过好像用不着,因为tomato里没有libssp? 所以configure ss的时候加上–disable-ssp即可, (lz想用在磊科q3上,jffs很小,entware里好像有libssp,不知道装上可不可以),可能是因为这个commit造成的

opkg install libssp

这个错误是

/home/oglop/x-tools/mipsel-unknown-linux-uclibc/lib/gcc/mipsel-unknown-linux-uclibc/5.2.0/../../../../mipsel-unknown-linux-uclibc/bin/ld: cannot find -lssp_nonshared
/home/oglop/x-tools/mipsel-unknown-linux-uclibc/lib/gcc/mipsel-unknown-linux-uclibc/5.2.0/../../../../mipsel-unknown-linux-uclibc/bin/ld: cannot find -lssp

ctng_libssp

  1. 编译openssl
    
    # 补装点东西 可能装多了 不是很确定
    sudo yum install -y gperf texinfo glib* libstdc++* help2man ncurses-devel makedepend ncurses-term expat-devel expat  expat-static
    
    # export path
    export PATH=/home/oglop/x-tools/mipsel-unknown-linux-uclibc/bin:$PATH
    
    cd openssl
    git clean -nfd
    git pull
    git checkout tags/OpenSSL_1_0_2g
    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 no-asm shared --prefix=/home/oglop/Downloads/openssl-install linux-mips32
    # make depend 会出一堆错,网上搜到说可以不管
    make && make install
    
  2. 编译shadowsocks 2.4.5
    git clone https://github.com/shadowsocks/shadowsocks-libev.git
    cd shadowsocks-libev
    git clean -nfd
    git pull
    git checkout tags/v2.4.5
    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/oglop/Downloads/ss-install  --with-openssl=/home/oglop/Downloads/openssl-install --host=mipsel-uclibc-linux --with-zlib=/home/oglop/Downloads/zlib-install
    make V=99 && make install
    

    strip然后upx

    [oglop@localhost strip]$ ~/Downloads/upx-3.91-amd64_linux/upx *
                           Ultimate Packer for eXecutables
                              Copyright (C) 1996 - 2013
    UPX 3.91        Markus Oberhumer, Laszlo Molnar & John Reiser   Sep 30th 2013
    
            File size         Ratio      Format      Name
       --------------------   ------   -----------   -----------
        228364 ->    102180   44.74%  linux/mipsel   ss-local                      
        106480 ->     46992   44.13%  linux/mipsel   ss-manager                    
        208412 ->     94960   45.56%  linux/mipsel   ss-redir                      
        265276 ->    115924   43.70%  linux/mipsel   ss-server                     
        207564 ->     94568   45.56%  linux/mipsel   ss-tunnel                     
       --------------------   ------   -----------   -----------
       1016096 ->    454624   44.74%                 [ 5 files ]
    
    Packed 5 files.
    

ps:lz在asus rt-n16上的tomato shibby版的v132上测试了下出现错误如下.

can't resolve symbol 'epoll_create1'

试试看升级到tomato shibby v133行不行

# 先备份下jffs
rsync --rsync-path=/opt/bin/rsync -avHe ssh root@192.168.1.2:/jffs .

# 升级好以后再拷回去
rsync --rsync-path=/opt/bin/rsync -avHe ssh jffs/* root@192.168.1.2:/jffs

结果果然不行,继续乱搞, lz又降回了v132,因为v133改动很大,多了multiwan,需要重设nvram,lz不想追新

路由器上的libc里果然是没有的

root@unknown:/tmp/home/root# strings /lib/libc.so.0  | grep epoll
epoll_pwait
epoll_wait
epoll_ctl
epoll_create

再看看 ct-ng 1.22 生成的toolchain里的libc.so

[oglop@localhost]$ strings /home/oglop/x-tools/mipsel-unknown-linux-uclibc/mipsel-unknown-linux-uclibc/sysroot/lib/libc.so.0  | grep epoll
epoll_create
epoll_create1
epoll_ctl
__libc_epoll_wait
__libc_epoll_pwait
epoll.c
epoll_create1
epoll_wait
__libc_epoll_wait
epoll_ctl
epoll_create
__libc_epoll_pwait
epoll_pwait

看看 ct-ng 1.21 生成的toolchain里的libc.so

[oglop@localhost]$ strings /home/oglop/x-tools/mipsel-unknown-linux-uclibc-1.21/mipsel-unknown-linux-uclibc/sysroot/lib/libc.so.0  | grep epoll
epoll_create
epoll_ctl
epoll_wait
epoll.c
epoll.h
SYS_epoll_pwait __NR_epoll_pwait
__NR_epoll_ctl (4000 + 249)
__NR_epoll_create (4000 + 248)
__NR_epoll_create1 (4000 + 326)
SYS_epoll_create1 __NR_epoll_create1
SYS_epoll_create __NR_epoll_create
SYS_epoll_wait __NR_epoll_wait
__NR_epoll_pwait (4000 + 313)
__NR_epoll_wait (4000 + 250)
SYS_epoll_ctl __NR_epoll_ctl
libc/sysdeps/linux/common/epoll.c
epoll_event
epoll_data
epoll_data_t
libc/sysdeps/linux/common/epoll.c
epoll_wait
epoll_ctl
epoll_create

测试uclibc不同配置文件的时候可以从编译到他的时候开始,省点时间

RESTART=libc ct-ng build

其他几条相关命令

# 显示so文件里有哪些symbol
mipsel-unknown-linux-uclibc-nm -D libc.so.0

# 显示gcc preprocessor defines
mipsel-unknown-linux-uclibc-gcc -dM -E - < /dev/null

# 只显示entware里packages的名字
opkg list |  awk '{print $1}'
opkg list |  cut -d' ' -f1

顺便发现前一篇文章里的2.4.1也有此问题,可能lz编译出来以后没测试就发出来共享了,试了下用本系列备忘录里的第一篇文章中共享的toolchain(由crosstools-ng 1.21生成)来编译最新的ss 2.4.5没有任何错误,看来是toolchain的问题,经比较配置文件后,大部分都一样,可能是由于linux kernel的差异造成1.21中的最低可选kernel是2.6.32.66,而1.22中的是 2.6.32.68,其实1.21里用的已经和tomato的有点不一样了,以前既然能用也就没管,tomato中的版本是

root@unknown:/tmp/home/root# uname -r
2.6.22.19

ct-ng里的kernel选择配置界面里有 custom tarball or directory的选项,lz下面就来用和tomato里版本一样的kernel来重新出一个“恰当”的toolchain,去官网 找到2.6.22.19

如果你直接设置用这个目录,build的时候会出类似下面的错

[oglop@localhost linux-stable-kernel]$ make ARCH=mips INSTALL_HDR_PATH=$(pwd)/hdr headers_install
Makefile:1443: *** mixed implicit and normal rules.  Stop.

crosstools-ng的 doc/B – Known issues.txt里有提到

Workaround:
  There two possible workarounds:
  1- ask crosstool-NG to build make-3.81 just for this build session:
     Select the following options:
        Paths and misc options  --->
            [*] Try features marked as EXPERIMENTAL
        Companion tools  --->
            [*] Build some companion tools
            [*]   make
  2- manually install make-3.81 to take precedence over the system make.

--------------------------------
Symptoms:
  The build fails with "mixed implicit and normal rules. Stop."

Explanations:
  Old glibc Makefiles break with make-3.82.

Status:
  CURRENT

Fix:
  None so far. See above issue.

Workaround:
  See above issue.

所以按照说明操作,去把那几个地方勾上,可以用ct-ng list-steps看从哪一步接着开始,比如

RESTART=kernel_headers ct-ng build

但是经lz测试,就算你勾了我要用3.8.1的make还是出这个错,所以lz放弃了不用2.6.22.19了,干脆还是用之前ct-ng 1.21里能正常工作的2.6.32.66得了,但是ct-ng 1.22里没有这个选项,lz下面来把他加回去

# 修改此文件 : /usr/local/lib/crosstool-ng-1.22.0/config/kernel/linux.in 在相应的地方加上

config KERNEL_V_2_6_32_66
    bool
    prompt "2.6.32.66" 

...

    default "2.6.32.66" if KERNEL_V_2_6_32_66

然后在菜单里选中这个kernel版本
ctng_1.22_custom_kernel

后来发现用老版的kernel还是不行,所以继续乱搞

lz最后屈服了,还是用的旧版ct-ng 1.21 toolchain编译的,在tomato shibby v132上测试可用, lz正在试travis ci,免得每次手试

tips:
如果出现 configure: error: expat is missing or unusable 而系统上又实在装不了libexpat的话,可以
把”–disable-expat –with-expat=no” 加到 “extra gdb configure args”里,

文件下载:
还是用上篇的ct-ng 1.21编译的
shadowsocks-libev_2.4.5_mipsel_OpenSSL_dynamic.tar.gz
mipsel-unknown-linux-uclibc-1.22.0-libssp.tar.gz
openssl-1.0.2g-dynamic-install.tar.gz

参考:
Re: cannot build crosstool due to Makefile issues (mixed implicit and normal rules)
GCC dump preprocessor defines
How do I interpret strace output?

Advertisements

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s

%d 博主赞过: