From patchwork Mon Aug 8 16:11:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 9268701 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D95346075A for ; Mon, 8 Aug 2016 16:28:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CA117283F8 for ; Mon, 8 Aug 2016 16:28:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BD79C28415; Mon, 8 Aug 2016 16:28:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3164B283F8 for ; Mon, 8 Aug 2016 16:28:52 +0000 (UTC) Received: from localhost ([::1]:58536 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bWnQ3-0006j7-CK for patchwork-qemu-devel@patchwork.kernel.org; Mon, 08 Aug 2016 12:28:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59310) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bWnBV-0000zs-Uh for qemu-devel@nongnu.org; Mon, 08 Aug 2016 12:13:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bWnBR-0004Gu-LA for qemu-devel@nongnu.org; Mon, 08 Aug 2016 12:13:48 -0400 Received: from orth.archaic.org.uk ([81.2.115.148]:50840) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bWnBR-0004Ed-Dz for qemu-devel@nongnu.org; Mon, 08 Aug 2016 12:13:45 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.84_2) (envelope-from ) id 1bWn9F-00018m-GN; Mon, 08 Aug 2016 17:11:29 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 8 Aug 2016 17:11:28 +0100 Message-Id: <1470672688-6754-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 81.2.115.148 Subject: [Qemu-devel] [PATCH for-2.7] pc-bios/optionrom: Fix OpenBSD build with better detection of linker emulation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Sean Bruno , Brad Smith , patches@linaro.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The various host OSes are irritatingly variable about the name of the linker emulation we need to pass to ld's -m option to build the i386 option ROMs. Instead of doing this via a CONFIG ifdef, check in configure whether any of the emulation names we know about will work and pass the right answer through to the makefile. If we can't find one, we fall back to not trying to build the option ROMs, in the same way we would for a non-x86 host platform. This is in particular necessary to unbreak the build on OpenBSD, since it wants a different answer to FreeBSD and we don't have an existing CONFIG_ variable that distinguishes the two. Signed-off-by: Peter Maydell Reviewed-by: Sean Bruno --- This works for Linux and for the Windows builds; I don't have any BSD systems to test it on. Brad and Sean, can I ask you to test this on OpenBSD and FreeBSD, please? (I think this is going to miss -rc2. Sorry about that; we'll get OpenBSD builds fixed for -rc3.) configure | 12 +++++++++++- pc-bios/optionrom/Makefile | 12 +----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/configure b/configure index f57fcc6..7c744ad 100755 --- a/configure +++ b/configure @@ -4699,7 +4699,16 @@ roms= if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \ "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \ "$softmmu" = yes ; then - roms="optionrom" + # Different host OS linkers have different ideas about the name of the ELF + # emulation. Linux and OpenBSD use 'elf_i386'; FreeBSD uses the _fbsd + # variant; and Windows uses i386pe. + for emu in elf_i386 elf_i386_fbsd i386pe; do + if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then + ld_i386_emulation="$emu" + roms="optionrom" + break + fi + done fi if test "$cpu" = "ppc64" -a "$targetos" != "Darwin" ; then roms="$roms spapr-rtas" @@ -5539,6 +5548,7 @@ fi echo "LDFLAGS=$LDFLAGS" >> $config_host_mak echo "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak echo "LD_REL_FLAGS=$LD_REL_FLAGS" >> $config_host_mak +echo "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak echo "LIBS+=$LIBS" >> $config_host_mak echo "LIBS_TOOLS+=$libs_tools" >> $config_host_mak echo "PTHREAD_LIB=$PTHREAD_LIB" >> $config_host_mak diff --git a/pc-bios/optionrom/Makefile b/pc-bios/optionrom/Makefile index 24e175e..5bbe233 100644 --- a/pc-bios/optionrom/Makefile +++ b/pc-bios/optionrom/Makefile @@ -41,18 +41,8 @@ build-all: multiboot.bin linuxboot.bin linuxboot_dma.bin kvmvapic.bin %.o: %.S $(call quiet-command,$(CPP) $(QEMU_INCLUDES) $(QEMU_DGFLAGS) -c -o - $< | $(AS) $(ASFLAGS) -o $@," AS $(TARGET_DIR)$@") -ifdef CONFIG_WIN32 -LD_EMULATION = i386pe -else -ifdef CONFIG_BSD -LD_EMULATION = elf_i386_fbsd -else -LD_EMULATION = elf_i386 -endif -endif - %.img: %.o - $(call quiet-command,$(LD) $(LDFLAGS_NOPIE) -m $(LD_EMULATION) -Ttext 0 -e _start -s -o $@ $<," Building $(TARGET_DIR)$@") + $(call quiet-command,$(LD) $(LDFLAGS_NOPIE) -m $(LD_I386_EMULATION) -Ttext 0 -e _start -s -o $@ $<," Building $(TARGET_DIR)$@") %.raw: %.img $(call quiet-command,$(OBJCOPY) -O binary -j .text $< $@," Building $(TARGET_DIR)$@")