GCC 8+ on OpenWrt?

I'm wondering if there are any ways I can install GCC 8 on OpenWRT? At this point I'm getting GCC 7, and trying to install some Ruby gems. However, I'm getting

arm-openwrt-linux-muslgnueabi-gcc: error: unrecognized command line option '-ffile-prefix-map...

So ffile-prefix-map option is not supported on GCC 7.

I can cross-compile, but only simple C programs. I'm looking for ways to install GCC 8 on OpenWrt. I understand there is no package, but maybe there is some other package sources or direct links to ipks?

OpenWrt isn't self-hosting, there are no header- or development libraries packaged - the runtime installable gcc won't do more than compiling the most trivial hello_world.c sources without external dependencies.

1 Like

Well, my final goal is to install a Ruby gem. I'm looking to install ffi https://github.com/ffi/ffi

I'm using just gem install ffi inside the OpenWrt, and I hope it will compile things with GCC 8.

With cross-compile I can compile, but can't figure out how to install/create the Ruby gem on host machine. There is no any instructions available, I spend like 20 hours or so on that. So it's easier for me just to compile inside the router.

The runtime installable gcc package is not going to help you with that, regardless of the version. Only the cross-compiler has those features, at build-time.

I never try to select/switch GCC versions. I noticed different openwrt version using different GCC, .config file has the info.
v21.02.0 uses GCC-8.4 and snapshot uses GCC-11.3, maybe it's devices dependent also.

It can be, but it's usually tried (really hard) to use the same toolchain- and kernel versions for all targets, to ease maintenance.

If it's true, do you mind running opkg install gcc on that system and paste the link to GCC v8?

I see there is v7 package https://openwrt.org/packages/pkgdata/gcc - but there is no any v8. If I have a link I can install it just with opkg install https://downloads... - in other words, with URL.

Hi, maybe I was wrong, we have OpenWrt package gcc (version 7.4.0-5) and compiler GCC (version 8.4...) defferent, no GCC v7.

In file openwrt\toolchain\gcc\common.mk, .config file decided which version GCC used:

include $(TOPDIR)/rules.mk

PKG_NAME:=gcc
GCC_VERSION:=$(call qstrip,$(CONFIG_GCC_VERSION))
PKG_VERSION:=$(firstword $(subst +, ,$(GCC_VERSION)))
GCC_DIR:=$(PKG_NAME)-$(PKG_VERSION)

PKG_SOURCE_URL:=@GNU/gcc/gcc-$(PKG_VERSION)
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz

ifeq ($(PKG_VERSION),8.4.0)
  PKG_HASH:=e30a6e52d10e1f27ed55104ad233c30bd1e99cfb5ff98ab022dc941edd1b2dd4
endif

ifeq ($(PKG_VERSION),10.3.0)
  PKG_HASH:=64f404c1a650f27fc33da242e1f2df54952e3963a49e06e73f6940f3223ac344
endif

ifeq ($(PKG_VERSION),11.3.0)
  PKG_HASH:=b47cf2818691f5b1e21df2bb38c795fac2cfbd640ede2d0a5e1c89e338a3ac39
endif

ifeq ($(PKG_VERSION),12.1.0)
  PKG_HASH:=62fd634889f31c02b64af2c468f064b47ad1ca78411c45abe6ac4b5f8dd19c7b
endif

PATCH_DIR=../patches/$(GCC_VERSION)

BUGURL=http://bugs.openwrt.org/
PKGVERSION=OpenWrt GCC $(PKG_VERSION) $(REVISION)

HOST_BUILD_PARALLEL:=1

include $(INCLUDE_DIR)/toolchain-build.mk

...........................