diff mbox series

build: enable thumb compile flag for 32bit architecture.

Message ID 20240103021144.240369-1-quic_shoudil@quicinc.com
State Changes Requested
Delegated to: Petr Štetiar
Headers show
Series build: enable thumb compile flag for 32bit architecture. | expand

Commit Message

Shoudi Li (Stephen) Jan. 3, 2024, 2:11 a.m. UTC
From: shoudil <quic_shoudil@quicinc.com>

Enable thumb flag to reduce package size, which help optimize the size
of system image as well.

Signed-off-by: shoudil <quic_shoudil@quicinc.com>
---
 include/hardening.mk | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Chuanhong Guo Jan. 3, 2024, 9:19 a.m. UTC | #1
Hi!

On Wed, Jan 3, 2024 at 10:14 AM <quic_shoudil@quicinc.com> wrote:
>
> From: shoudil <quic_shoudil@quicinc.com>
>
> Enable thumb flag to reduce package size, which help optimize the size
> of system image as well.
>
> Signed-off-by: shoudil <quic_shoudil@quicinc.com>
> ---
>  include/hardening.mk | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/include/hardening.mk b/include/hardening.mk
> index 6acd862f5c..8c59643866 100644
> --- a/include/hardening.mk
> +++ b/include/hardening.mk

"hardening.mk", as the file name implies, is specifically for hardening options.

> @@ -9,6 +9,10 @@ PKG_SSP ?= 1
>  PKG_FORTIFY_SOURCE ?= 1
>  PKG_RELRO ?= 1
>
> +ifeq ($(ARCH),arm)
> +    TARGET_CFLAGS += -mthumb
> +endif
> +

This isn't a hardening option, so it doesn't belong here.
This should probably be part of package.mk instead.
Robert Marko Jan. 3, 2024, 9:21 a.m. UTC | #2
On Wed, 3 Jan 2024 at 10:20, Chuanhong Guo <gch981213@gmail.com> wrote:
>
> Hi!
>
> On Wed, Jan 3, 2024 at 10:14 AM <quic_shoudil@quicinc.com> wrote:
> >
> > From: shoudil <quic_shoudil@quicinc.com>
> >
> > Enable thumb flag to reduce package size, which help optimize the size
> > of system image as well.
> >
> > Signed-off-by: shoudil <quic_shoudil@quicinc.com>
> > ---
> >  include/hardening.mk | 4 ++++
> >  1 file changed, 4 insertions(+)
> >
> > diff --git a/include/hardening.mk b/include/hardening.mk
> > index 6acd862f5c..8c59643866 100644
> > --- a/include/hardening.mk
> > +++ b/include/hardening.mk
>
> "hardening.mk", as the file name implies, is specifically for hardening options.
>
> > @@ -9,6 +9,10 @@ PKG_SSP ?= 1
> >  PKG_FORTIFY_SOURCE ?= 1
> >  PKG_RELRO ?= 1
> >
> > +ifeq ($(ARCH),arm)
> > +    TARGET_CFLAGS += -mthumb
> > +endif
> > +
>
> This isn't a hardening option, so it doesn't belong here.
> This should probably be part of package.mk instead.

Even then it should be a menuconfig option, not the default.

Regards,
Robert
> --
> Regards,
> Chuanhong Guo
>
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Shoudi Li (Stephen) Jan. 5, 2024, 10:44 a.m. UTC | #3
On 2024/1/3 17:21, Robert Marko wrote:
> On Wed, 3 Jan 2024 at 10:20, Chuanhong Guo <gch981213@gmail.com> wrote:
>>
>> Hi!
>>
>> On Wed, Jan 3, 2024 at 10:14 AM <quic_shoudil@quicinc.com> wrote:
>>>
>>> From: shoudil <quic_shoudil@quicinc.com>
>>>
>>> Enable thumb flag to reduce package size, which help optimize the size
>>> of system image as well.
>>>
>>> Signed-off-by: shoudil <quic_shoudil@quicinc.com>
>>> ---
>>>   include/hardening.mk | 4 ++++
>>>   1 file changed, 4 insertions(+)
>>>
>>> diff --git a/include/hardening.mk b/include/hardening.mk
>>> index 6acd862f5c..8c59643866 100644
>>> --- a/include/hardening.mk
>>> +++ b/include/hardening.mk
>>
>> "hardening.mk", as the file name implies, is specifically for hardening options.
>>
>>> @@ -9,6 +9,10 @@ PKG_SSP ?= 1
>>>   PKG_FORTIFY_SOURCE ?= 1
>>>   PKG_RELRO ?= 1
>>>
>>> +ifeq ($(ARCH),arm)
>>> +    TARGET_CFLAGS += -mthumb
>>> +endif
>>> +
>>
>> This isn't a hardening option, so it doesn't belong here.
>> This should probably be part of package.mk instead.
> 
> Even then it should be a menuconfig option, not the default.
> 
Thanks for the comments, I will consider to rework the change in 
menuconfig next.

Shoudil

> Regards,
> Robert
>> --
>> Regards,
>> Chuanhong Guo
>>
>> _______________________________________________
>> openwrt-devel mailing list
>> openwrt-devel@lists.openwrt.org
>> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
diff mbox series

Patch

diff --git a/include/hardening.mk b/include/hardening.mk
index 6acd862f5c..8c59643866 100644
--- a/include/hardening.mk
+++ b/include/hardening.mk
@@ -9,6 +9,10 @@  PKG_SSP ?= 1
 PKG_FORTIFY_SOURCE ?= 1
 PKG_RELRO ?= 1
 
+ifeq ($(ARCH),arm)
+    TARGET_CFLAGS += -mthumb
+endif
+
 ifdef CONFIG_PKG_CHECK_FORMAT_SECURITY
   ifeq ($(strip $(PKG_CHECK_FORMAT_SECURITY)),1)
     TARGET_CFLAGS += -Wformat -Werror=format-security