Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 51369 - qemu fails to link statically
Summary: qemu fails to link statically
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: x86 Linux
: High major
Assignee: Luca Barbato
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-05-18 02:07 UTC by Joseph
Modified: 2004-09-01 15:17 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph 2004-05-18 02:07:43 UTC
the ebuilds need to include the '--enable-shared --enable-static' flags to be passed to configure for the libggi, libgii and libsdl packages so that other applications such as qemu can compile correctly, this is not the only application but just one that is in portage that can be built if these flags are set. I have manually added these lines to the myconf variable in the ebuilds on my test system, re-emerged those packages and now ALL of the applications I have been trying to compile and use work.

Reproducible: Always
Steps to Reproduce:
1.
2.
3.
Comment 1 SpanKY gentoo-dev 2004-05-29 14:19:45 UTC
could you ... oh i dont know ... provide some more useful information ? :P

qemu builds just fine over here with those packages and ive never heard anyone report this 'kind' of problem with libsdl before

in fact, if you look at the output of `./configure --help` you'll see that both shared and static are enabled by default:
  --enable-shared[=PKGS]
                          build shared libraries [default=yes]
  --enable-static[=PKGS]
                          build static libraries [default=yes]
Comment 2 SpanKY gentoo-dev 2004-07-23 23:30:39 UTC
no info
Comment 3 Alexandros Karypidis 2004-08-21 14:59:45 UTC
Hi.

Can you re-open this bug with the following additional info?

I unmasked qemu-0.5.5-r1 to try this newer version and failed to compile it due to a linkage error. While searching for already existing bug-reports I found this one which may be related. Specifically, compilation fails at the following point:

================================ CUT
gcc  -static -Wl,-T,/local/var/tmp/portage/qemu-0.5.5-r1/work/qemu-0.5.5/i386-vl.ld  -o qemu-fast vl.o osdep.o block.o monitor.o ide.o ne2000.o pckbd.o vga.o sb16.o dma.o oss.o fdc.o mc146818rtc.o serial.o i8259.o i8254.o pc.o gdbstub.o sdl.o slirp/cksum.o slirp/if.o slirp/ip_icmp.o slirp/ip_input.o slirp/ip_output.o slirp/slirp.o slirp/mbuf.o slirp/misc.o slirp/sbuf.o slirp/socket.o slirp/tcp_input.o slirp/tcp_output.o slirp/tcp_subr.o slirp/tcp_timer.o slirp/udp.o slirp/bootp.o slirp/debug.o libqemu.a  -lm -L/usr/lib -Wl,-rpath,/usr/lib -lSDL -lpthread -lm -ldl -lasound -L/usr/X11R6/lib -lX11 -lXext -lvga -lutil
/usr/lib/libSDL.a(SDL_loadso.o)(.text+0x1b): In function `SDL_LoadObject':
: warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/../../../../i686-pc-linux-gnu/bin/ld: cannot find -lasound
collect2: ld returned 1 exit status
make[1]: *** [qemu-fast] Error 1
make[1]: Leaving directory `/local/var/tmp/portage/qemu-0.5.5-r1/work/qemu-0.5.5/i386'
make: *** [all] Error 1
================================ CUT

Maybe the original reporter got confused by the SDL-related warning, but if you look at the output the real error is related to no being able to link against libasound (ALSA). Now, on my system, I had emerged package alsa-lib without the "static" USE flag:

================================ CUT
dawn portage # emerge -vp alsa-lib

These are the packages that I would merge, in order:

Calculating dependencies ...done!
[ebuild   R   ] media-libs/alsa-lib-1.0.5-r3  -jack -static  563 kB

Total size of downloads: 563 kB

================================ CUT

To double-check, I re-emerged alsa-lib after adding "static" for alsa-lib to /etc/portage.use. So therefore now:

================================ CUT
dawn portage # emerge -vp alsa-lib

These are the packages that I would merge, in order:

Calculating dependencies ...done!
[ebuild   R   ] media-libs/alsa-lib-1.0.5-r3  -jack +static  0 kB

Total size of downloads: 0 kB
================================ CUT

Indeed, the compilation gets further down, but still fails with:

================================ CUT
ar rcs libqemu.a exec.o translate-all.o cpu-exec.o translate.o op.o helper.o helper2.o translate-copy.o disas.o  i386-dis.o
gcc  -static -Wl,-T,/local/var/tmp/portage/qemu-0.5.5-r1/work/qemu-0.5.5/i386-vl.ld  -o qemu-fast vl.o osdep.o block.o monitor.o ide.o ne2000.o pckbd.o vga.o sb16.o dma.o oss.o fdc.o mc146818rtc.o serial.o i8259.o i8254.o pc.o gdbstub.o sdl.o slirp/cksum.o slirp/if.o slirp/ip_icmp.o slirp/ip_input.o slirp/ip_output.o slirp/slirp.o slirp/mbuf.o slirp/misc.o slirp/sbuf.o slirp/socket.o slirp/tcp_input.o slirp/tcp_output.o slirp/tcp_subr.o slirp/tcp_timer.o slirp/udp.o slirp/bootp.o slirp/debug.o libqemu.a  -lm -L/usr/lib -Wl,-rpath,/usr/lib -lSDL -lpthread -lm -ldl -lasound -L/usr/X11R6/lib -lX11 -lXext -lvga -lutil
/usr/lib/libSDL.a(SDL_loadso.o)(.text+0x1b): In function `SDL_LoadObject':
: warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
slirp/misc.o(.text+0x2a): In function `getouraddr':
/local/var/tmp/portage/qemu-0.5.5-r1/work/qemu-0.5.5/slirp/misc.c:96: warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/X11R6/lib/libX11.a(x11trans.o)(.text+0x7de): In function `_X11TransSocketINETConnect':
: warning: Using 'getservbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/libSDL.a(SDL_alsa_audio.o)(.text+0x514): In function `ALSA_OpenAudio':
: undefined reference to `snd_pcm_hw_params_set_rate_near@ALSA_0.9'
/usr/lib/libSDL.a(SDL_alsa_audio.o)(.text+0x54d): In function `ALSA_OpenAudio':
: undefined reference to `snd_pcm_hw_params_set_period_size_near@ALSA_0.9'
/usr/lib/libSDL.a(SDL_alsa_audio.o)(.text+0x57e): In function `ALSA_OpenAudio':
: undefined reference to `snd_pcm_hw_params_set_periods_near@ALSA_0.9'
/usr/lib/libSDL.a(SDL_alsa_audio.o)(.text+0x67b): In function `ALSA_OpenAudio':
: undefined reference to `snd_pcm_hw_params_get_channels@ALSA_0.9'
collect2: ld returned 1 exit status
make[1]: *** [qemu-fast] Error 1
make[1]: Leaving directory `/local/var/tmp/portage/qemu-0.5.5-r1/work/qemu-0.5.5/i386'
make: *** [all] Error 1
================================ CUT

I then tried to set USE=-static and emerge qemu hoping that no statically-linked version is produced. During the build, I noticed the following output in the very begining:

================================ CUT
dawn portage # emerge qemu
Calculating dependencies ...done!
>>> emerge (1 of 1) app-emulation/qemu-0.5.5-r1 to /
>>> md5 src_uri ;-) qemu-0.5.5.tar.gz
>>> Unpacking source...
>>> Unpacking qemu-0.5.5.tar.gz to /local/var/tmp/portage/qemu-0.5.5-r1/work
>>> Source unpacked.
softmmu
qemu-fast
Install prefix    /usr
BIOS directory    /usr/share/qemu
binary directory  /usr/bin
Manual directory  /usr/share/man
ELF interp prefix /usr/gnemul/qemu-%M
Source path       /local/var/tmp/portage/qemu-0.5.5-r1/work/qemu-0.5.5
C compiler        gcc
make              make
host CPU          i386
host big endian   no
target list       arm-user i386-user ppc-user sparc-user i386-softmmu ppc-softmmu i386
gprof enabled     no
!!! --> static build      no
SDL support       yes
!!! --> SDL static link   yes
mingw32 support   no
================================ CUT

Notice the lines marked with "!!! --> " above. As you can see there are 2 parameters for static/shared linkage for qemu. In short (I'm not very familiar with ebuilds but...) I think that qemu should check if the static USE flag is set and disable both "static build" and "SDL static link".

Anyway, I insisted on trying to find a USE flags combination that works for qemu. I therefore re-emerged libsdl setting USE=static to make sure that no conflicts among SDL and ALSA exist due to emerging the static ALSA _after_ SDL (which was already on my system) but I still get the same last error.

Finally, I tried to emerge qemu with USE="-sdl -static" but this did not seem to disable SDL support for QEMU.
Comment 4 SpanKY gentoo-dev 2004-08-21 23:55:25 UTC
qemu-0.6.0 emerged just fine for me ... give that a run and i'll review the system specific info on my machine versus yours
Comment 5 Alexandros Karypidis 2004-08-22 03:13:37 UTC
Some more info on this. It could be a bug in libSDL. See this posting on the QEMU mailing list:

http://lists.gnu.org/archive/html/qemu-devel/2004-04/msg00021.html
Comment 6 Alexandros Karypidis 2004-08-22 03:48:48 UTC
Hi again,

I tried to emerge qemu 0.6.0 and the results are as follows:

Full-featured: softmmu qemu-fast sdl
======================================
dawn portage # USE="softmmu qemu-fast sdl" emerge qemu
Calculating dependencies ...done!
>>> emerge (1 of 1) app-emulation/qemu-0.6.0 to /
[....]
gcc  -static -Wl,-T,/local/var/tmp/portage/qemu-0.6.0/work/qemu-0.6.0/i386-vl.ld  -o qemu-fast vl.o osdep.o block.o monitor.o pci.o ide.o ne2000.o pckbd.o vga.o sb16.o dma.o oss.o fdc.o mc146818rtc.o serial.o i8259.o i8254.o pc.o cirrus_vga.o gdbstub.o sdl.o slirp/cksum.o slirp/if.o slirp/ip_icmp.o slirp/ip_input.o slirp/ip_output.o slirp/slirp.o slirp/mbuf.o slirp/misc.o slirp/sbuf.o slirp/socket.o slirp/tcp_input.o slirp/tcp_output.o slirp/tcp_subr.o slirp/tcp_timer.o slirp/udp.o slirp/bootp.o slirp/debug.o libqemu.a  -lm -L/usr/lib -Wl,-rpath,/usr/lib -lSDL -lpthread -lm -ldl -lasound -L/usr/X11R6/lib -lX11 -lXext -lvga -lutil
/usr/lib/libSDL.a(SDL_loadso.o)(.text+0x1b): In function `SDL_LoadObject':
: warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
slirp/misc.o(.text+0x2a): In function `getouraddr':
/local/var/tmp/portage/qemu-0.6.0/work/qemu-0.6.0/slirp/misc.c:96: warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/X11R6/lib/libX11.a(x11trans.o)(.text+0x7de): In function `_X11TransSocketINETConnect':
: warning: Using 'getservbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/libSDL.a(SDL_alsa_audio.o)(.text+0x514): In function `ALSA_OpenAudio':
: undefined reference to `snd_pcm_hw_params_set_rate_near@ALSA_0.9'
/usr/lib/libSDL.a(SDL_alsa_audio.o)(.text+0x54d): In function `ALSA_OpenAudio':
: undefined reference to `snd_pcm_hw_params_set_period_size_near@ALSA_0.9'
/usr/lib/libSDL.a(SDL_alsa_audio.o)(.text+0x57e): In function `ALSA_OpenAudio':
: undefined reference to `snd_pcm_hw_params_set_periods_near@ALSA_0.9'
/usr/lib/libSDL.a(SDL_alsa_audio.o)(.text+0x67b): In function `ALSA_OpenAudio':
: undefined reference to `snd_pcm_hw_params_get_channels@ALSA_0.9'
collect2: ld returned 1 exit status
make[1]: *** [qemu-fast] Error 1
make[1]: Leaving directory `/local/var/tmp/portage/qemu-0.6.0/work/qemu-0.6.0/i386'
make: *** [all] Error 1

!!! ERROR: app-emulation/qemu-0.6.0 failed.
!!! Function src_compile, Line 45, Exitcode 2
!!! make failed

dawn portage #
======================================




qemu-fast only: -softmmu qemu-fast sdl
======================================
Same error as above
======================================




softmmu-only: softmmu -qemu-fast sdl
======================================
Success
======================================


Both qemu-fast & softmmu but NO sdl
======================================
Success
======================================



So, as suggested in the mailing list posting I mentioned on my previous comment, It seems to be an issue with SDL and qemu-fast. What version of libsdl are you using? Mine is:

======================================
dawn qemu-0.6.0 # emerge -vp libsdl

These are the packages that I would merge, in order:

Calculating dependencies ...done!
[ebuild   R   ] media-libs/libsdl-1.2.7-r1  +X -aalib +alsa +arts -dga -directfb -esd -fbcon -ggi -libcaca -nas -noaudio -nojoystick -novideo +opengl -oss +svga -xinerama +xv  0 kB

Total size of downloads: 0 kB

dawn qemu-0.6.0 #
======================================

I am now going to try with a ~x86 libsdl(1.2.7-r2) and report again.
Comment 7 Alexandros Karypidis 2004-08-22 04:17:25 UTC
libsdl(1.2.7-r2) also fails when both qemu-fast and sdl are active.
Comment 8 SpanKY gentoo-dev 2004-08-22 19:39:15 UTC
so this has nothing to do with sub libraries and everything to do with qemu
Comment 9 Luca Barbato gentoo-dev 2004-08-23 03:25:22 UTC
qemu-fast will be disabled soon, the linker script it uses is at least problematic...
Comment 10 Joseph 2004-09-01 15:17:18 UTC
Sorry was out of the country for a while the problem stems from the libsdl package not making static libraries. It currently only makes dynamic libraries. Changing the ebuild file to pass the static and dynamic build parameters to configure fixes the problem.