[OpenWrt-Devel] [PATCH] build: always use -minterlink-mips16 if USE_MIPS16
Eneas U de Queiroz
cotequeiroz at gmail.com
Sun May 24 20:19:56 EDT 2020
Individual packages may turn off MIPS16 ISA individually with
PKG_USE_MIPS16. However, they may link to a library compiled with
MIPS16. In such cases, the -minterlink-mips16 is needed to ensure there
are no direct jumps to code compiled with a different ISA.
Instead of adding -minterlink-mips16 only when PKG_USE_MIPS16 is on, add
it when global USE_MIPS16 is on.
Signed-off-by: Eneas U de Queiroz <cotequeiroz at gmail.com>
---
Tested by compiling all packages in base, packages, routing and
telephony feeds for mips_74kc, with MIPS16 enabled.
This was discovered while working on lxc fixes
(https://github.com/openwrt/packages/pull/12241), where compilation with
mips16 would fail because of '-fstack-check=specific not implemented for
MIPS16', and it would fail with PKG_USE_MIPS16=0 because of jumping to a
different ISA mode:
lxc-4.0.2/src/lxc/caps.c:24:(.text+0xa4): unsupported jump between ISA
modes; consider recompiling with interlinking enabled
In theory this could happen in more places, so set interlinking on
whenever MIPS16 is turned on globally.
diff --git a/include/package.mk b/include/package.mk
index 0575692742..f2c699ef2f 100644
--- a/include/package.mk
+++ b/include/package.mk
@@ -25,10 +25,11 @@ else
PKG_JOBS?=$(if $(PKG_BUILD_PARALLEL),$(MAKE_J),-j1)
endif
ifdef CONFIG_USE_MIPS16
+ TARGET_ASFLAGS_DEFAULT = $(filter-out -mips16 -minterlink-mips16,$(TARGET_CFLAGS))
ifeq ($(strip $(PKG_USE_MIPS16)),1)
- TARGET_ASFLAGS_DEFAULT = $(filter-out -mips16 -minterlink-mips16,$(TARGET_CFLAGS))
- TARGET_CFLAGS += -mips16 -minterlink-mips16
+ TARGET_CFLAGS += -mips16
endif
+ TARGET_CFLAGS += -minterlink-mips16
endif
ifeq ($(strip $(PKG_IREMAP)),1)
IREMAP_CFLAGS = $(call iremap,$(PKG_BUILD_DIR),$(notdir $(PKG_BUILD_DIR)))
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list