Skip to contentSkip to conversation

Fix Linux Version Probed

PATCH In review Giulio Benetti 3 participants 5 messages Jan 4, 2023 – Feb 7, 2023

lore
Share & tools
lore
#0 lore raw

cover Fix Linux Version Probed

While trying to fix a bug on rtl8723ds I've found that LINUX_VERSION_PROBED doesn't contain the x.y.z Linux version but it contains instead the command to obtain it. I've found 2 errors and 2 fix for this with the patch you find.
I've checked the LINUX_VERSION_PROBED even with make 4.1 and it was wrong as well as make 4.3 and 4.3.91.

Let me know if someone else can give a try to this patch. It's mainly used by drivers and by linux.mk to strip build/ and source/ folders from target/ and I think that that part is failing.

Thank you
Giulio

Giulio Benetti (1):
linux: fix LINUX_VERSION_PROBED content

 linux/linux.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Signature · 6 lines
2.34.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

PATCH 1/1 linux: fix LINUX_VERSION_PROBED content

Actually LINUX_VERSION_PROBED is set with the string sorrounded by the backquotes including them. So when we evaluate $(LINUX_VERSION_PROBED) we end up having the command itself and instead we only need the Linux version probed in the style x.y.z.

Verifying it turns out that:
1) --no-print-directory and -s make flags must be passed before -C flag, The error was not visible because errors were suppressed with '2>/dev/null'
2) backquotes don't evaluate the expression they sorround but become part of the string they sorround and get assigned to the variable

To fix this let's move --no-print-directory right after $(MAKE) and use $(shell ) instead of backquotes.

---
 linux/linux.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
linux/linux.mk +1 -1
index 7645b5f507..23c169995a 100644
@@ -183,7 +183,7 @@ endif
 # Get the real Linux version, which tells us where kernel modules are
 # going to be installed in the target filesystem.
 # Filter out 'w' from MAKEFLAGS, to workaround a bug in make 4.1 (#13141)
-LINUX_VERSION_PROBED = `MAKEFLAGS='$(filter-out w,$(MAKEFLAGS))' $(MAKE) $(LINUX_MAKE_FLAGS) -C $(LINUX_DIR) --no-print-directory -s kernelrelease 2>/dev/null`
+LINUX_VERSION_PROBED = $(shell MAKEFLAGS='$(filter-out w,$(MAKEFLAGS))' $(MAKE) --no-print-directory -s $(LINUX_MAKE_FLAGS) -C $(LINUX_DIR) kernelrelease 2>/dev/null)
 
 LINUX_DTS_NAME += $(call qstrip,$(BR2_LINUX_KERNEL_INTREE_DTS_NAME))
 
Signature · 6 lines
2.34.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Tested-by on v1 1/1
#2 lore raw

Re: [Buildroot] [External] - [PATCH 1/1] linux: fix LINUX_VERSION_PROBED content

Quoted 22 lines

-----Original Message-----
From: buildroot <[email protected]> On Behalf Of Giulio Benetti
Sent: Tuesday, January 3, 2023 8:06 PM
To: [email protected]
Cc: Giulio Benetti <[email protected]>
Subject: [External] - [Buildroot] [PATCH 1/1] linux: fix LINUX_VERSION_PROBED content

Actually LINUX_VERSION_PROBED is set with the string sorrounded by the backquotes including them. So when we evaluate $(LINUX_VERSION_PROBED) we end up having the command itself and instead we only need the Linux version probed in the style x.y.z.

Verifying it turns out that:
1) --no-print-directory and -s make flags must be passed before -C flag, The error was not visible because errors were suppressed with '2>/dev/null'
2) backquotes don't evaluate the expression they sorround but become part of the string they sorround and get assigned to the variable

Quoted 4 lines

To fix this let's move --no-print-directory right after $(MAKE) and use $(shell ) instead of backquotes.

Quoted 26 lines
---
 linux/linux.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
linux/linux.mk index 7645b5f507..23c169995a renamed from linux/linux.mk +0 -0

100644

linux/linux.mk +0 -0
@@ -183,7 +183,7 @@ endif
 # Get the real Linux version, which tells us where kernel modules are  #

going to be installed in the target filesystem.
# Filter out 'w' from MAKEFLAGS, to workaround a bug in make 4.1 (#13141)
-LINUX_VERSION_PROBED = MAKEFLAGS='$(filter-out w,$(MAKEFLAGS))' $(MAKE) $(LINUX_MAKE_FLAGS) -C $(LINUX_DIR) --no-print-directory -s kernelrelease 2>/dev/null
+LINUX_VERSION_PROBED = $(shell MAKEFLAGS='$(filter-out w,$(MAKEFLAGS))'
+$(MAKE) --no-print-directory -s $(LINUX_MAKE_FLAGS) -C $(LINUX_DIR) +kernelrelease 2>/dev/null)

LINUX_DTS_NAME += $(call
qstrip,$(BR2_LINUX_KERNEL_INTREE_DTS_NAME))

--
2.34.1

Quoted 7 lines

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#3 lore raw

Re: [Buildroot] [PATCH 1/1] linux: fix LINUX_VERSION_PROBED content

In reply to Giulio Benetti

Hello Giulio,

Quoted 12 lines · On Wed, 4 Jan 2023 03:05:58 +0100 Giulio Benetti…

Actually LINUX_VERSION_PROBED is set with the string sorrounded by the backquotes including them. So when we evaluate $(LINUX_VERSION_PROBED) we end up having the command itself and instead we only need the Linux version probed in the style x.y.z.

Verifying it turns out that:
1) --no-print-directory and -s make flags must be passed before -C flag, The error was not visible because errors were suppressed with '2>/dev/null'
2) backquotes don't evaluate the expression they sorround but become part of the string they sorround and get assigned to the variable

Quoted 4 lines

To fix this let's move --no-print-directory right after $(MAKE) and use $(shell ) instead of backquotes.

What is this fixing exactly? Do you have a specific problem that this fixes? Or is this just fixing the fact that LINUX_VERSION_PROBED contains a very long command instead of the result of the command itself?

Indeed, switching back to $(shell ...) like you're proposing would result in basically backporting:

commit 28f57bb863ba48df054cec0057c844bf23d5969f

Author: Arnout Vandecappelle <[email protected]>
Date:   Sun Jul 12 16:35:27 2015 +0200

linux: use backtick instead of $(shell ...) make function

Verified that LINUX_VERSION_PROBED is only used in "-quoted commands (actually, usually it's not quoted).

which is not desirable, especially if you don't have a good justification of why the current situation doesn't work.

So for now, I'll mark as Rejected, but if you have a good justification, you can resend with a better commit log with this justification.

Best regards,

Thomas

Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#4 lore raw

Re: [Buildroot] [PATCH 1/1] linux: fix LINUX_VERSION_PROBED content

Hello Thomas, Vincent,

Quoted 20 lines · Thomas Petazzoni via buildroot

Hello Giulio,

Quoted 15 lines · On Wed, 4 Jan 2023 03:05:58 +0100 Giulio Benetti…

Actually LINUX_VERSION_PROBED is set with the string sorrounded by the backquotes including them. So when we evaluate $(LINUX_VERSION_PROBED) we end up having the command itself and instead we only need the Linux version probed in the style x.y.z.

Verifying it turns out that:
1) --no-print-directory and -s make flags must be passed before -C flag, The error was not visible because errors were suppressed with '2>/dev/null'
2) backquotes don't evaluate the expression they sorround but become part of the string they sorround and get assigned to the variable

To fix this let's move --no-print-directory right after $(MAKE) and use $(shell ) instead of backquotes.

Quoted 6 lines
Quoted 1 line

What is this fixing exactly? Do you have a specific problem that this fixes? Or is this just fixing the fact that LINUX_VERSION_PROBED contains a very long command instead of the result of the command itself?

While building the various rtl* wifi drivers I've noticed KVER='a very long command` but it gets evaluated correctly, indeed the .ko module is installed in the correct "lib/modules/$(LINUX_VERSION_PROBED)" path.

Quoted 15 lines

Indeed, switching back to $(shell ...) like you're proposing would result in basically backporting:

commit 28f57bb863ba48df054cec0057c844bf23d5969f

Author: Arnout Vandecappelle <[email protected]>
Date:   Sun Jul 12 16:35:27 2015 +0200

linux: use backtick instead of $(shell ...) make function

Verified that LINUX_VERSION_PROBED is only used in "-quoted commands (actually, usually it's not quoted).

Quoted 6 lines

which is not desirable, especially if you don't have a good justification of why the current situation doesn't work.

So for now, I'll mark as Rejected, but if you have a good justification, you can resend with a better commit log with this justification.

Let's keep it as rejected, sorry for the noise!

Best regards

Signature · 6 lines
Giulio Benetti
Benetti Engineering sas
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot