shadowsocks / shadowsocks-libev

Bug-fix-only libev port of shadowsocks. Future development moved to shadowsocks-rust
https://github.com/shadowsocks/shadowsocks-rust
GNU General Public License v3.0
15.79k stars 5.69k forks source link

Link error for asuswrt-merlin. (MIPS) #707

Closed zw963 closed 8 years ago

zw963 commented 8 years ago

Following is error message:

libtool: link: mipsel-linux-uclibc-gcc -g -O2 -Wall -Werror -Wno-deprecated-declarations -fno-strict-aliasing -std=gnu99 -D_GNU_SOURCE -pthread -I../libev -I../libudns -I../libsodium/src/libsodium/include -I../libipset/include -I../libcork/include -DMODULE_LOCAL -g -O2 -I/home/zw963/Dropbox/common/personal/ac66U/openssl/include -pthread -o ss-local ss_local-utils.o ss_local-jconf.o ss_local-json.o ss_local-encrypt.o ss_local-udprelay.o ss_local-cache.o ss_local-acl.o ss_local-netutils.o ss_local-local.o  -L/home/zw963/Dropbox/common/personal/ac66U/zlib -L/home/zw963/Dropbox/common/personal/ac66U/openssl/lib ../libipset/.libs/libipset.a ../libcork/.libs/libcork.a ../libev/.libs/libev.a ../libsodium/src/libsodium/.libs/libsodium.a ../libudns/.libs/libudns.a -lcrypto -lm -lz -ldl -pthread
/home/zw963/Git/asuswrt-merlin/tools/brcm/K26/hndtools-mipsel-uclibc-4.2.4/bin/../lib/gcc/mipsel-linux-uclibc/4.2.4/../../../../mipsel-linux-uclibc/bin/ld: warning: libc.so.1, needed by /home/zw963/Dropbox/common/personal/ac66U/zlib/libz.so, not found (try using -rpath or -rpath-link)
../libcork/.libs/libcork.a(libcork_la-error.o): In function `cork_error__get':
/home/zw963/Git/shadowsocks-libev/libcork/core/error.c:79: undefined reference to `__sync_val_compare_and_swap_4'
/home/zw963/Git/shadowsocks-libev/libcork/core/error.c:79: undefined reference to `__sync_val_compare_and_swap_4'
../libcork/.libs/libcork.a(libcork_la-error.o): In function `cork_error_get':
/home/zw963/Git/shadowsocks-libev/libcork/core/error.c:92: undefined reference to `__sync_val_compare_and_swap_4'
/home/zw963/Git/shadowsocks-libev/libcork/core/error.c:88: undefined reference to `__sync_val_compare_and_swap_4'
/home/zw963/Git/shadowsocks-libev/libcork/core/error.c:88: undefined reference to `__sync_val_compare_and_swap_4'
collect2: ld returned 1 exit status
make[2]: *** [ss-local] Error 1
make[2]: Leaving directory `/home/zw963/Git/shadowsocks-libev/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/zw963/Git/shadowsocks-libev'
make: *** [all] Error 2

The problem seem like is, make told me libc.so.1 could not found

warning: libc.so.1, needed by /home/zw963/Dropbox/common/personal/ac66U/zlib/libz.so, not found (try using -rpath or -rpath-link)

Following is my compile args, all need library is copy to $ac66U/lib, But, still told me missing lib files.

# all need library is copy to $ac66U/lib, But,  still told me missing lib files.

export LD_LIBRARY_PATH=$ac66u/lib
export LIBPATH=$LD_LIBRARY_PATH
export LDFLAGS=-L$ac66U/lib

./configure --prefix=$ac66U/ss \
            --with-openssl=$ac66U/openssl \
            --with-zlib-lib=$ac66U/zlib \
            --host=mipsel-uclibc-linux \
            --with-sysroot=$ac66U/lib \
            --disable-ssp
make V=99

Thanks.

zw963 commented 8 years ago

Hi, I found the LDFLAGS is not make effect.

The final -L export into Make files is: -L/home/zw963/Dropbox/common/personal/ac66U/zlib -L/home/zw963/Dropbox/common/personal/ac66U/openssl/lib

Not -L$ac66U/lib.

zw963 commented 8 years ago

I have try any method i know to let Makefile know I add a -Lpath in

  1. export LDFLAGS=-L$ac66U/lib
  2. LDFLAGS=-L$ac66U/lib make V=99
  3. configure LDFLAGS=-L$ac66U/lib ...

    But all not worked.

Current ystem: Linux Mint 17.3 x64.

Thanks.

madeye commented 8 years ago

You need a new toolchain. GCC 4.2 is not supported.

zw963 commented 8 years ago

Is there any alternative way to workaround this?

toolchain is select by merlin, not me.

It is seem like broken link is following commnd.

libtool: link: mipsel-linux-uclibc-gcc -g -O2 -Wall -Werror -Wno-deprecated-declarations -fno-strict-aliasing -std=gnu99 -D_GNU_SOURCE -pthread -I../libev -I../libudns -I../libsodium/src/libsodium/include -I../libipset/include -I../libcork/include -DMODULE_LOCAL -g -O2 -I/home/zw963/Dropbox/common/personal/ac66U/openssl/include -pthread -o ss-local ss_local-utils.o ss_local-jconf.o ss_local-json.o ss_local-encrypt.o ss_local-udprelay.o ss_local-cache.o ss_local-acl.o ss_local-netutils.o ss_local-local.o  -L/home/zw963/Dropbox/common/personal/ac66U/zlib -L/home/zw963/Dropbox/common/personal/ac66U/openssl/lib ../libipset/.libs/libipset.a ../libcork/.libs/libcork.a ../libev/.libs/libev.a ../libsodium/src/libsodium/.libs/libsodium.a ../libudns/.libs/libudns.a -lcrypto -lm -lz -ldl -pthread
rampageX commented 8 years ago

Use Tomatoware mipsel and static compile, slower but work.

zw963 commented 8 years ago

@rampageX , What the means of static compile ?

add --enable-static to configure ?

jun0s commented 7 years ago

@zw963 did you find some solution ? some workaround with gcc 4.2 ?¡ thanks.

zw963 commented 7 years ago

@jun0s , use Tomatoware toolchains.

rampageX commented 7 years ago

@zw963 @jun0s Tomatoware, Please refer to: https://github.com/lancethepants/tomatoware.

Simply install the support package on router and do native build on router, do not need do cross-compile.

In addition to Entware, I have all the necessary software that are compiled with Tomatoware on router, with static compile, compiled once then run everywhere, as long as the same type of CPU.

Attachment which I compile on my ASUS AC66U router, OpenSSL, Mbedtsl, PolarSSL three versions included.

Shadowsocks-libev.mipsel.v2.5.5.static.7z

Link: http://pan.baidu.com/s/1mhFy8Gw Password: 78nx

xc2 commented 7 years ago

The cork library needs __sync_add_and_fetch, __sync_fetch_and_add, __sync_sub_and_fetch, __sync_fetch_and_sub and __sync_val_compare_and_swap to work.

You can implement these functions using uclibc's, just like this (which is not full compatible, and has no variable argument lists support, but just works):

#ifdef __UCLIBC__
#ifndef UCLIBC_ATOMIC_H
#define UCLIBC_ATOMIC_H
#include <atomic.h>

#ifndef __sync_add_and_fetch
#define __sync_add_and_fetch(mem, value) \
(atomic_exchange_and_add ((mem), value) + value)
#endif

#ifndef __sync_fetch_and_add
#define __sync_fetch_and_add atomic_exchange_and_add
#endif

#ifndef __sync_sub_and_fetch
#define __sync_sub_and_fetch(mem, value) \
(atomic_exchange_and_add ((mem), 0 - value) - value)
#endif

#ifndef __sync_fetch_and_sub
#define __sync_fetch_and_sub(mem, value) \
atomic_exchange_and_add ((mem), 0 - value)
#endif

#ifndef __sync_val_compare_and_swap
#define __sync_val_compare_and_swap(mem, oldval, newval) \
atomic_compare_and_exchange_val_acq (mem, newval, oldval)
#endif

#endif /* UCBLIC_ATOMIC_H */
#endif /* __UCLIBC__ */

Try to include it in libcork/threads/atomics.h and continue compilation.

jun0s commented 7 years ago

thank you @zw963 but i need a toolchain for arm big endian, and thank you very much @rampageX but.. the same :( @xc2 did yout think that in my case can work ur solution?

Thank you so much guys... :)