Skip to contentSkip to conversation

qemu: fix out of tree cross compile

PATCH In review Alexey Kardashevskiy 5 participants 12 messages May 27, 2013 – May 29, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qemu: fix out of tree cross compile

QEMU uses headers from source directory, however the "asm" symlink was created in the build directory what broke KVM stuff compilation.

---
 configure |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
configure +1 -1
index 5ae7e4a..9c3c5e5 100755
@@ -4135,7 +4135,7 @@ if test "$linux" = "yes" ; then
   esac
     # For non-KVM architectures we will not have asm headers
     if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
-      symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
+      symlink "$source_path/linux-headers/asm-$linux_arch" $source_path/linux-headers/asm
     fi
 fi
 
Signature · 1 line
1.7.10.4
#1 lore raw
Quoted 13 lines · Alexey Kardashevskiy

QEMU uses headers from source directory, however the "asm" symlink was created in the build directory what broke KVM stuff compilation.

---
 configure |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
configure +0 -0
index 5ae7e4a..9c3c5e5 100755

configure if test "$linux" = "yes" ; then · line 4138

Quoted 5 lines
configure +1 -1
@@ -4135,7 +4135,7 @@ if test "$linux" = "yes" ; then
   esac
     # For non-KVM architectures we will not have asm headers
     if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
-      symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
+      symlink "$source_path/linux-headers/asm-$linux_arch" $source_path/linux-headers/asm

This is definitely wrong -- the asm symlink must be created in the build tree, because you could have two build trees which are building for different architectures and need different symlink targets. (More generally, an out of tree build should never create files in the source tree, because the point of out of tree builds is to leave the source tree in a pristine state.)

What is the actual bug here? QEMU builds fine for me, because the build directory is also in the include path via "-I.".

thanks
-- PMM

#2 lore raw
Quoted 20 lines · Peter Maydell
Quoted 13 lines · Alexey Kardashevskiy

QEMU uses headers from source directory, however the "asm" symlink was created in the build directory what broke KVM stuff compilation.

---
 configure |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
configure +0 -0
index 5ae7e4a..9c3c5e5 100755

configure if test "$linux" = "yes" ; then · line 4138

Quoted 5 lines
configure +1 -1
@@ -4135,7 +4135,7 @@ if test "$linux" = "yes" ; then
   esac
     # For non-KVM architectures we will not have asm headers
     if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
-      symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
+      symlink "$source_path/linux-headers/asm-$linux_arch" $source_path/linux-headers/asm
Quoted 7 lines

This is definitely wrong -- the asm symlink must be created in the build tree, because you could have two build trees which are building for different architectures and need different symlink targets. (More generally, an out of tree build should never create files in the source tree, because the point of out of tree builds is to leave the source tree in a pristine state.)

Ok, ok. Then I'll post another patch in a a response to this.

Quoted 2 lines

What is the actual bug here? QEMU builds fine for me, because the build directory is also in the include path via "-I.".

Does you build directory beside inside the source tree directory? I cannot see the other way for it to work. -I <blabla>/linux-headers must be added, "-I." is not enough.

The actual bug is that it does not cross compile until I apply this or the other patch.

This is how I run ./configure:
/home/alexey/pcipassthru/qemu-impreza/configure --source-path=/home/alexey/pcipassthru/qemu-impreza --target-list=ppc64-softmmu
--cpu=ppc64
--cross-prefix=powerpc64-linux- --prefix=/home/alexey/pcipassthru/lib4qemu/install --extra-ldflags=-L/home/alexey/pcipassthru/lib4qemu/usr/lib64 '--extra-cflags=--sysroot=/home/alexey/pcipassthru/lib4qemu/ -I/home/alexey/pcipassthru/lib4qemu/usr/include -D__EXCEPTIONS -D__LONG_DOUBLE_128__ -D__NO_INLINE__ -Wno-redundant-decls -Wno-missing-prototypes -Wmissing-include-dirs' --disable-werror
--enable-fdt
--enable-attr
--enable-kvm
--enable-profiler
--disable-seccomp
--enable-trace-backend=stderr
--enable-debug
--disable-debug-tcg
--enable-debug-info

This is where the compilation fails on:
powerpc64-linux-gcc \
-I/home/alexey/pcipassthru/qemu-impreza/tcg -I/home/alexey/pcipassthru/qemu-impreza/tcg/ppc64 -I/home/alexey/pcipassthru/qemu-impreza/linux-headers -I.
-I/home/alexey/pcipassthru/qemu-impreza -I/home/alexey/pcipassthru/qemu-impreza/include -I/home/alexey/pcipassthru/qemu-impreza/target-ppc -Itarget-ppc
-D_GNU_SOURCE
-D_FILE_OFFSET_BITS=64
-D_LARGEFILE_SOURCE
-Wstrict-prototypes
-Wredundant-decls -Wall
-Wundef
-Wwrite-strings
-Wmissing-prototypes
-fno-strict-aliasing --sysroot=/home/alexey/pcipassthru/lib4qemu/ -I/home/alexey/pcipassthru/lib4qemu/usr/include -D__EXCEPTIONS -D__LONG_DOUBLE_128__ -D__NO_INLINE__ -Wno-redundant-decls -Wno-missing-prototypes -Wmissing-include-dirs -Wendif-labels -Wmissing-include-dirs -Wempty-body
-Wnested-externs -Wformat-security
-Wformat-y2k -Winit-self -Wignored-qualifiers -Wold-style-declaration -Wold-style-definition -Wtype-limits -I/home/alexey/pcipassthru/lib4qemu/usr/include -I/home/alexey/pcipassthru/lib4qemu/usr/include/p11-kit-1 -I/home/alexey/pcipassthru/lib4qemu/usr/include -I/home/alexey/pcipassthru/lib4qemu/usr/include/libusb-1.0 -I/home/alexey/pcipassthru/lib4qemu/usr/include -I/home/alexey/pcipassthru/lib4qemu/usr/include/pixman-1 -I../linux-headers
-I..
-I/home/alexey/pcipassthru/qemu-impreza/target-ppc -DNEED_CPU_H -I/home/alexey/pcipassthru/qemu-impreza/include -pthread -I/home/alexey/pcipassthru/lib4qemu/usr/include/glib-2.0 -I/home/alexey/pcipassthru/lib4qemu/usr/lib64/glib-2.0/include -MMD -MP -MT target-ppc/kvm.o -MF target-ppc/kvm.d -g -I/home/alexey/pcipassthru/lib4qemu/usr/include -c
-o target-ppc/kvm.o /home/alexey/pcipassthru/qemu-impreza/target-ppc/kvm.c /home/alexey/pcipassthru/qemu-impreza/hw/ppc/xics.c: In function 'icp_get_kvm_state':
/home/alexey/pcipassthru/qemu-impreza/hw/ppc/xics.c:186:15: error:
'KVM_REG_PPC_ICP_STATE' undeclared (first use in this function)
.id = KVM_REG_PPC_ICP_STATE,
^
...

Signature · 1 line
Alexey
#3 lore raw

PATCH 1/1 qemu: fix out of tree cross compile

The symlink to platform linux headers is made in the build tree by the configure script but gcc is not told to look for them there. The patch fixes this.

---
 configure |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
configure +1 -1
index 5ae7e4a..5ba691a 100755
@@ -547,7 +547,7 @@ Haiku)
   if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
     audio_possible_drivers="$audio_possible_drivers fmod"
   fi
-  QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers $QEMU_INCLUDES"
+  QEMU_INCLUDES="-I$(pwd)/linux-headers $QEMU_INCLUDES"
 ;;
 esac
 
Signature · 1 line
1.7.10.4
#4 lore raw

Il 27/05/2013 16:12, Alexey Kardashevskiy ha scritto:

Quoted 14 lines

The symlink to platform linux headers is made in the build tree by the configure script but gcc is not told to look for them there. The patch fixes this.

---
 configure |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
configure +0 -0
index 5ae7e4a..5ba691a 100755

configure Haiku) · line 550

Quoted 5 lines
configure +1 -1
@@ -547,7 +547,7 @@ Haiku)
   if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
     audio_possible_drivers="$audio_possible_drivers fmod"
   fi
-  QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers $QEMU_INCLUDES"
+  QEMU_INCLUDES="-I$(pwd)/linux-headers $QEMU_INCLUDES"

You need to have both directories. Files other than asm/*.h will be found in the source path.

Paolo

#5 lore raw
Quoted 10 lines · Paolo Bonzini

Il 27/05/2013 16:12, Alexey Kardashevskiy ha scritto:

Quoted 9 lines

The symlink to platform linux headers is made in the build tree by the configure script but gcc is not told to look for them there. The patch fixes this.

---
 configure |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 13 lines

configure Haiku) · line 550

Quoted 10 lines
configure +1 -1
index 5ae7e4a..5ba691a 100755
@@ -547,7 +547,7 @@ Haiku)
   if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
     audio_possible_drivers="$audio_possible_drivers fmod"
   fi
-  QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers $QEMU_INCLUDES"
+  QEMU_INCLUDES="-I$(pwd)/linux-headers $QEMU_INCLUDES"

You need to have both directories. Files other than asm/*.h will be found in the source path.

So do I need this?

+ QEMU_INCLUDES="-I$(pwd)/linux-headers -I\$(SRC_PATH)/linux-headers $QEMU_INCLUDES"

Signature · 1 line
Alexey
#6 lore raw

PATCH v2 1/1 qemu: fix out of tree cross compile

The symlink to "asm" platform linux headers is made in the build tree by the configure script but gcc is not told to look for them there.

The patch fixes this.

---
 configure |    1 +
 1 file changed, 1 insertion(+)
configure +1 -0
index 5ae7e4a..20b42f0 100755
@@ -548,6 +548,7 @@ Haiku)
     audio_possible_drivers="$audio_possible_drivers fmod"
   fi
   QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers $QEMU_INCLUDES"
+  QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers -I$(pwd)/linux-headers $QEMU_INCLUDES"
 ;;
 esac
 
Signature · 1 line
1.7.10.4
#7 lore raw

PATCH v3 1/1 qemu: fix out of tree cross compile

The symlink to "asm" platform linux headers is made in the build tree by the configure script but gcc is not told to look for them there.

The patch fixes this.

---

The previous patch did not remove the old line adding includes. Early morning, lack of focus :)

---
 configure |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
configure +1 -1
index 5ae7e4a..eca2a20 100755
@@ -547,7 +547,7 @@ Haiku)
   if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
     audio_possible_drivers="$audio_possible_drivers fmod"
   fi
-  QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers $QEMU_INCLUDES"
+  QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers -I$(pwd)/linux-headers $QEMU_INCLUDES"
 ;;
 esac
 
Signature · 1 line
1.7.10.4
Reviewed-by on v3 1/1
#8 lore raw

Il 28/05/2013 01:49, Alexey Kardashevskiy ha scritto:

Quoted 21 lines

The symlink to "asm" platform linux headers is made in the build tree by the configure script but gcc is not told to look for them there.

The patch fixes this.

---

The previous patch did not remove the old line adding includes. Early morning, lack of focus :)

---
 configure |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
configure +0 -0
index 5ae7e4a..eca2a20 100755

configure Haiku) · line 553

Quoted 8 lines
configure +1 -1
@@ -547,7 +547,7 @@ Haiku)
   if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
     audio_possible_drivers="$audio_possible_drivers fmod"
   fi
-  QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers $QEMU_INCLUDES"
+  QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers -I$(pwd)/linux-headers $QEMU_INCLUDES"
 ;;
 esac
 

Paolo

#9 lore raw

Am 28.05.2013 10:54, schrieb Paolo Bonzini:

Quoted 16 lines

Il 28/05/2013 01:49, Alexey Kardashevskiy ha scritto:

Quoted 15 lines

The symlink to "asm" platform linux headers is made in the build tree by the configure script but gcc is not told to look for them there.

The patch fixes this.

---

The previous patch did not remove the old line adding includes. Early morning, lack of focus :)

---
 configure |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 16 lines
Quoted 6 lines
configure +0 -0
index 5ae7e4a..eca2a20 100755

configure Haiku) · line 553

Quoted 8 lines
configure +1 -1
@@ -547,7 +547,7 @@ Haiku)
   if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
     audio_possible_drivers="$audio_possible_drivers fmod"
   fi
-  QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers $QEMU_INCLUDES"
+  QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers -I$(pwd)/linux-headers $QEMU_INCLUDES"
 ;;
 esac
 

Hm, I see no other case of adding $(pwd) to QEMU_INCLUDES - shouldn't this just be -Ilinux-headers?

And might it make sense to give the build directory precedence over the source directory?

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#10 lore raw

Il 28/05/2013 11:12, Andreas Färber ha scritto:

Quoted 34 lines

Am 28.05.2013 10:54, schrieb Paolo Bonzini:

Quoted 16 lines

Il 28/05/2013 01:49, Alexey Kardashevskiy ha scritto:

Quoted 15 lines

The symlink to "asm" platform linux headers is made in the build tree by the configure script but gcc is not told to look for them there.

The patch fixes this.

---

The previous patch did not remove the old line adding includes. Early morning, lack of focus :)

---
 configure |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 16 lines
Quoted 6 lines
configure +0 -0
index 5ae7e4a..eca2a20 100755

configure Haiku) · line 553

Quoted 8 lines
configure +1 -1
@@ -547,7 +547,7 @@ Haiku)
   if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
     audio_possible_drivers="$audio_possible_drivers fmod"
   fi
-  QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers $QEMU_INCLUDES"
+  QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers -I$(pwd)/linux-headers $QEMU_INCLUDES"
 ;;
 esac
 
Quoted 2 lines

Hm, I see no other case of adding $(pwd) to QEMU_INCLUDES - shouldn't this just be -Ilinux-headers?

I think -Ilinux-headers would add <builddir>/x86_64-softmmu/linux-headers, which is wrong.

Quoted 2 lines

And might it make sense to give the build directory precedence over the source directory?

It shouldn't matter.

Paolo

#11 lore raw
In reply to Alexey Kardashevskiy
Quoted 10 lines · Alexey Kardashevskiy

The symlink to "asm" platform linux headers is made in the build tree by the configure script but gcc is not told to look for them there.

The patch fixes this.

---

The previous patch did not remove the old line adding includes. Early morning, lack of focus :)

Please repost as a top level patch.

Regards,

Anthony Liguori

Quoted 20 lines
---
 configure |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
configure +1 -1
index 5ae7e4a..eca2a20 100755
@@ -547,7 +547,7 @@ Haiku)
   if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
     audio_possible_drivers="$audio_possible_drivers fmod"
   fi
-  QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers $QEMU_INCLUDES"
+  QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers -I$(pwd)/linux-headers $QEMU_INCLUDES"
 ;;
 esac
 
Signature · 1 line
1.7.10.4