Re: [PATCH] Make m68k cross compile like every other architecture.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thursday 18 October 2007 4:14:20 pm Sam Ravnborg wrote:
> > Anyway, here's a try to make it autodetect m68k-linux-gnu-gcc and
> > m68k-linux-gcc. Perhaps it can be generalized in kbuild, to allow
> > arch/*/Makefile to set a list of possible cross-compiler prefixes?
>
> Here is my first try.
> We only touch CROSS_COMPILE is empty and building for another arch.
>
> I can obviously move crossgcc part of this to core kbuild.
> Any better name?
>
> 	Sam
>
>
> diff --git a/arch/m68k/Makefile b/arch/m68k/Makefile
> index 4a1bd44..6465bbe 100644
> --- a/arch/m68k/Makefile
> +++ b/arch/m68k/Makefile
> @@ -13,17 +13,26 @@
>  # Copyright (C) 1994 by Hamish Macdonald
>  #
>
> -# test for cross compiling
> -COMPILE_ARCH = $(shell uname -m)
> +# usage:
> +# CROSS_COMPILE := $(call crossgcc, foo bar /usr/bin/)
> +# CROSS_COMPILE will be assinged the first prefix that point
> +# to a gcc in the path
> +crossgcc =  $(word 1, $(foreach c,$(1),                               \
> +		$(shell set -e;                                       \
> +		if (which $(strip $(c))$(CC)) > /dev/null 2>&1 ; then \
> +			echo $(c);                                    \
> +		fi)))

Searching for common cross compiler prefixes.  Cool.

What do you do if you want to use gcc as your host compiler, but m68k-pcc or 
arm-tcc as your target compiler?  (I have no idea, CROSS_COMPILE=m68k- CC=pcc 
HOSTCC=gcc perhaps?  Where does CC get set right now, anyway...  Ah, top 
level Makefile:
  CC              = $(CROSS_COMPILE)gcc

That...  should work.  Odd and roundabout, but ok...

> +ifneq ($(SUBARCH),$(ARCH))
> +        ifeq ($(CROSS_COMPILE),)
> +                CROSS_COMPILE := $(call crossgcc, m68k-linux-gnu-)
> +        endif
> +endif

Other query:

If CROSS_COMPILE isn't set, and we iterate through all the standard prefixes 
but don't find a compiler, what's the right "fall off the end" behavior?  If 
it falls back to using the host gcc, presumably the build will break if you 
feed your host gcc target flags it doesn't understand, but there are 
platforms where that sometimes doesn't seem to happen until the very end 
(building x86_64 on x86 for example)...  Should the build just die with 
a "You are cross compiling, set CROSS_COMPILE".

I suppose there's the weird corner case where your hostcc is tcc and your 
targetcc is gcc...

Rob
-- 
"One of my most productive days was throwing away 1000 lines of code."
  - Ken Thompson.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux