On 2016-09-01 22:46, Peng Fan wrote:
> Hi Jan,
> On Thu, Sep 01, 2016 at 06:25:22PM -0400, Jan Kiszka wrote:
>> On 2016-08-31 21:29, Peng Fan wrote:
>>> To some toolchains, need to pass sysroot to gcc.
>>> If directly assign $(CROSS_COMPILE)gcc to CC, there is
>>> no chance to pass sysroot to gcc.
>>>
>>> So, checking whether CC is set in user bash environment,
>>> if not set, choose $(CROSS_COMPILE)gcc.
>>>
>>> In my case, I have this in my bash script:
>>> export CC="aarch64-poky-linux-gcc  --sysroot=$SDKTARGETSYSROOT"
>>>
>>> Signed-off-by: Peng Fan <[email protected]>
>>> ---
>>>  tools/Makefile | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/tools/Makefile b/tools/Makefile
>>> index 6975a76..d60c625 100644
>>> --- a/tools/Makefile
>>> +++ b/tools/Makefile
>>> @@ -10,7 +10,7 @@
>>>  # the COPYING file in the top-level directory.
>>>  #
>>>  
>>> -CC = $(CROSS_COMPILE)gcc
>>> +CC ?= $(CROSS_COMPILE)gcc
>>>  
>>>  CFLAGS = -g -O3 -I../driver -DLIBEXECDIR=\"$(libexecdir)\" \
>>>     -Wall -Wextra -Wmissing-declarations -Wmissing-prototypes -Werror \
>>>
>>
>> Somehow not working as expected: something decides here that CC should
>> be "cc" and, thus, CROSS_COMPILE is now no longer prepended.
> 
> Not every toolchain needs pass sysroot to it. I do not need to pass sysroot
> to my arm-linux-gnueabihf-gcc toolchain. But for aarch64 toolchain, I need
> to pass sysroot to it.
> 
> You mean directly use "cc", but not using $(CC)?
> 
>>
>> We've taken this pattern actually from many Makefiles in linux/tools. Do
>> you face the same issue with cross-building them?
> 
> I did not cross compile Linux kernel tools. But I met same issue when cross
> compiling xen hypervisor, same with compiling jailhouse tools.
> 

Looking at your case from a different angle again: Why not using
EXTRA_CFLAGS to pass in the sysroot? That should work without any patching.

Jan

-- 
Siemens AG, Corporate Technology, CT RDA ITP SES-DE
Corporate Competence Center Embedded Linux

-- 
You received this message because you are subscribed to the Google Groups 
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to