Compile Error GCC 7

I’m running in to an error compiling in Ubuntu.

/home/zerauskire/Downloads/Lakka-LibreELEC/build.Lakka-Generic.x86_64-8.2-devel/pkg-config-0.29.1/glib/glib/gdate.c: In function 'g_date_strftime':
/home/zerauskire/Downloads/Lakka-LibreELEC/build.Lakka-Generic.x86_64-8.2-devel/pkg-config-0.29.1/glib/glib/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
make[7]: *** [Makefile:1387: libglib_2_0_la-gdate.lo] Error 1
make[7]: *** Waiting for unfinished jobs....
libtool: compile:  /home/zerauskire/Downloads/Lakka-LibreELEC/build.Lakka-Generic.x86_64-8.2-devel/toolchain/bin/host-gcc -DHAVE_CONFIG_H -I. -I/home/zerauskire/Downloads/Lakka-LibreELEC/build.Lakka-Generic.x86_64-8.2-devel/pkg-config-0.29.1/glib/glib -I.. -I.. -I../glib -I/home/zerauskire/Downloads/Lakka-LibreELEC/build.Lakka-Generic.x86_64-8.2-devel/pkg-config-0.29.1/glib/glib -I/home/zerauskire/Downloads/Lakka-LibreELEC/build.Lakka-Generic.x86_64-8.2-devel/pkg-config-0.29.1/glib -DG_LOG_DOMAIN=\"GLib\" -DG_DISABLE_CAST_CHECKS -DGLIB_COMPILATION -DPCRE_STATIC -pthread -Wall -Wstrict-prototypes -Werror=declaration-after-statement -Werror=missing-prototypes -Werror=implicit-function-declaration -Werror=pointer-arith -Werror=init-self -Werror=format-security -Werror=format=2 -Werror=missing-include-dirs -fvisibility=hidden -O2 -Wall -pipe -I/home/zerauskire/Downloads/Lakka-LibreELEC/build.Lakka-Generic.x86_64-8.2-devel/toolchain/include -Wno-format-security -MT libglib_2_0_la-gstringchunk.lo -MD -MP -MF .deps/libglib_2_0_la-gstringchunk.Tpo -c /home/zerauskire/Downloads/Lakka-LibreELEC/build.Lakka-Generic.x86_64-8.2-devel/pkg-config-0.29.1/glib/glib/gstringchunk.c -o libglib_2_0_la-gstringchunk.o
mv -f .deps/libglib_2_0_la-gstringchunk.Tpo .deps/libglib_2_0_la-gstringchunk.Plo
mv -f .deps/libglib_2_0_la-gstring.Tpo .deps/libglib_2_0_la-gstring.Plo
mv -f .deps/libglib_2_0_la-gstrfuncs.Tpo .deps/libglib_2_0_la-gstrfuncs.Plo
make[7]: Leaving directory '/home/zerauskire/Downloads/Lakka-LibreELEC/build.Lakka-Generic.x86_64-8.2-devel/pkg-config-0.29.1/.x86_64-linux-gnu/glib/glib'
make[6]: *** [Makefile:1934: all-recursive] Error 1
make[6]: Leaving directory '/home/zerauskire/Downloads/Lakka-LibreELEC/build.Lakka-Generic.x86_64-8.2-devel/pkg-config-0.29.1/.x86_64-linux-gnu/glib/glib'
make[5]: *** [Makefile:953: all] Error 2
make[5]: Leaving directory '/home/zerauskire/Downloads/Lakka-LibreELEC/build.Lakka-Generic.x86_64-8.2-devel/pkg-config-0.29.1/.x86_64-linux-gnu/glib/glib'
make[4]: *** [Makefile:1046: all-recursive] Error 1
make[4]: Leaving directory '/home/zerauskire/Downloads/Lakka-LibreELEC/build.Lakka-Generic.x86_64-8.2-devel/pkg-config-0.29.1/.x86_64-linux-gnu/glib'
make[3]: *** [Makefile:770: all] Error 2
make[3]: Leaving directory '/home/zerauskire/Downloads/Lakka-LibreELEC/build.Lakka-Generic.x86_64-8.2-devel/pkg-config-0.29.1/.x86_64-linux-gnu/glib'
make[2]: *** [Makefile:707: all-recursive] Error 1
make[2]: Leaving directory '/home/zerauskire/Downloads/Lakka-LibreELEC/build.Lakka-Generic.x86_64-8.2-devel/pkg-config-0.29.1/.x86_64-linux-gnu'
make[1]: *** [Makefile:463: all] Error 2
make[1]: Leaving directory '/home/zerauskire/Downloads/Lakka-LibreELEC/build.Lakka-Generic.x86_64-8.2-devel/pkg-config-0.29.1/.x86_64-linux-gnu'
Makefile:12: recipe for target 'image' failed
make: *** [image] Error 2

After some searching around on google it looks like this error is caused by the fact that i’m using GCC 7 and if I were to downgrade to GCC 5 it would fix the error but… I came across this post

In the comments in that post there’s a guy who mentions a fix to this by making some adjustments to the makefile. Obviously this was in reference to compiling a completely different project but would this be something you guys could do in order to allow this to compile using GCC 7?

Until this is fixed would someone be able to just verify what the most current version of GCC and G++ that compiles without error. That way I can just downgrade for now and then set up aliases so that it compiles.

I’m using a

gcc (Ubuntu 5.4.0-6ubuntu1~16.04.5) 5.4.0 20160609

Ok. I’ll downgrade and see how it goes. Thank you.

Well i fixed this error even though I hit a new one. The fix for this error is pretty simple though.

This issue is with glib. This issue has been addressed in newer versions of glib.

You can manually modify the gdate.c file of the current version of glib here. /Lakka-LibreELEC/build.Lakka-Generic.x86_64-8.2-devel/pkg-config-0.29.1/glib/glib/gdate.c

and make the changes seen in this commit here.

Ignore the red text of the deleted lines this was just updates a previous fix that broke things for earlier versions of GCC. Just add the lines in green.

or a more practical fix would be to update the version of glib in “Lakka-LibreELEC\packages\devel\glib\package.mk” to are more current version. This is still pulling down version 2.46.2.

Newer version here: https://git.gnome.org/browse/glib/

Ok. So my second error while trying to compile with GCC 7 has to do with automake. It appears that it has some deprecated regex. It just needs to be updated.

Open the file at this location. /Lakka-LibreELEC/build.Lakka-Generic.x86_64-8.2-devel/toolchain/bin/automake-1.15

On line 3936 you need to correct the regex. Just put brackets around the first brace. “[{]” See below.

Original: $text =~ s/${([^ \t=:+{}]+)}/substitute_ac_subst_variables_worker ($1)/ge;

Fixed: $text =~ s/$[{]([^ \t=:+{}]+)}/substitute_ac_subst_variables_worker ($1)/ge;

This solves that issue. Still doesn’t compile fully in GCC 7 yet though. Hit another error that i’m working on. As discussed with Kivutar over on GitHub, these issues all appear to be addressed in the newest version of LibreELEC which should be included in an upcoming release of Lakka. I’m only documenting these changes for anyone looking to compile with GCC 7 before that happens.

Next error is within the ubsan.c file.

This error is easy to correct as well.

Open this file: Lakka-LibreELEC/build.Lakka-Generic.x86_64-8.2-devel/gcc-6.2.0/gcc/ubsan.c

Go to line 1472 and update the line to reflect this change

Original: || xloc.file == ‘\0’ || xloc.file[0] == ‘\xff’

Fixed: || xloc.file[0] == ‘\0’ || xloc.file[0] == ‘\xff’

Ok. The next error was a little trickier to correct.

I had to apply the following patches to LibreELEC from the “escalade” fork.

Almost there… I think… Got another error after this one and i’m working on that.