Unable to compiling (ancient) OpenWrt on ubuntu 22.04

Hi everyone I am unable to compile OpenWrt-21.02 on ubuntu 22.04.
I am getting the below error. Please help.

/home/sagar/projects/q14-wlanAP/wlan-ap/openwrt/build_dir/toolchain-arm_cortex-a7_gcc-5.5.0_musl_eabi/gcc-5.5.0/gcc/reload1.c: In function 'void init_reload()':
/home/sagar/projects/q14-wlanAP/wlan-ap/openwrt/build_dir/toolchain-arm_cortex-a7_gcc-5.5.0_musl_eabi/gcc-5.5.0/gcc/reload1.c:115:24: error: use of an operand of type 'bool' in 'operator++' is forbidden in C++17
  115 |   (this_target_reload->x_spill_indirect_levels)
      |   ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/home/sagar/projects/q14-wlanAP/wlan-ap/openwrt/build_dir/toolchain-arm_cortex-a7_gcc-5.5.0_musl_eabi/gcc-5.5.0/gcc/reload1.c:470:7: note: in expansion of macro 'spill_indirect_levels'
  470 |       spill_indirect_levels++;
      |       ^~~~~~~~~~~~~~~~~~~~~
/home/sagar/projects/q14-wlanAP/wlan-ap/openwrt/build_dir/toolchain-arm_cortex-a7_gcc-5.5.0_musl_eabi/gcc-5.5.0/gcc/reload1.c: In function 'void elimination_effects(rtx, machine_mode)':
/home/sagar/projects/q14-wlanAP/wlan-ap/openwrt/build_dir/toolchain-arm_cortex-a7_gcc-5.5.0_musl_eabi/gcc-5.5.0/gcc/reload1.c:3085:7: warning: this statement may fall through [-Wimplicit-fallthrough=]
 3085 |       if (code == POST_MODIFY || code == PRE_MODIFY)
      |       ^~
/home/sagar/projects/q14-wlanAP/wlan-ap/openwrt/build_dir/toolchain-arm_cortex-a7_gcc-5.5.0_musl_eabi/gcc-5.5.0/gcc/reload1.c:3089:5: note: here
 3089 |     case STRICT_LOW_PART:
      |     ^~~~
make[5]: *** [Makefile:1066: reload1.o] Error 1
make[5]: Leaving directory '/home/sagar/projects/q14-wlanAP/wlan-ap/openwrt/build_dir/toolchain-arm_cortex-a7_gcc-5.5.0_musl_eabi/gcc-5.5.0-initial/gcc'
make[4]: *** [Makefile:4100: all-gcc] Error 2
make[4]: Leaving directory '/home/sagar/projects/q14-wlanAP/wlan-ap/openwrt/build_dir/toolchain-arm_cortex-a7_gcc-5.5.0_musl_eabi/gcc-5.5.0-initial'
make[3]: *** [Makefile:37: /home/sagar/projects/q14-wlanAP/wlan-ap/openwrt/build_dir/toolchain-arm_cortex-a7_gcc-5.5.0_musl_eabi/gcc-5.5.0-initial/.built] Error 2
make[3]: Leaving directory '/home/sagar/projects/q14-wlanAP/wlan-ap/openwrt/toolchain/gcc/initial'
time: toolchain/gcc/initial/compile#9.85#0.65#10.44
    ERROR: toolchain/gcc/initial failed to build.
make[2]: *** [toolchain/Makefile:97: toolchain/gcc/initial/compile] Error 1
make[2]: Leaving directory '/home/sagar/projects/q14-wlanAP/wlan-ap/openwrt'
make[1]: *** [toolchain/Makefile:93: /home/sagar/projects/q14-wlanAP/wlan-ap/openwrt/staging_dir/toolchain-arm_cortex-a7_gcc-5.5.0_musl_eabi/stamp/.toolchain_compile] Error 2
make[1]: Leaving directory '/home/sagar/projects/q14-wlanAP/wlan-ap/openwrt'
make: *** [/home/sagar/projects/q14-wlanAP/wlan-ap/openwrt/include/toplevel.mk:230: world] Error 2

Sorry, but no help from me.

gcc-5.5.0 is ancient and not used by any normal OpenWrt release.
OpenWrt (LEDE) 17.01 used gcc 5.4.0 while 18.06 used gcc 7.3.0

1 Like

This looks like a vendor SDK based on ancient code.

1 Like

I have a similar problem with old OpenWrt version

I have solved with an old computer witrh old Debian 9.13


Yep, that is relevant advice.

You could try using Ubuntu from the same period, e.g. 16.04, so that it is has an ancient native gcc that might accept the source code in OpenWrt.

1 Like

Try Ubuntu 14 32bit for older versions, worked well back then.

But 22.04 is not old, what previous steps have you taken before compiling?
What's the target system?

But have you successfully installed latest version of all the depandables for the compiler?

I run Ubuntu 22.04 and it worked yesterday.

Have you seen the recently updated Modernized set for Ubuntu 22.04 for OpenWrt master, 22.03 and 21.02 branches that do not need python2.7 any more. Python3 is installed by default in Ubuntu22.04.

Just remembered I had all kind of issues with newer Ubuntu versions, I had switched so Debian, much faster and way less buggy.

However setting up Debian is a little messy, so I made a backup in ready state and uploaded to Drive have a backup, you can also use it!

It has arm-linux-gnueabi-gcc installed, but it's irrelevant, that was for a different hardware, different project, doesn't affect Openwrt at all.
Turned out to be a great building machine for it, I might have compiled Openwrt 22.03 no less than 50 times in it!

(Debian 10 AMD64, kernel 4.19, for Virtualbox):

Otherwise try an older Ubuntu x64 version, like 16.04, which has older kernel, and install these packages:

# Install stuff
sudo apt update && sudo apt install -y wget unzip build-essential rsync git bc swig libncurses-dev libacl1-dev libpython3-dev libssl-dev python3-distutils git cmake autoconf u-boot-tools bison flex

# Optional if you're using Virtualbox and want to install Guest Additions
sudo apt install  linux-headers-$(uname -r)

Then just:
git clone https://github.com/openwrt/openwrt --recursive -b openwrt-22.03 openwrt-22.03
cd openwrt-22.03
scripts/feeds update -a
scripts/feeds install -a
make defconfig

make menuconfig

# Select your targets etc, save config..

# Replace number with CPU cores+1, 
# Ex. for 8 cores:
make -sj9

# This will take a while!

And thats's all!

I am able to compile the OpenWrt on Ubuntu 20.04 successfully.

1 Like

Are you using a real computer or virtual installations in any form?

I have had no problems building OpenWrt images with either Ubuntu 21.02 or recently upgraded to Ubuntu 22.04. But this is primary and only installation on a real computer.

The only OpenWrt build problem I repeatedly seem to have over time is download servers often in Cambridge doesn’t answer on weekends.

I'm running Virtualbox in a real computer

But virtual installations is a false computer in a real computer, and that solution has pros and cons and can work little good or little bad.

With any decent quadcore CPU with <10 years which has virtualization and at least 8GB RAM, VM should work great.
In the end it's almost the same thing as a real machine, but much easier and safer to handle, backup and maintain.
Remember to enable Virtualization in the Bios or It work extremely slow, if using Windows disable Hyper-V or Virtualbox won't stop crashing, freezing and displaying all kind of strange errors.
I already gave you everything to start compiling, couldn't be easier, now is up to you what to do!

Yea, but it can be a VB/VM driver issue for the Ubuntu 22.04 since it is only a handful of months old.

Not really.
How is a driver going to cause a compilation error? It's unrelated.
It's often caused by upgraded libraries/tools, breaking compatibility with older code.

Openwrt 21.02 also compiled perfectly in that Debian machine!