Re: [OpenWrt-Devel] [PATCH] build: always use -minterlink-mips16 if USE_MIPS16

2020-05-25 Thread Eneas Queiroz
On Mon, May 25, 2020 at 5:06 AM Felix Fietkau  wrote:
>
> On 2020-05-25 02:19, Eneas U de Queiroz wrote:
> > 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 
> > ---
> > 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.
> I think there needs be a way to opt-out of this behavior.
> The -minterlink-mips16 flag affects the performance and code size of
> generated code, so libraries that disable MIPS16 for performance reasons
> and don't depend on other MIPS16 enabled libraries should not be
> compiled with this flag.
>
> - Felix

Let's leave it as is, then.  Right now this failure appears to be an
exception, not a rule.  Packages can opt-in by adding the
-minterlink-mips16 flag themselves, as was done with lxc.

Eneas

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH] build: always use -minterlink-mips16 if USE_MIPS16

2020-05-25 Thread Felix Fietkau
On 2020-05-25 02:19, Eneas U de Queiroz wrote:
> 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 
> ---
> 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.
I think there needs be a way to opt-out of this behavior.
The -minterlink-mips16 flag affects the performance and code size of
generated code, so libraries that disable MIPS16 for performance reasons
and don't depend on other MIPS16 enabled libraries should not be
compiled with this flag.

- Felix

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] build: always use -minterlink-mips16 if USE_MIPS16

2020-05-24 Thread Eneas U de Queiroz
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 
---
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@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel