diff mbox series

[2/2] package/rtl8192eu: fix build failure on Big Endian architectures

Message ID 20221129210800.802451-2-giulio.benetti@benettiengineering.com
State Changes Requested
Headers show
Series [1/2] DEVELOPERS: add Giulio Benetti to rtl8192eu package | expand

Commit Message

Giulio Benetti Nov. 29, 2022, 9:08 p.m. UTC
Add local patch that allows to override CONFIG_LITTLE_ENDIAN in case we're
building for Big Endian architectures. Then let's undefine
CONFIG_LITTLE_ENDIAN and define endianness according to $(BR2_ENDIAN).

Fixes:
http://autobuild.buildroot.net/results/13a/13a809570423ead33628663033db4c3c4001a79b/

Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
---
 ...TRA_CFLAGS-USER_EXTRA_CFLAGS-at-the-.patch | 40 +++++++++++++++++++
 package/rtl8192eu/rtl8192eu.mk                |  9 ++++-
 2 files changed, 48 insertions(+), 1 deletion(-)
 create mode 100644 package/rtl8192eu/0001-Makefile-move-EXTRA_CFLAGS-USER_EXTRA_CFLAGS-at-the-.patch

Comments

Arnout Vandecappelle Nov. 29, 2022, 10:16 p.m. UTC | #1
On 29/11/2022 22:08, Giulio Benetti wrote:
> Add local patch that allows to override CONFIG_LITTLE_ENDIAN in case we're
> building for Big Endian architectures. Then let's undefine
> CONFIG_LITTLE_ENDIAN and define endianness according to $(BR2_ENDIAN).
> 
> Fixes:
> http://autobuild.buildroot.net/results/13a/13a809570423ead33628663033db4c3c4001a79b/
> 
> Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
> ---
>   ...TRA_CFLAGS-USER_EXTRA_CFLAGS-at-the-.patch | 40 +++++++++++++++++++
>   package/rtl8192eu/rtl8192eu.mk                |  9 ++++-
>   2 files changed, 48 insertions(+), 1 deletion(-)
>   create mode 100644 package/rtl8192eu/0001-Makefile-move-EXTRA_CFLAGS-USER_EXTRA_CFLAGS-at-the-.patch
> 
> diff --git a/package/rtl8192eu/0001-Makefile-move-EXTRA_CFLAGS-USER_EXTRA_CFLAGS-at-the-.patch b/package/rtl8192eu/0001-Makefile-move-EXTRA_CFLAGS-USER_EXTRA_CFLAGS-at-the-.patch
> new file mode 100644
> index 0000000000..2f6ecfb210
> --- /dev/null
> +++ b/package/rtl8192eu/0001-Makefile-move-EXTRA_CFLAGS-USER_EXTRA_CFLAGS-at-the-.patch
> @@ -0,0 +1,40 @@
> +From f51cbcbeafd8d60e9b8f35b7ca62b6c941d72e3b Mon Sep 17 00:00:00 2001
> +From: Giulio Benetti <giulio.benetti@benettiengineering.com>
> +Date: Wed, 28 Sep 2022 21:17:17 +0200
> +Subject: [PATCH] Makefile: move 'EXTRA_CFLAGS += $(USER_EXTRA_CFLAGS)' at the
> + end of EXTRA_FLAGS assignment
> +
> +At the moment USER_EXTRA_CFLAGS can't override local Makfile EXTRA_CFLAGS
> +since it's assigned at the beginning of the Makefile. For example it's not
> +possible to undefine the hardcoded CONFIG_LITTLE_ENDIAN and this doesn't
> +allow to build these modules for big endian architectures. So let's move
> +the assignment of USER_EXTRA_CFLAGS to EXTRA_CFLAGS after the last
> +EXTRA_CFLAGS assignment.
> +
> +[Upstream status: https://github.com/clnhub/rtl8192eu-linux/pull/65]
> +Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
> +---
> + Makefile | 3 ++-
> + 1 file changed, 2 insertions(+), 1 deletion(-)
> +
> +diff --git a/Makefile b/Makefile
> +index 32a1898..b67a5a4 100755
> +--- a/Makefile
> ++++ b/Makefile
> +@@ -1,4 +1,3 @@
> +-EXTRA_CFLAGS += $(USER_EXTRA_CFLAGS)
> + EXTRA_CFLAGS += -O1
> + #EXTRA_CFLAGS += -O3
> + #EXTRA_CFLAGS += -Wall
> +@@ -2329,6 +2328,8 @@ ifneq ($(USER_MODULE_NAME),)
> + MODULE_NAME := $(USER_MODULE_NAME)
> + endif
> +
> ++EXTRA_CFLAGS += $(USER_EXTRA_CFLAGS)
> ++
> + ifneq ($(KERNELRELEASE),)
> +
> + ########### this part for *.mk ############################
> +--
> +2.34.1
> +
> diff --git a/package/rtl8192eu/rtl8192eu.mk b/package/rtl8192eu/rtl8192eu.mk
> index 0e8ffea5cb..589cb7f59e 100644
> --- a/package/rtl8192eu/rtl8192eu.mk
> +++ b/package/rtl8192eu/rtl8192eu.mk
> @@ -7,9 +7,16 @@
>   RTL8192EU_VERSION = 1e15b6d451731bc4d3ffd587194dc4bd0f286ac0
>   RTL8192EU_SITE = $(call github,clnhub,rtl8192eu-linux,$(RTL8192EU_VERSION))
>   RTL8192EU_LICENSE = GPL-2.0
> +
> +# Undefine the hardcoded CONFIG_LITTLE_ENDIAN
> +RTL8192EU_USER_EXTRA_CLAGS = -UCONFIG_LITTLE_ENDIAN

  It is not actually hardcoded. The only thing that is hardcoded is 
CONFIG_PLATFORM_I386_PC=y, which triggers the following fragment in the Makefile:

ifeq ($(CONFIG_PLATFORM_I386_PC), y)
EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN
EXTRA_CFLAGS += -DCONFIG_IOCTL_CFG80211 -DRTW_USE_CFG80211_STA_EVENT

SUBARCH := $(shell uname -m | sed -e s/i.86/i386/)
ARCH ?= $(SUBARCH)
CROSS_COMPILE ?=
KVER  := $(shell uname -r)
KSRC := /lib/modules/$(KVER)/build
MODDESTDIR := /lib/modules/$(KVER)/kernel/drivers/net/wireless/
INSTALL_PREFIX :=
STAGINGMODDIR := /lib/modules/$(KVER)/kernel/drivers/staging
endif


Clearly, all of this is rubbish in Buildroot context. So what we should do is to 
set

RTL8192EU_MODULE_MAKE_OPTS = ... CONFIG_PLATFORM_I386_PC=n

At that point, we can set all the appropriate config options we like, which 
would be the -DCONFIG_IOCTL_CFG80211 -DRTW_USE_CFG80211_STA_EVENT in 
USER_EXTRA_CFLAGS.


  Regards,
  Arnout

> +# Set endianness
> +RTL8192EU_USER_EXTRA_CLAGS += -DCONFIG_$(call qstrip,$(BR2_ENDIAN))_ENDIAN
> +RTL8192EU_USER_EXTRA_CLAGS += -Wno-error
> +
>   RTL8192EU_MODULE_MAKE_OPTS = \
>   	CONFIG_RTL8192EU=m \
> -	USER_EXTRA_CFLAGS="-Wno-error"
> +	USER_EXTRA_CFLAGS="$(RTL8192EU_USER_EXTRA_CLAGS)"
>   
>   define RTL8192EU_LINUX_CONFIG_FIXUPS
>   	$(call KCONFIG_ENABLE_OPT,CONFIG_NET)
Giulio Benetti Nov. 29, 2022, 10:25 p.m. UTC | #2
Hi Arnout,

> Il giorno 29 nov 2022, alle ore 23:16, Arnout Vandecappelle <arnout@mind.be> ha scritto:
> 
> 
> 
>> On 29/11/2022 22:08, Giulio Benetti wrote:
>> Add local patch that allows to override CONFIG_LITTLE_ENDIAN in case we're
>> building for Big Endian architectures. Then let's undefine
>> CONFIG_LITTLE_ENDIAN and define endianness according to $(BR2_ENDIAN).
>> Fixes:
>> http://autobuild.buildroot.net/results/13a/13a809570423ead33628663033db4c3c4001a79b/
>> Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
>> ---
>>  ...TRA_CFLAGS-USER_EXTRA_CFLAGS-at-the-.patch | 40 +++++++++++++++++++
>>  package/rtl8192eu/rtl8192eu.mk                |  9 ++++-
>>  2 files changed, 48 insertions(+), 1 deletion(-)
>>  create mode 100644 package/rtl8192eu/0001-Makefile-move-EXTRA_CFLAGS-USER_EXTRA_CFLAGS-at-the-.patch
>> diff --git a/package/rtl8192eu/0001-Makefile-move-EXTRA_CFLAGS-USER_EXTRA_CFLAGS-at-the-.patch b/package/rtl8192eu/0001-Makefile-move-EXTRA_CFLAGS-USER_EXTRA_CFLAGS-at-the-.patch
>> new file mode 100644
>> index 0000000000..2f6ecfb210
>> --- /dev/null
>> +++ b/package/rtl8192eu/0001-Makefile-move-EXTRA_CFLAGS-USER_EXTRA_CFLAGS-at-the-.patch
>> @@ -0,0 +1,40 @@
>> +From f51cbcbeafd8d60e9b8f35b7ca62b6c941d72e3b Mon Sep 17 00:00:00 2001
>> +From: Giulio Benetti <giulio.benetti@benettiengineering.com>
>> +Date: Wed, 28 Sep 2022 21:17:17 +0200
>> +Subject: [PATCH] Makefile: move 'EXTRA_CFLAGS += $(USER_EXTRA_CFLAGS)' at the
>> + end of EXTRA_FLAGS assignment
>> +
>> +At the moment USER_EXTRA_CFLAGS can't override local Makfile EXTRA_CFLAGS
>> +since it's assigned at the beginning of the Makefile. For example it's not
>> +possible to undefine the hardcoded CONFIG_LITTLE_ENDIAN and this doesn't
>> +allow to build these modules for big endian architectures. So let's move
>> +the assignment of USER_EXTRA_CFLAGS to EXTRA_CFLAGS after the last
>> +EXTRA_CFLAGS assignment.
>> +
>> +[Upstream status: https://github.com/clnhub/rtl8192eu-linux/pull/65]
>> +Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
>> +---
>> + Makefile | 3 ++-
>> + 1 file changed, 2 insertions(+), 1 deletion(-)
>> +
>> +diff --git a/Makefile b/Makefile
>> +index 32a1898..b67a5a4 100755
>> +--- a/Makefile
>> ++++ b/Makefile
>> +@@ -1,4 +1,3 @@
>> +-EXTRA_CFLAGS += $(USER_EXTRA_CFLAGS)
>> + EXTRA_CFLAGS += -O1
>> + #EXTRA_CFLAGS += -O3
>> + #EXTRA_CFLAGS += -Wall
>> +@@ -2329,6 +2328,8 @@ ifneq ($(USER_MODULE_NAME),)
>> + MODULE_NAME := $(USER_MODULE_NAME)
>> + endif
>> +
>> ++EXTRA_CFLAGS += $(USER_EXTRA_CFLAGS)
>> ++
>> + ifneq ($(KERNELRELEASE),)
>> +
>> + ########### this part for *.mk ############################
>> +--
>> +2.34.1
>> +
>> diff --git a/package/rtl8192eu/rtl8192eu.mk b/package/rtl8192eu/rtl8192eu.mk
>> index 0e8ffea5cb..589cb7f59e 100644
>> --- a/package/rtl8192eu/rtl8192eu.mk
>> +++ b/package/rtl8192eu/rtl8192eu.mk
>> @@ -7,9 +7,16 @@
>>  RTL8192EU_VERSION = 1e15b6d451731bc4d3ffd587194dc4bd0f286ac0
>>  RTL8192EU_SITE = $(call github,clnhub,rtl8192eu-linux,$(RTL8192EU_VERSION))
>>  RTL8192EU_LICENSE = GPL-2.0
>> +
>> +# Undefine the hardcoded CONFIG_LITTLE_ENDIAN
>> +RTL8192EU_USER_EXTRA_CLAGS = -UCONFIG_LITTLE_ENDIAN
> 
> It is not actually hardcoded. The only thing that is hardcoded is CONFIG_PLATFORM_I386_PC=y, which triggers the following fragment in the Makefile:
> 
> ifeq ($(CONFIG_PLATFORM_I386_PC), y)
> EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN
> EXTRA_CFLAGS += -DCONFIG_IOCTL_CFG80211 -DRTW_USE_CFG80211_STA_EVENT
> 
> SUBARCH := $(shell uname -m | sed -e s/i.86/i386/)
> ARCH ?= $(SUBARCH)
> CROSS_COMPILE ?=
> KVER  := $(shell uname -r)
> KSRC := /lib/modules/$(KVER)/build
> MODDESTDIR := /lib/modules/$(KVER)/kernel/drivers/net/wireless/
> INSTALL_PREFIX :=
> STAGINGMODDIR := /lib/modules/$(KVER)/kernel/drivers/staging
> endif
> 
> 
> Clearly, all of this is rubbish in Buildroot context. So what we should do is to set
> 
> RTL8192EU_MODULE_MAKE_OPTS = ... CONFIG_PLATFORM_I386_PC=n
> 
> At that point, we can set all the appropriate config options we like, which would be the -DCONFIG_IOCTL_CFG80211 -DRTW_USE_CFG80211_STA_EVENT in USER_EXTRA_CFLAGS.

Yes, this is another approach, but there is only a patch with my proposed solution applied [1]
so maybe for consistency we could keep it the same, what about it?

Thanks for reviewing
Giulio

[1]: https://github.com/buildroot/buildroot/commit/354f9387f33b5fab023cb98e52d84d58624f0ecf

> 
> 
> Regards,
> Arnout
> 
>> +# Set endianness
>> +RTL8192EU_USER_EXTRA_CLAGS += -DCONFIG_$(call qstrip,$(BR2_ENDIAN))_ENDIAN
>> +RTL8192EU_USER_EXTRA_CLAGS += -Wno-error
>> +
>>  RTL8192EU_MODULE_MAKE_OPTS = \
>>      CONFIG_RTL8192EU=m \
>> -    USER_EXTRA_CFLAGS="-Wno-error"
>> +    USER_EXTRA_CFLAGS="$(RTL8192EU_USER_EXTRA_CLAGS)"
>>    define RTL8192EU_LINUX_CONFIG_FIXUPS
>>      $(call KCONFIG_ENABLE_OPT,CONFIG_NET)
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot
Thomas Petazzoni Dec. 11, 2022, 8:29 p.m. UTC | #3
On Tue, 29 Nov 2022 23:25:29 +0100
Giulio Benetti <giulio.benetti@benettiengineering.com> wrote:

> > Clearly, all of this is rubbish in Buildroot context. So what we should do is to set
> > 
> > RTL8192EU_MODULE_MAKE_OPTS = ... CONFIG_PLATFORM_I386_PC=n
> > 
> > At that point, we can set all the appropriate config options we like, which would be the -DCONFIG_IOCTL_CFG80211 -DRTW_USE_CFG80211_STA_EVENT in USER_EXTRA_CFLAGS.  
> 
> Yes, this is another approach, but there is only a patch with my proposed solution applied [1]
> so maybe for consistency we could keep it the same, what about it?

Well, Arnout has a point that having CONFIG_PLATFORM_I386_PC=y is not
really good. So perhaps 354f9387f33b5fab023cb98e52d84d58624f0ecf also
needs to be changed like Arnout suggested?

Best regards,

Thomas
Giulio Benetti Dec. 13, 2022, 9:14 p.m. UTC | #4
Hello Thomas, Arnout, All,

On 11/12/22 21:29, Thomas Petazzoni via buildroot wrote:
> On Tue, 29 Nov 2022 23:25:29 +0100
> Giulio Benetti <giulio.benetti@benettiengineering.com> wrote:
> 
>>> Clearly, all of this is rubbish in Buildroot context. So what we should do is to set
>>>
>>> RTL8192EU_MODULE_MAKE_OPTS = ... CONFIG_PLATFORM_I386_PC=n
>>>
>>> At that point, we can set all the appropriate config options we like, which would be the -DCONFIG_IOCTL_CFG80211 -DRTW_USE_CFG80211_STA_EVENT in USER_EXTRA_CFLAGS.
>>
>> Yes, this is another approach, but there is only a patch with my proposed solution applied [1]
>> so maybe for consistency we could keep it the same, what about it?
> 
> Well, Arnout has a point that having CONFIG_PLATFORM_I386_PC=y is not
> really good. 


Yes, I've rechecked the Makefile and Arnout had a very good idea that
gives us the total control and I've sent a V2 patch for this:
https://patchwork.ozlabs.org/project/buildroot/patch/20221213203236.171656-1-giulio.benetti@benettiengineering.com/

> So perhaps 354f9387f33b5fab023cb98e52d84d58624f0ecf also
> needs to be changed like Arnout suggested?

Yes, I've sent one for this too:
https://patchwork.ozlabs.org/project/buildroot/patch/20221213211313.735422-1-giulio.benetti@benettiengineering.com/

If new bugs like this arise I will use that approach now on.

Thank you both!
Best regards
diff mbox series

Patch

diff --git a/package/rtl8192eu/0001-Makefile-move-EXTRA_CFLAGS-USER_EXTRA_CFLAGS-at-the-.patch b/package/rtl8192eu/0001-Makefile-move-EXTRA_CFLAGS-USER_EXTRA_CFLAGS-at-the-.patch
new file mode 100644
index 0000000000..2f6ecfb210
--- /dev/null
+++ b/package/rtl8192eu/0001-Makefile-move-EXTRA_CFLAGS-USER_EXTRA_CFLAGS-at-the-.patch
@@ -0,0 +1,40 @@ 
+From f51cbcbeafd8d60e9b8f35b7ca62b6c941d72e3b Mon Sep 17 00:00:00 2001
+From: Giulio Benetti <giulio.benetti@benettiengineering.com>
+Date: Wed, 28 Sep 2022 21:17:17 +0200
+Subject: [PATCH] Makefile: move 'EXTRA_CFLAGS += $(USER_EXTRA_CFLAGS)' at the
+ end of EXTRA_FLAGS assignment
+
+At the moment USER_EXTRA_CFLAGS can't override local Makfile EXTRA_CFLAGS
+since it's assigned at the beginning of the Makefile. For example it's not
+possible to undefine the hardcoded CONFIG_LITTLE_ENDIAN and this doesn't
+allow to build these modules for big endian architectures. So let's move
+the assignment of USER_EXTRA_CFLAGS to EXTRA_CFLAGS after the last
+EXTRA_CFLAGS assignment.
+
+[Upstream status: https://github.com/clnhub/rtl8192eu-linux/pull/65]
+Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
+---
+ Makefile | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/Makefile b/Makefile
+index 32a1898..b67a5a4 100755
+--- a/Makefile
++++ b/Makefile
+@@ -1,4 +1,3 @@
+-EXTRA_CFLAGS += $(USER_EXTRA_CFLAGS)
+ EXTRA_CFLAGS += -O1
+ #EXTRA_CFLAGS += -O3
+ #EXTRA_CFLAGS += -Wall
+@@ -2329,6 +2328,8 @@ ifneq ($(USER_MODULE_NAME),)
+ MODULE_NAME := $(USER_MODULE_NAME)
+ endif
+ 
++EXTRA_CFLAGS += $(USER_EXTRA_CFLAGS)
++
+ ifneq ($(KERNELRELEASE),)
+ 
+ ########### this part for *.mk ############################
+-- 
+2.34.1
+
diff --git a/package/rtl8192eu/rtl8192eu.mk b/package/rtl8192eu/rtl8192eu.mk
index 0e8ffea5cb..589cb7f59e 100644
--- a/package/rtl8192eu/rtl8192eu.mk
+++ b/package/rtl8192eu/rtl8192eu.mk
@@ -7,9 +7,16 @@ 
 RTL8192EU_VERSION = 1e15b6d451731bc4d3ffd587194dc4bd0f286ac0
 RTL8192EU_SITE = $(call github,clnhub,rtl8192eu-linux,$(RTL8192EU_VERSION))
 RTL8192EU_LICENSE = GPL-2.0
+
+# Undefine the hardcoded CONFIG_LITTLE_ENDIAN
+RTL8192EU_USER_EXTRA_CLAGS = -UCONFIG_LITTLE_ENDIAN
+# Set endianness
+RTL8192EU_USER_EXTRA_CLAGS += -DCONFIG_$(call qstrip,$(BR2_ENDIAN))_ENDIAN
+RTL8192EU_USER_EXTRA_CLAGS += -Wno-error
+
 RTL8192EU_MODULE_MAKE_OPTS = \
 	CONFIG_RTL8192EU=m \
-	USER_EXTRA_CFLAGS="-Wno-error"
+	USER_EXTRA_CFLAGS="$(RTL8192EU_USER_EXTRA_CLAGS)"
 
 define RTL8192EU_LINUX_CONFIG_FIXUPS
 	$(call KCONFIG_ENABLE_OPT,CONFIG_NET)