Skip to contentSkip to conversation

capstone broke mingw cross build

Qemu-devel Gerd Hoffmann 5 participants 10 messages Nov 3, 2017 – Nov 7, 2017

lore
Share & tools
lore
#0 lore raw

Hi,

see $subject

make: Entering directory `/home/kraxel/projects/qemu/build-win64' mkdir -p dtc/libfdt
mkdir -p dtc/tests
make[1]: `/home/kraxel/projects/qemu/build-win64/capstone/capstone.lib' is up to date.
  LINK    qemu-ga.exe
  LINK    qemu-img.exe /home/kraxel/projects/qemu/build-win64/capstone/capstone.lib: error adding symbols: Archive has no index; run ranlib to add one
collect2: error: ld returned 1 exit status
  LINK    qemu-io.exe
make: *** [qemu-img.exe] Error 1
make: *** Waiting for unfinished jobs.... /home/kraxel/projects/qemu/build-win64/capstone/capstone.lib: error adding symbols: Archive has no index; run ranlib to add one
collect2: error: ld returned 1 exit status
make: *** [qemu-io.exe] Error 1
make: Leaving directory `/home/kraxel/projects/qemu/build-win64'

cheers,
Gerd

#1 lore raw

Hi Gerd,

Quoted 14 lines · Gerd Hoffmann

Hi,

see $subject

make: Entering directory `/home/kraxel/projects/qemu/build-win64' mkdir -p dtc/libfdt
mkdir -p dtc/tests
make[1]: `/home/kraxel/projects/qemu/build-win64/capstone/capstone.lib' is up to date.
  LINK    qemu-ga.exe
  LINK    qemu-img.exe /home/kraxel/projects/qemu/build-win64/capstone/capstone.lib: error adding symbols: Archive has no index; run ranlib to add one
collect2: error: ld returned 1 exit status

Quoted 8 lines

  LINK    qemu-io.exe
make: *** [qemu-img.exe] Error 1
make: *** Waiting for unfinished jobs.... /home/kraxel/projects/qemu/build-win64/capstone/capstone.lib: error adding symbols: Archive has no index; run ranlib to add one
collect2: error: ld returned 1 exit status
make: *** [qemu-io.exe] Error 1
make: Leaving directory `/home/kraxel/projects/qemu/build-win64'

I can't reproduce your error running:

$ docker run --rm -v $(pwd):$(pwd) -w $(pwd) -u $(id -u) \
  qemu:debian-win32-cross bash -c \
  'mkdir -p build/win32 && cd build/win32 && ../../configure
$QEMU_CONFIGURE_OPTS && make qemu-img.exe'
Install prefix    c:/Program Files/QEMU
BIOS directory    c:/Program Files/QEMU
...
GIT submodules    ui/keycodemapdb dtc capstone
C compiler        i686-w64-mingw32.shared-gcc
Host C compiler   cc
C++ compiler      i686-w64-mingw32.shared-g++
Objective-C compiler clang
ARFLAGS           rv
...
capstone          git
mkdir -p dtc/libfdt
mkdir -p dtc/tests
  CC      cs.o
  CC      utils.o
  CC      SStream.o
  CC      MCInstrDesc.o
  CC      MCRegisterInfo.o
  CC      arch/ARM/ARMDisassembler.o
  CC      arch/ARM/ARMInstPrinter.o
  CC      arch/ARM/ARMMapping.o
  CC      arch/ARM/ARMModule.o
  CC      arch/AArch64/AArch64BaseInfo.o
  CC      arch/AArch64/AArch64Disassembler.o
  CC      arch/AArch64/AArch64InstPrinter.o
  CC      arch/AArch64/AArch64Mapping.o
  CC      arch/AArch64/AArch64Module.o
  CC      arch/Mips/MipsDisassembler.o
  CC      arch/Mips/MipsInstPrinter.o
  CC      arch/Mips/MipsMapping.o
  CC      arch/Mips/MipsModule.o
  CC      arch/PowerPC/PPCDisassembler.o
  CC      arch/PowerPC/PPCInstPrinter.o
  CC      arch/PowerPC/PPCMapping.o
  CC      arch/PowerPC/PPCModule.o
  CC      arch/Sparc/SparcDisassembler.o
  CC      arch/Sparc/SparcInstPrinter.o
  CC      arch/Sparc/SparcMapping.o
  CC      arch/Sparc/SparcModule.o
  CC      arch/SystemZ/SystemZDisassembler.o
  CC      arch/SystemZ/SystemZInstPrinter.o
  CC      arch/SystemZ/SystemZMapping.o
  CC      arch/SystemZ/SystemZModule.o
  CC      arch/SystemZ/SystemZMCTargetDesc.o
  CC      arch/X86/X86DisassemblerDecoder.o
  CC      arch/X86/X86Disassembler.o
  CC      arch/X86/X86IntelInstPrinter.o
  CC      arch/X86/X86ATTInstPrinter.o
  CC      arch/X86/X86Mapping.o
  CC      arch/X86/X86Module.o
  CC      arch/XCore/XCoreDisassembler.o
  CC      arch/XCore/XCoreInstPrinter.o
  CC      arch/XCore/XCoreMapping.o
  CC      arch/XCore/XCoreModule.o
  CC      MCInst.o
  AR      capstone.lib
i686-w64-mingw32.shared-ar: creating
/home/phil/source/qemu/build/win32/capstone/capstone.lib
  RC      version.o
...
  GEN     nbd/trace.c
  GEN     scsi/trace.c
mkdir -p dtc/libfdt
mkdir -p dtc/tests
make[1]: '/home/phil/source/qemu/build/win32/capstone/capstone.lib' is
up to date.
  GEN     qemu-img-cmds.h
  CC      qemu-img.o
...
  CC      stubs/xen-hvm.o
  CC      stubs/pci-host-piix.o
  AR      libqemuutil.a
  LINK    qemu-img.exe
$ file build/win32/qemu-img.exe
build/win32/qemu-img.exe: PE32 executable (console) Intel 80386, for MS
Windows

and with:

$ docker run --rm -v $(pwd):$(pwd) -w $(pwd) -u $(id -u) \
  qemu:debian-win64-cross bash -c \
  'mkdir -p build/win64 && cd build/win64 && ../../configure
--cross-prefix=x86_64-w64-mingw32.shared- && make qemu-img.exe'
...
  CC      arch/XCore/XCoreMapping.o
  CC      arch/XCore/XCoreModule.o
  CC      MCInst.o
  AR      capstone.lib
x86_64-w64-mingw32.shared-ar: creating
/home/phil/source/qemu/build/win64/capstone/capstone.lib
  RC      version.o
  GEN     qemu-options.def
...
  AR      libqemuutil.a
  LINK    qemu-img.exe
$ file build/win64/qemu-img.exe
build/win64/qemu-img.exe: PE32+ executable (console) x86-64, for MS Windows

What mingw toolchain are you using?

Regards,

Phil.

#3 lore raw
In reply to Gerd Hoffmann
Quoted 14 lines · Gerd Hoffmann

Hi,

see $subject

make: Entering directory `/home/kraxel/projects/qemu/build-win64' mkdir -p dtc/libfdt
mkdir -p dtc/tests
make[1]: `/home/kraxel/projects/qemu/build-win64/capstone/capstone.lib' is up to date.
LINK qemu-ga.exe
LINK qemu-img.exe
/home/kraxel/projects/qemu/build-win64/capstone/capstone.lib: error adding symbols: Archive has no index; run ranlib to add one
collect2: error: ld returned 1 exit status

Quoted 8 lines

LINK qemu-io.exe
make: *** [qemu-img.exe] Error 1
make: *** Waiting for unfinished jobs.... /home/kraxel/projects/qemu/build-win64/capstone/capstone.lib: error adding symbols: Archive has no index; run ranlib to add one
collect2: error: ld returned 1 exit status
make: *** [qemu-io.exe] Error 1
make: Leaving directory `/home/kraxel/projects/qemu/build-win64'

Works for me for the crossbuild I do with mingw64, so I wonder what's different about your setup?

thanks
-- PMM

#2 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 26 lines · * Philippe Mathieu-Daudé ([email protected]) wrote:

Hi Gerd,

Quoted 14 lines · Gerd Hoffmann

Hi,

see $subject

make: Entering directory `/home/kraxel/projects/qemu/build-win64' mkdir -p dtc/libfdt
mkdir -p dtc/tests
make[1]: `/home/kraxel/projects/qemu/build-win64/capstone/capstone.lib' is up to date.
  LINK    qemu-ga.exe
  LINK    qemu-img.exe /home/kraxel/projects/qemu/build-win64/capstone/capstone.lib: error adding symbols: Archive has no index; run ranlib to add one
collect2: error: ld returned 1 exit status

Quoted 8 lines

  LINK    qemu-io.exe
make: *** [qemu-img.exe] Error 1
make: *** Waiting for unfinished jobs.... /home/kraxel/projects/qemu/build-win64/capstone/capstone.lib: error adding symbols: Archive has no index; run ranlib to add one
collect2: error: ld returned 1 exit status
make: *** [qemu-io.exe] Error 1
make: Leaving directory `/home/kraxel/projects/qemu/build-win64'

Quoted 1 line

I can't reproduce your error running:

I had the same problem as Gerd with my fedora23 mingw build.

Dave

Quoted 103 lines
$ docker run --rm -v $(pwd):$(pwd) -w $(pwd) -u $(id -u) \
  qemu:debian-win32-cross bash -c \
  'mkdir -p build/win32 && cd build/win32 && ../../configure
$QEMU_CONFIGURE_OPTS && make qemu-img.exe'
Install prefix    c:/Program Files/QEMU
BIOS directory    c:/Program Files/QEMU
...
GIT submodules    ui/keycodemapdb dtc capstone
C compiler        i686-w64-mingw32.shared-gcc
Host C compiler   cc
C++ compiler      i686-w64-mingw32.shared-g++
Objective-C compiler clang
ARFLAGS           rv
...
capstone          git
mkdir -p dtc/libfdt
mkdir -p dtc/tests
  CC      cs.o
  CC      utils.o
  CC      SStream.o
  CC      MCInstrDesc.o
  CC      MCRegisterInfo.o
  CC      arch/ARM/ARMDisassembler.o
  CC      arch/ARM/ARMInstPrinter.o
  CC      arch/ARM/ARMMapping.o
  CC      arch/ARM/ARMModule.o
  CC      arch/AArch64/AArch64BaseInfo.o
  CC      arch/AArch64/AArch64Disassembler.o
  CC      arch/AArch64/AArch64InstPrinter.o
  CC      arch/AArch64/AArch64Mapping.o
  CC      arch/AArch64/AArch64Module.o
  CC      arch/Mips/MipsDisassembler.o
  CC      arch/Mips/MipsInstPrinter.o
  CC      arch/Mips/MipsMapping.o
  CC      arch/Mips/MipsModule.o
  CC      arch/PowerPC/PPCDisassembler.o
  CC      arch/PowerPC/PPCInstPrinter.o
  CC      arch/PowerPC/PPCMapping.o
  CC      arch/PowerPC/PPCModule.o
  CC      arch/Sparc/SparcDisassembler.o
  CC      arch/Sparc/SparcInstPrinter.o
  CC      arch/Sparc/SparcMapping.o
  CC      arch/Sparc/SparcModule.o
  CC      arch/SystemZ/SystemZDisassembler.o
  CC      arch/SystemZ/SystemZInstPrinter.o
  CC      arch/SystemZ/SystemZMapping.o
  CC      arch/SystemZ/SystemZModule.o
  CC      arch/SystemZ/SystemZMCTargetDesc.o
  CC      arch/X86/X86DisassemblerDecoder.o
  CC      arch/X86/X86Disassembler.o
  CC      arch/X86/X86IntelInstPrinter.o
  CC      arch/X86/X86ATTInstPrinter.o
  CC      arch/X86/X86Mapping.o
  CC      arch/X86/X86Module.o
  CC      arch/XCore/XCoreDisassembler.o
  CC      arch/XCore/XCoreInstPrinter.o
  CC      arch/XCore/XCoreMapping.o
  CC      arch/XCore/XCoreModule.o
  CC      MCInst.o
  AR      capstone.lib
i686-w64-mingw32.shared-ar: creating
/home/phil/source/qemu/build/win32/capstone/capstone.lib
  RC      version.o
...
  GEN     nbd/trace.c
  GEN     scsi/trace.c
mkdir -p dtc/libfdt
mkdir -p dtc/tests
make[1]: '/home/phil/source/qemu/build/win32/capstone/capstone.lib' is
up to date.
  GEN     qemu-img-cmds.h
  CC      qemu-img.o
...
  CC      stubs/xen-hvm.o
  CC      stubs/pci-host-piix.o
  AR      libqemuutil.a
  LINK    qemu-img.exe
$ file build/win32/qemu-img.exe
build/win32/qemu-img.exe: PE32 executable (console) Intel 80386, for MS
Windows

and with:

$ docker run --rm -v $(pwd):$(pwd) -w $(pwd) -u $(id -u) \
  qemu:debian-win64-cross bash -c \
  'mkdir -p build/win64 && cd build/win64 && ../../configure
--cross-prefix=x86_64-w64-mingw32.shared- && make qemu-img.exe'
...
  CC      arch/XCore/XCoreMapping.o
  CC      arch/XCore/XCoreModule.o
  CC      MCInst.o
  AR      capstone.lib
x86_64-w64-mingw32.shared-ar: creating
/home/phil/source/qemu/build/win64/capstone/capstone.lib
  RC      version.o
  GEN     qemu-options.def
...
  AR      libqemuutil.a
  LINK    qemu-img.exe
$ file build/win64/qemu-img.exe
build/win64/qemu-img.exe: PE32+ executable (console) x86-64, for MS Windows
Quoted 6 lines

What mingw toolchain are you using?

Regards,

Phil.

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#4 lore raw
In reply to Peter Maydell

Hi,

Quoted 2 lines

Works for me for the crossbuild I do with mingw64, so I wonder what's different about your setup?

It's RHEL-7, with the mingw packages from epel.

For some reason just using x86_64-w64-mingw32-ar seems to not be enough. When running "x86_64-w64-mingw32-ranlib capstone/capstone.lib" (as suggested by the error msg) manually, then kick "make" again the build finishes successfully.

"x86_64-w64-mingw32-ar --version" says "GNU ar (GNU Binutils) 2.25"

cheers,
Gerd

#5 lore raw
Quoted 11 lines · Gerd Hoffmann
Quoted 2 lines

Works for me for the crossbuild I do with mingw64, so I wonder what's different about your setup?

It's RHEL-7, with the mingw packages from epel.

For some reason just using x86_64-w64-mingw32-ar seems to not be enough. When running "x86_64-w64-mingw32-ranlib capstone/capstone.lib" (as suggested by the error msg) manually, then kick "make" again the build finishes successfully.

"x86_64-w64-mingw32-ar --version" says "GNU ar (GNU Binutils) 2.25"

Hmm, I guess this 'ar' isn't capable of avoiding the requirement for ranlib. The capstone makefiles look like they have support for running ranlib, though...

Probably unrelatedly, when you build on OSX ranlib complains a lot:
AR libcapstone.a
ar: creating archive /Users/pm215/src/qemu/build/x86/capstone/libcapstone.a /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib:
file: /Users/pm215/src/qemu/build/x86/capstone/libcapstone.a(MipsDisassembler.o) has no symbols /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib:
file: /Users/pm215/src/qemu/build/x86/capstone/libcapstone.a(MipsInstPrinter.o) has no symbols
[etc etc etc for 40 or 50 files] /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib:
file: /Users/pm215/src/qemu/build/x86/capstone/libcapstone.a(XCoreModule.o)
has no symbols

thanks
-- PMM

#6 lore raw

Hi,

Quoted 5 lines
Quoted 1 line

"x86_64-w64-mingw32-ar --version" says "GNU ar (GNU Binutils) 2.25"

Hmm, I guess this 'ar' isn't capable of avoiding the requirement for ranlib. The capstone makefiles look like they have support for running ranlib, though...

Ah, the recursive call in the qemu Makefile doesn't set RANLIB. So it probably works if that happens to be set correctly in the environment. I'm using 'configure --cross-prefix=x86_64-w64-mingw32-' for cross builds though.

cheers,
Gerd

#7 lore raw
Quoted 4 lines · Gerd Hoffmann

Hi,

Quoted 2 lines
Quoted 1 line

"x86_64-w64-mingw32-ar --version" says "GNU ar (GNU Binutils) 2.25"

Quoted 8 lines
Quoted 3 lines

Hmm, I guess this 'ar' isn't capable of avoiding the requirement for ranlib. The capstone makefiles look like they have support for running ranlib, though...

Ah, the recursive call in the qemu Makefile doesn't set RANLIB. So it probably works if that happens to be set correctly in the environment. I'm using 'configure --cross-prefix=x86_64-w64-mingw32-' for cross builds though.

I'm seeing the same problem on RHEL7.2 as well. Did you find a nicer solution then manually running runlib?

Thanks,
Alistair

Quoted 5 lines

cheers,
Gerd

#8 lore raw
Quoted 9 lines · Alistair Francis
Quoted 8 lines · Gerd Hoffmann

Hi,

Quoted 5 lines
Quoted 1 line

"x86_64-w64-mingw32-ar --version" says "GNU ar (GNU Binutils) 2.25"

Hmm, I guess this 'ar' isn't capable of avoiding the requirement for ranlib. The capstone makefiles look like they have support for running ranlib, though...

Quoted 7 lines
Quoted 4 lines

Ah, the recursive call in the qemu Makefile doesn't set RANLIB. So it probably works if that happens to be set correctly in the environment. I'm using 'configure --cross-prefix=x86_64-w64-mingw32-' for cross builds though.

I'm seeing the same problem on RHEL7.2 as well. Did you find a nicer solution then manually running runlib?

Does adding RANLIB to the Makefile rune that calls the capstone makefile work? (I guess we might need to set it up in configure too.)

thanks
-- PMM

#9 lore raw
Quoted 15 lines · Peter Maydell
Quoted 14 lines · Alistair Francis
Quoted 12 lines · Gerd Hoffmann

Hi,

Quoted 5 lines
Quoted 1 line

"x86_64-w64-mingw32-ar --version" says "GNU ar (GNU Binutils) 2.25"

Hmm, I guess this 'ar' isn't capable of avoiding the requirement for ranlib. The capstone makefiles look like they have support for running ranlib, though...

Ah, the recursive call in the qemu Makefile doesn't set RANLIB. So it probably works if that happens to be set correctly in the environment. I'm using 'configure --cross-prefix=x86_64-w64-mingw32-' for cross builds though.

Quoted 5 lines
Quoted 2 lines

I'm seeing the same problem on RHEL7.2 as well. Did you find a nicer solution then manually running runlib?

Does adding RANLIB to the Makefile rune that calls the capstone makefile work? (I guess we might need to set it up in configure too.)

It does, I'll send a patch out.

Thanks for the help Peter

Alistair

Quoted 3 lines

thanks
-- PMM