mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Florian Fainelli <florian.fainelli@broadcom.com>
To: Peng Fan <peng.fan@nxp.com>,
	"Peng Fan (OSS)" <peng.fan@oss.nxp.com>,
	Thomas Renninger <trenn@suse.com>, Shuah Khan <shuah@kernel.org>,
	"John B. Wyatt IV" <jwyatt@redhat.com>,
	John Kacur <jkacur@redhat.com>
Cc: "linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 2/2] pm: cpupower: Makefile: Allow overriding cross-compiling env params
Date: Thu, 21 Nov 2024 09:02:49 -0800	[thread overview]
Message-ID: <16411b6f-3e1d-4d52-a047-8c322774ec8c@broadcom.com> (raw)
In-Reply-To: <DB9PR04MB846134093D2302B6D67E7E6288222@DB9PR04MB8461.eurprd04.prod.outlook.com>

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

  reply	other threads:[~2024-11-21 17:02 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=16411b6f-3e1d-4d52-a047-8c322774ec8c@broadcom.com \
    --to=florian.fainelli@broadcom.com \
    --cc=jkacur@redhat.com \
    --cc=jwyatt@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=peng.fan@nxp.com \
    --cc=peng.fan@oss.nxp.com \
    --cc=shuah@kernel.org \
    --cc=trenn@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®