How do I tell OpenWrt to use gcc4 instead of gcc7?

This should be quite simple but for the life of me I can't find a solution. I am trying to install an old Linux kernel (3.14) together with the latest version of OpenWRT from "master" branch. I have managed to get everything working up to the point of compiling the kernel.

In file included from include/linux/compiler.h:54:0,
                 from include/uapi/linux/stddef.h:1,
                 from include/linux/stddef.h:4,
                 from /home/osboxes/openwrt/openwrt/build_dir/target-mips_24kc_musl/linux-ath79_generic/linux-3.14/include/uapi/linux/posix_types.h:4,
                 from include/uapi/linux/types.h:13,
                 from include/linux/types.h:5,
                 from include/linux/page-flags.h:8,
                 from kernel/bounds.c:9:
include/linux/compiler-gcc.h:106:1: fatal error: linux/compiler-gcc7.h: No such file or directory
 #include gcc_header(__GNUC__)
compilation terminated.
/home/osboxes/openwrt/openwrt/build_dir/target-mips_24kc_musl/linux-ath79_generic/linux-3.14/./Kbuild:35: recipe for target 'kernel/bounds.s' failed
make[6]: *** [kernel/bounds.s] Error 1
Makefile:884: recipe for target 'prepare0' failed
make[5]: *** [prepare0] Error 2
make[5]: Leaving directory '/home/osboxes/openwrt/openwrt/build_dir/target-mips_24kc_musl/linux-ath79_generic/linux-3.14'

I suspect this kernel requires to be compiled with only gcc3 or gcc4 (in the directory where it's trying to look for 'compiler-gcc7.h', there is 'compiler-gcc3.h' and 'compiler-gcc4.h'). How can I tell Openwrt to use gcc4 for this kernel? Something like:

make V=s gcc=4

If I can get it to work with gcc4, I am sure everything will compile fine. Also, I got the kernel from OpenWrt, by modifying makefile, so it is supported. Just the gcc bit messing things up. I have tried installing gcc4 on my system, it didn't help. I even set 'alias gcc=/usr/bin/gcc4' to ensure its the one being used, didn't help me a bit.

You will have to check the OpenWrt git history to revert the patches removing support for your preferred gcc version - and then hunt down the numerous packages that require a newer gcc and won't build with an older one. This will be a considerable amount of work and would completely up to you to find and debug, as this constellation isn't supported anymore.


That is not simple. Kernel 3.14 is ancient and all support for it had been removed from from OpenWrt. It is not only about modifying the version in Makefile. Kernel support includes 100+ patches, both in the generic Linux as well as target specific source directories. gcc version is your smallest headache.