Ubuntu18.04编译Openwrt 15.05.1 Chaos Calmer版本固件遇到的问题汇总

前言:编译所用gcc版本: gcc version 5.5.0

book@100ask ~$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.5.0-12ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 5.5.0 20171010 (Ubuntu 5.5.0-12ubuntu1)
book@100ask ~$

问题1:Unescaped left brace in regex is illegal here in regex; marked by <-- HERE in m/${ <-- HERE ([^ \t=:+{}]+)}/ at ./bin/automake.tmp line 3938.

编译报错提示:

make[3]: Leaving directory '/home/book/hi-wooya/openwrt-hiwooya/tools/xz'
make[3]: Entering directory '/home/book/hi-wooya/openwrt-hiwooya/tools/automake'
(cd /home/book/hi-wooya/openwrt-hiwooya/build_dir/host/automake-1.15; AUTOM4TE=/home/book/hi-wooya/openwrt-hiwooya/staging_dir/host/bin/autom4te AUTOCONF=/home/book/hi-wooya/openwrt-hiwooya/staging_dir/host/bin/autoconf AUTOMAKE=/home/book/hi-wooya/openwrt-hiwooya/staging_dir/host/bin/automake ACLOCAL=/home/book/hi-wooya/openwrt-hiwooya/staging_dir/host/bin/aclocal AUTOHEADER=/home/book/hi-wooya/openwrt-hiwooya/staging_dir/host/bin/autoheader LIBTOOLIZE=/home/book/hi-wooya/openwrt-hiwooya/staging_dir/host/bin/libtoolize LIBTOOL=/home/book/hi-wooya/openwrt-hiwooya/staging_dir/host/bin/libtool M4=/home/book/hi-wooya/openwrt-hiwooya/staging_dir/host/bin/m4 AUTOPOINT=true STAGING_DIR="" ./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 '/home/book/hi-wooya/openwrt-hiwooya/build_dir/host/automake-1.15/.configured' failed
make[3]: *** [/home/book/hi-wooya/openwrt-hiwooya/build_dir/host/automake-1.15/.configured] Error 255
make[3]: Leaving directory '/home/book/hi-wooya/openwrt-hiwooya/tools/automake'
tools/Makefile:122: recipe for target 'tools/automake/compile' failed
make[2]: *** [tools/automake/compile] Error 2
make[2]: Leaving directory '/home/book/hi-wooya/openwrt-hiwooya'
tools/Makefile:121: recipe for target '/home/book/hi-wooya/openwrt-hiwooya/staging_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/stamp/.tools_install_yynyynynynyyyyyyyyynyyyyyyyyynyyyyynnyyynnyynnnyy' failed
make[1]: *** [/home/book/hi-wooya/openwrt-hiwooya/staging_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/stamp/.tools_install_yynyynynynyyyyyyyyynyyyyyyyyynyyyyynnyyynnyynnnyy] Error 2
make[1]: Leaving directory '/home/book/hi-wooya/openwrt-hiwooya'
/home/book/hi-wooya/openwrt-hiwooya/include/toplevel.mk:181: recipe for target 'world' failed
make: *** [world] Error 2
book@100ask ~/hi-wooya/openwrt-hiwooya [master]$

原因:Perl版本更新后对语法规范进行了变更,若左花括号作为文本则应当进行转义
修改:找到automake源码进行修改,automake源码压缩包预先下载在dl文件夹,源码解压后的位于openwrt安装目录的子目录build_dir/host下边:
/home/book/hi-wooya/openwrt-hiwooya/build_dir/host
进入automake源码目录automake-1.15/binautomake.in文件进行修改
找到报错位置,如下:

3868 # Helper function for 'substitute_ac_subst_variables'.
3869 sub substitute_ac_subst_variables_worker
3870 {
3871   my ($token) = @_;
3872   return "\@$token\@" if var $token;
3873   return "\${$token\}";
3874 }
3875
3876 # substitute_ac_subst_variables ($TEXT)
3877 # -------------------------------------
3878 # Replace any occurrence of ${FOO} in $TEXT by @FOO@ if FOO is an AC_SUBST
3879 # variable.
3880 sub substitute_ac_subst_variables
3881 {
3882   my ($text) = @_;
3883   $text =~ s/\${([^ \t=:+{}]+)}/substitute_ac_subst_variables_worker ($1)/ge;
3884   return $text;
3885 }

对3883行进行修改,如下:

3876 # substitute_ac_subst_variables ($TEXT)
3877 # -------------------------------------
3878 # Replace any occurrence of ${FOO} in $TEXT by @FOO@ if FOO is an AC_SUBST
3879 # variable.
3880 sub substitute_ac_subst_variables
3881 {
3882   my ($text) = @_;
3883  #$text =~ s/\${([^ \t=:+{}]+)}/substitute_ac_subst_variables_worker ($1)/ge;
3884   $text =~ s/\$[{]([^ \t=:+{}]+)}/substitute_ac_subst_variables_worker ($1)/ge;
3885   return $text;
3886 }

重新编译即可。

问题2:gdate.c:2497:7: error: format not a string literal, format string not checked [-Werror=format-nonliteral]

编译报错提示如下:

mv -f .deps/libglib_2_0_la-gconvert.Tpo .deps/libglib_2_0_la-gconvert.Plo
/usr/bin/env bash ../libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I. -I..  -I.. -I../glib -I../glib -I..  -DG_LOG_DOMAIN=\"GLib\" -DG_DISABLE_CAST_CHECKS -DGLIB_COMPILATION -DPCRE_$
TATIC -I/home/book/hi-wooya/openwrt-hiwooya/staging_dir/host/include -I/home/book/hi-wooya/openwrt-hiwooya/staging_dir/host/usr/include -pthread -Wall -Wstrict-prototypes -Werror=declaration-$
fter-statement -Werror=missing-prototypes -Werror=implicit-function-declaration -Werror=pointer-arith -Werror=init-self -Werror=format-security -Werror=format=2 -fvisibility=hidden -O2 -I/hom$
/book/hi-wooya/openwrt-hiwooya/staging_dir/host/include -I/home/book/hi-wooya/openwrt-hiwooya/staging_dir/host/usr/include -MT libglib_2_0_la-gdate.lo -MD -MP -MF .deps/libglib_2_0_la-gdate.T$
o -c -o libglib_2_0_la-gdate.lo `test -f 'gdate.c' || echo './'`gdate.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I.. -I.. -I../glib -I../glib -I.. -DG_LOG_DOMAIN=\"GLib\" -DG_DISABLE_CAST_CHECKS -DGLIB_COMPILATION -DPCRE_STATIC -I/home/book/hi-wooya/openwrt-hi$
ooya/staging_dir/host/include -I/home/book/hi-wooya/openwrt-hiwooya/staging_dir/host/usr/include -pthread -Wall -Wstrict-prototypes -Werror=declaration-after-statement -Werror=missing-prototy$
es -Werror=implicit-function-declaration -Werror=pointer-arith -Werror=init-self -Werror=format-security -Werror=format=2 -fvisibility=hidden -O2 -I/home/book/hi-wooya/openwrt-hiwooya/staging$
dir/host/include -I/home/book/hi-wooya/openwrt-hiwooya/staging_dir/host/usr/include -MT libglib_2_0_la-gdate.lo -MD -MP -MF .deps/libglib_2_0_la-gdate.Tpo -c gdate.c -o libglib_2_0_la-gdate.o
gdate.c: In function 'g_date_strftime':
gdate.c:2497:7: error: format not a string literal, format string not checked [-Werror=format-nonliteral]
       tmplen = strftime (tmpbuf, tmpbufsize, locale_format, &tm);
       ^~~~~~
cc1: some warnings being treated as errors
Makefile:1386: recipe for target 'libglib_2_0_la-gdate.lo' failed
make[10]: *** [libglib_2_0_la-gdate.lo] Error 1
make[10]: Leaving directory '/home/book/hi-wooya/openwrt-hiwooya/build_dir/host/pkg-config-0.29/glib/glib'
Makefile:1933: recipe for target 'all-recursive' failed
make[9]: *** [all-recursive] Error 1
make[9]: Leaving directory '/home/book/hi-wooya/openwrt-hiwooya/build_dir/host/pkg-config-0.29/glib/glib'
Makefile:952: recipe for target 'all' failed
make[8]: *** [all] Error 2
make[8]: Leaving directory '/home/book/hi-wooya/openwrt-hiwooya/build_dir/host/pkg-config-0.29/glib/glib'
Makefile:1045: recipe for target 'all-recursive' failed
make[7]: *** [all-recursive] Error 1
make[7]: Leaving directory '/home/book/hi-wooya/openwrt-hiwooya/build_dir/host/pkg-config-0.29/glib'
Makefile:769: recipe for target 'all' failed
make[6]: *** [all] Error 2
make[6]: Leaving directory '/home/book/hi-wooya/openwrt-hiwooya/build_dir/host/pkg-config-0.29/glib'
Makefile:697: recipe for target 'all-recursive' failed
make[5]: *** [all-recursive] Error 1
make[5]: Leaving directory '/home/book/hi-wooya/openwrt-hiwooya/build_dir/host/pkg-config-0.29'
Makefile:456: recipe for target 'all' failed
make[4]: *** [all] Error 2
make[4]: Leaving directory '/home/book/hi-wooya/openwrt-hiwooya/build_dir/host/pkg-config-0.29'
Makefile:39: recipe for target '/home/book/hi-wooya/openwrt-hiwooya/build_dir/host/pkg-config-0.29/.built' failed
make[3]: *** [/home/book/hi-wooya/openwrt-hiwooya/build_dir/host/pkg-config-0.29/.built] Error 2
make[3]: Leaving directory '/home/book/hi-wooya/openwrt-hiwooya/tools/pkg-config'
tools/Makefile:122: recipe for target 'tools/pkg-config/compile' failed
make[2]: *** [tools/pkg-config/compile] Error 2
make[2]: Leaving directory '/home/book/hi-wooya/openwrt-hiwooya'
tools/Makefile:121: recipe for target '/home/book/hi-wooya/openwrt-hiwooya/staging_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/stamp/.tools_install_yynyynynynyyyyyyyyynyyyyyyyyynyyyyynnyyynny$
nnnyy' failed
make[1]: *** [/home/book/hi-wooya/openwrt-hiwooya/staging_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/stamp/.tools_install_yynyynynynyyyyyyyyynyyyyyyyyynyyyyynnyyynnyynnnyy] Error 2
make[1]: Leaving directory '/home/book/hi-wooya/openwrt-hiwooya'
/home/book/hi-wooya/openwrt-hiwooya/include/toplevel.mk:181: recipe for target 'world' failed
make: *** [world] Error 2

问题:网上资料说gcc版本大于6导致
解决:添加补丁,在Openwrt安装目录tools/pkg-config下创建一个文件夹patches,如下所示:

book@100ask ~/hi-wooya/openwrt-hiwooya/tools/pkg-config [master]$ ls
files  Makefile  patches
book@100ask ~/hi-wooya/openwrt-hiwooya/tools/pkg-config [master]$

进入patches文件夹,新建一个补丁文件命名为:001-glib-gdate-suppress-string-format-literal-warning.patch

book@100ask ~/hi-wooya/openwrt-hiwooya/tools/pkg-config/patches [master]$ ls
001-glib-gdate-suppress-string-format-literal-warning.patch
book@100ask ~/hi-wooya/openwrt-hiwooya/tools/pkg-config/patches [master]$

在001-glib-gdate-suppress-string-format-literal-warning.patch文件中输入如下内容:

--- a/glib/glib/gdate.c
+++ b/glib/glib/gdate.c
@@ -2439,6 +2439,9 @@ win32_strftime_helper (const GDate     *d,
  *
  * Returns: number of characters written to the buffer, or 0 the buffer was too small
  */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+
 gsize
 g_date_strftime (gchar       *s,
                  gsize        slen,
@@ -2549,3 +2552,5 @@ g_date_strftime (gchar       *s,
   return retval;
 #endif
 }
+
+#pragma GCC diagnostic pop

参考:https://github.com/widora/openwrt_widora/issues/12

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值