【QCA】ubuntu1804 与 QSDK 编译环境适配问题

0.环境

spf11.0 , u-boot-2016-10
ubuntu 18.4 , OpenSSL 1.1.1 11 ,perl-v5.26.1 , ocaml 4.05.0 ,gcc-7

1. 问题汇总

问题1:perl版本与{格式兼容问题

# cmd : make 导致编译失败
make -j10
# log
/*
make[3]: Entering directory '/xxxxxxx/qsdk/tools/automake'
. /xxxxxxxx/qsdk/include/shell.sh; xzcat /xxxxxxxx/qsdk/dl/automake-1.15.tar.xz | tar -C /xxxxxxxxx/qsdk/build_dir/host/automake-1.15/.. -xf -

Applying ./patches/000-relocatable.patch using plaintext:
patching file lib/Automake/Config.in
patching file bin/aclocal.in
patching file bin/automake.in
patching file t/wrap/aclocal.in
patching file t/wrap/automake.in

Applying ./patches/200-do-not-override-silent-rules.patch using plaintext:
patching file m4/silent.m4
touch /xxxxxxxxx/qsdk/build_dir/host/automake-1.15/.preparede614279ad0d4e37445021068e4d2aebb
(cd /hxxxxxxx/qsdk/build_dir/host/automake-1.15; 
....
 ./bootstrap.sh)
Unescaped left brace in regex is illegal here in regex; marked by <-- HERE in m/\${ <-- HERE ([^ \t=:+{}]+)}/ at ./bin/automake.tmp line 3938.
Makefile:50: recipe for target '/xxxxxxx/qsdk/build_dir/host/automake-1.15/.configured' failed
make[3]: *** [/xxxxxx/qsdk/build_dir/host/automake-1.15/.configured] Error 255
make[3]: Leaving directory '/xxxxxx/qsdk/tools/automake'
*/

debug

# debug : 获得error 前后log,定位到问题log:
> “Unescaped left brace in regex ...” 表明左括号的格式有问题,
# debug :检查报错文件格式是否正确,cmd & log:
//cmd:
vi ./build_dir/host/automake-1.15/bin/automake.tmp +3938
//log:
/*
   3 sub substitute_ac_subst_variables
   2 {
   1   my ($text) = @_;
3938   $text =~ s/\${([^ \t=:+{}]+)}/substitute_ac_subst_variables_worker ($1)/ge;
   1   return $text;
   2 }
*/
# debug : 分析头部判断语言种类为Perl,上述格式跟版本不匹配了
/*
   2 #!perl
   1 # -*- perl -*-
 3   # Generated from bin/automake.in; do not edit by hand.
*/
# debug : 如果不清楚这个问题可以继续探究一下,或者调到最后修改部分。
# debug :从-j1 参数和log可以看出,在“patching file m4/silent.m4”后出现了该error,先试试从这里开始往下理出来。
# cmd & lgo : 看一下bootstrap.sh这里处理上述patch的程序段,cmd & log如下:
/* 
//cmd
$ vi ./build_dir/host/automake-1.15/bootstrap.sh
//log
  5 # Overwrite amversion.m4.
  4 dosubst m4/amversion.in m4/amversion.m4
  3
  2 # Create temporary replacement for aclocal and automake.
  1 for p in bin/aclocal bin/automake; do
103   dosubst $p.in $p.tmp
  1   $PERL -w bin/gen-perl-protos $p.tmp > $p.tmp2
  2   mv -f $p.tmp2 $p.tmp
  3 done
*/
# debug :再看这里的bin/automake是个什么东西。(budild_dir/是生成的,尽量不在这里修改问题)
# debug :根据make吐出的log,从makefile进入tools/automake文件夹下执行程序到出现error都没有Leaving directory,很显然要去tools/automake/找源文件
# debug :进入该目录,首先查看Makefile,cmd & log如下:
// cmd : 
vi tools/automake/Makefile
// log :
/*
  3 PKG_NAME:=automake
  2 PKG_VERSION:=1.15
  1
12  PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
  1 PKG_SOURCE_URL:=@GNU/automake
  2 PKG_MD5SUM:=9a1ddb0e053474d9d1105cfe39b0c48d
*/
# ret : 果然是个压缩文件解压出来的文件,找到source code 压缩包名字及md5
//automake-1.15.tar.xz  md5:9a1ddb0e053474d9d1105cfe39b0c48d
# find : 应该在dl/下,实际也确实是。
> md5校验值两者是相符合的,确定是该文件。
> 打开压缩包,确认压缩包中原始automake.in脚本有格式问题

Modify

# M : 解压原始文件并修改automake.in中格式问题,并重新打包
//cmd 参考如下:
xz -d automake-1.15.tar.xz	//解压文件为tar包
tar -xvf automake-1.15.tar  //打开tar包
vi automake-1.15/bin/automake.in +3881// 修改如下:
/*
-$text =~ s/\${([^ \t=:+{}]+)}/substitute_ac_subst_variables_worker ($1)/ge;
+$text =~ s/\$[{]([^ \t=:+{}]+)}/substitute_ac_subst_variables_worker ($1)/ge;
*/
tar -cvf automake-1.15.tar automake-1.15/ //先做tar包
xz -z automake-1.15.tar                   //在压缩
cp automake-1.15.tar.xz /xxxx/qsdk/dl/    //cp到dl下替换原来的文件
# M : 替换源文件,需要修改Makefile中md5校验值,不然会因为不匹配重新下载该文件,造成修改后的文件仍然会被替换掉
vi qsdk/tools/automake/Makefile

verify

# test : 重新编译:
//删除build_dir/ , 避免build_dir/host/.../automake.tmp相关文件不被重新编译
rm -rf build_dir/
make V=s -j10
# Fix 

修改后的文件参考附录

问题2:rsa源码 与 openssl 版本兼容问题

# log 
/* 
/xxxxxxx/qsdk/build_dir/host/u-boot-2014.10/lib/rsa/rsa-sign.c:213:2: warning: implicit declaration of function 'EVP_MD_CTX_cleanup'; did you mean 'EVP_MD_CT
X_create'? [-Wimplicit-function-declaration]
  EVP_MD_CTX_cleanup(context);
  ^~~~~~~~~~~~~~~~~~
  EVP_MD_CTX_create
...
/xxxxx/qsdk/build_dir/host/u-boot-2014.10/lib/rsa/rsa-sign.c:279:21: error: dereferencing pointer to incomplete type 'RSA {aka struct rsa_st}'
  if (BN_num_bits(key->e) > 64)
                     ^~
scripts/Makefile.host:134: recipe for target 'tools/lib/rsa/rsa-sign.o' failed
make[5]: *** [tools/lib/rsa/rsa-sign.o] Error 1
Makefile:1195: recipe for target 'tools-only' failed
make[4]: *** [tools-only] Error 2
*/

debug

# debug : 凡是在内核编译时出现这种 “did you mean ...”提示你是不是需要输入错误的,多半都是版本问题导致的。
> 大多数情况下内核源码中是不会出现这种低端错误,同时只是简单make了一下,并没有修改此处相关文件。
# find : 看一下新版的uboot源码是否不一致,不一致再看下git log 是不是有对此的说明。
//githut uboot url:
/*
https://github.com/u-boot/u-boot/blob/master/lib/rsa/rsa-sign.c
*/
# find : qsdk中用的是201410月的源码,查看前后两次提交源码,都存在这个问题
/*
//2014.8.9
https://github.com/u-boot/u-boot/blob/542671623129f1db947801d2756186b501c98c49/lib/rsa/rsa-sign.c
//2016.7.22
https://github.com/u-boot/u-boot/blob/2b9ec762c4fb5c0f933f5b3380ef9f5c353d0eef/lib/rsa/rsa-sign.c
*/
# find : 最新的源码是ok的,那么肯定是中间哪次提交修复的,git log :
2017.5.12 有一次提交中提到了EVP_MD_CTX_reset 的问题,
查看pathch , URL :
/*
https://github.com/u-boot/u-boot/commit/c3b4328166b03d6749b86eb0fbb21a10e4395cfd?branch=c3b4328166b03d6749b86eb0fbb21a10e4395cfd&diff=split
*/
# ret : 得到如下相关修改代码:
/*
-	*e = BN_get_word(key->e);
+	*e = BN_get_word(key_e);

-	if (BN_num_bits(key->e) < 33) {
+	if (BN_num_bits(key_e) < 33) {
		ret = 0;
		goto cleanup;
	}
*/

modify

# M : 把该 patch 合并入qsdk源码中
# M : patch参考如下,
/*
https://github.com/u-boot/u-boot/commit/c3b4328166b03d6749b86eb0fbb21a10e4395cfd?branch=c3b4328166b03d6749b86eb0fbb21a10e4395cfd&diff=split
*/
// 修改后的文件参考如下源码:
# url:FIX openSSL , rsa-sign.c源码
/*
https://github.com/u-boot/u-boot/blob/c3b4328166b03d6749b86eb0fbb21a10e4395cfd/lib/rsa/rsa-sign.c
*/
// 修改后的文件参考附件(2016年的代码,较之最新版本还有些问题,暂时先不管)

verify

# cmd 
//删除生成的各类build_dir/等
make V=s 
# FIX

修改后的文件参考附录

问题3:ubuntu18.04 默认ocaml版本过高

# log : 错误log
/*
File "./main.ml", line 777, characters 22-49:
Warning 52: Code should not depend on the actual values of
this constructor's arguments. They are only for information
and may change in future versions. (See manual section 8.5)
File "./main.ml", line 956, characters 35-60:
Error: Unbound module Parmap
Makefile:656: recipe for target 'main.cmo' failed
make[7]: *** [main.cmo] Error 2
*/

debug

# debug : 看样子是版本问题,检查一下具体程序:
vi ./build_dir/host/coccinelle-coccinelle-1.0.0-rc24/main.ml
-> Copyright 2012-2014, INRIA
# debug: 最后一次修改时2014年,已经是7年前的代码了
# log : "/usr/bin/ocamlc.opt" 看log是用的本机环境,看一下本机环境
ocaml --version
/*
The OCaml toplevel, version 4.05.0
*/
#  find : 去github上看一下这个版本,Commits on Jun 16, 2017
> 没找到相关的commit 信息,不确定降级到哪一版本,源程序中只判断了版本必须>3.7
> 选择版本3.7~时间点为2014之前的某个版本,具体版本不确定,参考BD的建议:4.02.3

Modify

# cmd : 修改ocaml版本为 4.02.3
# find :opam官方配置文档:
/*
1. To configure OPAM in the current shell session, you need to run:
      eval `opam config env`
2. To correctly configure OPAM for subsequent use, add the following
   line to your profile file (for instance ~/.profile):
      . /home/liam/.opam/opam-init/init.sh > /dev/null 2> /dev/null || true
3. To avoid issues related to non-system installations of `ocamlfind`
   add the following lines to ~/.ocamlinit (create it if necessary):
      let () =
        try Topdirs.dir_directory (Sys.getenv "OCAML_TOPLEVEL_PATH")
        with Not_found -> ()
      ;;
*/ 
# cmd : 命令汇总一下:
/*
cmd1: 
eval `opam config env`
opam switch --all //查看可用版本,
opam switch create 4.02.3
cmd2: . /home/xxxxx/.opam/opam-init/init.sh > /dev/null 2> /dev/null || true
cmd3: vi ~/.ocamlinit,添加如下信息;
      let () =
        try Topdirs.dir_directory (Sys.getenv "OCAML_TOPLEVEL_PATH")
        with Not_found -> ()
      ;;
配置当前shell:
cmd4: eval `opam config env`
*/
# cmd : 尝试重新编译
/*
eval `opam config env`
ocaml -version // 确定下当前shell中的版本
cd qsdk/build_dir/host/coccinelle-coccinelle-1.0.0-rc24
  1 Then simply type
  2  ./configure --enable-release
  3  make
  4  make install
*/
# FIX 

verify

# cmd : 重新编译QSDK
# faile: 删除build_dir 后重新编译
# FIX

问题4:gcc版本与spf11.0版本不兼容

# log :
/*
In file included from /xxxxxx/qsdk/build_dir/toolchain-arm_cortex-a7_gcc-5.2.0_musl-1.1.16_eabi/gcc-5.2.0/gcc/cp/except.c:1023:0:
cfns.gperf: In function 'const char* libc_name_p(const char*, unsigned int)':
cfns.gperf:101:1: error: 'const char* libc_name_p(const char*, unsigned int)' redeclared inline with 'gnu_inline' attribute
cfns.gperf:26:14: note: 'const char* libc_name_p(const char*, unsigned int)' previously declared here
cfns.gperf: At global scope:
cfns.gperf:26:14: warning: inline function 'const char* libc_name_p(const char*, unsigned int)' used but never defined
Makefile:1065: recipe for target 'cp/except.o' failed
*/

debug

# debug : 显然是gcc版本问题,查看本机环境,并修改
# M :找到并替换编译程序
//cmd  : 找到这个x86_64-linux-gnu-g++,
whereis x86_64-linux-gnu-g++
/* //log :
ls -l -> /usr/bin/x86_64-linux-gnu-g++ -> g++-7
*/

Modify

#  cmd :修改链接 指向 gcc-5
cd /usr/bin/ //这是我的环境
sudo mv x86_64-linux-gnu-g++ x86_64-linux-gnu-g++-ori //把原始的链接换个名字,删除也行
sudo ln -s g++-5 x86_64-linux-gnu-g++  //新建link指向g++-5

verify

# cmd : 重新编译
make V=s -10
# FIX

2. 总结

问题1:perl版本正则表达式格式中”{“格式的兼容问题

1. perl新版本中,正则表达式不兼容左大括号
2. 修改automake.in的相关源码,可自定义添加patch在编译时修改,也可直接修改原始压缩包中的automake.in文件,再打包,
同时需要修改相关Makefile中md5值,避免重新编译时导致MD5不符合重新下载源码,进而复现该问题。

问题2:rsa源码 与 openssl 版本兼容问题

1.kernel中已知的兼容问题,与openssl 1.1.x 冲突
2.参考github中uboot源码,修改以支持超过1.1.x的版本命令。

问题3:ubuntu18.04 默认ocaml版本过高

1.ocaml版本过高,也是高版本格式变化导致的兼容问题
2.ocaml降级为 4.02.3

问题4:gcc版本与spf11.0版本不兼容

1.ubuntu1804默认为gcc7,这个sdk需要的是gcc5
2.修改用户link,x86_64-linux-gnu-g++ 指向为 g++-5

附录-修改后的源码文件

# file :修改后的automake-1.15.tar.xz 、Makefile
# url 
/*
待补充
*/
# file :rsa-sign.c 与 openssl 问题
# url 
/*
待补充
*/

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

过得精彩

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值