Skip to contentSkip to conversation

Fix QEMU build on OpenBSD on x86 archs

PATCH Applied Brad Smith 5 participants 15 messages Dec 11, 2013 – Feb 18, 2014

lore
Share & tools
lore

Brad Smith

author
#0 lore raw

PATCH v3 1/1 Fix QEMU build on OpenBSD on x86 archs

This resolves the build issue with building the ROMs on OpenBSD on x86 archs. As of OpenBSD 5.3 the compiler builds PIE binaries by default and thus the whole OS/packages and so forth. The ROMs need to have PIE disabled. This is my initial attempt at trying to get somehting upstream so that QEMU both builds out of the box and to resolve the build issue with the buildbots that has been around for awhile. We have a patch in our ports tree but it is just the flags hardcoded into the Makefile which obviously is not appropriate for upstream.

Quoted 1 line

From the OpenBSD buildbots..

Building optionrom/multiboot.img
ld: multiboot.o: relocation R_X86_64_16 can not be used when making a shared object; recompile with -fPIC

Signed-off by: Brad Smith <[email protected]>
---

Change in v2:
* Fix '==' is not portable syntax.

Change in v3:
* Rename variables and use compile_prog to detect the presence of the compiler/linker flags, as suggested by Stefan Weil.

configure +7 -0
index 5d82283..89ae89d 100755
@@ -1365,6 +1365,11 @@ EOF
       pie="no"
     fi
   fi
+
+  if compile_prog "-fno-pie" "-nopie"; then
+    CFLAGS_NOPIE="-fno-pie"
+    LDFLAGS_NOPIE="-nopie"
+  fi
 fi
 
 ##########################################
@@ -4320,6 +4325,7 @@ echo "LD=$ld" >> $config_host_mak
 echo "WINDRES=$windres" >> $config_host_mak
 echo "LIBTOOL=$libtool" >> $config_host_mak
 echo "CFLAGS=$CFLAGS" >> $config_host_mak
+echo "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
 echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
 echo "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
 if test "$sparse" = "yes" ; then
@@ -4333,6 +4339,7 @@ else
   echo "AUTOCONF_HOST := "                             >> $config_host_mak
 fi
 echo "LDFLAGS=$LDFLAGS" >> $config_host_mak
+echo "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak
 echo "LIBTOOLFLAGS=$LIBTOOLFLAGS" >> $config_host_mak
 echo "LIBS+=$LIBS" >> $config_host_mak
 echo "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
pc-bios/optionrom/Makefile +2 -1
index 57d8bd0..ce4852a 100644
@@ -12,6 +12,7 @@ $(call set-vpath, $(SRC_PATH)/pc-bios/optionrom)
 CFLAGS := -Wall -Wstrict-prototypes -Werror -fomit-frame-pointer -fno-builtin
 CFLAGS += -I$(SRC_PATH)
 CFLAGS += $(call cc-option, $(CFLAGS), -fno-stack-protector)
+CFLAGS += $(CFLAGS_NOPIE)
 QEMU_CFLAGS = $(CFLAGS)
 
 build-all: multiboot.bin linuxboot.bin kvmvapic.bin
@@ -20,7 +21,7 @@ build-all: multiboot.bin linuxboot.bin kvmvapic.bin
 .SECONDARY:
 
 %.img: %.o
-	$(call quiet-command,$(LD) -Ttext 0 -e _start -s -o $@ $<,"  Building $(TARGET_DIR)$@")
+	$(call quiet-command,$(LD) $(LDFLAGS_NOPIE) -Ttext 0 -e _start -s -o $@ $<,"  Building $(TARGET_DIR)$@")
 
 %.raw: %.img
 	$(call quiet-command,$(OBJCOPY) -O binary -j .text $< $@,"  Building $(TARGET_DIR)$@")
Signature · 3 lines
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
author
#1 lore raw
Quoted 9 lines · Brad Smith

This resolves the build issue with building the ROMs on OpenBSD on x86 archs. As of OpenBSD 5.3 the compiler builds PIE binaries by default and thus the whole OS/packages and so forth. The ROMs need to have PIE disabled. This is my initial attempt at trying to get somehting upstream so that QEMU both builds out of the box and to resolve the build issue with the buildbots that has been around for awhile. We have a patch in our ports tree but it is just the flags hardcoded into the Makefile which obviously is not appropriate for upstream.

Quoted 5 lines

From the OpenBSD buildbots..
Building optionrom/multiboot.img
ld: multiboot.o: relocation R_X86_64_16 can not be used when making a shared object; recompile with -fPIC

Signed-off by: Brad Smith <[email protected]>

ping.

Quoted 63 lines

---

Change in v2:
* Fix '==' is not portable syntax.

Change in v3:
* Rename variables and use compile_prog to detect the presence of the compiler/linker flags, as suggested by Stefan Weil.

configure +7 -0
index 5d82283..89ae89d 100755
@@ -1365,6 +1365,11 @@ EOF
        pie="no"
      fi
    fi
+
+  if compile_prog "-fno-pie" "-nopie"; then
+    CFLAGS_NOPIE="-fno-pie"
+    LDFLAGS_NOPIE="-nopie"
+  fi
  fi
 
  ##########################################
@@ -4320,6 +4325,7 @@ echo "LD=$ld" >> $config_host_mak
  echo "WINDRES=$windres" >> $config_host_mak
  echo "LIBTOOL=$libtool" >> $config_host_mak
  echo "CFLAGS=$CFLAGS" >> $config_host_mak
+echo "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
  echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
  echo "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
  if test "$sparse" = "yes" ; then
@@ -4333,6 +4339,7 @@ else
    echo "AUTOCONF_HOST := "                             >> $config_host_mak
  fi
  echo "LDFLAGS=$LDFLAGS" >> $config_host_mak
+echo "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak
  echo "LIBTOOLFLAGS=$LIBTOOLFLAGS" >> $config_host_mak
  echo "LIBS+=$LIBS" >> $config_host_mak
  echo "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
pc-bios/optionrom/Makefile +2 -1
index 57d8bd0..ce4852a 100644
@@ -12,6 +12,7 @@ $(call set-vpath, $(SRC_PATH)/pc-bios/optionrom)
  CFLAGS := -Wall -Wstrict-prototypes -Werror -fomit-frame-pointer -fno-builtin
  CFLAGS += -I$(SRC_PATH)
  CFLAGS += $(call cc-option, $(CFLAGS), -fno-stack-protector)
+CFLAGS += $(CFLAGS_NOPIE)
  QEMU_CFLAGS = $(CFLAGS)
 
  build-all: multiboot.bin linuxboot.bin kvmvapic.bin
@@ -20,7 +21,7 @@ build-all: multiboot.bin linuxboot.bin kvmvapic.bin
  .SECONDARY:
 
  %.img: %.o
-	$(call quiet-command,$(LD) -Ttext 0 -e _start -s -o $@ $<,"  Building $(TARGET_DIR)$@")
+	$(call quiet-command,$(LD) $(LDFLAGS_NOPIE) -Ttext 0 -e _start -s -o $@ $<,"  Building $(TARGET_DIR)$@")
 
  %.raw: %.img
  	$(call quiet-command,$(OBJCOPY) -O binary -j .text $< $@,"  Building $(TARGET_DIR)$@")
Signature · 3 lines
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
author
#2 lore raw
Quoted 12 lines · Brad Smith
Quoted 11 lines · Brad Smith

This resolves the build issue with building the ROMs on OpenBSD on x86 archs.
As of OpenBSD 5.3 the compiler builds PIE binaries by default and thus the
whole OS/packages and so forth. The ROMs need to have PIE disabled. This is my initial attempt at trying to get somehting upstream so that QEMU both builds out of the box and to resolve the build issue with the buildbots that has been around for awhile. We have a patch in our ports tree but it is just the flags hardcoded into the Makefile which obviously is not appropriate for upstream.

Quoted 8 lines
Quoted 6 lines

From the OpenBSD buildbots..
Building optionrom/multiboot.img
ld: multiboot.o: relocation R_X86_64_16 can not be used when making a shared object; recompile with -fPIC

Signed-off by: Brad Smith <[email protected]>

ping.

ping ping.

Quoted 71 lines
Quoted 69 lines

---

Change in v2:
* Fix '==' is not portable syntax.

Change in v3:
* Rename variables and use compile_prog to detect the presence of
the compiler/linker
flags, as suggested by Stefan Weil.

configure +6 -0
index 5d82283..89ae89d 100755
@@ -1365,6 +1365,11 @@ EOF
        pie="no"
      fi
    fi
+
+  if compile_prog "-fno-pie" "-nopie"; then
+    CFLAGS_NOPIE="-fno-pie"
+    LDFLAGS_NOPIE="-nopie"
+  fi
  fi
 
  ##########################################
@@ -4320,6 +4325,7 @@ echo "LD=$ld" >> $config_host_mak
  echo "WINDRES=$windres" >> $config_host_mak
  echo "LIBTOOL=$libtool" >> $config_host_mak
  echo "CFLAGS=$CFLAGS" >> $config_host_mak
+echo "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
  echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
  echo "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
  if test "$sparse" = "yes" ; then
@@ -4333,6 +4339,7 @@ else
    echo "AUTOCONF_HOST := "                             >>

$config_host_mak
fi
echo "LDFLAGS=$LDFLAGS" >> $config_host_mak

configure +1 -0
+echo "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak
  echo "LIBTOOLFLAGS=$LIBTOOLFLAGS" >> $config_host_mak
  echo "LIBS+=$LIBS" >> $config_host_mak
  echo "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
pc-bios/optionrom/Makefile +2 -3
index 57d8bd0..ce4852a 100644
@@ -12,6 +12,7 @@ $(call set-vpath, $(SRC_PATH)/pc-bios/optionrom)
  CFLAGS := -Wall -Wstrict-prototypes -Werror -fomit-frame-pointer
-fno-builtin
  CFLAGS += -I$(SRC_PATH)
  CFLAGS += $(call cc-option, $(CFLAGS), -fno-stack-protector)
+CFLAGS += $(CFLAGS_NOPIE)
  QEMU_CFLAGS = $(CFLAGS)
 
  build-all: multiboot.bin linuxboot.bin kvmvapic.bin
@@ -20,7 +21,7 @@ build-all: multiboot.bin linuxboot.bin kvmvapic.bin
  .SECONDARY:
 
  %.img: %.o
-    $(call quiet-command,$(LD) -Ttext 0 -e _start -s -o $@ $<,"
 Building $(TARGET_DIR)$@")
+    $(call quiet-command,$(LD) $(LDFLAGS_NOPIE) -Ttext 0 -e _start -s
-o $@ $<,"  Building $(TARGET_DIR)$@")
 
  %.raw: %.img
      $(call quiet-command,$(OBJCOPY) -O binary -j .text $< $@,"

Building $(TARGET_DIR)$@")

Signature · 3 lines
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
author
#3 lore raw
Quoted 18 lines · Brad Smith
Quoted 17 lines · Brad Smith
Quoted 16 lines · Brad Smith

This resolves the build issue with building the ROMs on OpenBSD on x86 archs.
As of OpenBSD 5.3 the compiler builds PIE binaries by default and thus the
whole OS/packages and so forth. The ROMs need to have PIE disabled. This is my initial attempt at trying to get somehting upstream so that QEMU both builds out of the box and to resolve the build issue with the buildbots that has been around for awhile. We have a patch in our ports tree but it is just the flags hardcoded into the Makefile which obviously is not appropriate for upstream.

From the OpenBSD buildbots..
Building optionrom/multiboot.img
ld: multiboot.o: relocation R_X86_64_16 can not be used when making a shared object; recompile with -fPIC

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Signed-off by: Brad Smith <[email protected]>

ping.

ping ping.

ping ping ping.

Signature · 3 lines
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Reviewed-by on v3 1/1
#4 lore raw
In reply to Brad Smith
Quoted 16 lines · Brad Smith

This resolves the build issue with building the ROMs on OpenBSD on x86 archs. As of OpenBSD 5.3 the compiler builds PIE binaries by default and thus the whole OS/packages and so forth. The ROMs need to have PIE disabled. This is my initial attempt at trying to get somehting upstream so that QEMU both builds out of the box and to resolve the build issue with the buildbots that has been around for awhile. We have a patch in our ports tree but it is just the flags hardcoded into the Makefile which obviously is not appropriate for upstream.

From the OpenBSD buildbots..
Building optionrom/multiboot.img
ld: multiboot.o: relocation R_X86_64_16 can not be used when making a shared object; recompile with -fPIC

Signed-off by: Brad Smith <[email protected]>
---

Quoted 6 lines

Change in v2:
* Fix '==' is not portable syntax.

Change in v3:
* Rename variables and use compile_prog to detect the presence of the compiler/linker flags, as suggested by Stefan Weil.

author
#5 lore raw
Quoted 17 lines · Stefan Hajnoczi
Quoted 16 lines · Brad Smith

This resolves the build issue with building the ROMs on OpenBSD on x86 archs. As of OpenBSD 5.3 the compiler builds PIE binaries by default and thus the whole OS/packages and so forth. The ROMs need to have PIE disabled. This is my initial attempt at trying to get somehting upstream so that QEMU both builds out of the box and to resolve the build issue with the buildbots that has been around for awhile. We have a patch in our ports tree but it is just the flags hardcoded into the Makefile which obviously is not appropriate for upstream.

From the OpenBSD buildbots..
Building optionrom/multiboot.img
ld: multiboot.o: relocation R_X86_64_16 can not be used when making a shared object; recompile with -fPIC

Signed-off by: Brad Smith <[email protected]>
---

Quoted 8 lines
Quoted 6 lines

Change in v2:
* Fix '==' is not portable syntax.

Change in v3:
* Rename variables and use compile_prog to detect the presence of the compiler/linker flags, as suggested by Stefan Weil.

Is there some sort of process I am missing to have build fixes commited so that QEMU actually builds?

Signature · 3 lines
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
#6 lore raw

Il 26/01/2014 02:37, Brad Smith ha scritto:

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Is there some sort of process I am missing to have build fixes commited so that QEMU actually builds?

Right now we have problems getting patches committed at all.

This patch and the other NetBSD patch is not lost.

Paolo

author
#7 lore raw
Quoted 11 lines · Paolo Bonzini

Il 26/01/2014 02:37, Brad Smith ha scritto:

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Is there some sort of process I am missing to have build fixes commited so that QEMU actually builds?

Right now we have problems getting patches committed at all.

This patch and the other NetBSD patch is not lost.

I know it is not literally lost.

I don't follow the list that closely.. what was the reason for there being two incidents over the last 2 months of there being no commits for over a week (at least from the perspective of git.qemu.org)?

Signature · 3 lines
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
#8 lore raw
Quoted 18 lines · Brad Smith
Quoted 8 lines · Paolo Bonzini

Il 26/01/2014 02:37, Brad Smith ha scritto:

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Quoted 7 lines
Quoted 2 lines

Is there some sort of process I am missing to have build fixes commited so that QEMU actually builds?

Right now we have problems getting patches committed at all.

This patch and the other NetBSD patch is not lost.

Quoted 6 lines

I know it is not literally lost.

I don't follow the list that closely.. what was the reason for there being two incidents over the last 2 months of there being no commits for over a week (at least from the perspective of git.qemu.org)?

Historically, having multiple committers has avoided this problem because when one person gets bogged down, there's someone else to step up.

Right now, it seems all current committers are in a bogged down state.

I've added another committer, Peter Maydell, to try to break the log jam. I'll try to devote more time to applying patches but hopefully with Peter's help too, we can get things moving at the appropriate speed again.

Regards,

Anthony Liguori

Quoted 7 lines

--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

author
#9 lore raw
Quoted 30 lines · Anthony Liguori
Quoted 18 lines · Brad Smith
Quoted 8 lines · Paolo Bonzini

Il 26/01/2014 02:37, Brad Smith ha scritto:

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Quoted 7 lines
Quoted 2 lines

Is there some sort of process I am missing to have build fixes commited so that QEMU actually builds?

Right now we have problems getting patches committed at all.

This patch and the other NetBSD patch is not lost.

Quoted 6 lines

I know it is not literally lost.

I don't follow the list that closely.. what was the reason for there being two incidents over the last 2 months of there being no commits for over a week (at least from the perspective of git.qemu.org)?

Historically, having multiple committers has avoided this problem because when one person gets bogged down, there's someone else to step up.

Quoted 6 lines

Right now, it seems all current committers are in a bogged down state.

I've added another committer, Peter Maydell, to try to break the log jam. I'll try to devote more time to applying patches but hopefully with Peter's help too, we can get things moving at the appropriate speed again.

Ok, I see. Thank you for the response.

Signature · 3 lines
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
author
#10 lore raw
In reply to Paolo Bonzini
Quoted 5 lines · Paolo Bonzini

Il 26/01/2014 02:37, Brad Smith ha scritto:

Quoted 4 lines
Quoted 3 lines
Quoted 1 line
Quoted 8 lines
Quoted 2 lines

Is there some sort of process I am missing to have build fixes commited so that QEMU actually builds?

Right now we have problems getting patches committed at all.

This patch and the other NetBSD patch is not lost.

Paolo

ping.

Signature · 3 lines
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
#11 lore raw
Quoted 13 lines · Brad Smith
Quoted 12 lines · Paolo Bonzini

Il 26/01/2014 02:37, Brad Smith ha scritto:

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

Is there some sort of process I am missing to have build fixes commited so that QEMU actually builds?

Quoted 8 lines
Quoted 5 lines

Right now we have problems getting patches committed at all.

This patch and the other NetBSD patch is not lost.

Paolo

ping.

Applied, thanks. Apologies for the delays.

-- PMM

author
#12 lore raw
Quoted 16 lines · Peter Maydell
Quoted 15 lines · Brad Smith
Quoted 14 lines · Paolo Bonzini

Il 26/01/2014 02:37, Brad Smith ha scritto:

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

Is there some sort of process I am missing to have build fixes commited so that QEMU actually builds?

Right now we have problems getting patches committed at all.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

This patch and the other NetBSD patch is not lost.

Paolo

ping.

Applied, thanks. Apologies for the delays.

Thank you very much.

Just one issue... just curious why my last name is missing from the commit?

Signature · 3 lines
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
#13 lore raw
Quoted 2 lines · Brad Smith

Just one issue... just curious why my last name is missing from the commit?

Ah, we've run into a bug in patchwork. I downloaded your patch:
http://patchwork.ozlabs.org/patch/299656/

but patchwork reconstructs patch mboxes from its database rather than just returning the original email, and it has a bug where it will always remember the name used by the very first email it ever saw from you. I guess it has a patch in the system way back from you with a misconfigured fullname. Sorry about that. I know they've discussed this issue on the patchwork mailing list but they obviously haven't implemented a fix yet.

thanks
-- PMM

author
#14 lore raw
Quoted 7 lines · Peter Maydell
Quoted 2 lines · Brad Smith

Just one issue... just curious why my last name is missing from the commit?

Ah, we've run into a bug in patchwork. I downloaded your patch:
http://patchwork.ozlabs.org/patch/299656/

Quoted 8 lines

but patchwork reconstructs patch mboxes from its database rather than just returning the original email, and it has a bug where it will always remember the name used by the very first email it ever saw from you. I guess it has a patch in the system way back from you with a misconfigured fullname. Sorry about that. I know they've discussed this issue on the patchwork mailing list but they obviously haven't implemented a fix yet.

Well, it was intentionally left out back then but that was quite awhile ago. I have changed my e-mail setup since then to include the last name. Anyway, thanks for looking into this.

Signature · 3 lines
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.