https://github.com/honwen/openwrt-shadowsocksr
https://github.com/AlexZhuo/openwrt-shadowsocksr?tab=readme-ov-file (有错误说明)
https://github.com/kimking666/shadowsocksr-libev_openwrt
目录
遇到的问题
一、编译问题
1.size of array element is not a multiple of its alignment
In file included from crypto_generichash/blake2/ref/blake2b-compress-ref.c:5:
crypto_generichash/blake2/ref/blake2.h:118:5: error: size of array element is not a multiple of its alignment
118 | blake2s_state S[8][1];
| ^~~~~~~~~~~~~
crypto_generichash/blake2/ref/blake2.h:119:5: error: size of array element is not a multiple of its alignment
119 | blake2s_state R[1];
| ^~~~~~~~~~~~~
crypto_generichash/blake2/ref/blake2.h:126:5: error: size of array element is not a multiple of its alignment
126 | blake2b_state S[4][1];
| ^~~~~~~~~~~~~
crypto_generichash/blake2/ref/blake2.h:127:5: error: size of array element is not a multiple of its alignment
127 | blake2b_state R[1];
| ^~~~~~~~~~~~~
make[8]: *** [Makefile:2722: crypto_generichash/blake2/ref/libsodium_la-blake2b-compress-ref.lo] Error 1
make[8]: Leaving directory '/home/openwrt/lede/build_dir/target-x86_64_musl/shadowsocksr-libev/shadowsocksr-libev-2018-03-07-d63ff863800a5645aca4309d5dd5962bd1e95543/libsodium/src/libsodium'
make[7]: *** [Makefile:3719: all-recursive] Error 1
make[7]: Leaving directory '/home/openwrt/lede/build_dir/target-x86_64_musl/shadowsocksr-libev/shadowsocksr-libev-2018-03-07-d63ff863800a5645aca4309d5dd5962bd1e95543/libsodium/src/libsodium'
make[6]: *** [Makefile:377: all-recursive] Error 1
make[6]: Leaving directory '/home/openwrt/lede/build_dir/target-x86_64_musl/shadowsocksr-libev/shadowsocksr-libev-2018-03-07-d63ff863800a5645aca4309d5dd5962bd1e95543/libsodium/src'
make[5]: *** [Makefile:427: all-recursive] Error 1
make[5]: Leaving directory '/home/openwrt/lede/build_dir/target-x86_64_musl/shadowsocksr-libev/shadowsocksr-libev-2018-03-07-d63ff863800a5645aca4309d5dd5962bd1e95543/libsodium'
make[4]: *** [Makefile:480: all-recursive] Error 1
make[4]: Leaving directory '/home/openwrt/lede/build_dir/target-x86_64_musl/shadowsocksr-libev/shadowsocksr-libev-2018-03-07-d63ff863800a5645aca4309d5dd5962bd1e95543'
make[3]: *** [Makefile:389: all] Error 2
make[3]: Leaving directory '/home/openwrt/lede/build_dir/target-x86_64_musl/shadowsocksr-libev/shadowsocksr-libev-2018-03-07-d63ff863800a5645aca4309d5dd5962bd1e95543'
make[2]: *** [Makefile:90: /home/openwrt/lede/build_dir/target-x86_64_musl/shadowsocksr-libev//shadowsocksr-libev-2018-03-07-d63ff863800a5645aca4309d5dd5962bd1e95543/.built] Error 2
make[2]: Leaving directory '/home/openwrt/lede/package/feeds/shadowsocksr-libev'
time: package/feeds/shadowsocksr-libev/compile#22.22#8.14#40.22
ERROR: package/feeds/shadowsocksr-libev failed to build.
make[1]: *** [package/Makefile:116: package/feeds/shadowsocksr-libev/compile] Error 1
make[1]: Leaving directory '/home/openwrt/lede'
make: *** [/home/openwrt/lede/include/toplevel.mk:231:package/shadowsocksr-libev/compile] 错误 2
查看日志可以知道问题出现在./build_dir/target-x86_64_musl/shadowsocksr-libev/shadowsocksr-libev-2018-03-07-d63ff863800a5645aca4309d5dd5962bd1e95543/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2.h
文件中,也就是libsodium库编译时出现的问题。
CRYPTO_ALIGN( 64 ) typedef struct blake2s_state_
{
uint32_t h[8];
uint32_t t[2];
uint32_t f[2];
uint8_t buf[2 * BLAKE2S_BLOCKBYTES];
size_t buflen;
uint8_t last_node;
} blake2s_state ;
...
#ifndef DEFINE_BLAKE2B_STATE
typedef crypto_generichash_blake2b_state blake2b_state;
#else
CRYPTO_ALIGN( 64 ) typedef struct blake2b_state_
{
uint64_t h[8];
uint64_t t[2];
uint64_t f[2];
uint8_t buf[2 * BLAKE2B_BLOCKBYTES];
size_t buflen;
uint8_t last_node;
} blake2b_state;
#endif
typedef struct blake2sp_state_
{
blake2s_state S[8][1];
blake2s_state R[1];
uint8_t buf[8 * BLAKE2S_BLOCKBYTES];
size_t buflen;
} blake2sp_state;
typedef struct blake2bp_state_
{
blake2b_state S[4][1];
blake2b_state R[1];
uint8_t buf[4 * BLAKE2B_BLOCKBYTES];
size_t buflen;
} blake2bp_state;
1)问题原因:
基本可以确定是在定义blake2s_state与blake2b_state结构体时使用的CRYPTO_ALIGN关键字,造成了编译器报错,具体编译器为什么报错待深究。
2)尝试解决问题:
- 2-1)修改blake2.h文件,去掉报错位置的CRYPTO_ALIGN宏定义。
重新执行sudo make package/shadowsocksr-libev/compile V=99
后,发现blake2.h文件又还原了。
观察编译日志发现上面的编译指令会删除旧文件并重新下载并编译
SHELL= flock /home/openwrt/lede/tmp/.shadowsocksr-libev-2018-03-07-d63ff863800a5645aca4309d5dd5962bd1e95543.tar.gz.flock -c ' /home/openwrt/lede/scripts/dl_github_archive.py --dl-dir="/home/openwrt/lede/dl" --url="https://github.com/shadowsocksrr/shadowsocksr-libev.git" --version="d63ff863800a5645aca4309d5dd5962bd1e95543" --subdir="shadowsocksr-libev-2018-03-07-d63ff863800a5645aca4309d5dd5962bd1e95543" --source="shadowsocksr-libev-2018-03-07-d63ff863800a5645aca4309d5dd5962bd1e95543.tar.gz" --hash="x" || ( echo "Checking out files from the git repository..."; mkdir -p /home/openwrt/lede/tmp/dl && cd /home/openwrt/lede/tmp/dl && rm -rf shadowsocksr-libev-2018-03-07-d63ff863800a5645aca4309d5dd5962bd1e95543 && [ \! -d shadowsocksr-libev-2018-03-07-d63ff863800a5645aca4309d5dd5962bd1e95543 ] && git clone https://github.com/shadowsocksrr/shadowsocksr-libev.git shadowsocksr-libev-2018-03-07-d63ff863800a5645aca4309d5dd5962bd1e95543 && (cd shadowsocksr-libev-2018-03-07-d63ff863800a5645aca4309d5dd5962bd1e95543 && git checkout d63ff863800a5645aca4309d5dd5962bd1e95543 && git submodule update --init --recursive) && echo "Packing checkout..." && export TAR_TIMESTAMP=
cd shadowsocksr-libev-2018-03-07-d63ff863800a5645aca4309d5dd5962bd1e95543 && git log -1 --format='\''@%ct'\''&& rm -rf shadowsocksr-libev-2018-03-07-d63ff863800a5645aca4309d5dd5962bd1e95543/.git && tar --numeric-owner --owner=0 --group=0 --mode=a-s --sort=name ${TAR_TIMESTAMP:+--mtime="$TAR_TIMESTAMP"} -c shadowsocksr-libev-2018-03-07-d63ff863800a5645aca4309d5dd5962bd1e95543 | gzip -nc > /home/openwrt/lede/tmp/dl/shadowsocksr-libev-2018-03-07-d63ff863800a5645aca4309d5dd5962bd1e95543.tar.gz && mv /home/openwrt/lede/tmp/dl/shadowsocksr-libev-2018-03-07-d63ff863800a5645aca4309d5dd5962bd1e95543.tar.gz /home/openwrt/lede/dl/ && rm -rf shadowsocksr-libev-2018-03-07-d63ff863800a5645aca4309d5dd5962bd1e95543; ); '
紧接着执行一系统指令(解压包)
然后进入到/home/openwrt/lede/build_dir/target-x86_64_musl/shadowsocksr-libev//shadowsocksr-libev-2018-03-07-d63ff863800a5645aca4309d5dd5962bd1e95543
开始编译
》》configure libsodium库
autoreconf: configure.ac: adding subdirectory libsodium to autoreconf
autoreconf: Entering directory `libsodium'
=== configuring in libsodium
》》 指定编译器参数并编译shadowsocksr-libev
假设下面的shell指令名为SHELL_COMMAND_A
CFLAGS="-Os -pipe -fno-caller-saves -fno-plt -fhonour-copts -fmacro-prefix-map=/home/openwrt/lede/build_dir/target-x86_64_musl/shadowsocksr-libev//shadowsocksr-libev-2018-03-07-d63ff863800a5645aca4309d5dd5962bd1e95543=shadowsocksr-libev-2018-03-07-d63ff863800a5645aca4309d5dd5962bd1e95543 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -I/home/openwrt/lede/staging_dir/toolchain-x86_64_gcc-11.3.0_musl/usr/include -I/home/openwrt/lede/staging_dir/toolchain-x86_64_gcc-11.3.0_musl/include/fortify -I/home/openwrt/lede/staging_dir/toolchain-x86_64_gcc-11.3.0_musl/include " CXXFLAGS="-Os -pipe -fno-caller-saves -fno-plt -fhonour-copts -fmacro-prefix-map=/home/openwrt/lede/build_dir/target-x86_64_musl/shadowsocksr-libev//shadowsocksr-libev-2018-03-07-d63ff863800a5645aca4309d5dd5962bd1e95543=shadowsocksr-libev-2018-03-07-d63ff863800a5645aca4309d5dd5962bd1e95543 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -I/home/openwrt/lede/staging_dir/toolchain-x86_64_gcc-11.3.0_musl/usr/include -I/home/openwrt/lede/staging_dir/toolchain-x86_64_gcc-11.3.0_musl/include/fortify -I/home/openwrt/lede/staging_dir/toolchain-x86_64_gcc-11.3.0_musl/include " LDFLAGS="-L/home/openwrt/lede/staging_dir/toolchain-x86_64_gcc-11.3.0_musl/usr/lib -L/home/openwrt/lede/staging_dir/toolchain-x86_64_gcc-11.3.0_musl/lib -znow -zrelro " make -C /home/openwrt/lede/build_dir/target-x86_64_musl/shadowsocksr-libev//shadowsocksr-libev-2018-03-07-d63ff863800a5645aca4309d5dd5962bd1e95543/. AR="x86_64-openwrt-linux-musl-gcc-ar" AS="x86_64-openwrt-linux-musl-gcc -c -Os -pipe -fno-caller-saves -fno-plt -fhonour-copts -fmacro-prefix-map=/home/openwrt/lede/build_dir/target-x86_64_musl/shadowsocksr-libev//shadowsocksr-libev-2018-03-07-d63ff863800a5645aca4309d5dd5962bd1e95543=shadowsocksr-libev-2018-03-07-d63ff863800a5645aca4309d5dd5962bd1e95543 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro" LD=x86_64-openwrt-linux-musl-ld NM="x86_64-openwrt-linux-musl-gcc-nm" CC="x86_64-openwrt-linux-musl-gcc" GCC="x86_64-openwrt-linux-musl-gcc" CXX="x86_64-openwrt-linux-musl-g++" RANLIB="x86_64-openwrt-linux-musl-gcc-ranlib" STRIP=x86_64-openwrt-linux-musl-strip OBJCOPY=x86_64-openwrt-linux-musl-objcopy OBJDUMP=x86_64-openwrt-linux-musl-objdump SIZE=x86_64-openwrt-linux-musl-size CROSS="x86_64-openwrt-linux-musl-" ARCH="x86_64" ;
然后就遇到上面的报错了
- 2-2)修改blake2.h文件,去掉报错位置的CRYPTO_ALIGN宏定义,并直接执行SHELL_COMMAND_A.
SHELL_COMMAND_A需要稍做修改,将gcc相关文件路径改成绝对路径不然会报各种gcc执行文件找不到,且make -C需要加sudo。
实际配置环境变量按道理说应该也可以,但是报错找不到:
echo 'export PATH=$PATH:/home/openwrt/lede/staging_dir/toolchain-x86_64_gcc-11.3.0_musl/bin' >> ~/.bashrc
source ~/.bashrc
12月25日 11:20echo 'export PATH=$PATH:/home/openwrt/lede/staging_dir/toolchain-x86_64_gcc-11.3.0_musl/bin' >> /etc/profile
source /etc/profile
2-2-2)上面修改完之后接着又会报错
/home/openwrt/lede/staging_dir/toolchain-x86_64_gcc-11.3.0_musl/lib/gcc/x86_64-openwrt-linux-musl/11.3.0/../../../../x86_64-openwrt-linux-musl/bin/ld: ss_local-http.o:/home/openwrt/lede/build_dir/target-x86_64_musl/shadowsocksr-libev/shadowsocksr-libev-2018-03-07-d63ff863800a5645aca4309d5dd5962bd1e95543/src/http.h:32: multiple definition of `http_protocol'; ss_local-local.o:/home/openwrt/lede/build_dir/target-x86_64_musl/shadowsocksr-libev/shadowsocksr-libev-2018-03-07-d63ff863800a5645aca4309d5dd5962bd1e95543/src/http.h:32: first defined here
/home/openwrt/lede/staging_dir/toolchain-x86_64_gcc-11.3.0_musl/lib/gcc/x86_64-openwrt-linux-musl/11.3.0/../../../../x86_64-openwrt-linux-musl/bin/ld: ss_local-tls.o:/home/openwrt/lede/build_dir/target-x86_64_musl/shadowsocksr-libev/shadowsocksr-libev-2018-03-07-d63ff863800a5645aca4309d5dd5962bd1e95543/src/tls.h:31: multiple definition of `tls_protocol'; ss_local-local.o:/home/openwrt/lede/build_dir/target-x86_64_musl/shadowsocksr-libev/shadowsocksr-libev-2018-03-07-d63ff863800a5645aca4309d5dd5962bd1e95543/src/tls.h:31: first defined here
解决参考办法见:https://blog.51cto.com/u_16117621/6293024
2-2-3)continue
虽然没有报上面的错了,但是编译流程并没有走完整,ipk文件没有生成。
尝试clean/compile任意一个插件包,我用的是pdnsd-alt,定位上面的编译流程没有执行完的步骤(打包):
/bin/bash /home/openwrt/lede/build_dir/target-x86_64_musl/pdnsd-1.2.9b-par/install-sh -d "/home/openwrt/lede/build_dir/target-x86_64_musl/pdnsd-1.2.9b-par/ipkg-install/var/pdnsd"
但是shadowsocksr-libev的源码下面并没有install-sh这个文件...
- 2-3)最终解决方案
a.修改include/download.mk将DownloadMethod/rawgit
的函数体注释掉,这样重新make时,shadowsocksr-libev的源码就不会重新下载了。define DownloadMethod/rawgit echo "CZLog Checking out files from the git repository..."; endef
查找思路:根据编译日志中的git相关日志
SHELL= flock /home/openwrt/lede/tmp/.shadowsocksr-libev-2018-03-07-d63ff863800a5645aca4309d5dd5962bd1e95543.tar.gz.flock -c ' /home/openwrt/lede/scripts/dl_github_archive.py --dl-dir="/home/openwrt/lede/dl" --url="https://github.com/shadowsocksrr/shadowsocksr-libev.git" --version="d63ff863800a5645aca4309d5dd5962bd1e95543" --subdir="shadowsocksr-libev-2018-03-07-d63ff863800a5645aca4309d5dd5962bd1e95543" --source="shadowsocksr-libev-2018-03-07-d63ff863800a5645aca4309d5dd5962bd1e95543.tar.gz" --hash="x" || ( echo "Checking out files from the git repository..."; mkdir -p /home/openwrt/lede/tmp/dl && cd /home/openwrt/lede/tmp/dl && rm -rf shadowsocksr-libev-2018-03-07-d63ff863800a5645aca4309d5dd5962bd1e95543 && [ \! -d shadowsocksr-libev-2018-03-07-d63ff863800a5645aca4309d5dd5962bd1e95543 ] && git clone https://github.com/shadowsocksrr/shadowsocksr-libev.git shadowsocksr-libev-2018-03-07-d63ff863800a5645aca4309d5dd5962bd1e95543 && (cd shadowsocksr-libev-2018-03-07-d63ff863800a5645aca4309d5dd5962bd1e95543 && git checkout d63ff863800a5645aca4309d5dd5962bd1e95543 && git submodule update --init --recursive) && echo "Packing checkout..." && export TAR_TIMESTAMP=
cd shadowsocksr-libev-2018-03-07-d63ff863800a5645aca4309d5dd5962bd1e95543 && git log -1 --format='\''@%ct'\''&& rm -rf shadowsocksr-libev-2018-03-07-d63ff863800a5645aca4309d5dd5962bd1e95543/.git && tar --numeric-owner --owner=0 --group=0 --mode=a-s --sort=name ${TAR_TIMESTAMP:+--mtime="$TAR_TIMESTAMP"} -c shadowsocksr-libev-2018-03-07-d63ff863800a5645aca4309d5dd5962bd1e95543 | gzip -nc > /home/openwrt/lede/tmp/dl/shadowsocksr-libev-2018-03-07-d63ff863800a5645aca4309d5dd5962bd1e95543.tar.gz && mv /home/openwrt/lede/tmp/dl/shadowsocksr-libev-2018-03-07-d63ff863800a5645aca4309d5dd5962bd1e95543.tar.gz /home/openwrt/lede/dl/ && rm -rf shadowsocksr-libev-2018-03-07-d63ff863800a5645aca4309d5dd5962bd1e95543; ); '
b.更新相关的Makefile,将一些对报错有影响的gcc参数注释掉,如-fstack-protector。
shadowsocksr-libev源码根目录
shadowsocksr-libev/libsodium库下的所有Makefile文件
由于不知道gcc该减或者加上哪些参数才能避免上述错误,所以此方法暂时搁置。todo
c.老办法,修改blake2.h文件,去掉CRYPTO_ALIGN。
但是仍有报错:
In file included from crypto_generichash/blake2/ref/blake2b-compress-ref.c:5:
crypto_generichash/blake2/ref/blake2.h:126:5: error: size of array element is not a multiple of its alignment
126 | blake2b_state S[4][1];
| ^~~~~~~~~~~~~
crypto_generichash/blake2/ref/blake2.h:127:5: error: size of array element is not a multiple of its alignment
127 | blake2b_state R[1];
| ^~~~~~~~~~~~~
经调试发现blake2b_state真正的类型是crypto_generichash_blake2b_state,并不是注释的blake2b_state_类型。
typedef crypto_generichash_blake2b_state blake2b_state;
果然,在libsodium/src/libsodium/include/sodium/crypto_generichash_blake2b.h
文件发现CRYPTO_ALIGN
typedef CRYPTO_ALIGN(64) struct crypto_generichash_blake2b_state {
注释CRYPTO_ALIGN之后没有再报上面的错误,但是会有下面的错误。
2. multiple definition of
budns/.libs/libudns.a -lmbedcrypto -lpcre
/home/openwrt/lede/staging_dir/toolchain-x86_64_gcc-11.3.0_musl/lib/gcc/x86_64-openwrt-linux-musl/11.3.0/../../../../x86_64-openwrt-linux-musl/bin/ld: ss_local-http.o:/home/openwrt/lede/build_dir/target-x86_64_musl/shadowsocksr-libev/shadowsocksr-libev-2018-03-07-d63ff863800a5645aca4309d5dd5962bd1e95543/src/http.h:32: multiple definition of `http_protocol'; ss_local-local.o:/home/openwrt/lede/build_dir/target-x86_64_musl/shadowsocksr-libev/shadowsocksr-libev-2018-03-07-d63ff863800a5645aca4309d5dd5962bd1e95543/src/http.h:32: first defined here
/home/openwrt/lede/staging_dir/toolchain-x86_64_gcc-11.3.0_musl/lib/gcc/x86_64-openwrt-linux-musl/11.3.0/../../../../x86_64-openwrt-linux-musl/bin/ld: ss_local-tls.o:/home/openwrt/lede/build_dir/target-x86_64_musl/shadowsocksr-libev/shadowsocksr-libev-2018-03-07-d63ff863800a5645aca4309d5dd5962bd1e95543/src/tls.h:31: multiple definition of `tls_protocol'; ss_local-local.o:/home/openwrt/lede/build_dir/target-x86_64_musl/shadowsocksr-libev/shadowsocksr-libev-2018-03-07-d63ff863800a5645aca4309d5dd5962bd1e95543/src/tls.h:31: first defined here
collect2: error: ld returned 1 exit status
解决办法:在报错的变量前加extern关键字。
二、安装问题
root@OpenWrt:/tmp# opkg install shadowsocksr-libev.ipk
Unknown package 'shadowsocksr-libev'.
Collected errors:
* pkg_hash_check_unresolved: cannot find dependency libpcre for shadowsocksr-libev
* pkg_hash_check_unresolved: cannot find dependency libmbedtls2.4.0-3 for shadowsocksr-libev
* pkg_hash_fetch_best_installation_candidate: Packages for shadowsocksr-libev found, but incompatible with the architectures configured
* opkg_install_cmd: Cannot install package shadowsocksr-libev.
root@OpenWrt:/tmp# opkg install libpcre
Unknown package 'libpcre'.
Collected errors:
* opkg_install_cmd: Cannot install package libpcre.
- pcre
官网可下载:https://archive.openwrt.org/releases/23.05.5/packages/x86_64/packages/
pcre2的版本可以在https://archive.openwrt.org/releases/23.05.5/packages/x86_64/base/ 这里下载
其实依赖包直接在源码中编译时已经生成了,位于bin/packages/x86_64/base
。
0 条评论