Skip to contentSkip to conversation

configure: Try to fix --static linking

PATCH Superseded Philippe Mathieu-Daudé 4 participants 15 messages Jun 14, 2019

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover configure: Try to fix --static linking

Hi,

Apparently QEMU static linking is slowly bitroting. Obviously it depends the libraries an user has installed, anyway it seems there are not much testing done.

This series fixes few issues, enough to build QEMU on a Ubuntu aarch64 host, but not yet on a x86_64 host:

    LINK    x86_64-softmmu/qemu-system-x86_64

/usr/bin/ld: cannot find -lgtk-3
/usr/bin/ld: cannot find -latk-bridge-2.0
/usr/bin/ld: cannot find -latspi
/usr/bin/ld: cannot find -lsystemd
/usr/bin/ld: cannot find -lgdk-3
/usr/bin/ld: cannot find -lwayland-egl
/usr/bin/ld: cannot find -lmirclient
/usr/bin/ld: cannot find -lmircore
/usr/bin/ld: cannot find -lmircookie
/usr/bin/ld: cannot find -lepoxy
/usr/bin/ld: cannot find -latk-1.0
/usr/bin/ld: cannot find -lgdk_pixbuf-2.0
/usr/bin/ld: cannot find -lselinux
/usr/bin/ld: cannot find -lgtk-3
/usr/bin/ld: cannot find -latk-bridge-2.0
/usr/bin/ld: cannot find -latspi
/usr/bin/ld: cannot find -lsystemd
/usr/bin/ld: cannot find -lgdk-3
/usr/bin/ld: cannot find -lwayland-egl
/usr/bin/ld: cannot find -lmirclient
/usr/bin/ld: cannot find -lmircore
/usr/bin/ld: cannot find -lmircookie
/usr/bin/ld: cannot find -lepoxy
/usr/bin/ld: cannot find -latk-1.0
/usr/bin/ld: cannot find -lgdk_pixbuf-2.0
/usr/bin/ld: cannot find -lselinux
/usr/bin/ld: attempted static link of dynamic object `/usr/lib/x86_64-linux-gnu/libz.so'
collect2: error: ld returned 1 exit status

Regards,

Phil.

Philippe Mathieu-Daudé (6):
configure: Only generate GLUSTERFS variables if glusterfs is usable
configure: Link test before auto-enabling glusterfs libraries
configure: Link test before auto-enabling the libusb library
configure: Link test before auto-enabling the libusbredir library
configure: Link test before auto-enabling the pulseaudio library .travis.yml: Test static linking

 .travis.yml |   5 +++
 configure   | 113 +++++++++++++++++++++++++++++++++++++++-------------
 2 files changed, 90 insertions(+), 28 deletions(-)
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/6 configure: Only generate GLUSTERFS variables if glusterfs is usable

It is pointless and confusing to have GLUSTERFS variables in config-host.mak when glusterfs is not usable.

---
 configure | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)
configure +18 -18
index b091b82cb3..13fd4a1166 100755
@@ -7118,30 +7118,30 @@ if test "$glusterfs" = "yes" ; then
   echo "CONFIG_GLUSTERFS=m" >> $config_host_mak
   echo "GLUSTERFS_CFLAGS=$glusterfs_cflags" >> $config_host_mak
   echo "GLUSTERFS_LIBS=$glusterfs_libs" >> $config_host_mak
-fi
 
-if test "$glusterfs_xlator_opt" = "yes" ; then
-  echo "CONFIG_GLUSTERFS_XLATOR_OPT=y" >> $config_host_mak
-fi
+  if test "$glusterfs_xlator_opt" = "yes" ; then
+    echo "CONFIG_GLUSTERFS_XLATOR_OPT=y" >> $config_host_mak
+  fi
 
-if test "$glusterfs_discard" = "yes" ; then
-  echo "CONFIG_GLUSTERFS_DISCARD=y" >> $config_host_mak
-fi
+  if test "$glusterfs_discard" = "yes" ; then
+    echo "CONFIG_GLUSTERFS_DISCARD=y" >> $config_host_mak
+  fi
 
-if test "$glusterfs_fallocate" = "yes" ; then
-  echo "CONFIG_GLUSTERFS_FALLOCATE=y" >> $config_host_mak
-fi
+  if test "$glusterfs_fallocate" = "yes" ; then
+    echo "CONFIG_GLUSTERFS_FALLOCATE=y" >> $config_host_mak
+  fi
 
-if test "$glusterfs_zerofill" = "yes" ; then
-  echo "CONFIG_GLUSTERFS_ZEROFILL=y" >> $config_host_mak
-fi
+  if test "$glusterfs_zerofill" = "yes" ; then
+    echo "CONFIG_GLUSTERFS_ZEROFILL=y" >> $config_host_mak
+  fi
 
-if test "$glusterfs_ftruncate_has_stat" = "yes" ; then
-  echo "CONFIG_GLUSTERFS_FTRUNCATE_HAS_STAT=y" >> $config_host_mak
-fi
+  if test "$glusterfs_ftruncate_has_stat" = "yes" ; then
+    echo "CONFIG_GLUSTERFS_FTRUNCATE_HAS_STAT=y" >> $config_host_mak
+  fi
 
-if test "$glusterfs_iocb_has_stat" = "yes" ; then
-  echo "CONFIG_GLUSTERFS_IOCB_HAS_STAT=y" >> $config_host_mak
+  if test "$glusterfs_iocb_has_stat" = "yes" ; then
+    echo "CONFIG_GLUSTERFS_IOCB_HAS_STAT=y" >> $config_host_mak
+  fi
 fi
 
 if test "$libssh2" = "yes" ; then
Signature · 1 line
2.20.1
Reviewed-by on v1 1/6
#2 lore raw

Re: [Qemu-devel] [PATCH 1/6] configure: Only generate GLUSTERFS variables if glusterfs is usable

Quoted 4 lines · Philippe Mathieu-Daudé

It is pointless and confusing to have GLUSTERFS variables in config-host.mak when glusterfs is not usable.

Looks good to me, thanks.

Quoted 60 lines
---
 configure | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)
configure +18 -18
index b091b82cb3..13fd4a1166 100755
@@ -7118,30 +7118,30 @@ if test "$glusterfs" = "yes" ; then
   echo "CONFIG_GLUSTERFS=m" >> $config_host_mak
   echo "GLUSTERFS_CFLAGS=$glusterfs_cflags" >> $config_host_mak
   echo "GLUSTERFS_LIBS=$glusterfs_libs" >> $config_host_mak
-fi
 
-if test "$glusterfs_xlator_opt" = "yes" ; then
-  echo "CONFIG_GLUSTERFS_XLATOR_OPT=y" >> $config_host_mak
-fi
+  if test "$glusterfs_xlator_opt" = "yes" ; then
+    echo "CONFIG_GLUSTERFS_XLATOR_OPT=y" >> $config_host_mak
+  fi
 
-if test "$glusterfs_discard" = "yes" ; then
-  echo "CONFIG_GLUSTERFS_DISCARD=y" >> $config_host_mak
-fi
+  if test "$glusterfs_discard" = "yes" ; then
+    echo "CONFIG_GLUSTERFS_DISCARD=y" >> $config_host_mak
+  fi
 
-if test "$glusterfs_fallocate" = "yes" ; then
-  echo "CONFIG_GLUSTERFS_FALLOCATE=y" >> $config_host_mak
-fi
+  if test "$glusterfs_fallocate" = "yes" ; then
+    echo "CONFIG_GLUSTERFS_FALLOCATE=y" >> $config_host_mak
+  fi
 
-if test "$glusterfs_zerofill" = "yes" ; then
-  echo "CONFIG_GLUSTERFS_ZEROFILL=y" >> $config_host_mak
-fi
+  if test "$glusterfs_zerofill" = "yes" ; then
+    echo "CONFIG_GLUSTERFS_ZEROFILL=y" >> $config_host_mak
+  fi
 
-if test "$glusterfs_ftruncate_has_stat" = "yes" ; then
-  echo "CONFIG_GLUSTERFS_FTRUNCATE_HAS_STAT=y" >> $config_host_mak
-fi
+  if test "$glusterfs_ftruncate_has_stat" = "yes" ; then
+    echo "CONFIG_GLUSTERFS_FTRUNCATE_HAS_STAT=y" >> $config_host_mak
+  fi
 
-if test "$glusterfs_iocb_has_stat" = "yes" ; then
-  echo "CONFIG_GLUSTERFS_IOCB_HAS_STAT=y" >> $config_host_mak
+  if test "$glusterfs_iocb_has_stat" = "yes" ; then
+    echo "CONFIG_GLUSTERFS_IOCB_HAS_STAT=y" >> $config_host_mak
+  fi
 fi
 
 if test "$libssh2" = "yes" ; then
Signature · 1 line
2.20.1
#3 lore raw

PATCH 2/6 configure: Link test before auto-enabling glusterfs libraries

In reply to Philippe Mathieu-Daudé

Similarly to commit a73e82ef912, test the libraries link correctly before considering them as usable.

This fixes using ./configure --static on Ubuntu 18.04:

  $ make subdir-aarch64-softmmu
  [...]
    LINK    aarch64-softmmu/qemu-system-aarch64
  /usr/bin/ld: cannot find -lgfapi
  /usr/bin/ld: cannot find -lglusterfs
  /usr/bin/ld: cannot find -lgfrpc
  /usr/bin/ld: cannot find -lgfxdr
  collect2: error: ld returned 1 exit status
  Makefile:204: recipe for target 'qemu-system-aarch64' failed
  make[1]: *** [qemu-system-aarch64] Error 1
  $ fgrep gf config-host.mak
  GLUSTERFS_LIBS=-lacl -lgfapi -lglusterfs -lgfrpc -lgfxdr -luuid
  $ lsb_release -cri
  Distributor ID: Ubuntu
  Release:        18.04
  Codename:       bionic
---
 configure | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
configure +16 -2
index 13fd4a1166..3428adb75b 100755
@@ -4179,9 +4179,23 @@ fi
 # glusterfs probe
 if test "$glusterfs" != "no" ; then
   if $pkg_config --atleast-version=3 glusterfs-api; then
-    glusterfs="yes"
     glusterfs_cflags=$($pkg_config --cflags glusterfs-api)
-    glusterfs_libs=$($pkg_config --libs glusterfs-api)
+    if test "$static" = "yes"; then
+        glusterfs_libs=$($pkg_config --libs --static glusterfs-api)
+    else
+        glusterfs_libs=$($pkg_config --libs glusterfs-api)
+    fi
+    # Packaging for the static libraries is not always correct.
+    # At least ubuntu 18.04 ships only shared libraries.
+    write_c_skeleton
+    if ! compile_prog "$glusterfs_cflags" "$glusterfs_libs" ; then
+        if test "$glusterfs" = "yes" ; then
+          error_exit "glusterfs check failed."
+        fi
+        glusterfs="no"
+    else
+        glusterfs="yes"
+    fi
     if $pkg_config --atleast-version=4 glusterfs-api; then
       glusterfs_xlator_opt="yes"
     fi
Signature · 1 line
2.20.1
#4 lore raw

Re: [Qemu-devel] [PATCH 2/6] configure: Link test before auto-enabling glusterfs libraries

Quoted 35 lines · Philippe Mathieu-Daudé

Similarly to commit a73e82ef912, test the libraries link correctly before considering them as usable.

This fixes using ./configure --static on Ubuntu 18.04:

  $ make subdir-aarch64-softmmu
  [...]
    LINK    aarch64-softmmu/qemu-system-aarch64
  /usr/bin/ld: cannot find -lgfapi
  /usr/bin/ld: cannot find -lglusterfs
  /usr/bin/ld: cannot find -lgfrpc
  /usr/bin/ld: cannot find -lgfxdr
  collect2: error: ld returned 1 exit status
  Makefile:204: recipe for target 'qemu-system-aarch64' failed
  make[1]: *** [qemu-system-aarch64] Error 1
  $ fgrep gf config-host.mak
  GLUSTERFS_LIBS=-lacl -lgfapi -lglusterfs -lgfrpc -lgfxdr -luuid
  $ lsb_release -cri
  Distributor ID: Ubuntu
  Release:        18.04
  Codename:       bionic
---
 configure | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
configure +0 -0
index 13fd4a1166..3428adb75b 100755
@@ -4179,9 +4179,23 @@ fi
 # glusterfs probe

configure fi · line 4187

Quoted 10 lines
configure +5 -2
 if test "$glusterfs" != "no" ; then
   if $pkg_config --atleast-version=3 glusterfs-api; then
-    glusterfs="yes"
     glusterfs_cflags=$($pkg_config --cflags glusterfs-api)
-    glusterfs_libs=$($pkg_config --libs glusterfs-api)
+    if test "$static" = "yes"; then
+        glusterfs_libs=$($pkg_config --libs --static glusterfs-api)
+    else
+        glusterfs_libs=$($pkg_config --libs glusterfs-api)
+    fi

I just noticed in ./configure:

case "$opt" in
--static)
static="yes"
LDFLAGS="-static $LDFLAGS" QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
;;

And

pkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"

query_pkg_config() {
    "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
}

pkg_config=query_pkg_config

So I shouldn't need to test "$static" = "yes" and manually add --static. (same apply to other patches in this series).

I'll see what's wrong...

Quoted 15 lines
configure +11 -0
+    # Packaging for the static libraries is not always correct.
+    # At least ubuntu 18.04 ships only shared libraries.
+    write_c_skeleton
+    if ! compile_prog "$glusterfs_cflags" "$glusterfs_libs" ; then
+        if test "$glusterfs" = "yes" ; then
+          error_exit "glusterfs check failed."
+        fi
+        glusterfs="no"
+    else
+        glusterfs="yes"
+    fi
     if $pkg_config --atleast-version=4 glusterfs-api; then
       glusterfs_xlator_opt="yes"
     fi
#5 lore raw

PATCH 3/6 configure: Link test before auto-enabling the libusb library

In reply to Philippe Mathieu-Daudé

Similarly to commit a73e82ef912, test the library links correctly before considering it as usable.

This fixes using ./configure --static on Ubuntu 18.04:

  $ make subdir-aarch64-softmmu
  [...]
    LINK    aarch64-softmmu/qemu-system-aarch64
  /usr/bin/ld: cannot find -ludev
  collect2: error: ld returned 1 exit status
  Makefile:204: recipe for target 'qemu-system-aarch64' failed
  make[1]: *** [qemu-system-aarch64] Error 1
  $ fgrep udev config-host.mak
  LIBUSB_LIBS=-lusb-1.0 -ludev -pthread
  $ lsb_release -cri
  Distributor ID: Ubuntu
  Release:        18.04
  Codename:       bionic
---
 configure | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
configure +16 -2
index 3428adb75b..e2511df1e3 100755
@@ -4898,9 +4898,23 @@ fi
 # check for libusb
 if test "$libusb" != "no" ; then
     if $pkg_config --atleast-version=1.0.13 libusb-1.0; then
-        libusb="yes"
         libusb_cflags=$($pkg_config --cflags libusb-1.0)
-        libusb_libs=$($pkg_config --libs libusb-1.0)
+        if test "$static" = "yes"; then
+            libusb_libs=$($pkg_config --libs --static libusb-1.0)
+        else
+            libusb_libs=$($pkg_config --libs libusb-1.0)
+        fi
+        # Packaging for the static libraries is not always correct.
+        # At least ubuntu 18.04 ships only shared libraries.
+        write_c_skeleton
+        if ! compile_prog "$libusb_cflags" "$libusb_libs" ; then
+            if test "$libusb" = "yes" ; then
+              error_exit "libusb check failed."
+            fi
+            libusb="no"
+        else
+            libusb="yes"
+        fi
     else
         if test "$libusb" = "yes"; then
             feature_not_found "libusb" "Install libusb devel >= 1.0.13"
Signature · 1 line
2.20.1
#6 lore raw

PATCH 4/6 configure: Link test before auto-enabling the libusbredir library

In reply to Philippe Mathieu-Daudé

Similarly to commit a73e82ef912, test the library links correctly before considering it as usable.

This fixes using ./configure --static on Ubuntu 18.04:

  $ make subdir-aarch64-softmmu
  [...]
    LINK    aarch64-softmmu/qemu-system-aarch64
  /usr/bin/ld: cannot find -lusbredirparser
  collect2: error: ld returned 1 exit status
  Makefile:204: recipe for target 'qemu-system-aarch64' failed
  make[1]: *** [qemu-system-aarch64] Error 1
  $ fgrep redir config-host.mak
  USB_REDIR_LIBS=-lusbredirparser
  $ lsb_release -cri
  Distributor ID: Ubuntu
  Release:        18.04
  Codename:       bionic
---
 configure | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
configure +16 -2
index e2511df1e3..4eed33e1b1 100755
@@ -4926,9 +4926,23 @@ fi
 # check for usbredirparser for usb network redirection support
 if test "$usb_redir" != "no" ; then
     if $pkg_config --atleast-version=0.6 libusbredirparser-0.5; then
-        usb_redir="yes"
         usb_redir_cflags=$($pkg_config --cflags libusbredirparser-0.5)
-        usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5)
+        if test "$static" = "yes"; then
+            usb_redir_libs=$($pkg_config --libs --static libusbredirparser-0.5)
+        else
+            usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5)
+        fi
+        # Packaging for the static libraries is not always correct.
+        # At least ubuntu 18.04 ships only shared libraries.
+        write_c_skeleton
+        if ! compile_prog "$usb_redir_cflags" "$usb_redir_libs" ; then
+            if test "$usb_redir" = "yes" ; then
+              error_exit "usbredir check failed."
+            fi
+            usb_redir="no"
+        else
+            usb_redir="yes"
+        fi
     else
         if test "$usb_redir" = "yes"; then
             feature_not_found "usb-redir" "Install usbredir devel"
Signature · 1 line
2.20.1
#7 lore raw

PATCH 5/6 configure: Link test before auto-enabling the pulseaudio library

In reply to Philippe Mathieu-Daudé

Similarly to commit a73e82ef912, test the library links correctly before considering it as usable.

This fixes using ./configure --static on Ubuntu 18.04:

  $ make subdir-aarch64-softmmu
  [...]
    LINK    aarch64-softmmu/qemu-system-aarch64
  /usr/bin/ld: cannot find -lpulse
  /usr/bin/ld: cannot find -lpulsecommon-11.1
  collect2: error: ld returned 1 exit status
  Makefile:204: recipe for target 'qemu-system-aarch64' failed
  make[1]: *** [qemu-system-aarch64] Error 1
  $ fgrep pulse config-host.mak
  PULSE_LIBS=-L/usr/lib/aarch64-linux-gnu/pulseaudio -lpulse -lpulsecommon-11.1
  $ lsb_release -cri
  Distributor ID: Ubuntu
  Release:        18.04
  Codename:       bionic
---
 configure | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)
configure +19 -4
index 4eed33e1b1..4d015496ae 100755
@@ -3408,10 +3408,25 @@ for drv in $audio_drv_list; do
 
     pa | try-pa)
     if $pkg_config libpulse --exists; then
-        pulse_libs=$($pkg_config libpulse --libs)
-        audio_pt_int="yes"
-        if test "$drv" = "try-pa"; then
-            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-pa/pa/')
+        pulse_cflags=$($pkg_config --cflags libpulse)
+        if test "$static" = "yes"; then
+            pulse_libs=$($pkg_config --libs --static libpulse)
+        else
+            pulse_libs=$($pkg_config --libs libpulse)
+        fi
+        # Packaging for the static libraries is not always correct.
+        # At least ubuntu 18.04 ships only shared libraries.
+        write_c_skeleton
+        if ! compile_prog "$pulse_cflags" "$pulse_libs" ; then
+            unset pulse_cflags pulse_libs
+            if test "$drv" = "try-pa"; then
+                audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-pa//')
+            fi
+        else
+            audio_pt_int="yes"
+            if test "$drv" = "try-pa"; then
+                audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-pa/pa/')
+            fi
         fi
     else
         if test "$drv" = "try-pa"; then
Signature · 1 line
2.20.1
#8 lore raw

PATCH 6/6 .travis.yml: Test static linking

In reply to Philippe Mathieu-Daudé

---
This job currently fails:

LINK lm32-softmmu/qemu-system-lm32
/usr/bin/ld: cannot find -lgtk-3
/usr/bin/ld: cannot find -latk-bridge-2.0
/usr/bin/ld: cannot find -latspi
/usr/bin/ld: cannot find -lsystemd
/usr/bin/ld: cannot find -lgdk-3
/usr/bin/ld: cannot find -lwayland-egl
/usr/bin/ld: cannot find -lmirclient
/usr/bin/ld: cannot find -lmircore
/usr/bin/ld: cannot find -lmircookie
/usr/bin/ld: cannot find -lepoxy
/usr/bin/ld: cannot find -latk-1.0
/usr/bin/ld: cannot find -lgdk_pixbuf-2.0
/usr/bin/ld: cannot find -lselinux
/usr/bin/ld: cannot find -lgtk-3
/usr/bin/ld: cannot find -latk-bridge-2.0
/usr/bin/ld: cannot find -latspi
/usr/bin/ld: cannot find -lsystemd
/usr/bin/ld: cannot find -lgdk-3
/usr/bin/ld: cannot find -lwayland-egl
/usr/bin/ld: cannot find -lmirclient
/usr/bin/ld: cannot find -lmircore
/usr/bin/ld: cannot find -lmircookie
/usr/bin/ld: cannot find -lepoxy
/usr/bin/ld: cannot find -latk-1.0
/usr/bin/ld: cannot find -lgdk_pixbuf-2.0
/usr/bin/ld: cannot find -lselinux
/usr/bin/ld: attempted static link of dynamic object `/usr/lib/x86_64-linux-gnu/libz.so'
collect2: error: ld returned 1 exit status
Makefile:204: recipe for target 'qemu-system-lm32' failed
make[1]: *** [qemu-system-lm32] Error 1
Makefile:472: recipe for target 'subdir-lm32-softmmu' failed
make: *** [subdir-lm32-softmmu] Error 2

---
 .travis.yml | 5 +++++
 1 file changed, 5 insertions(+)
.travis.yml +5 -0
index 08502c0aa2..6962fff826 100644
@@ -92,6 +92,11 @@ matrix:
         - CONFIG="--disable-user --target-list-exclude=${MAIN_SOFTMMU_TARGETS}"
 
 
+    # Test static linking
+    - env:
+        - CONFIG="--static --target-list=lm32-softmmu"
+
+
     # Just build tools and run minimal unit and softfloat checks
     - env:
         - BASE_CONFIG="--enable-tools"
Signature · 1 line
2.20.1
#9 lore raw

Re: [Qemu-devel] [PATCH 6/6] .travis.yml: Test static linking

Quoted 46 lines · Philippe Mathieu-Daudé

---
This job currently fails:

LINK lm32-softmmu/qemu-system-lm32
/usr/bin/ld: cannot find -lgtk-3
/usr/bin/ld: cannot find -latk-bridge-2.0
/usr/bin/ld: cannot find -latspi
/usr/bin/ld: cannot find -lsystemd
/usr/bin/ld: cannot find -lgdk-3
/usr/bin/ld: cannot find -lwayland-egl
/usr/bin/ld: cannot find -lmirclient
/usr/bin/ld: cannot find -lmircore
/usr/bin/ld: cannot find -lmircookie
/usr/bin/ld: cannot find -lepoxy
/usr/bin/ld: cannot find -latk-1.0
/usr/bin/ld: cannot find -lgdk_pixbuf-2.0
/usr/bin/ld: cannot find -lselinux
/usr/bin/ld: cannot find -lgtk-3
/usr/bin/ld: cannot find -latk-bridge-2.0
/usr/bin/ld: cannot find -latspi
/usr/bin/ld: cannot find -lsystemd
/usr/bin/ld: cannot find -lgdk-3
/usr/bin/ld: cannot find -lwayland-egl
/usr/bin/ld: cannot find -lmirclient
/usr/bin/ld: cannot find -lmircore
/usr/bin/ld: cannot find -lmircookie
/usr/bin/ld: cannot find -lepoxy
/usr/bin/ld: cannot find -latk-1.0
/usr/bin/ld: cannot find -lgdk_pixbuf-2.0
/usr/bin/ld: cannot find -lselinux
/usr/bin/ld: attempted static link of dynamic object `/usr/lib/x86_64-linux-gnu/libz.so'
collect2: error: ld returned 1 exit status
Makefile:204: recipe for target 'qemu-system-lm32' failed
make[1]: *** [qemu-system-lm32] Error 1
Makefile:472: recipe for target 'subdir-lm32-softmmu' failed
make: *** [subdir-lm32-softmmu] Error 2

---
 .travis.yml | 5 +++++
 1 file changed, 5 insertions(+)
.travis.yml +0 -0
index 08502c0aa2..6962fff826 100644

.travis.yml matrix: · line 99

Quoted 8 lines
.travis.yml +5 -0
@@ -92,6 +92,11 @@ matrix:
         - CONFIG="--disable-user --target-list-exclude=${MAIN_SOFTMMU_TARGETS}"
 
 
+    # Test static linking
+    - env:
+        - CONFIG="--static --target-list=lm32-softmmu"
+
+

It's probably more useful to have a:

  CONFIG="--disable-system --static"

In fact arguably we could just add it to the first --disable-system stanza as there are other linux-user builds scattered about to catch the cases where we break dynamically linked linux-user builds.

.travis.yml matrix: · line 102

Quoted 3 lines
.travis.yml +0 -0
     # Just build tools and run minimal unit and softfloat checks
     - env:
         - BASE_CONFIG="--enable-tools"

--
Alex Bennée

#10 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 30 lines · Philippe Mathieu-Daudé

Hi,

Apparently QEMU static linking is slowly bitroting. Obviously it depends the libraries an user has installed, anyway it seems there are not much testing done.

This series fixes few issues, enough to build QEMU on a Ubuntu aarch64 host, but not yet on a x86_64 host:

    LINK    x86_64-softmmu/qemu-system-x86_64

/usr/bin/ld: cannot find -lgtk-3
/usr/bin/ld: cannot find -latk-bridge-2.0
/usr/bin/ld: cannot find -latspi
/usr/bin/ld: cannot find -lsystemd
/usr/bin/ld: cannot find -lgdk-3
/usr/bin/ld: cannot find -lwayland-egl
/usr/bin/ld: cannot find -lmirclient
/usr/bin/ld: cannot find -lmircore
/usr/bin/ld: cannot find -lmircookie
/usr/bin/ld: cannot find -lepoxy
/usr/bin/ld: cannot find -latk-1.0
/usr/bin/ld: cannot find -lgdk_pixbuf-2.0
/usr/bin/ld: cannot find -lselinux
/usr/bin/ld: cannot find -lgtk-3
/usr/bin/ld: cannot find -latk-bridge-2.0
/usr/bin/ld: cannot find -latspi
/usr/bin/ld: cannot find -lsystemd
/usr/bin/ld: cannot find -lgdk-3
/usr/bin/ld: cannot find -lwayland-egl
/usr/bin/ld: cannot find -lmirclient

Quoted 8 lines

/usr/bin/ld: cannot find -lmircore
/usr/bin/ld: cannot find -lmircookie
/usr/bin/ld: cannot find -lepoxy
/usr/bin/ld: cannot find -latk-1.0
/usr/bin/ld: cannot find -lgdk_pixbuf-2.0
/usr/bin/ld: cannot find -lselinux
/usr/bin/ld: attempted static link of dynamic object `/usr/lib/x86_64-linux-gnu/libz.so'
collect2: error: ld returned 1 exit status

This one is funny, when installing libvte on Ubuntu 18.04:

    LINK    x86_64-softmmu/qemu-system-x86_64

c++: error: /usr/lib/x86_64-linux-gnu/libunistring.so: No such file or
directory
c++: error: /usr/lib/x86_64-linux-gnu/libunistring.so: No such file or
directory
c++: error: /usr/lib/x86_64-linux-gnu/libunistring.so: No such file or
directory
c++: error: /usr/lib/x86_64-linux-gnu/libunistring.so: No such file or
directory

$ pkg-config --libs --static vte-2.91
-lvte-2.91 -lgtk-3 -latk-bridge-2.0 -latspi -ldbus-1 -lpthread -lsystemd
-lgdk-3 -lXinerama -lXi -lXrandr -lXcursor -lXcomposite -lXdamage
-lXfixes -lxkbcommon -lwayland-cursor -lwayland-egl -lwayland-client
-lepoxy -ldl -lpangocairo-1.0 -lpangoft2-1.0 -lharfbuzz -lm -lgraphite2
-lpango-1.0 -lm -latk-1.0 -lcairo-gobject -lcairo -lz -lpixman-1
-lfontconfig -lexpat -lfreetype -lexpat -lfreetype -lpng16 -lm -lz -lm
-lxcb-shm -lxcb-render -lXrender -lXext -lX11 -lpthread -lxcb -lXau
-lXdmcp -lgdk_pixbuf-2.0 -lm -lpng16 -lm -lz -lm -lgio-2.0 -lz -lresolv
-lselinux -lmount -lgmodule-2.0 -pthread -ldl -lgobject-2.0 -lffi
-lglib-2.0 -pthread -lpcre -pthread -lgnutls -lgmp
/usr/lib/x86_64-linux-gnu/libunistring.so -lidn2 -lhogweed -lgmp
-lnettle -ltasn1 -lp11-kit -lz
$ ls -ld /usr/lib/x86_64-linux-gnu/libunistring.so
ls: cannot access '/usr/lib/x86_64-linux-gnu/libunistring.so': No such
file or directory
$ ls -ld /usr/lib/x86_64-linux-gnu/libunistring.so*
lrwxrwxrwx. 1 root root      21 Mar  3  2018
/usr/lib/x86_64-linux-gnu/libunistring.so.2 -> libunistring.so.2.1.0
-rw-r--r--. 1 root root 1562664 Mar  3  2018
/usr/lib/x86_64-linux-gnu/libunistring.so.2.1.0

The fix is probably "sudo ln -s libunistring.so.2
/usr/lib/x86_64-linux-gnu/libunistring.so".

#11 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 3 lines · Philippe Mathieu-Daudé

Apparently QEMU static linking is slowly bitroting. Obviously it depends the libraries an user has installed, anyway it seems there are not much testing done.

The main reason for supporting static linking is so we can build the user-mode emulators. Almost always the problems with static linking the softmmu binaries and the tools are issues with the distro's packaging of the static libraries (pkg-config files which specify things that don't work for static is a common one).

So we could put in a lot of checking of "is what pkg-config tells us broken". Or we could just say "we don't support static linking for anything except the usermode binaries". We should probably phase in deprecation of that because it's possible somebody's using it seriously, but it seems like a fairly weird thing to do to me.

thanks
-- PMM

#12 lore raw
Quoted 12 lines · Peter Maydell
Quoted 3 lines · Philippe Mathieu-Daudé

Apparently QEMU static linking is slowly bitroting. Obviously it depends the libraries an user has installed, anyway it seems there are not much testing done.

The main reason for supporting static linking is so we can build the user-mode emulators. Almost always the problems with static linking the softmmu binaries and the tools are issues with the distro's packaging of the static libraries (pkg-config files which specify things that don't work for static is a common one).

Quoted 6 lines

So we could put in a lot of checking of "is what pkg-config tells us broken". Or we could just say "we don't support static linking for anything except the usermode binaries". We should probably phase in deprecation of that because it's possible somebody's using it seriously, but it seems like a fairly weird thing to do to me.

It would be nice to have a --static-user config flag and deprecate the --static flag. I don't think there is a decent use case for system emulation targets.

The Gentoo ebuild currently jumps through hoops to build QEMU by doing the build twice, first for softmmu targets and then for user targets. I suspect all of that is mostly to handle the reasonable "static-user" use case which is what people really want*.

*I'm guessing

--
Alex Bennée

#13 lore raw
Quoted 3 lines · Alex Bennée

It would be nice to have a --static-user config flag and deprecate the --static flag. I don't think there is a decent use case for system emulation targets.

It would be really tricky to build half with static and half
without: our configure and build system really assumes that fundamental stuff like "what libraries" and "what compiler flags" are the same across the whole of the build.

Is --static-user really much better than:
* allow --static --disable-system --disable-tools
* forbid --static without --disable-system --disable-tools
* require users to build the static usermode binaries separately from the system/tools build

(which is in practice what we have now) ?

Debian wants both static usermode and non-static usermode binaries, so they'd still need to build multiple times anyway.

thanks
-- PMM

#14 lore raw
Quoted 17 lines · Peter Maydell
Quoted 3 lines · Alex Bennée

It would be nice to have a --static-user config flag and deprecate the --static flag. I don't think there is a decent use case for system emulation targets.

It would be really tricky to build half with static and half
without: our configure and build system really assumes that fundamental stuff like "what libraries" and "what compiler flags" are the same across the whole of the build.

Is --static-user really much better than:
* allow --static --disable-system --disable-tools
* forbid --static without --disable-system --disable-tools
* require users to build the static usermode binaries separately from the system/tools build

Quoted 4 lines

(which is in practice what we have now) ?

Debian wants both static usermode and non-static usermode binaries, so they'd still need to build multiple times anyway.

Glad to read, so the v2 of this series is worthful.