public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sam Ravnborg <sam@ravnborg.org>
To: Rob Landley <rob@landley.net>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>,
	Finn Thain <fthain@telegraphics.com.au>,
	LKML <linux-kernel@vger.kernel.org>,
	Linux/m68k <linux-m68k@vger.kernel.org>
Subject: Re: [PATCH] Make m68k cross compile like every other architecture.
Date: Fri, 19 Oct 2007 17:10:53 +0200	[thread overview]
Message-ID: <20071019151053.GA30825@uranus.ravnborg.org> (raw)
In-Reply-To: <200710190138.39005.rob@landley.net>

On Fri, Oct 19, 2007 at 01:38:38AM -0500, Rob Landley wrote:
> 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?
find-crossgcc

> >
> > 	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...
I see no other way to do it - and it seems obvious since you guessed right.

> 
> > +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".
No - that would be a bug. One may set up PATH sp gcc point to the
cross-compile gcc. fallback to native (host) gcc is expected and fine.

> 
> I suppose there's the weird corner case where your hostcc is tcc and your 
> targetcc is gcc...
I do not see why thats a problem - you just need to set both CC and HOSTCC.

	Sam

  reply	other threads:[~2007-10-19 15:09 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-10 22:22 [PATCH] Make m68k cross compile like every other architecture Rob Landley
2007-10-11  7:25 ` Geert Uytterhoeven
2007-10-11 11:31   ` Rob Landley
2007-10-11 11:39   ` Sam Ravnborg
2007-10-11 12:46     ` Geert Uytterhoeven
2007-10-11 13:27       ` Rob Landley
2007-10-11 13:52         ` Paul Mundt
2007-10-11 15:12         ` Geert Uytterhoeven
2007-10-11 16:26           ` Finn Thain
2007-10-11 21:14             ` Rob Landley
2007-10-12  6:51               ` Geert Uytterhoeven
2007-10-12  7:54                 ` Finn Thain
2007-10-12  8:51                   ` Geert Uytterhoeven
2007-10-12 10:21                     ` Sam Ravnborg
2007-10-15 20:25                       ` Geert Uytterhoeven
2007-10-16  0:31                         ` Rob Landley
2007-10-16  4:15                           ` Sam Ravnborg
2007-10-18 21:14                         ` Sam Ravnborg
2007-10-19  6:38                           ` Rob Landley
2007-10-19 15:10                             ` Sam Ravnborg [this message]
2007-10-11 16:24       ` Sam Ravnborg

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=20071019151053.GA30825@uranus.ravnborg.org \
    --to=sam@ravnborg.org \
    --cc=fthain@telegraphics.com.au \
    --cc=geert@linux-m68k.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-m68k@vger.kernel.org \
    --cc=rob@landley.net \
    /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