Using LLVM as a crosscompiler

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

Using LLVM as a crosscompiler

Koen Kooi-3
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

After hearing Chris' talk at bossaconference I wanted to see if I could use LLVM (and/or
llvm-gcc) as a crosscompiler for ARM. The documentation beautifully outlines how to build
it for your host and how to crosscompile it, but not how to build it as a cross-compiler.

So my question is: How should I build llvm and llvm-gcc4 to have it cross-compile from x86
to ARM/EABI?

regards,

Koen
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Darwin)

iD8DBQFGEAdjMkyGM64RGpERAgsOAKCKHyT0N8NVsyk0e+yMUCrqSD9CywCeKG7P
UT6nehh6gaxySsa3ujr2qcc=
=NwUP
-----END PGP SIGNATURE-----
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Using LLVM as a crosscompiler

Anton Korobeynikov
Hello, Koen.

> So my question is: How should I build llvm and llvm-gcc4 to have it cross-compile from x86
> to ARM/EABI?
Well, just supply appropriate --host/--target options to configure.
I haven't tried ARM, but this definitely works for crosscompiling from
linux to mingw32. Please also note, that you'll need native (=arm) tools
(binutils, libcheaders, etc) during gcc build process.
--
With best regards, Anton Korobeynikov.

Faculty of Mathematics & Mechanics, Saint Petersburg State University.


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Using LLVM as a crosscompiler

Reid Spencer-2
In reply to this post by Koen Kooi-3
On Sun, 2007-04-01 at 21:26 +0200, Koen Kooi wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi,
>
> After hearing Chris' talk at bossaconference I wanted to see if I could use LLVM (and/or
> llvm-gcc) as a crosscompiler for ARM. The documentation beautifully outlines how to build
> it for your host and how to crosscompile it, but not how to build it as a cross-compiler.
>
> So my question is: How should I build llvm and llvm-gcc4 to have it cross-compile from x86
> to ARM/EABI?

For the LLVM build, just build it on an x86 host and make sure the ARM
target is enabled. You can do that with the --enable-targets=ARM option
to configure. The default is to build all targets which will work fine
too.

For the llvm-gcc build, you just build it like you would any GCC
cross-compiler. That is, you use the --target option on the configure
line for llvm-gcc. The value of the --target option should be the target
triple that you want to cross compile too. I don't know the details but
it should be something like --target=arm-iphone-darwin.

This --target option in llvm-gcc will cause llvm-gcc to emit a
"target=arm-iphone-darwin" directive in the output to LLVM. This will
cause LLVM to select the ARM backend and any subtargets for
"iphone-darwin".

Please note, the "iphone-darwin" part is fictional. I don't know the
correct full target triple for your target but it at least starts with
"arm".

Reid.

>
> regards,
>
> Koen
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.5 (Darwin)
>
> iD8DBQFGEAdjMkyGM64RGpERAgsOAKCKHyT0N8NVsyk0e+yMUCrqSD9CywCeKG7P
> UT6nehh6gaxySsa3ujr2qcc=
> =NwUP
> -----END PGP SIGNATURE-----
> _______________________________________________
> LLVM Developers mailing list
> [hidden email]         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Using LLVM as a crosscompiler

Koen Kooi-3
In reply to this post by Anton Korobeynikov
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Anton Korobeynikov schreef:
> Hello, Koen.
>
>> So my question is: How should I build llvm and llvm-gcc4 to have it cross-compile from x86
>> to ARM/EABI?
> Well, just supply appropriate --host/--target options to configure.

To llvm or llvm-gcc4?

> I haven't tried ARM, but this definitely works for crosscompiling from
> linux to mingw32. Please also note, that you'll need native (=arm) tools
> (binutils, libcheaders, etc)

You mean binutils-cross, right?

> during gcc build process.

Building gcc as a crosscompiler is fully automized in OpenEmbedded, I'm trying to add
llvm-gcc4 into that framework.

regards,

Koen

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Darwin)

iD8DBQFGEBMwMkyGM64RGpERAnL+AKC4gtxNAPJetf0kOPJC2NAqF31tDwCfWmAu
WiNlCu36rf5JQ+AwGs7VSMs=
=LLY2
-----END PGP SIGNATURE-----
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Using LLVM as a crosscompiler

Koen Kooi-3
In reply to this post by Reid Spencer-2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Reid Spencer schreef:

> On Sun, 2007-04-01 at 21:26 +0200, Koen Kooi wrote:
> Hi,
>
> After hearing Chris' talk at bossaconference I wanted to see if I could use LLVM (and/or
> llvm-gcc) as a crosscompiler for ARM. The documentation beautifully outlines how to build
> it for your host and how to crosscompile it, but not how to build it as a cross-compiler.
>
> So my question is: How should I build llvm and llvm-gcc4 to have it cross-compile from x86
> to ARM/EABI?
>
>> For the LLVM build, just build it on an x86 host and make sure the ARM
>> target is enabled. You can do that with the --enable-targets=ARM option
>> to configure. The default is to build all targets which will work fine
>> too.

OK, that's easy I already have that working :)


>> For the llvm-gcc build, you just build it like you would any GCC
>> cross-compiler. That is, you use the --target option on the configure
>> line for llvm-gcc. The value of the --target option should be the target
>> triple that you want to cross compile too. I don't know the details but
>> it should be something like --target=arm-iphone-darwin.

Is llvm-gcc4 a modified gcc? I have a big pile of patches to unbreak various part of gcc
4.1.x for ARM. E.g.
http://www.openembedded.org/repo/org.openembedded.dev/packages/gcc/gcc-4.1.2/unbreak-armv4t.patch
to make gcc stop emitting armv5te instructions for armv4t cpus. Will llvm-gcc4 require the
same patches.

>> This --target option in llvm-gcc will cause llvm-gcc to emit a
>> "target=arm-iphone-darwin" directive in the output to LLVM. This will
>> cause LLVM to select the ARM backend and any subtargets for
>> "iphone-darwin".
>
>> Please note, the "iphone-darwin" part is fictional. I don't know the
>> correct full target triple for your target but it at least starts with
>> "arm".

'xscale' would also be an option, but lets not get into un(der)documented features in gcc ;)

It would probably be 'arm-<target vendor>-linuxgnueabi' for the things I'm interested in
(The neo1973 phone for example).

After having dealt with gcc as crosscompiler for the past years I get the "It can't be
this easy to setup" feeling, but I'll find out tomorrow.

Thanks for your speedy replies!

regards,

Koen
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Darwin)

iD8DBQFGEBTlMkyGM64RGpERAsMhAJ0SjJnRJKS8XBaij1h0p0uiur5kzACfbnFm
riI+LdmQD6o6N5JKUU7+yBA=
=Y/fp
-----END PGP SIGNATURE-----
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Using LLVM as a crosscompiler

Lauro Ramos Venancio
In reply to this post by Koen Kooi-3
Hi Koen,

The process to build llvm-gcc as a crosscompiler is basically the same
as build a normal gcc as crosscompiler. The differences: you need a
LLVM installed (compiled for the host). You must configure llvm-gcc
with --enable-llvm.

Problems:
- Today LLVM supports ARM/EABI, but llvm-gcc don't. You must apply the patch:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070319/046070.html
(Please someone commit this patch!)
- If your host system libraries are newer then gcc 4.0, you must
configure llvm-gcc with "--disable-shared" (this is a workaround for a
bug)


It would be great to have llvm-gcc inside OpenEmbedded. The Mamona
project could be the first Linux distribution totally compiled by
llvm-gcc!

Lauro

2007/4/1, Koen Kooi <[hidden email]>:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Anton Korobeynikov schreef:
> > Hello, Koen.
> >
> >> So my question is: How should I build llvm and llvm-gcc4 to have it cross-compile from x86
> >> to ARM/EABI?
> > Well, just supply appropriate --host/--target options to configure.
>
> To llvm or llvm-gcc4?
>
> > I haven't tried ARM, but this definitely works for crosscompiling from
> > linux to mingw32. Please also note, that you'll need native (=arm) tools
> > (binutils, libcheaders, etc)
>
> You mean binutils-cross, right?
>
> > during gcc build process.
>
> Building gcc as a crosscompiler is fully automized in OpenEmbedded, I'm trying to add
> llvm-gcc4 into that framework.
>
> regards,
>
> Koen
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.5 (Darwin)
>
> iD8DBQFGEBMwMkyGM64RGpERAnL+AKC4gtxNAPJetf0kOPJC2NAqF31tDwCfWmAu
> WiNlCu36rf5JQ+AwGs7VSMs=
> =LLY2
> -----END PGP SIGNATURE-----
> _______________________________________________
> LLVM Developers mailing list
> [hidden email]         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Using LLVM as a crosscompiler

Koen Kooi-3
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Lauro Ramos Venancio schreef:

> It would be great to have llvm-gcc inside OpenEmbedded. The Mamona
> project could be the first Linux distribution totally compiled by
> llvm-gcc!

llvm-native 1.9 is in OE[1], I'm now working on getting the cvs version added and when
that works llvm-gcc4 + EABI patch. I'll have to finish a project at the university first,
but a llvm-gcc4 recipe should be ready for testing somewhere between easter and ELC2007.

Any recommended testsuites I could run?

regards,

Koen

[1] http://www.openembedded.org/filebrowser/org.openembedded.dev/packages/llvm
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Darwin)

iD8DBQFGEVctMkyGM64RGpERApgVAKC7QElBNdoRnRr6kWIMCObKab+cowCfcdYI
siQoxf2YONM1zd42dzKkivE=
=kUb+
-----END PGP SIGNATURE-----
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Using LLVM as a crosscompiler

Koen Kooi-3
In reply to this post by Lauro Ramos Venancio
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Lauro Ramos Venancio schreef:

> Hi Koen,
>
> The process to build llvm-gcc as a crosscompiler is basically the same
> as build a normal gcc as crosscompiler. The differences: you need a
> LLVM installed (compiled for the host). You must configure llvm-gcc
> with --enable-llvm.
>
> Problems:
> - Today LLVM supports ARM/EABI, but llvm-gcc don't. You must apply the
> patch:
> http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070319/046070.html

That doesn't apply anymore :(

regards,

Koen
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Darwin)

iD8DBQFGEWPTMkyGM64RGpERAgzUAJoDlCPbR9t0U9S7BaC+db9SdByiZQCfRW7n
MyGmdIjq5lot9V1czd1eZcs=
=rT0C
-----END PGP SIGNATURE-----
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Using LLVM as a crosscompiler

Lauro Ramos Venancio
> > - Today LLVM supports ARM/EABI, but llvm-gcc don't. You must apply the
> > patch:
> > http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070319/046070.html
>
> That doesn't apply anymore :(

You must use the llvm-gcc4 from the svn. It has some bug fixes that
are important to ARM EABI and the patch should apply cleanly.

Lauro
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Using LLVM as a crosscompiler

Dale Johannesen
On Apr 2, 2007, at 2:26 PM, Lauro Ramos Venancio wrote:

>>> - Today LLVM supports ARM/EABI, but llvm-gcc don't. You must  
>>> apply the
>>> patch:
>>> http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of- 
>>> Mon-20070319/046070.html
>>
>> That doesn't apply anymore :(
>
> You must use the llvm-gcc4 from the svn. It has some bug fixes that
> are important to ARM EABI and the patch should apply cleanly.
>
> Lauro

This patch doesn't break anything on powerpc-apple-darwin8, so I've  
checked it in
(note that configuration doesn't use the libstdc++ bits, though).    
Lauro, please keep
an eye open for regressions.

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Using LLVM as a crosscompiler

Koen Kooi-3
In reply to this post by Lauro Ramos Venancio
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Lauro Ramos Venancio schreef:
> Hi Koen,
>
> The process to build llvm-gcc as a crosscompiler is basically the same
> as build a normal gcc as crosscompiler. The differences: you need a
> LLVM installed (compiled for the host). You must configure llvm-gcc
> with --enable-llvm.

grep llvm configure* doesn't return anything in trunk/, did I checkout[1] the wrong svn?

regards,

Koen

[1] svn://anonsvn.opensource.apple.com/svn/llvm/trunk
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Darwin)

iD8DBQFGE2eoMkyGM64RGpERAh4pAJ9VYr2XbnsGQuFJXsVXF0/TKUAlwACeMbCt
WFL6OSSM1JTV0wYauDPheAI=
=/KyZ
-----END PGP SIGNATURE-----
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Using LLVM as a crosscompiler

Anton Korobeynikov
In reply to this post by Lauro Ramos Venancio
Hello

> grep llvm configure* doesn't return anything in trunk/, did I
> checkout[1] the wrong svn?
No. It's ok :) It's just complicated nature of gcc's build system. In
fact, try "grep llvm gcc/configure" :)

--
With best regards, Anton Korobeynikov.

Faculty of Mathematics & Mechanics, Saint Petersburg State University.


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev