All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] Cross-compiling QEMU for ARM
@ 2013-03-10 14:36 Leonid Bloch
  2013-03-10 14:59 ` Peter Maydell
  2013-03-10 15:04 ` Peter Maydell
  0 siblings, 2 replies; 11+ messages in thread
From: Leonid Bloch @ 2013-03-10 14:36 UTC (permalink / raw)
  To: qemu-devel

Hello,

I want to cross compile QEMU itself to run on ARM, but all my searches
lead me to tutorials for cross compiling other programs for ARM and
testing them with QEMU, which is not what I need.
The only relevant link I found was this:
http://lists.gnu.org/archive/html/qemu-devel/2011-05/msg00099.html
But this doesn't work for me as well.

I am using Buildroot as my toolchain, and the farthest I got was:
$ ./configure --cpu=armv7hl --static --cc=arm-linux-cc
$ make
...And then I get a lot of errors about libintl and libiconv.

Also tried Crosstool-NG and Sourcery CodeBench with even less success.

Have anyone here cross compiled QEMU for ARM or can point me to a tutorial?

Thanks,
Leonid.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] Cross-compiling QEMU for ARM
  2013-03-10 14:36 [Qemu-devel] Cross-compiling QEMU for ARM Leonid Bloch
@ 2013-03-10 14:59 ` Peter Maydell
  2013-03-10 15:35   ` Blue Swirl
                     ` (2 more replies)
  2013-03-10 15:04 ` Peter Maydell
  1 sibling, 3 replies; 11+ messages in thread
From: Peter Maydell @ 2013-03-10 14:59 UTC (permalink / raw)
  To: Leonid Bloch; +Cc: qemu-devel

On 10 March 2013 14:36, Leonid Bloch <lb@tx.technion.ac.il> wrote:
> I want to cross compile QEMU itself to run on ARM, but all my searches
> lead me to tutorials for cross compiling other programs for ARM and
> testing them with QEMU, which is not what I need.
> The only relevant link I found was this:
> http://lists.gnu.org/archive/html/qemu-devel/2011-05/msg00099.html
> But this doesn't work for me as well.
>
> I am using Buildroot as my toolchain, and the farthest I got was:
> $ ./configure --cpu=armv7hl --static --cc=arm-linux-cc

Don't specify --cpu : this is almost always going to break things,
and you should just let configure work it out based on your compiler.
Don't just specify --cc, because we want to run other cross tools
too. Instead, use --cross-prefix=arm-linux-gnueabi- (or whatever
the correct prefix is for your toolchain).
You'll also need to have a cross-build environment with the minimal
set of libraries/includes that QEMU needs to build, including
but not limited to zlib and glib. How to set this up depends on
what your cross compilation setup is; in this case you'll need to
ask the buildroot folks.

Question for the qemu-devel folks: does anybody have a situation
where they genuinely need to pass --cpu to configure (ie the
autodetection is wrong or insufficient)? [configure does mention
one case, which is when cross-compiling to x86 Darwin and SunOS,
but the latter at least is busted anyway because later on we
do things based on SunOS uname results which there is no way
to override for the cross-compile case.] I'm tempted to suggest
we should drop --cpu entirely...

-- PMM

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] Cross-compiling QEMU for ARM
  2013-03-10 14:36 [Qemu-devel] Cross-compiling QEMU for ARM Leonid Bloch
  2013-03-10 14:59 ` Peter Maydell
@ 2013-03-10 15:04 ` Peter Maydell
  2013-03-11  1:59   ` Peter Crosthwaite
  1 sibling, 1 reply; 11+ messages in thread
From: Peter Maydell @ 2013-03-10 15:04 UTC (permalink / raw)
  To: Leonid Bloch; +Cc: qemu-devel

On 10 March 2013 14:36, Leonid Bloch <lb@tx.technion.ac.il> wrote:
> I am using Buildroot as my toolchain, and the farthest I got was:
> $ ./configure --cpu=armv7hl --static --cc=arm-linux-cc
> $ make
> ...And then I get a lot of errors about libintl and libiconv.

Oh, and I forgot -- don't try to build system emulators with --static:
it's only really meant for the linux-user targets. Do specify
--target-list=[whichever emulators you actually wanted], especially
when you're trying to get your build environment sorted out: this
will massively reduce the build time so you can find out whether
you still have issues to deal with more quickly. [--enable-debug
is also good for speeding up the build but you'll want to drop
that for actual use.]

-- PMM

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] Cross-compiling QEMU for ARM
  2013-03-10 14:59 ` Peter Maydell
@ 2013-03-10 15:35   ` Blue Swirl
  2013-03-10 16:28   ` Leonid Bloch
  2013-03-11  1:56   ` Peter Crosthwaite
  2 siblings, 0 replies; 11+ messages in thread
From: Blue Swirl @ 2013-03-10 15:35 UTC (permalink / raw)
  To: Peter Maydell; +Cc: Leonid Bloch, qemu-devel

On Sun, Mar 10, 2013 at 2:59 PM, Peter Maydell <peter.maydell@linaro.org> wrote:
> On 10 March 2013 14:36, Leonid Bloch <lb@tx.technion.ac.il> wrote:
>> I want to cross compile QEMU itself to run on ARM, but all my searches
>> lead me to tutorials for cross compiling other programs for ARM and
>> testing them with QEMU, which is not what I need.
>> The only relevant link I found was this:
>> http://lists.gnu.org/archive/html/qemu-devel/2011-05/msg00099.html
>> But this doesn't work for me as well.
>>
>> I am using Buildroot as my toolchain, and the farthest I got was:
>> $ ./configure --cpu=armv7hl --static --cc=arm-linux-cc
>
> Don't specify --cpu : this is almost always going to break things,
> and you should just let configure work it out based on your compiler.
> Don't just specify --cc, because we want to run other cross tools
> too. Instead, use --cross-prefix=arm-linux-gnueabi- (or whatever
> the correct prefix is for your toolchain).
> You'll also need to have a cross-build environment with the minimal
> set of libraries/includes that QEMU needs to build, including
> but not limited to zlib and glib. How to set this up depends on
> what your cross compilation setup is; in this case you'll need to
> ask the buildroot folks.
>
> Question for the qemu-devel folks: does anybody have a situation
> where they genuinely need to pass --cpu to configure (ie the
> autodetection is wrong or insufficient)? [configure does mention
> one case, which is when cross-compiling to x86 Darwin and SunOS,
> but the latter at least is busted anyway because later on we
> do things based on SunOS uname results which there is no way
> to override for the cross-compile case.] I'm tempted to suggest
> we should drop --cpu entirely...

Checking config files, I'm using --cpu to build for Sparc32 and
Sparc64 on Sparc/Linux where the compiler can build either version
with -m32/-m64, also to build in i386 chroot in x86_64 host but it
looks like here --cpu is redundant.

>
> -- PMM
>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] Cross-compiling QEMU for ARM
  2013-03-10 14:59 ` Peter Maydell
  2013-03-10 15:35   ` Blue Swirl
@ 2013-03-10 16:28   ` Leonid Bloch
  2013-03-10 17:11     ` Peter Maydell
  2013-03-11  8:54     ` KONRAD Frédéric
  2013-03-11  1:56   ` Peter Crosthwaite
  2 siblings, 2 replies; 11+ messages in thread
From: Leonid Bloch @ 2013-03-10 16:28 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-devel

On Sun, Mar 10, 2013 at 4:59 PM, Peter Maydell <peter.maydell@linaro.org> wrote:
> On 10 March 2013 14:36, Leonid Bloch <lb@tx.technion.ac.il> wrote:
>> I want to cross compile QEMU itself to run on ARM, but all my searches
>> lead me to tutorials for cross compiling other programs for ARM and
>> testing them with QEMU, which is not what I need.
>> The only relevant link I found was this:
>> http://lists.gnu.org/archive/html/qemu-devel/2011-05/msg00099.html
>> But this doesn't work for me as well.
>>
>> I am using Buildroot as my toolchain, and the farthest I got was:
>> $ ./configure --cpu=armv7hl --static --cc=arm-linux-cc
>
> Don't specify --cpu : this is almost always going to break things,
> and you should just let configure work it out based on your compiler.
> Don't just specify --cc, because we want to run other cross tools
> too. Instead, use --cross-prefix=arm-linux-gnueabi- (or whatever
> the correct prefix is for your toolchain).

Tried that at first, but then getting an error:
Error: pkg-config binary 'arm-linux-pkg-config' not found

> You'll also need to have a cross-build environment with the minimal
> set of libraries/includes that QEMU needs to build, including
> but not limited to zlib and glib. How to set this up depends on
> what your cross compilation setup is; in this case you'll need to
> ask the buildroot folks.
>
> Question for the qemu-devel folks: does anybody have a situation
> where they genuinely need to pass --cpu to configure (ie the
> autodetection is wrong or insufficient)? [configure does mention
> one case, which is when cross-compiling to x86 Darwin and SunOS,
> but the latter at least is busted anyway because later on we
> do things based on SunOS uname results which there is no way
> to override for the cross-compile case.] I'm tempted to suggest
> we should drop --cpu entirely...
>
> -- PMM

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] Cross-compiling QEMU for ARM
  2013-03-10 16:28   ` Leonid Bloch
@ 2013-03-10 17:11     ` Peter Maydell
  2013-03-11  8:54     ` KONRAD Frédéric
  1 sibling, 0 replies; 11+ messages in thread
From: Peter Maydell @ 2013-03-10 17:11 UTC (permalink / raw)
  To: Leonid Bloch; +Cc: qemu-devel

On 10 March 2013 16:28, Leonid Bloch <lb@tx.technion.ac.il> wrote:
> Tried that at first, but then getting an error:
> Error: pkg-config binary 'arm-linux-pkg-config' not found

This means you need to fix your cross compile set up. It
should have a cross-version of pkg-config, which should be
named 'arm-linux-pkg-config'.

-- PMM

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] Cross-compiling QEMU for ARM
  2013-03-10 14:59 ` Peter Maydell
  2013-03-10 15:35   ` Blue Swirl
  2013-03-10 16:28   ` Leonid Bloch
@ 2013-03-11  1:56   ` Peter Crosthwaite
  2 siblings, 0 replies; 11+ messages in thread
From: Peter Crosthwaite @ 2013-03-11  1:56 UTC (permalink / raw)
  To: Peter Maydell; +Cc: David Holsgrove, Leonid Bloch, qemu-devel

Hi Peter,

On Mon, Mar 11, 2013 at 12:59 AM, Peter Maydell
<peter.maydell@linaro.org> wrote:
> Question for the qemu-devel folks: does anybody have a situation
> where they genuinely need to pass --cpu to configure (ie the
> autodetection is wrong or insufficient)? [configure does mention
> one case, which is when cross-compiling to x86 Darwin and SunOS,
> but the latter at least is busted anyway because later on we
> do things based on SunOS uname results which there is no way
> to override for the cross-compile case.] I'm tempted to suggest
> we should drop --cpu entirely...

We are are using --cpu=i386 to cross build QEMU as a 32-bit binary on
64 bit platforms. Although admittedly that is still failing to build
due to werror issues.

Regards,
Peter

>
> -- PMM
>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] Cross-compiling QEMU for ARM
  2013-03-10 15:04 ` Peter Maydell
@ 2013-03-11  1:59   ` Peter Crosthwaite
  2013-03-11  9:01     ` Peter Maydell
  0 siblings, 1 reply; 11+ messages in thread
From: Peter Crosthwaite @ 2013-03-11  1:59 UTC (permalink / raw)
  To: Peter Maydell; +Cc: David Holsgrove, Leonid Bloch, qemu-devel

Hi Peter,

On Mon, Mar 11, 2013 at 1:04 AM, Peter Maydell <peter.maydell@linaro.org> wrote:
> On 10 March 2013 14:36, Leonid Bloch <lb@tx.technion.ac.il> wrote:
>> I am using Buildroot as my toolchain, and the farthest I got was:
>> $ ./configure --cpu=armv7hl --static --cc=arm-linux-cc
>> $ make
>> ...And then I get a lot of errors about libintl and libiconv.
>
> Oh, and I forgot -- don't try to build system emulators with --static:
> it's only really meant for the linux-user targets. Do specify

Works for us quite nicely. Any known issues here or reasons why system
emulators shouldn't be built static?

Regards,
Peter

> --target-list=[whichever emulators you actually wanted], especially
> when you're trying to get your build environment sorted out: this
> will massively reduce the build time so you can find out whether
> you still have issues to deal with more quickly. [--enable-debug
> is also good for speeding up the build but you'll want to drop
> that for actual use.]
>
> -- PMM
>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] Cross-compiling QEMU for ARM
  2013-03-10 16:28   ` Leonid Bloch
  2013-03-10 17:11     ` Peter Maydell
@ 2013-03-11  8:54     ` KONRAD Frédéric
  2013-03-11 10:16       ` Leonid Bloch
  1 sibling, 1 reply; 11+ messages in thread
From: KONRAD Frédéric @ 2013-03-11  8:54 UTC (permalink / raw)
  To: Leonid Bloch; +Cc: Peter Maydell, qemu-devel

On 10/03/2013 17:28, Leonid Bloch wrote:
> On Sun, Mar 10, 2013 at 4:59 PM, Peter Maydell <peter.maydell@linaro.org> wrote:
>> On 10 March 2013 14:36, Leonid Bloch <lb@tx.technion.ac.il> wrote:
>>> I want to cross compile QEMU itself to run on ARM, but all my searches
>>> lead me to tutorials for cross compiling other programs for ARM and
>>> testing them with QEMU, which is not what I need.
>>> The only relevant link I found was this:
>>> http://lists.gnu.org/archive/html/qemu-devel/2011-05/msg00099.html
>>> But this doesn't work for me as well.
>>>
>>> I am using Buildroot as my toolchain, and the farthest I got was:
>>> $ ./configure --cpu=armv7hl --static --cc=arm-linux-cc
>> Don't specify --cpu : this is almost always going to break things,
>> and you should just let configure work it out based on your compiler.
>> Don't just specify --cc, because we want to run other cross tools
>> too. Instead, use --cross-prefix=arm-linux-gnueabi- (or whatever
>> the correct prefix is for your toolchain).
> Tried that at first, but then getting an error:
> Error: pkg-config binary 'arm-linux-pkg-config' not found
>
I compiled qemu for ARM with buildroot:

- You have to install pkg-config for your buildroot toolchain.
- fdt, glib, zlib...

Some of them are really tricky to cross-compile, if I remember right.

Which buildroot version are you using?

Fred
>> You'll also need to have a cross-build environment with the minimal
>> set of libraries/includes that QEMU needs to build, including
>> but not limited to zlib and glib. How to set this up depends on
>> what your cross compilation setup is; in this case you'll need to
>> ask the buildroot folks.
>>
>> Question for the qemu-devel folks: does anybody have a situation
>> where they genuinely need to pass --cpu to configure (ie the
>> autodetection is wrong or insufficient)? [configure does mention
>> one case, which is when cross-compiling to x86 Darwin and SunOS,
>> but the latter at least is busted anyway because later on we
>> do things based on SunOS uname results which there is no way
>> to override for the cross-compile case.] I'm tempted to suggest
>> we should drop --cpu entirely...
>>
>> -- PMM

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] Cross-compiling QEMU for ARM
  2013-03-11  1:59   ` Peter Crosthwaite
@ 2013-03-11  9:01     ` Peter Maydell
  0 siblings, 0 replies; 11+ messages in thread
From: Peter Maydell @ 2013-03-11  9:01 UTC (permalink / raw)
  To: Peter Crosthwaite; +Cc: David Holsgrove, Leonid Bloch, qemu-devel

On 11 March 2013 01:59, Peter Crosthwaite <peter.crosthwaite@xilinx.com> wrote:
> On Mon, Mar 11, 2013 at 1:04 AM, Peter Maydell <peter.maydell@linaro.org> wrote:
>> Oh, and I forgot -- don't try to build system emulators with --static:
>> it's only really meant for the linux-user targets. Do specify
>
> Works for us quite nicely. Any known issues here or reasons why system
> emulators shouldn't be built static?

System emulation uses a lot more of glib and also various glibc
functions that will do dynamic loading anyhow (eg NSS functions).
[You'll note that at the linking stage there are warnings about
this.] I trust linux-user's code to be minimal enough that it
doesn't do anything bad or that won't work, and it's a well used
and tested config to use linux-user static. System mode touches
much more of glib/glibc and also links against more external
library code; also compiling it static is less common
and less useful. Basically my impression is that it's not a
"supported" config (to the extent that as upstream we support
anything ;-)), so I prefer to recommend against using it,
especially when it's unclear that somebody actually needs it
at all.

-- PMM

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] Cross-compiling QEMU for ARM
  2013-03-11  8:54     ` KONRAD Frédéric
@ 2013-03-11 10:16       ` Leonid Bloch
  0 siblings, 0 replies; 11+ messages in thread
From: Leonid Bloch @ 2013-03-11 10:16 UTC (permalink / raw)
  To: KONRAD Frédéric; +Cc: Peter Maydell, qemu-devel

On Mon, Mar 11, 2013 at 10:54 AM, KONRAD Frédéric
<fred.konrad@greensocs.com> wrote:
> On 10/03/2013 17:28, Leonid Bloch wrote:
>>
>> On Sun, Mar 10, 2013 at 4:59 PM, Peter Maydell <peter.maydell@linaro.org>
>> wrote:
>>>
>>> On 10 March 2013 14:36, Leonid Bloch <lb@tx.technion.ac.il> wrote:
>>>>
>>>> I want to cross compile QEMU itself to run on ARM, but all my searches
>>>> lead me to tutorials for cross compiling other programs for ARM and
>>>> testing them with QEMU, which is not what I need.
>>>> The only relevant link I found was this:
>>>> http://lists.gnu.org/archive/html/qemu-devel/2011-05/msg00099.html
>>>> But this doesn't work for me as well.
>>>>
>>>> I am using Buildroot as my toolchain, and the farthest I got was:
>>>> $ ./configure --cpu=armv7hl --static --cc=arm-linux-cc
>>>
>>> Don't specify --cpu : this is almost always going to break things,
>>> and you should just let configure work it out based on your compiler.
>>> Don't just specify --cc, because we want to run other cross tools
>>> too. Instead, use --cross-prefix=arm-linux-gnueabi- (or whatever
>>> the correct prefix is for your toolchain).
>>
>> Tried that at first, but then getting an error:
>> Error: pkg-config binary 'arm-linux-pkg-config' not found
>>
> I compiled qemu for ARM with buildroot:
>
> - You have to install pkg-config for your buildroot toolchain.
> - fdt, glib, zlib...
>
> Some of them are really tricky to cross-compile, if I remember right.
>
> Which buildroot version are you using?
>
> Fred
>
>>> You'll also need to have a cross-build environment with the minimal
>>> set of libraries/includes that QEMU needs to build, including
>>> but not limited to zlib and glib. How to set this up depends on
>>> what your cross compilation setup is; in this case you'll need to
>>> ask the buildroot folks.
>>>
>>> Question for the qemu-devel folks: does anybody have a situation
>>> where they genuinely need to pass --cpu to configure (ie the
>>> autodetection is wrong or insufficient)? [configure does mention
>>> one case, which is when cross-compiling to x86 Darwin and SunOS,
>>> but the latter at least is busted anyway because later on we
>>> do things based on SunOS uname results which there is no way
>>> to override for the cross-compile case.] I'm tempted to suggest
>>> we should drop --cpu entirely...
>>>
>>> -- PMM
>
>

OK, finally managed to compile:

I installed the necessary libs from within Buildroot config menu (just
marked zlib etc. until it worked)
The problem with pkg-config was that it was named "pkg-config" and not
"arm-linux-pkg-config", like all the other cross compiling tools, so I
just renamed it.
Then:
./configure --target-list=arm-linux-user --cpu=armv7hl --static
--cross-prefix=arm-linux-
(kept the "--cpu" because it didn't do any harm, and kept "--static"
because I need a static binary.
did "make" and there was an error:

~/Compile/qemu-1.4.0/user-exec.c: In function 'cpu_arm_signal_handler':
~/Compile/qemu-1.4.0/user-exec.c:440:25: error: 'mcontext_t' has no
member named 'gregs'
make[1]: *** [user-exec.o] Error 1
make: *** [subdir-arm-linux-user] Error 2

So I just changed "pc = uc->uc_mcontext.gregs[R15];" in line 440 of
user-exec.c to "pc = uc->uc_mcontext.arm_pc;"
(I know, this is the farthest thing from elegant, and will work only
for my needs, but couldn't think of anything better right now)
Does anyone have an idea how to fix it properly?
It appears after:
#if defined(__GLIBC__) && (__GLIBC__ < 2 || (__GLIBC__ == 2 &&
__GLIBC_MINOR__ <= 3))
And I use uClibc, so I don't understand why this condition is true...

Anyway, after I changed the above, it compiled, and all I was left to do is:
arm-linux-strip ~/Compile/qemu-1.4.0/arm-linux-user/qemu-arm
to strip the binary.


Leonid.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2013-03-11 10:16 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-10 14:36 [Qemu-devel] Cross-compiling QEMU for ARM Leonid Bloch
2013-03-10 14:59 ` Peter Maydell
2013-03-10 15:35   ` Blue Swirl
2013-03-10 16:28   ` Leonid Bloch
2013-03-10 17:11     ` Peter Maydell
2013-03-11  8:54     ` KONRAD Frédéric
2013-03-11 10:16       ` Leonid Bloch
2013-03-11  1:56   ` Peter Crosthwaite
2013-03-10 15:04 ` Peter Maydell
2013-03-11  1:59   ` Peter Crosthwaite
2013-03-11  9:01     ` Peter Maydell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.