linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] tools: power: cpupower: Allow overriding cross-compiling envs
@ 2024-09-19 12:08 Peng Fan (OSS)
  2024-09-19 12:08 ` [PATCH v2 1/2] pm: cpupower: bench: print config file path when open cpufreq-bench.conf fails Peng Fan (OSS)
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Peng Fan (OSS) @ 2024-09-19 12:08 UTC (permalink / raw)
  To: Thomas Renninger, Shuah Khan, John B. Wyatt IV, John Kacur
  Cc: linux-pm, linux-kernel, Peng Fan

Two minor patches:
Patch 1 is not relevant for cross-compiling, but done when I playing
with cpupower on ARM64 boards.
Patch 2 is to make it easier for Yocto users to cross-compiling cpupower
tools.

Signed-off-by: Peng Fan <peng.fan@nxp.com>

V2:
 subject update, commit log update in patch 1, 2
 Use strerror in patch 1
 without patch 2, need update Makefile with 'CROSS =
 [cross toolchain path]/aarch64-poky-linux-'

---
Peng Fan (2):
      pm: cpupower: bench: print config file path when open cpufreq-bench.conf fails
      pm: cpupower: Makefile: Allow overriding cross-compiling env params

 tools/power/cpupower/Makefile      | 12 ++++++------
 tools/power/cpupower/bench/parse.c |  5 +++--
 2 files changed, 9 insertions(+), 8 deletions(-)
---
base-commit: 6708132e80a2ced620bde9b9c36e426183544a23
change-id: 20240917-pm-08147f104e70

Best regards,
-- 
Peng Fan <peng.fan@nxp.com>


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH v2 1/2] pm: cpupower: bench: print config file path when open cpufreq-bench.conf fails
  2024-09-19 12:08 [PATCH v2 0/2] tools: power: cpupower: Allow overriding cross-compiling envs Peng Fan (OSS)
@ 2024-09-19 12:08 ` Peng Fan (OSS)
  2024-09-19 12:08 ` [PATCH v2 2/2] pm: cpupower: Makefile: Allow overriding cross-compiling env params Peng Fan (OSS)
  2024-09-19 16:38 ` [PATCH v2 0/2] tools: power: cpupower: Allow overriding cross-compiling envs John B. Wyatt IV
  2 siblings, 0 replies; 16+ messages in thread
From: Peng Fan (OSS) @ 2024-09-19 12:08 UTC (permalink / raw)
  To: Thomas Renninger, Shuah Khan, John B. Wyatt IV, John Kacur
  Cc: linux-pm, linux-kernel, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Print out the config file path when fopen failed. It will be easy
for users to know where to create the file.

Since we are here, use strerror to drop the usage of perror.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 tools/power/cpupower/bench/parse.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tools/power/cpupower/bench/parse.c b/tools/power/cpupower/bench/parse.c
index e63dc11fa3a5..080678d9d74e 100644
--- a/tools/power/cpupower/bench/parse.c
+++ b/tools/power/cpupower/bench/parse.c
@@ -4,6 +4,7 @@
  *  Copyright (C) 2008 Christian Kornacker <ckornacker@suse.de>
  */
 
+#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdarg.h>
@@ -165,8 +166,8 @@ int prepare_config(const char *path, struct config *config)
 
 	configfile = fopen(path, "r");
 	if (configfile == NULL) {
-		perror("fopen");
-		fprintf(stderr, "error: unable to read configfile\n");
+		fprintf(stderr, "error: unable to read configfile: %s, %s\n",
+			path, strerror(errno));
 		free(config);
 		return 1;
 	}

-- 
2.37.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v2 2/2] pm: cpupower: Makefile: Allow overriding cross-compiling env params
  2024-09-19 12:08 [PATCH v2 0/2] tools: power: cpupower: Allow overriding cross-compiling envs Peng Fan (OSS)
  2024-09-19 12:08 ` [PATCH v2 1/2] pm: cpupower: bench: print config file path when open cpufreq-bench.conf fails Peng Fan (OSS)
@ 2024-09-19 12:08 ` Peng Fan (OSS)
  2024-11-21  4:41   ` Florian Fainelli
  2024-09-19 16:38 ` [PATCH v2 0/2] tools: power: cpupower: Allow overriding cross-compiling envs John B. Wyatt IV
  2 siblings, 1 reply; 16+ messages in thread
From: Peng Fan (OSS) @ 2024-09-19 12:08 UTC (permalink / raw)
  To: Thomas Renninger, Shuah Khan, John B. Wyatt IV, John Kacur
  Cc: linux-pm, linux-kernel, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Allow overriding the cross-comple env parameters to make it
easier for Yocto users. Then cross-compiler toolchains to build
cpupower with only two steps:
- source (toolchain path)/environment-setup-armv8a-poky-linux
- make

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 tools/power/cpupower/Makefile | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/tools/power/cpupower/Makefile b/tools/power/cpupower/Makefile
index 6c02f401069e..e2a48af6fa2a 100644
--- a/tools/power/cpupower/Makefile
+++ b/tools/power/cpupower/Makefile
@@ -86,12 +86,12 @@ INSTALL_SCRIPT = ${INSTALL} -m 644
 # If you are running a cross compiler, you may want to set this
 # 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-
-CC = $(CROSS)gcc
-LD = $(CROSS)gcc
-AR = $(CROSS)ar
-STRIP = $(CROSS)strip
-RANLIB = $(CROSS)ranlib
+CROSS ?= #/usr/i386-linux-uclibc/usr/bin/i386-uclibc-
+CC ?= $(CROSS)gcc
+LD ?= $(CROSS)gcc
+AR ?= $(CROSS)ar
+STRIP ?= $(CROSS)strip
+RANLIB ?= $(CROSS)ranlib
 HOSTCC = gcc
 MKDIR = mkdir
 

-- 
2.37.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH v2 0/2] tools: power: cpupower: Allow overriding cross-compiling envs
  2024-09-19 12:08 [PATCH v2 0/2] tools: power: cpupower: Allow overriding cross-compiling envs Peng Fan (OSS)
  2024-09-19 12:08 ` [PATCH v2 1/2] pm: cpupower: bench: print config file path when open cpufreq-bench.conf fails Peng Fan (OSS)
  2024-09-19 12:08 ` [PATCH v2 2/2] pm: cpupower: Makefile: Allow overriding cross-compiling env params Peng Fan (OSS)
@ 2024-09-19 16:38 ` John B. Wyatt IV
  2024-09-20  8:58   ` Peng Fan
  2 siblings, 1 reply; 16+ messages in thread
From: John B. Wyatt IV @ 2024-09-19 16:38 UTC (permalink / raw)
  To: Peng Fan (OSS)
  Cc: Thomas Renninger, Shuah Khan, John Kacur, linux-pm, linux-kernel,
	Peng Fan

Hi Peng,

A few comments:

> V2:
>  subject update, commit log update in patch 1, 2
>  Use strerror in patch 1
>  without patch 2, need update Makefile with 'CROSS =
>  [cross toolchain path]/aarch64-poky-linux-'

Version information is applied per commit patch. Not in the cover letter.

Example:

https://lore.kernel.org/linux-pm/20240905021916.15938-2-jwyatt@redhat.com/

Reference:

https://www.kernel.org/doc/html/latest/process/submitting-patches.html#the-canonical-patch-format

You will need to submit a V3 version of this.

>  without patch 2, need update Makefile with 'CROSS =
>  [cross toolchain path]/aarch64-poky-linux-'

I am not sure what this is saying exactly. Please clarify.

> Subject: Re: [PATCH v2 0/2] tools: power: cpupower: Allow overriding

Not sure you need 'tools: power: cpupower:' in the cover letter.

> pm: cpupower: bench: print config file path when open cpufreq-bench.conf fails

I do not think you need bench either.

-- 
Sincerely,
John Wyatt
Software Engineer, Core Kernel
Red Hat


^ permalink raw reply	[flat|nested] 16+ messages in thread

* RE: [PATCH v2 0/2] tools: power: cpupower: Allow overriding cross-compiling envs
  2024-09-19 16:38 ` [PATCH v2 0/2] tools: power: cpupower: Allow overriding cross-compiling envs John B. Wyatt IV
@ 2024-09-20  8:58   ` Peng Fan
  2024-09-20  9:01     ` Peng Fan
  0 siblings, 1 reply; 16+ messages in thread
From: Peng Fan @ 2024-09-20  8:58 UTC (permalink / raw)
  To: John B. Wyatt IV, Peng Fan (OSS)
  Cc: Thomas Renninger, Shuah Khan, John Kacur,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org

Hi John,

> Subject: Re: [PATCH v2 0/2] tools: power: cpupower: Allow overriding
> cross-compiling envs
> 
> Hi Peng,
> 
> A few comments:
> 
> > V2:
> >  subject update, commit log update in patch 1, 2  Use strerror in
> > patch 1  without patch 2, need update Makefile with 'CROSS =  [cross
> > toolchain path]/aarch64-poky-linux-'
> 
> Version information is applied per commit patch. Not in the cover
> letter.
> 
> Example:
> 
> https://lore.kernel.org/linux-pm/20240905021916.15938-2-jwyatt@redhat.com/
> Reference:
> 
> 
> You will need to submit a V3 version of this.
> https://www.kernel.org/doc/html/latest/process/submitting-patches.html#the-canonical-patch-format

Sure, I will follow in v3.

> >  without patch 2, need update Makefile with 'CROSS =  [cross
> toolchain
> > path]/aarch64-poky-linux-'
> 
> I am not sure what this is saying exactly. Please clarify.
> 

Shuah asked to put that in changelog,

https://lore.kernel.org/all/0f8df90f-007a-483e-83ce-df8ff0e99791@linuxfoundation.org/

I could put in patch 1/2 change log in V3.

> > Subject: Re: [PATCH v2 0/2] tools: power: cpupower: Allow
> overriding
> 
> Not sure you need 'tools: power: cpupower:' in the cover letter.

Will use "tools: power:" in v3.
> 
> > pm: cpupower: bench: print config file path when open
> > cpufreq-bench.conf fails
> 
> I do not think you need bench either.

Will drop "bench" in v3.


Thanks,
Peng.

> 
> --
> Sincerely,
> John Wyatt
> Software Engineer, Core Kernel
> Red Hat


^ permalink raw reply	[flat|nested] 16+ messages in thread

* RE: [PATCH v2 0/2] tools: power: cpupower: Allow overriding cross-compiling envs
  2024-09-20  8:58   ` Peng Fan
@ 2024-09-20  9:01     ` Peng Fan
  2024-09-20 12:41       ` John B. Wyatt IV
  2024-09-20 12:44       ` John B. Wyatt IV
  0 siblings, 2 replies; 16+ messages in thread
From: Peng Fan @ 2024-09-20  9:01 UTC (permalink / raw)
  To: Peng Fan, John B. Wyatt IV, Peng Fan (OSS)
  Cc: Thomas Renninger, Shuah Khan, John Kacur,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org

> Subject: RE: [PATCH v2 0/2] tools: power: cpupower: Allow overriding
> cross-compiling envs
> 
> Hi John,
> 
> > Subject: Re: [PATCH v2 0/2] tools: power: cpupower: Allow
> overriding
> > cross-compiling envs
> >
> > Hi Peng,
> >
> > A few comments:
> >
> > > V2:
> > >  subject update, commit log update in patch 1, 2  Use strerror in
> > > patch 1  without patch 2, need update Makefile with 'CROSS =
> [cross
> > > toolchain path]/aarch64-poky-linux-'
> >
> > Version information is applied per commit patch. Not in the cover
> > letter.
> >

Just get this from the page:
https://www.kernel.org/doc/html/latest/process/submitting-patches.html#the-canonical-patch-format
When sending a next version, add a patch changelog to the cover
Letter or to individual patches explaining difference against
previous submission

So it is fine to put changelog in cover-letter?

Thanks,
Peng.

> 
> Sure, I will follow in v3.
> 
> > >  without patch 2, need update Makefile with 'CROSS =  [cross
> > toolchain
> > > path]/aarch64-poky-linux-'
> >
> > I am not sure what this is saying exactly. Please clarify.
> >
> 
> Shuah asked to put that in changelog,
> 
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2F
> lore.kernel.org%2Fall%2F0f8df90f-007a-483e-83ce-
> df8ff0e99791%40linuxfoundation.org%2F&data=05%7C02%7Cpeng.fa
> n%40nxp.com%7C246bfa4c006340cb2f3108dcd95293ec%7C686ea1d
> 3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C638624195921233948%
> 7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2lu
> MzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=Kj9
> PVl7PaBNAMZQ0bHL7F2ZIAhcziUEkEE3vdIrYmtU%3D&reserved=0
> 
> I could put in patch 1/2 change log in V3.
> 
> > > Subject: Re: [PATCH v2 0/2] tools: power: cpupower: Allow
> > overriding
> >
> > Not sure you need 'tools: power: cpupower:' in the cover letter.
> 
> Will use "tools: power:" in v3.
> >
> > > pm: cpupower: bench: print config file path when open
> > > cpufreq-bench.conf fails
> >
> > I do not think you need bench either.
> 
> Will drop "bench" in v3.
> 
> 
> Thanks,
> Peng.
> 
> >
> > --
> > Sincerely,
> > John Wyatt
> > Software Engineer, Core Kernel
> > Red Hat
> 


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v2 0/2] tools: power: cpupower: Allow overriding cross-compiling envs
  2024-09-20  9:01     ` Peng Fan
@ 2024-09-20 12:41       ` John B. Wyatt IV
  2024-09-20 12:44       ` John B. Wyatt IV
  1 sibling, 0 replies; 16+ messages in thread
From: John B. Wyatt IV @ 2024-09-20 12:41 UTC (permalink / raw)
  To: Peng Fan
  Cc: Peng Fan (OSS), Thomas Renninger, Shuah Khan, John Kacur,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org

On Fri, Sep 20, 2024 at 09:01:49AM +0000, Peng Fan wrote:
> > > > V2:
> > > >  subject update, commit log update in patch 1, 2  Use strerror in
> > > > patch 1  without patch 2, need update Makefile with 'CROSS =
> > [cross
> > > > toolchain path]/aarch64-poky-linux-'
> > >
> > > Version information is applied per commit patch. Not in the cover
> > > letter.
> > >
> 
> Just get this from the page:
> https://www.kernel.org/doc/html/latest/process/submitting-patches.html#the-canonical-patch-format
> When sending a next version, add a patch changelog to the cover
> Letter or to individual patches explaining difference against
> previous submission
> 
> So it is fine to put changelog in cover-letter?

Ah, my mistake. It is fine.

-- 
Sincerely,
John Wyatt
Software Engineer, Core Kernel
Red Hat


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v2 0/2] tools: power: cpupower: Allow overriding cross-compiling envs
  2024-09-20  9:01     ` Peng Fan
  2024-09-20 12:41       ` John B. Wyatt IV
@ 2024-09-20 12:44       ` John B. Wyatt IV
  2024-09-23  6:26         ` Peng Fan
  1 sibling, 1 reply; 16+ messages in thread
From: John B. Wyatt IV @ 2024-09-20 12:44 UTC (permalink / raw)
  To: Peng Fan
  Cc: Peng Fan (OSS), Thomas Renninger, Shuah Khan, John Kacur,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org

On Fri, Sep 20, 2024 at 09:01:49AM +0000, Peng Fan wrote:
> > > Not sure you need 'tools: power: cpupower:' in the cover letter.
> > 
> > Will use "tools: power:" in v3.
> > >
> > > > pm: cpupower: bench: print config file path when open
> > > > cpufreq-bench.conf fails
> > >
> > > I do not think you need bench either.
> > 
> > Will drop "bench" in v3.

I do not think those alone are needed for a v3 since I was corrected on
the changelog; at least as far I am concerned.

-- 
Sincerely,
John Wyatt
Software Engineer, Core Kernel
Red Hat


^ permalink raw reply	[flat|nested] 16+ messages in thread

* RE: [PATCH v2 0/2] tools: power: cpupower: Allow overriding cross-compiling envs
  2024-09-20 12:44       ` John B. Wyatt IV
@ 2024-09-23  6:26         ` Peng Fan
  2024-09-30 15:52           ` Shuah Khan
  0 siblings, 1 reply; 16+ messages in thread
From: Peng Fan @ 2024-09-23  6:26 UTC (permalink / raw)
  To: John B. Wyatt IV
  Cc: Peng Fan (OSS), Thomas Renninger, Shuah Khan, John Kacur,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org

> Subject: Re: [PATCH v2 0/2] tools: power: cpupower: Allow overriding
> cross-compiling envs
> 
> On Fri, Sep 20, 2024 at 09:01:49AM +0000, Peng Fan wrote:
> > > > Not sure you need 'tools: power: cpupower:' in the cover letter.
> > >
> > > Will use "tools: power:" in v3.
> > > >
> > > > > pm: cpupower: bench: print config file path when open
> > > > > cpufreq-bench.conf fails
> > > >
> > > > I do not think you need bench either.
> > >
> > > Will drop "bench" in v3.
> 
> I do not think those alone are needed for a v3 since I was corrected on
> the changelog; at least as far I am concerned.

I will do a v3 to convert perror to strerror per the reply in v1 from
Shuah.

Thanks,
Peng.

> 
> --
> Sincerely,
> John Wyatt
> Software Engineer, Core Kernel
> Red Hat


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v2 0/2] tools: power: cpupower: Allow overriding cross-compiling envs
  2024-09-23  6:26         ` Peng Fan
@ 2024-09-30 15:52           ` Shuah Khan
  0 siblings, 0 replies; 16+ messages in thread
From: Shuah Khan @ 2024-09-30 15:52 UTC (permalink / raw)
  To: Peng Fan, John B. Wyatt IV
  Cc: Peng Fan (OSS), Thomas Renninger, Shuah Khan, John Kacur,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	Shuah Khan

On 9/23/24 00:26, Peng Fan wrote:
>> Subject: Re: [PATCH v2 0/2] tools: power: cpupower: Allow overriding
>> cross-compiling envs
>>
>> On Fri, Sep 20, 2024 at 09:01:49AM +0000, Peng Fan wrote:
>>>>> Not sure you need 'tools: power: cpupower:' in the cover letter.
>>>>
>>>> Will use "tools: power:" in v3.
>>>>>
>>>>>> pm: cpupower: bench: print config file path when open
>>>>>> cpufreq-bench.conf fails
>>>>>
>>>>> I do not think you need bench either.
>>>>
>>>> Will drop "bench" in v3.
>>
>> I do not think those alone are needed for a v3 since I was corrected on
>> the changelog; at least as far I am concerned.
> 
> I will do a v3 to convert perror to strerror per the reply in v1 from
> Shuah.
> 

You can send perror to strerror in this file in a separate patch on top
of my cpupower branch.

Thank you. Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux.git/log/?h=cpupower

It will be included in my next pull request to PM maintainer.

thanks,
-- Shuah


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v2 2/2] pm: cpupower: Makefile: Allow overriding cross-compiling env params
  2024-09-19 12:08 ` [PATCH v2 2/2] pm: cpupower: Makefile: Allow overriding cross-compiling env params Peng Fan (OSS)
@ 2024-11-21  4:41   ` Florian Fainelli
  2024-11-21 12:40     ` Peng Fan
  0 siblings, 1 reply; 16+ messages in thread
From: Florian Fainelli @ 2024-11-21  4:41 UTC (permalink / raw)
  To: Peng Fan (OSS), Thomas Renninger, Shuah Khan, John B. Wyatt IV,
	John Kacur
  Cc: linux-pm, linux-kernel, Peng Fan

Hi Peng,

On 9/19/2024 5:08 AM, Peng Fan (OSS) wrote:
> From: Peng Fan <peng.fan@nxp.com>
> 
> Allow overriding the cross-comple env parameters to make it
> easier for Yocto users. Then cross-compiler toolchains to build
> cpupower with only two steps:
> - source (toolchain path)/environment-setup-armv8a-poky-linux
> - make

This patch breaks the way that buildroot builds cpupower:

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

and after enabling verbose it becomes clear as to why, see below:

 >>> linux-tools  Configuring
 >>> linux-tools  Building
GIT_DIR=. 
PATH="/local/users/fainelli/buildroot-upstream/output/arm/host/bin:/local/users/fainelli/buildroot-upstream/output/arm/host/sbin:/projects/firepath/tools/bin:/home/ff944844/bin:/home/ff944844/.local/bin:/opt/stblinux/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/opt/toolchains/metaware-vctools-0.4.1/bin/" 
/usr/bin/make -j97 
CROSS=/local/users/fainelli/buildroot-upstream/output/arm/host/bin/arm-linux- 
CPUFREQ_BENCH=false NLS=false LDFLAGS="-L. 
-L/local/users/fainelli/buildroot-upstream/output/arm/target/usr/lib" 
DEBUG=false V=1 -C 
/local/users/fainelli/buildroot-upstream/output/arm/build/linux-custom/tools 
cpupower
mkdir -p power/cpupower && /usr/bin/make  subdir=power/cpupower 
--no-print-directory -C power/cpupower
cc -DVERSION=\"6.12.0\" -DPACKAGE=\"cpupower\" 
-DPACKAGE_BUGREPORT=\"linux-pm@vger.kernel.org\" -D_GNU_SOURCE -pipe 
-Wall -Wchar-subscripts -Wpointer-arith -Wsign-compare -Wno-pointer-sign 
-Wdeclaration-after-statement -Wshadow -Os -fomit-frame-pointer -fPIC -o 
lib/cpufreq.o -c lib/cpufreq.c

Here we use cc, aka host compiler, rather than $(CROSS)gcc as we should, 
so we are no longer cross compiling at all.

The issue is the use of the lazy set if absent for *all* of CC, LD, AR, 
STRIP, RANLIB, rather than just for CROSS. The following fixes it for me:

diff --git a/tools/power/cpupower/Makefile b/tools/power/cpupower/Makefile
index 175004ce44b2..96bb1e5f3970 100644
--- a/tools/power/cpupower/Makefile
+++ b/tools/power/cpupower/Makefile
@@ -87,11 +87,11 @@ 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-
-CC ?= $(CROSS)gcc
-LD ?= $(CROSS)gcc
-AR ?= $(CROSS)ar
-STRIP ?= $(CROSS)strip
-RANLIB ?= $(CROSS)ranlib
+CC = $(CROSS)gcc
+LD = $(CROSS)gcc
+AR = $(CROSS)ar
+STRIP = $(CROSS)strip
+RANLIB = $(CROSS)ranlib
  HOSTCC = gcc
  MKDIR = mkdir

-- 
Florian


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* RE: [PATCH v2 2/2] pm: cpupower: Makefile: Allow overriding cross-compiling env params
  2024-11-21  4:41   ` Florian Fainelli
@ 2024-11-21 12:40     ` Peng Fan
  2024-11-21 17:02       ` Florian Fainelli
  0 siblings, 1 reply; 16+ messages in thread
From: Peng Fan @ 2024-11-21 12:40 UTC (permalink / raw)
  To: Florian Fainelli, Peng Fan (OSS), Thomas Renninger, Shuah Khan,
	John B. Wyatt IV, John Kacur
  Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org

> Subject: Re: [PATCH v2 2/2] pm: cpupower: Makefile: Allow overriding
> cross-compiling env params
> 
> Hi Peng,
> 
> On 9/19/2024 5:08 AM, Peng Fan (OSS) wrote:
> > From: Peng Fan <peng.fan@nxp.com>
> >
> > Allow overriding the cross-comple env parameters to make it easier
> for
> > Yocto users. Then cross-compiler toolchains to build cpupower with
> > only two steps:
> > - source (toolchain path)/environment-setup-armv8a-poky-linux
> > - make
> 
> This patch breaks the way that buildroot builds cpupower:
> 
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2F
> git.buildroot.net%2Fbuildroot%2Ftree%2Fpackage%2Flinux-
> tools%2Flinux-tool-
> cpupower.mk.in&data=05%7C02%7Cpeng.fan%40nxp.com%7C246da9
> 2d8b6243d138c808dd09e6d644%7C686ea1d3bc2b4c6fa92cd99c5c3
> 01635%7C0%7C0%7C638677609234547728%7CUnknown%7CTWFpb
> GZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJX
> aW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdat
> a=nL1YUl%2F07Vd8F0GpW7uRqdpZT74avOku1ox9N3%2FFkUg%3D&r
> eserved=0
> 
> and after enabling verbose it becomes clear as to why, see below:
> 
>  >>> linux-tools  Configuring
>  >>> linux-tools  Building
> GIT_DIR=.
> PATH="/local/users/fainelli/buildroot-
> upstream/output/arm/host/bin:/local/users/fainelli/buildroot-
> upstream/output/arm/host/sbin:/projects/firepath/tools/bin:/home/ff
> 944844/bin:/home/ff944844/.local/bin:/opt/stblinux/bin:/usr/local/sb
> in:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/ga
> mes:/snap/bin:/opt/toolchains/metaware-vctools-0.4.1/bin/"
> /usr/bin/make -j97
> CROSS=/local/users/fainelli/buildroot-
> upstream/output/arm/host/bin/arm-linux-
> CPUFREQ_BENCH=false NLS=false LDFLAGS="-L.
> -L/local/users/fainelli/buildroot-upstream/output/arm/target/usr/lib"
> DEBUG=false V=1 -C
> /local/users/fainelli/buildroot-upstream/output/arm/build/linux-
> custom/tools
> cpupower
> mkdir -p power/cpupower && /usr/bin/make  subdir=power/cpupower
> --no-print-directory -C power/cpupower cc -DVERSION=\"6.12.0\" -
> DPACKAGE=\"cpupower\"
> -DPACKAGE_BUGREPORT=\"linux-pm@vger.kernel.org\" -
> D_GNU_SOURCE -pipe -Wall -Wchar-subscripts -Wpointer-arith -Wsign-
> compare -Wno-pointer-sign -Wdeclaration-after-statement -Wshadow -
> Os -fomit-frame-pointer -fPIC -o lib/cpufreq.o -c lib/cpufreq.c

You are building on an ARM host? Or you are cross compiling
with cc is actually arm gcc?

> 
> Here we use cc, aka host compiler, rather than $(CROSS)gcc as we
> should, so we are no longer cross compiling at all.

I not understand. CROSS was set, but using cc to compile for host?

> 
> The issue is the use of the lazy set if absent for *all* of CC, LD, AR, STRIP,
> RANLIB, rather than just for CROSS. The following fixes it for me:
> 
> diff --git a/tools/power/cpupower/Makefile
> b/tools/power/cpupower/Makefile index
> 175004ce44b2..96bb1e5f3970 100644
> --- a/tools/power/cpupower/Makefile
> +++ b/tools/power/cpupower/Makefile
> @@ -87,11 +87,11 @@ 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-
> -CC ?= $(CROSS)gcc
> -LD ?= $(CROSS)gcc
> -AR ?= $(CROSS)ar
> -STRIP ?= $(CROSS)strip
> -RANLIB ?= $(CROSS)ranlib
> +CC = $(CROSS)gcc
> +LD = $(CROSS)gcc
> +AR = $(CROSS)ar
> +STRIP = $(CROSS)strip
> +RANLIB = $(CROSS)ranlib

The ? is just allow to override CC/LD/AR.., so in your env,
CC is set, but should not be used for cpupower compling?

Thanks,
Peng.

>   HOSTCC = gcc
>   MKDIR = mkdir
> 
> --
> Florian


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v2 2/2] pm: cpupower: Makefile: Allow overriding cross-compiling env params
  2024-11-21 12:40     ` Peng Fan
@ 2024-11-21 17:02       ` Florian Fainelli
  2024-11-22  0:13         ` Peng Fan
  0 siblings, 1 reply; 16+ messages in thread
From: Florian Fainelli @ 2024-11-21 17:02 UTC (permalink / raw)
  To: Peng Fan, Peng Fan (OSS), Thomas Renninger, Shuah Khan,
	John B. Wyatt IV, John Kacur
  Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org

On 11/21/24 04:40, Peng Fan wrote:
>> Subject: Re: [PATCH v2 2/2] pm: cpupower: Makefile: Allow overriding
>> cross-compiling env params
>>
>> Hi Peng,
>>
>> On 9/19/2024 5:08 AM, Peng Fan (OSS) wrote:
>>> From: Peng Fan <peng.fan@nxp.com>
>>>
>>> Allow overriding the cross-comple env parameters to make it easier
>> for
>>> Yocto users. Then cross-compiler toolchains to build cpupower with
>>> only two steps:
>>> - source (toolchain path)/environment-setup-armv8a-poky-linux
>>> - make
>>
>> This patch breaks the way that buildroot builds cpupower:
>>
>> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2F
>> git.buildroot.net%2Fbuildroot%2Ftree%2Fpackage%2Flinux-
>> tools%2Flinux-tool-
>> cpupower.mk.in&data=05%7C02%7Cpeng.fan%40nxp.com%7C246da9
>> 2d8b6243d138c808dd09e6d644%7C686ea1d3bc2b4c6fa92cd99c5c3
>> 01635%7C0%7C0%7C638677609234547728%7CUnknown%7CTWFpb
>> GZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJX
>> aW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdat
>> a=nL1YUl%2F07Vd8F0GpW7uRqdpZT74avOku1ox9N3%2FFkUg%3D&r
>> eserved=0
>>
>> and after enabling verbose it becomes clear as to why, see below:
>>
>>   >>> linux-tools  Configuring
>>   >>> linux-tools  Building
>> GIT_DIR=.
>> PATH="/local/users/fainelli/buildroot-
>> upstream/output/arm/host/bin:/local/users/fainelli/buildroot-
>> upstream/output/arm/host/sbin:/projects/firepath/tools/bin:/home/ff
>> 944844/bin:/home/ff944844/.local/bin:/opt/stblinux/bin:/usr/local/sb
>> in:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/ga
>> mes:/snap/bin:/opt/toolchains/metaware-vctools-0.4.1/bin/"
>> /usr/bin/make -j97
>> CROSS=/local/users/fainelli/buildroot-
>> upstream/output/arm/host/bin/arm-linux-
>> CPUFREQ_BENCH=false NLS=false LDFLAGS="-L.
>> -L/local/users/fainelli/buildroot-upstream/output/arm/target/usr/lib"
>> DEBUG=false V=1 -C
>> /local/users/fainelli/buildroot-upstream/output/arm/build/linux-
>> custom/tools
>> cpupower
>> mkdir -p power/cpupower && /usr/bin/make  subdir=power/cpupower
>> --no-print-directory -C power/cpupower cc -DVERSION=\"6.12.0\" -
>> DPACKAGE=\"cpupower\"
>> -DPACKAGE_BUGREPORT=\"linux-pm@vger.kernel.org\" -
>> D_GNU_SOURCE -pipe -Wall -Wchar-subscripts -Wpointer-arith -Wsign-
>> compare -Wno-pointer-sign -Wdeclaration-after-statement -Wshadow -
>> Os -fomit-frame-pointer -fPIC -o lib/cpufreq.o -c lib/cpufreq.c
> 
> You are building on an ARM host? Or you are cross compiling
> with cc is actually arm gcc?

This is cross compiling targeting ARM, which is why CROSS is set to 
../arm-linux-

> 
>>
>> Here we use cc, aka host compiler, rather than $(CROSS)gcc as we
>> should, so we are no longer cross compiling at all.
> 
> I not understand. CROSS was set, but using cc to compile for host?

See below.

> 
>>
>> The issue is the use of the lazy set if absent for *all* of CC, LD, AR, STRIP,
>> RANLIB, rather than just for CROSS. The following fixes it for me:
>>
>> diff --git a/tools/power/cpupower/Makefile
>> b/tools/power/cpupower/Makefile index
>> 175004ce44b2..96bb1e5f3970 100644
>> --- a/tools/power/cpupower/Makefile
>> +++ b/tools/power/cpupower/Makefile
>> @@ -87,11 +87,11 @@ 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-
>> -CC ?= $(CROSS)gcc
>> -LD ?= $(CROSS)gcc
>> -AR ?= $(CROSS)ar
>> -STRIP ?= $(CROSS)strip
>> -RANLIB ?= $(CROSS)ranlib
>> +CC = $(CROSS)gcc
>> +LD = $(CROSS)gcc
>> +AR = $(CROSS)ar
>> +STRIP = $(CROSS)strip
>> +RANLIB = $(CROSS)ranlib
> 
> The ? is just allow to override CC/LD/AR.., so in your env,
> CC is set, but should not be used for cpupower compling?

Adding debug to show the origin of the CC variable shows the following:

CROSS=/local/users/fainelli/buildroot-upstream/output/arm/host/bin/arm-linux-
CC origin is (default) and value is (cc)
LD origin is (default) and value is (ld)
CC=cc
LD=ld
AR=ar
STRIP=
RANLIB=

See 
https://www.gnu.org/software/make/manual/html_node/Origin-Function.html#Origin-Function
-- 
Florian

^ permalink raw reply	[flat|nested] 16+ messages in thread

* RE: [PATCH v2 2/2] pm: cpupower: Makefile: Allow overriding cross-compiling env params
  2024-11-21 17:02       ` Florian Fainelli
@ 2024-11-22  0:13         ` Peng Fan
  2024-11-22 17:34           ` Florian Fainelli
  0 siblings, 1 reply; 16+ messages in thread
From: Peng Fan @ 2024-11-22  0:13 UTC (permalink / raw)
  To: Florian Fainelli, Peng Fan (OSS), Thomas Renninger, Shuah Khan,
	John B. Wyatt IV, John Kacur
  Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org

> Subject: Re: [PATCH v2 2/2] pm: cpupower: Makefile: Allow overriding
> cross-compiling env params
> 
> On 11/21/24 04:40, Peng Fan wrote:
> >> Subject: Re: [PATCH v2 2/2] pm: cpupower: Makefile: Allow
> overriding
> >> cross-compiling env params
> >>
> >> Hi Peng,
> >>
> >> On 9/19/2024 5:08 AM, Peng Fan (OSS) wrote:
> >>> From: Peng Fan <peng.fan@nxp.com>
> >>>
> >>> Allow overriding the cross-comple env parameters to make it
> easier
> >> for
> >>> Yocto users. Then cross-compiler toolchains to build cpupower
> with
> >>> only two steps:
> >>> - source (toolchain path)/environment-setup-armv8a-poky-linux
> >>> - make
> >>
> >> This patch breaks the way that buildroot builds cpupower:
> >>
> >>
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2F
> >> git.buildroot.net%2Fbuildroot%2Ftree%2Fpackage%2Flinux-
> >> tools%2Flinux-tool-
> >>
> cpupower.mk.in&data=05%7C02%7Cpeng.fan%40nxp.com%7C246da9
> >>
> 2d8b6243d138c808dd09e6d644%7C686ea1d3bc2b4c6fa92cd99c5c3
> >>
> 01635%7C0%7C0%7C638677609234547728%7CUnknown%7CTWFpb
> >>
> GZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJX
> >>
> aW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdat
> >>
> a=nL1YUl%2F07Vd8F0GpW7uRqdpZT74avOku1ox9N3%2FFkUg%3D&r
> >> eserved=0
> >>
> >> and after enabling verbose it becomes clear as to why, see below:
> >>
> >>   >>> linux-tools  Configuring
> >>   >>> linux-tools  Building
> >> GIT_DIR=.
> >> PATH="/local/users/fainelli/buildroot-
> >> upstream/output/arm/host/bin:/local/users/fainelli/buildroot-
> >>
> upstream/output/arm/host/sbin:/projects/firepath/tools/bin:/home/ff
> >>
> 944844/bin:/home/ff944844/.local/bin:/opt/stblinux/bin:/usr/local/sb
> >> in:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local
> >> /ga mes:/snap/bin:/opt/toolchains/metaware-vctools-0.4.1/bin/"
> >> /usr/bin/make -j97
> >> CROSS=/local/users/fainelli/buildroot-
> >> upstream/output/arm/host/bin/arm-linux-
> >> CPUFREQ_BENCH=false NLS=false LDFLAGS="-L.
> >> -L/local/users/fainelli/buildroot-
> upstream/output/arm/target/usr/lib"
> >> DEBUG=false V=1 -C
> >> /local/users/fainelli/buildroot-upstream/output/arm/build/linux-
> >> custom/tools
> >> cpupower
> >> mkdir -p power/cpupower && /usr/bin/make
> subdir=power/cpupower
> >> --no-print-directory -C power/cpupower cc -DVERSION=\"6.12.0\" -
> >> DPACKAGE=\"cpupower\"
> >> -DPACKAGE_BUGREPORT=\"linux-pm@vger.kernel.org\" -
> D_GNU_SOURCE -pipe
> >> -Wall -Wchar-subscripts -Wpointer-arith -Wsign- compare
> >> -Wno-pointer-sign -Wdeclaration-after-statement -Wshadow - Os
> >> -fomit-frame-pointer -fPIC -o lib/cpufreq.o -c lib/cpufreq.c
> >
> > You are building on an ARM host? Or you are cross compiling with cc
> is
> > actually arm gcc?
> 
> This is cross compiling targeting ARM, which is why CROSS is set to
> ../arm-linux-
> 
> >
> >>
> >> Here we use cc, aka host compiler, rather than $(CROSS)gcc as we
> >> should, so we are no longer cross compiling at all.
> >
> > I not understand. CROSS was set, but using cc to compile for host?
> 
> See below.
> 
> >
> >>
> >> The issue is the use of the lazy set if absent for *all* of CC, LD,
> >> AR, STRIP, RANLIB, rather than just for CROSS. The following fixes it
> for me:
> >>
> >> diff --git a/tools/power/cpupower/Makefile
> >> b/tools/power/cpupower/Makefile index
> >> 175004ce44b2..96bb1e5f3970 100644
> >> --- a/tools/power/cpupower/Makefile
> >> +++ b/tools/power/cpupower/Makefile
> >> @@ -87,11 +87,11 @@ 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-
> >> -CC ?= $(CROSS)gcc
> >> -LD ?= $(CROSS)gcc
> >> -AR ?= $(CROSS)ar
> >> -STRIP ?= $(CROSS)strip
> >> -RANLIB ?= $(CROSS)ranlib
> >> +CC = $(CROSS)gcc
> >> +LD = $(CROSS)gcc
> >> +AR = $(CROSS)ar
> >> +STRIP = $(CROSS)strip
> >> +RANLIB = $(CROSS)ranlib
> >
> > The ? is just allow to override CC/LD/AR.., so in your env, CC is set,
> > but should not be used for cpupower compling?
> 
> Adding debug to show the origin of the CC variable shows the following:
> 
> CROSS=/local/users/fainelli/buildroot-
> upstream/output/arm/host/bin/arm-linux-
> CC origin is (default) and value is (cc) LD origin is (default) and value is
> (ld) CC=cc LD=ld AR=ar STRIP= RANLIB=


How about
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

Thanks,
Peng.

> 
> See
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2F
> www.gnu.org%2Fsoftware%2Fmake%2Fmanual%2Fhtml_node%2FOrig
> in-Function.html%23Origin-
> Function&data=05%7C02%7Cpeng.fan%40nxp.com%7C02c643288e1e
> 456e69e108dd0a4e58d7%7C686ea1d3bc2b4c6fa92cd99c5c301635%
> 7C0%7C0%7C638678053808856433%7CUnknown%7CTWFpbGZsb3d8
> eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiI
> sIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=L4xd4j
> ijUJXibguQnxUTzcAUA%2FGSUGUQzmA5FfVaaAQ%3D&reserved=0
> --
> Florian

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v2 2/2] pm: cpupower: Makefile: Allow overriding cross-compiling env params
  2024-11-22  0:13         ` Peng Fan
@ 2024-11-22 17:34           ` Florian Fainelli
  2024-11-29  0:38             ` Peng Fan
  0 siblings, 1 reply; 16+ messages in thread
From: Florian Fainelli @ 2024-11-22 17:34 UTC (permalink / raw)
  To: Peng Fan, Peng Fan (OSS), Thomas Renninger, Shuah Khan,
	John B. Wyatt IV, John Kacur
  Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org

On 11/21/24 16:13, Peng Fan wrote:
>> Subject: Re: [PATCH v2 2/2] pm: cpupower: Makefile: Allow overriding
>> cross-compiling env params
>>
>> On 11/21/24 04:40, Peng Fan wrote:
>>>> Subject: Re: [PATCH v2 2/2] pm: cpupower: Makefile: Allow
>> overriding
>>>> cross-compiling env params
>>>>
>>>> Hi Peng,
>>>>
>>>> On 9/19/2024 5:08 AM, Peng Fan (OSS) wrote:
>>>>> From: Peng Fan <peng.fan@nxp.com>
>>>>>
>>>>> Allow overriding the cross-comple env parameters to make it
>> easier
>>>> for
>>>>> Yocto users. Then cross-compiler toolchains to build cpupower
>> with
>>>>> only two steps:
>>>>> - source (toolchain path)/environment-setup-armv8a-poky-linux
>>>>> - make
>>>>
>>>> This patch breaks the way that buildroot builds cpupower:
>>>>
>>>>
>> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2F
>>>> git.buildroot.net%2Fbuildroot%2Ftree%2Fpackage%2Flinux-
>>>> tools%2Flinux-tool-
>>>>
>> cpupower.mk.in&data=05%7C02%7Cpeng.fan%40nxp.com%7C246da9
>>>>
>> 2d8b6243d138c808dd09e6d644%7C686ea1d3bc2b4c6fa92cd99c5c3
>>>>
>> 01635%7C0%7C0%7C638677609234547728%7CUnknown%7CTWFpb
>>>>
>> GZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJX
>>>>
>> aW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdat
>>>>
>> a=nL1YUl%2F07Vd8F0GpW7uRqdpZT74avOku1ox9N3%2FFkUg%3D&r
>>>> eserved=0
>>>>
>>>> and after enabling verbose it becomes clear as to why, see below:
>>>>
>>>>    >>> linux-tools  Configuring
>>>>    >>> linux-tools  Building
>>>> GIT_DIR=.
>>>> PATH="/local/users/fainelli/buildroot-
>>>> upstream/output/arm/host/bin:/local/users/fainelli/buildroot-
>>>>
>> upstream/output/arm/host/sbin:/projects/firepath/tools/bin:/home/ff
>>>>
>> 944844/bin:/home/ff944844/.local/bin:/opt/stblinux/bin:/usr/local/sb
>>>> in:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local
>>>> /ga mes:/snap/bin:/opt/toolchains/metaware-vctools-0.4.1/bin/"
>>>> /usr/bin/make -j97
>>>> CROSS=/local/users/fainelli/buildroot-
>>>> upstream/output/arm/host/bin/arm-linux-
>>>> CPUFREQ_BENCH=false NLS=false LDFLAGS="-L.
>>>> -L/local/users/fainelli/buildroot-
>> upstream/output/arm/target/usr/lib"
>>>> DEBUG=false V=1 -C
>>>> /local/users/fainelli/buildroot-upstream/output/arm/build/linux-
>>>> custom/tools
>>>> cpupower
>>>> mkdir -p power/cpupower && /usr/bin/make
>> subdir=power/cpupower
>>>> --no-print-directory -C power/cpupower cc -DVERSION=\"6.12.0\" -
>>>> DPACKAGE=\"cpupower\"
>>>> -DPACKAGE_BUGREPORT=\"linux-pm@vger.kernel.org\" -
>> D_GNU_SOURCE -pipe
>>>> -Wall -Wchar-subscripts -Wpointer-arith -Wsign- compare
>>>> -Wno-pointer-sign -Wdeclaration-after-statement -Wshadow - Os
>>>> -fomit-frame-pointer -fPIC -o lib/cpufreq.o -c lib/cpufreq.c
>>>
>>> You are building on an ARM host? Or you are cross compiling with cc
>> is
>>> actually arm gcc?
>>
>> This is cross compiling targeting ARM, which is why CROSS is set to
>> ../arm-linux-
>>
>>>
>>>>
>>>> Here we use cc, aka host compiler, rather than $(CROSS)gcc as we
>>>> should, so we are no longer cross compiling at all.
>>>
>>> I not understand. CROSS was set, but using cc to compile for host?
>>
>> See below.
>>
>>>
>>>>
>>>> The issue is the use of the lazy set if absent for *all* of CC, LD,
>>>> AR, STRIP, RANLIB, rather than just for CROSS. The following fixes it
>> for me:
>>>>
>>>> diff --git a/tools/power/cpupower/Makefile
>>>> b/tools/power/cpupower/Makefile index
>>>> 175004ce44b2..96bb1e5f3970 100644
>>>> --- a/tools/power/cpupower/Makefile
>>>> +++ b/tools/power/cpupower/Makefile
>>>> @@ -87,11 +87,11 @@ 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-
>>>> -CC ?= $(CROSS)gcc
>>>> -LD ?= $(CROSS)gcc
>>>> -AR ?= $(CROSS)ar
>>>> -STRIP ?= $(CROSS)strip
>>>> -RANLIB ?= $(CROSS)ranlib
>>>> +CC = $(CROSS)gcc
>>>> +LD = $(CROSS)gcc
>>>> +AR = $(CROSS)ar
>>>> +STRIP = $(CROSS)strip
>>>> +RANLIB = $(CROSS)ranlib
>>>
>>> The ? is just allow to override CC/LD/AR.., so in your env, CC is set,
>>> but should not be used for cpupower compling?
>>
>> Adding debug to show the origin of the CC variable shows the following:
>>
>> CROSS=/local/users/fainelli/buildroot-
>> upstream/output/arm/host/bin/arm-linux-
>> CC origin is (default) and value is (cc) LD origin is (default) and value is
>> (ld) CC=cc LD=ld AR=ar STRIP= RANLIB=
> 
> 
> How about
> 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

Yes, this works just as well, do you want to submit this if that works 
in your environment as well?
-- 
Florian

^ permalink raw reply	[flat|nested] 16+ messages in thread

* RE: [PATCH v2 2/2] pm: cpupower: Makefile: Allow overriding cross-compiling env params
  2024-11-22 17:34           ` Florian Fainelli
@ 2024-11-29  0:38             ` Peng Fan
  0 siblings, 0 replies; 16+ messages in thread
From: Peng Fan @ 2024-11-29  0:38 UTC (permalink / raw)
  To: Florian Fainelli, Peng Fan (OSS), Thomas Renninger, Shuah Khan,
	John B. Wyatt IV, John Kacur
  Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org

> Subject: Re: [PATCH v2 2/2] pm: cpupower: Makefile: Allow overriding
> cross-compiling env params
> 
> On 11/21/24 16:13, Peng Fan wrote:
> >> Subject: Re: [PATCH v2 2/2] pm: cpupower: Makefile: Allow
> overriding
> >> cross-compiling env params
> >>
> >> On 11/21/24 04:40, Peng Fan wrote:
> >>>> Subject: Re: [PATCH v2 2/2] pm: cpupower: Makefile: Allow
> >> overriding
> >>>> cross-compiling env params
> >>>>
> >>>> Hi Peng,
> >>>>
> >>>> On 9/19/2024 5:08 AM, Peng Fan (OSS) wrote:
> >>>>> From: Peng Fan <peng.fan@nxp.com>
> >>>>>
> >>>>> Allow overriding the cross-comple env parameters to make it
> >> easier
> >>>> for
> >>>>> Yocto users. Then cross-compiler toolchains to build cpupower
> >> with
> >>>>> only two steps:
> >>>>> - source (toolchain path)/environment-setup-armv8a-poky-linux
> >>>>> - make
> >>>>
> >>>> This patch breaks the way that buildroot builds cpupower:
> >>>>
> >>>>
> >>
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2F
> >>>> git.buildroot.net%2Fbuildroot%2Ftree%2Fpackage%2Flinux-
> >>>> tools%2Flinux-tool-
> >>>>
> >>
> cpupower.mk.in&data=05%7C02%7Cpeng.fan%40nxp.com%7C246da9
> >>>>
> >>
> 2d8b6243d138c808dd09e6d644%7C686ea1d3bc2b4c6fa92cd99c5c3
> >>>>
> >>
> 01635%7C0%7C0%7C638677609234547728%7CUnknown%7CTWFpb
> >>>>
> >>
> GZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJX
> >>>>
> >>
> aW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdat
> >>>>
> >>
> a=nL1YUl%2F07Vd8F0GpW7uRqdpZT74avOku1ox9N3%2FFkUg%3D&r
> >>>> eserved=0
> >>>>
> >>>> and after enabling verbose it becomes clear as to why, see below:
> >>>>
> >>>>    >>> linux-tools  Configuring
> >>>>    >>> linux-tools  Building
> >>>> GIT_DIR=.
> >>>> PATH="/local/users/fainelli/buildroot-
> >>>> upstream/output/arm/host/bin:/local/users/fainelli/buildroot-
> >>>>
> >>
> upstream/output/arm/host/sbin:/projects/firepath/tools/bin:/home/ff
> >>>>
> >>
> 944844/bin:/home/ff944844/.local/bin:/opt/stblinux/bin:/usr/local/sb
> >>>> in:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/loc
> >>>> al /ga mes:/snap/bin:/opt/toolchains/metaware-vctools-
> 0.4.1/bin/"
> >>>> /usr/bin/make -j97
> >>>> CROSS=/local/users/fainelli/buildroot-
> >>>> upstream/output/arm/host/bin/arm-linux-
> >>>> CPUFREQ_BENCH=false NLS=false LDFLAGS="-L.
> >>>> -L/local/users/fainelli/buildroot-
> >> upstream/output/arm/target/usr/lib"
> >>>> DEBUG=false V=1 -C
> >>>> /local/users/fainelli/buildroot-upstream/output/arm/build/linux-
> >>>> custom/tools
> >>>> cpupower
> >>>> mkdir -p power/cpupower && /usr/bin/make
> >> subdir=power/cpupower
> >>>> --no-print-directory -C power/cpupower cc -DVERSION=\"6.12.0\"
> -
> >>>> DPACKAGE=\"cpupower\"
> >>>> -DPACKAGE_BUGREPORT=\"linux-pm@vger.kernel.org\" -
> >> D_GNU_SOURCE -pipe
> >>>> -Wall -Wchar-subscripts -Wpointer-arith -Wsign- compare
> >>>> -Wno-pointer-sign -Wdeclaration-after-statement -Wshadow - Os
> >>>> -fomit-frame-pointer -fPIC -o lib/cpufreq.o -c lib/cpufreq.c
> >>>
> >>> You are building on an ARM host? Or you are cross compiling with
> cc
> >> is
> >>> actually arm gcc?
> >>
> >> This is cross compiling targeting ARM, which is why CROSS is set to
> >> ../arm-linux-
> >>
> >>>
> >>>>
> >>>> Here we use cc, aka host compiler, rather than $(CROSS)gcc as we
> >>>> should, so we are no longer cross compiling at all.
> >>>
> >>> I not understand. CROSS was set, but using cc to compile for host?
> >>
> >> See below.
> >>
> >>>
> >>>>
> >>>> The issue is the use of the lazy set if absent for *all* of CC, LD,
> >>>> AR, STRIP, RANLIB, rather than just for CROSS. The following fixes
> >>>> it
> >> for me:
> >>>>
> >>>> diff --git a/tools/power/cpupower/Makefile
> >>>> b/tools/power/cpupower/Makefile index
> >>>> 175004ce44b2..96bb1e5f3970 100644
> >>>> --- a/tools/power/cpupower/Makefile
> >>>> +++ b/tools/power/cpupower/Makefile
> >>>> @@ -87,11 +87,11 @@ 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-
> >>>> -CC ?= $(CROSS)gcc
> >>>> -LD ?= $(CROSS)gcc
> >>>> -AR ?= $(CROSS)ar
> >>>> -STRIP ?= $(CROSS)strip
> >>>> -RANLIB ?= $(CROSS)ranlib
> >>>> +CC = $(CROSS)gcc
> >>>> +LD = $(CROSS)gcc
> >>>> +AR = $(CROSS)ar
> >>>> +STRIP = $(CROSS)strip
> >>>> +RANLIB = $(CROSS)ranlib
> >>>
> >>> The ? is just allow to override CC/LD/AR.., so in your env, CC is
> >>> set, but should not be used for cpupower compling?
> >>
> >> Adding debug to show the origin of the CC variable shows the
> following:
> >>
> >> CROSS=/local/users/fainelli/buildroot-
> >> upstream/output/arm/host/bin/arm-linux-
> >> CC origin is (default) and value is (cc) LD origin is (default) and
> >> value is
> >> (ld) CC=cc LD=ld AR=ar STRIP= RANLIB=
> >
> >
> > How about
> > 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
> 
> Yes, this works just as well, do you want to submit this if that works in
> your environment as well?

I will prepare a patch.

Thanks,
Peng.

> --
> Florian

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2024-11-29  0:38 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-19 12:08 [PATCH v2 0/2] tools: power: cpupower: Allow overriding cross-compiling envs Peng Fan (OSS)
2024-09-19 12:08 ` [PATCH v2 1/2] pm: cpupower: bench: print config file path when open cpufreq-bench.conf fails Peng Fan (OSS)
2024-09-19 12:08 ` [PATCH v2 2/2] pm: cpupower: Makefile: Allow overriding cross-compiling env params Peng Fan (OSS)
2024-11-21  4:41   ` Florian Fainelli
2024-11-21 12:40     ` Peng Fan
2024-11-21 17:02       ` Florian Fainelli
2024-11-22  0:13         ` Peng Fan
2024-11-22 17:34           ` Florian Fainelli
2024-11-29  0:38             ` Peng Fan
2024-09-19 16:38 ` [PATCH v2 0/2] tools: power: cpupower: Allow overriding cross-compiling envs John B. Wyatt IV
2024-09-20  8:58   ` Peng Fan
2024-09-20  9:01     ` Peng Fan
2024-09-20 12:41       ` John B. Wyatt IV
2024-09-20 12:44       ` John B. Wyatt IV
2024-09-23  6:26         ` Peng Fan
2024-09-30 15:52           ` Shuah Khan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).