diff mbox series

pm: cpupower: Makefile: Fix cross compilation

Message ID 20241129012006.3068626-1-peng.fan@oss.nxp.com
State New
Headers show
Series pm: cpupower: Makefile: Fix cross compilation | expand

Commit Message

Peng Fan (OSS) Nov. 29, 2024, 1:20 a.m. UTC
From: Peng Fan <peng.fan@nxp.com>

After commit f79473ed9220 ("pm: cpupower: Makefile: Allow overriding
cross-compiling env params") we would fail to cross compile cpupower in
buildroot which uses the recipe at [1] where only the CROSS variable is
being set.

The issue here is the use of the lazy evaluation for all variables: CC,
LD, AR, STRIP, RANLIB, rather than just CROSS.

[1]:
https://git.buildroot.net/buildroot/tree/package/linux-tools/linux-tool-cpupower.mk.in

Fixes: f79473ed9220 ("pm: cpupower: Makefile: Allow overriding cross-compiling env params")
Reported-by: Florian Fainelli <florian.fainelli@broadcom.com>
Closes: https://lore.kernel.org/all/2bbabd2c-24ef-493c-a199-594e5dada3da@broadcom.com/
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 tools/power/cpupower/Makefile | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Shuah Khan Dec. 10, 2024, 12:58 a.m. UTC | #1
On 12/2/24 10:12, Florian Fainelli wrote:
> On 11/28/24 17:20, Peng Fan (OSS) wrote:
>> From: Peng Fan <peng.fan@nxp.com>
>>
>> After commit f79473ed9220 ("pm: cpupower: Makefile: Allow overriding
>> cross-compiling env params") we would fail to cross compile cpupower in
>> buildroot which uses the recipe at [1] where only the CROSS variable is
>> being set.
>>
>> The issue here is the use of the lazy evaluation for all variables: CC,
>> LD, AR, STRIP, RANLIB, rather than just CROSS.
>>
>> [1]:
>> https://git.buildroot.net/buildroot/tree/package/linux-tools/linux-tool-cpupower.mk.in
>>
>> Fixes: f79473ed9220 ("pm: cpupower: Makefile: Allow overriding cross-compiling env params")
>> Reported-by: Florian Fainelli <florian.fainelli@broadcom.com>
>> Closes: https://lore.kernel.org/all/2bbabd2c-24ef-493c-a199-594e5dada3da@broadcom.com/
>> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> 
> Tested-by: Florian Fainelli <florian.fainelli@broadcom.com>
> 
> Thanks!

Thank you. Applied to linux-cpupower for my next full request to
Rafael.

thanks,
-- Shuah
Florian Fainelli Jan. 7, 2025, 6:56 p.m. UTC | #2
On 12/9/24 16:58, Shuah Khan wrote:
> On 12/2/24 10:12, Florian Fainelli wrote:
>> On 11/28/24 17:20, Peng Fan (OSS) wrote:
>>> From: Peng Fan <peng.fan@nxp.com>
>>>
>>> After commit f79473ed9220 ("pm: cpupower: Makefile: Allow overriding
>>> cross-compiling env params") we would fail to cross compile cpupower in
>>> buildroot which uses the recipe at [1] where only the CROSS variable is
>>> being set.
>>>
>>> The issue here is the use of the lazy evaluation for all variables: CC,
>>> LD, AR, STRIP, RANLIB, rather than just CROSS.
>>>
>>> [1]:
>>> https://git.buildroot.net/buildroot/tree/package/linux-tools/linux- 
>>> tool-cpupower.mk.in
>>>
>>> Fixes: f79473ed9220 ("pm: cpupower: Makefile: Allow overriding cross- 
>>> compiling env params")
>>> Reported-by: Florian Fainelli <florian.fainelli@broadcom.com>
>>> Closes: https://lore.kernel.org/all/2bbabd2c-24ef-493c- 
>>> a199-594e5dada3da@broadcom.com/
>>> Signed-off-by: Peng Fan <peng.fan@nxp.com>
>>
>> Tested-by: Florian Fainelli <florian.fainelli@broadcom.com>
>>
>> Thanks!
> 
> Thank you. Applied to linux-cpupower for my next full request to
> Rafael.

Since this is a bug fix, any chance you can fast track that change so we 
can keep on building that tool in various environments?

Thanks
Shuah Khan Jan. 7, 2025, 8:38 p.m. UTC | #3
On 1/7/25 11:56, Florian Fainelli wrote:
> On 12/9/24 16:58, Shuah Khan wrote:
>> On 12/2/24 10:12, Florian Fainelli wrote:
>>> On 11/28/24 17:20, Peng Fan (OSS) wrote:
>>>> From: Peng Fan <peng.fan@nxp.com>
>>>>
>>>> After commit f79473ed9220 ("pm: cpupower: Makefile: Allow overriding
>>>> cross-compiling env params") we would fail to cross compile cpupower in
>>>> buildroot which uses the recipe at [1] where only the CROSS variable is
>>>> being set.
>>>>
>>>> The issue here is the use of the lazy evaluation for all variables: CC,
>>>> LD, AR, STRIP, RANLIB, rather than just CROSS.
>>>>
>>>> [1]:
>>>> https://git.buildroot.net/buildroot/tree/package/linux-tools/linux- tool-cpupower.mk.in
>>>>
>>>> Fixes: f79473ed9220 ("pm: cpupower: Makefile: Allow overriding cross- compiling env params")
>>>> Reported-by: Florian Fainelli <florian.fainelli@broadcom.com>
>>>> Closes: https://lore.kernel.org/all/2bbabd2c-24ef-493c- a199-594e5dada3da@broadcom.com/
>>>> Signed-off-by: Peng Fan <peng.fan@nxp.com>
>>>
>>> Tested-by: Florian Fainelli <florian.fainelli@broadcom.com>
>>>
>>> Thanks!
>>
>> Thank you. Applied to linux-cpupower for my next full request to
>> Rafael.
> 
> Since this is a bug fix, any chance you can fast track that change so we can keep on building that tool in various environments?
> 

I am planning to send pull request to Rafael later on today.
It will be available in linux-next once Rafael pulls it in.

I don't think if it can be fast tracked with the vacations
and holidays for the past 3 weeks or so. The best I can do
is getting this into linux-next

thanks,
-- Shuah
diff mbox series

Patch

diff --git a/tools/power/cpupower/Makefile b/tools/power/cpupower/Makefile
index 175004ce44b2..51a95239fe06 100644
--- a/tools/power/cpupower/Makefile
+++ b/tools/power/cpupower/Makefile
@@ -87,11 +87,19 @@  INSTALL_SCRIPT = ${INSTALL} -m 644
 # to something more interesting, like "arm-linux-".  If you want
 # to compile vs uClibc, that can be done here as well.
 CROSS ?= #/usr/i386-linux-uclibc/usr/bin/i386-uclibc-
+ifneq ($(CROSS), )
+CC = $(CROSS)gcc
+LD = $(CROSS)gcc
+AR = $(CROSS)ar
+STRIP = $(CROSS)strip
+RANLIB = $(CROSS)ranlib
+else
 CC ?= $(CROSS)gcc
 LD ?= $(CROSS)gcc
 AR ?= $(CROSS)ar
 STRIP ?= $(CROSS)strip
 RANLIB ?= $(CROSS)ranlib
+endif
 HOSTCC = gcc
 MKDIR = mkdir