* [Qemu-devel] [PATCH 1/2] configure: fix detection for cURL libs when static linking
2012-09-02 13:09 [Qemu-devel] [PATCH 0/2 v3] Fix static linking for cURL and SDL Yann E. MORIN
@ 2012-09-02 13:09 ` Yann E. MORIN
2012-09-02 13:09 ` [Qemu-devel] [PATCH 2/2] configure: fix detection for SDL " Yann E. MORIN
` (3 subsequent siblings)
4 siblings, 0 replies; 10+ messages in thread
From: Yann E. MORIN @ 2012-09-02 13:09 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Stefan Hajnoczi, Yann E. MORIN, Peter Maydell
Currently, to check for cURL, configure uses either pkg-config (the default),
or curl-config (as a fallback).
But curl-config and pkg-config do not have the same set of options:
- to check for shared libs, both use the option: --libs
- to check for static libs:
- pkg-config uses: --static --libs
- curl-config uses: --static-libs
To add to the complexity, pkg-config is called through the querry_pkg_config
wrapper, that already passes --static when static linking is required, but
there is no such wrapper for curl-config, so we miss the occasion to pass
--static-libs
To fix this:
- introduce a new variable QEMU_XXX_CONFIG_LIBS_FLAGS that mirrors the
behavior of QEMU_PKG_CONFIG_FLAGS; this variable can be used by all
xxx-config scripts (eg. curl-config, but later sdl-config too).
Default it to '--libs', which is for shared linking;
- properly use either --libs for pkg-config (--static is already taken
care of in the wrapper), or $QEMU_XXX_CONFIG_LIBS_FLAGS for curl-config.
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Reviewed-by: Stefan Hajnoczi <stefanha@gmail.com>
---
configure | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/configure b/configure
index d97fd81..67c9238 100755
--- a/configure
+++ b/configure
@@ -126,7 +126,7 @@ audio_win_int=""
cc_i386=i386-pc-linux-gnu-gcc
libs_qga=""
debug_info="yes"
-
+QEMU_XXX_CONFIG_LIBS_FLAGS="--libs"
target_list=""
# Default value for a variable defining feature "foo".
@@ -626,6 +626,7 @@ for opt do
static="yes"
LDFLAGS="-static $LDFLAGS"
QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
+ QEMU_XXX_CONFIG_LIBS_FLAGS="--static-libs"
;;
--mandir=*) mandir="$optarg"
;;
@@ -2077,8 +2078,10 @@ fi
if $pkg_config libcurl --modversion >/dev/null 2>&1; then
curlconfig="$pkg_config libcurl"
+ curlconfiglibs="--libs"
else
curlconfig=curl-config
+ curlconfiglibs="$QEMU_XXX_CONFIG_LIBS_FLAGS"
fi
if test "$curl" != "no" ; then
@@ -2087,7 +2090,7 @@ if test "$curl" != "no" ; then
int main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
EOF
curl_cflags=`$curlconfig --cflags 2>/dev/null`
- curl_libs=`$curlconfig --libs 2>/dev/null`
+ curl_libs=`$curlconfig $curlconfiglibs 2>/dev/null`
if compile_prog "$curl_cflags" "$curl_libs" ; then
curl=yes
libs_tools="$curl_libs $libs_tools"
--
1.7.2.5
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [Qemu-devel] [PATCH 2/2] configure: fix detection for SDL libs when static linking
2012-09-02 13:09 [Qemu-devel] [PATCH 0/2 v3] Fix static linking for cURL and SDL Yann E. MORIN
2012-09-02 13:09 ` [Qemu-devel] [PATCH 1/2] configure: fix detection for cURL libs when static linking Yann E. MORIN
@ 2012-09-02 13:09 ` Yann E. MORIN
2012-09-03 9:31 ` [Qemu-devel] [PATCH 0/2 v3] Fix static linking for cURL and SDL Stefan Hajnoczi
` (2 subsequent siblings)
4 siblings, 0 replies; 10+ messages in thread
From: Yann E. MORIN @ 2012-09-02 13:09 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Stefan Hajnoczi, Yann E. MORIN, Peter Maydell
Currently, configure checks for SDL libs either with pkg-config (the
default), or with sdl-config (as a fallback).
But sdl-config does not have the same set of options as pkg-config:
- to check for shared libs, both use the option: --libs
- to check for static libs:
- pkg-config uses: --static --libs
- sdl-config uses: --static-libs
Fix that by using the previously introduced $QEMU_XXX_CONFIG_LIBS_FLAGS
variable, the way it was done previously for cURL.
Also, simplify the code-path for checking for SDL libs with a single,
non-conditional call to $sdlconfig, which is either pkg-config or
sdl-config, as checked just above.
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Reviewed-by: Stefan Hajnoczi <stefanha@gmail.com>
---
configure | 8 +++-----
1 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/configure b/configure
index 67c9238..c5888fa 100755
--- a/configure
+++ b/configure
@@ -1646,9 +1646,11 @@ fi
if $pkg_config sdl --modversion >/dev/null 2>&1; then
sdlconfig="$pkg_config sdl"
+ sdlconfiglibs="--libs"
_sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
elif has ${sdl_config}; then
sdlconfig="$sdl_config"
+ sdlconfiglibs="$QEMU_XXX_CONFIG_LIBS_FLAGS"
_sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
else
if test "$sdl" = "yes" ; then
@@ -1668,11 +1670,7 @@ if test "$sdl" != "no" ; then
int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
EOF
sdl_cflags=`$sdlconfig --cflags 2> /dev/null`
- if test "$static" = "yes" ; then
- sdl_libs=`$sdlconfig --static-libs 2>/dev/null`
- else
- sdl_libs=`$sdlconfig --libs 2> /dev/null`
- fi
+ sdl_libs=`$sdlconfig $sdlconfiglibs 2> /dev/null`
if compile_prog "$sdl_cflags" "$sdl_libs" ; then
if test "$_sdlversion" -lt 121 ; then
sdl_too_old=yes
--
1.7.2.5
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH 0/2 v3] Fix static linking for cURL and SDL
2012-09-02 13:09 [Qemu-devel] [PATCH 0/2 v3] Fix static linking for cURL and SDL Yann E. MORIN
2012-09-02 13:09 ` [Qemu-devel] [PATCH 1/2] configure: fix detection for cURL libs when static linking Yann E. MORIN
2012-09-02 13:09 ` [Qemu-devel] [PATCH 2/2] configure: fix detection for SDL " Yann E. MORIN
@ 2012-09-03 9:31 ` Stefan Hajnoczi
2012-09-03 15:41 ` Andreas Färber
2012-09-05 9:33 ` Stefan Hajnoczi
4 siblings, 0 replies; 10+ messages in thread
From: Stefan Hajnoczi @ 2012-09-03 9:31 UTC (permalink / raw)
To: Yann E. MORIN; +Cc: qemu-trivial, Peter Maydell, qemu-devel
On Sun, Sep 2, 2012 at 2:09 PM, Yann E. MORIN <yann.morin.1998@free.fr> wrote:
> Hello All!
>
> Currently, configure checks for cURL and SDL with either pkg-config (the
> default), or with {curl,sdl}-config (as a fallback).
>
> But pkg-config and {curl,sdl}-config do not have the same set of options:
> - to check for shared libs, both use the option: --libs
> - to check for static libs:
> - pkg-config uses : --static --libs
> - {curl,sdl}-config use: --static-libs
>
> To add to the complexity, pkg-config is called through the querry_pkg_config
> wrapper, that already passes --static when static linking is required, but
> there is no such wrapper for {curl,sdl}-config, so we miss the occasion to
> pass --static-libs.
>
> To fix this:
> - introduce a new variable QEMU_XXX_CONFIG_LIBS_FLAGS that mirrors the
> behavior of QEMU_PKG_CONFIG_FLAGS; this variable can be used by all
> xxx-config scripts (eg. curl-config, but later sdl-config too).
> Default it to '--libs', which is for shared linking.
> - properly use either --libs for pkg-config (--static is already taken
> care of in the wrapper), or $QEMU_XXX_CONFIG_LIBS_FLAGS for
> {curl,sdl}-config.
>
>
> Changes since v2:
> - remove trailing reference to cURL in the SDL patch (Stefan Hajnoczi)
> - sent to qemu-devel and cc qemu-trivial (Peter Maydell, Stefan)
> - fix type in the name of the new variable
>
> Changes since v1:
> - drop the spice fix, it is not needed (bad env locally)
> - drop the added --static to calls to pkg-config, as it's already in the
> wrapper (Stefan Hajnoczi)
Reviewed-by: Stefan Hajnoczi <stefanha@gmail.com>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH 0/2 v3] Fix static linking for cURL and SDL
2012-09-02 13:09 [Qemu-devel] [PATCH 0/2 v3] Fix static linking for cURL and SDL Yann E. MORIN
` (2 preceding siblings ...)
2012-09-03 9:31 ` [Qemu-devel] [PATCH 0/2 v3] Fix static linking for cURL and SDL Stefan Hajnoczi
@ 2012-09-03 15:41 ` Andreas Färber
2012-09-03 15:44 ` Peter Maydell
2012-09-05 9:33 ` Stefan Hajnoczi
4 siblings, 1 reply; 10+ messages in thread
From: Andreas Färber @ 2012-09-03 15:41 UTC (permalink / raw)
To: Yann E. MORIN, Stefan Hajnoczi
Cc: qemu-trivial, Peter Maydell, Riku Voipio, qemu-devel
Hello,
Am 02.09.2012 15:09, schrieb Yann E. MORIN:
> Currently, configure checks for cURL and SDL with either pkg-config (the
> default), or with {curl,sdl}-config (as a fallback).
>
> But pkg-config and {curl,sdl}-config do not have the same set of options:
> - to check for shared libs, both use the option: --libs
> - to check for static libs:
> - pkg-config uses : --static --libs
> - {curl,sdl}-config use: --static-libs
>
> To add to the complexity, pkg-config is called through the querry_pkg_config
> wrapper, that already passes --static when static linking is required, but
> there is no such wrapper for {curl,sdl}-config, so we miss the occasion to
> pass --static-libs.
>
> To fix this:
> - introduce a new variable QEMU_XXX_CONFIG_LIBS_FLAGS that mirrors the
> behavior of QEMU_PKG_CONFIG_FLAGS; this variable can be used by all
> xxx-config scripts (eg. curl-config, but later sdl-config too).
> Default it to '--libs', which is for shared linking.
> - properly use either --libs for pkg-config (--static is already taken
> care of in the wrapper), or $QEMU_XXX_CONFIG_LIBS_FLAGS for
> {curl,sdl}-config.
While this patch set looks okay technically, I wonder if this is fixing
the wrong problem...
The only use case for QEMU's --static compilation I know is linux-user,
and that doesn't need cURL or SDL AFAIK. Shouldn't we rather sanitize
our configure-time checks to only look for the actually needed stuff
than making sure that unnecessary dependencies are generated nicely?
Regards,
Andreas
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH 0/2 v3] Fix static linking for cURL and SDL
2012-09-03 15:41 ` Andreas Färber
@ 2012-09-03 15:44 ` Peter Maydell
2012-09-03 16:28 ` Yann E. MORIN
0 siblings, 1 reply; 10+ messages in thread
From: Peter Maydell @ 2012-09-03 15:44 UTC (permalink / raw)
To: Andreas Färber
Cc: qemu-trivial, Stefan Hajnoczi, Riku Voipio, Yann E. MORIN,
qemu-devel
On 3 September 2012 16:41, Andreas Färber <afaerber@suse.de> wrote:
> The only use case for QEMU's --static compilation I know is linux-user,
> and that doesn't need cURL or SDL AFAIK. Shouldn't we rather sanitize
> our configure-time checks to only look for the actually needed stuff
> than making sure that unnecessary dependencies are generated nicely?
In particular it might be nice to be able to build in a single
run both (a) dynamically linked softmmu targets and (b) statically
linked linux-user targets (and maybe even also (c) dynamically
linked linux-user targets?).
Personally I think it might indeed be a good idea to just say
"statically linked softmmu isn't supported" and forbid it, unless
somebody has a good use case for it...
-- PMM
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH 0/2 v3] Fix static linking for cURL and SDL
2012-09-03 15:44 ` Peter Maydell
@ 2012-09-03 16:28 ` Yann E. MORIN
2012-09-03 16:38 ` Peter Maydell
0 siblings, 1 reply; 10+ messages in thread
From: Yann E. MORIN @ 2012-09-03 16:28 UTC (permalink / raw)
To: Peter Maydell
Cc: qemu-trivial, Stefan Hajnoczi, Riku Voipio, Andreas Färber,
qemu-devel
Hello All,
On Monday 03 September 2012 17:44:51 Peter Maydell wrote:
> On 3 September 2012 16:41, Andreas Färber <afaerber@suse.de> wrote:
> > The only use case for QEMU's --static compilation I know is linux-user,
> > and that doesn't need cURL or SDL AFAIK. Shouldn't we rather sanitize
> > our configure-time checks to only look for the actually needed stuff
> > than making sure that unnecessary dependencies are generated nicely?
>
> In particular it might be nice to be able to build in a single
> run both (a) dynamically linked softmmu targets and (b) statically
> linked linux-user targets (and maybe even also (c) dynamically
> linked linux-user targets?).
>
> Personally I think it might indeed be a good idea to just say
> "statically linked softmmu isn't supported" and forbid it, unless
> somebody has a good use case for it...
I personnally have such a use-case: provide run-everywhere qemu softmmu
binaries that do have minimal requirements on the distro they'll be
running on, especially when the distros can be very different (in kinds
and in age).
For example, I can use it to provide:
- a qemu binary
- a VM image
- a script
that users can simply drop anywhere they want (without needing root
access) and run the VM, without requiring them to install a myriad
packages, especially on older distros that may lack those packages,
or whose packaged versions are too old for qemu.
Regards,
Yann E. MORIN.
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH 0/2 v3] Fix static linking for cURL and SDL
2012-09-03 16:28 ` Yann E. MORIN
@ 2012-09-03 16:38 ` Peter Maydell
2012-09-03 17:06 ` Yann E. MORIN
0 siblings, 1 reply; 10+ messages in thread
From: Peter Maydell @ 2012-09-03 16:38 UTC (permalink / raw)
To: Yann E. MORIN
Cc: qemu-trivial, Stefan Hajnoczi, Riku Voipio, Andreas Färber,
qemu-devel
On 3 September 2012 17:28, Yann E. MORIN <yann.morin.1998@free.fr> wrote:
> On Monday 03 September 2012 17:44:51 Peter Maydell wrote:
>> Personally I think it might indeed be a good idea to just say
>> "statically linked softmmu isn't supported" and forbid it, unless
>> somebody has a good use case for it...
>
> I personnally have such a use-case: provide run-everywhere qemu softmmu
> binaries that do have minimal requirements on the distro they'll be
> running on, especially when the distros can be very different (in kinds
> and in age).
...have you audited all of qemu's library usage to confirm that it
doesn't use any of the bits of glibc that don't work in the static
linking scenario? I'm reasonably confident that the linux-user binaries
are OK, much less so for the system binaries...
-- PMM
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH 0/2 v3] Fix static linking for cURL and SDL
2012-09-03 16:38 ` Peter Maydell
@ 2012-09-03 17:06 ` Yann E. MORIN
0 siblings, 0 replies; 10+ messages in thread
From: Yann E. MORIN @ 2012-09-03 17:06 UTC (permalink / raw)
To: Peter Maydell
Cc: qemu-trivial, Stefan Hajnoczi, Riku Voipio, Andreas Färber,
qemu-devel
Peter, All,
On Monday 03 September 2012 18:38:48 Peter Maydell wrote:
> On 3 September 2012 17:28, Yann E. MORIN <yann.morin.1998@free.fr> wrote:
> > On Monday 03 September 2012 17:44:51 Peter Maydell wrote:
> >> Personally I think it might indeed be a good idea to just say
> >> "statically linked softmmu isn't supported" and forbid it, unless
> >> somebody has a good use case for it...
> >
> > I personnally have such a use-case: provide run-everywhere qemu softmmu
> > binaries that do have minimal requirements on the distro they'll be
> > running on, especially when the distros can be very different (in kinds
> > and in age).
>
> ...have you audited all of qemu's library usage to confirm that it
> doesn't use any of the bits of glibc that don't work in the static
> linking scenario? I'm reasonably confident that the linux-user binaries
> are OK, much less so for the system binaries...
I guess you mean the nsswitch stuff?
I'm using a uClibc-based toolchain that does not have such libs, and allows
a truly static link.
Regards,
Yann E. MORIN.
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH 0/2 v3] Fix static linking for cURL and SDL
2012-09-02 13:09 [Qemu-devel] [PATCH 0/2 v3] Fix static linking for cURL and SDL Yann E. MORIN
` (3 preceding siblings ...)
2012-09-03 15:41 ` Andreas Färber
@ 2012-09-05 9:33 ` Stefan Hajnoczi
4 siblings, 0 replies; 10+ messages in thread
From: Stefan Hajnoczi @ 2012-09-05 9:33 UTC (permalink / raw)
To: Yann E. MORIN; +Cc: qemu-trivial, Peter Maydell, qemu-devel
On Sun, Sep 02, 2012 at 03:09:44PM +0200, Yann E. MORIN wrote:
> Hello All!
>
> Currently, configure checks for cURL and SDL with either pkg-config (the
> default), or with {curl,sdl}-config (as a fallback).
>
> But pkg-config and {curl,sdl}-config do not have the same set of options:
> - to check for shared libs, both use the option: --libs
> - to check for static libs:
> - pkg-config uses : --static --libs
> - {curl,sdl}-config use: --static-libs
>
> To add to the complexity, pkg-config is called through the querry_pkg_config
> wrapper, that already passes --static when static linking is required, but
> there is no such wrapper for {curl,sdl}-config, so we miss the occasion to
> pass --static-libs.
>
> To fix this:
> - introduce a new variable QEMU_XXX_CONFIG_LIBS_FLAGS that mirrors the
> behavior of QEMU_PKG_CONFIG_FLAGS; this variable can be used by all
> xxx-config scripts (eg. curl-config, but later sdl-config too).
> Default it to '--libs', which is for shared linking.
> - properly use either --libs for pkg-config (--static is already taken
> care of in the wrapper), or $QEMU_XXX_CONFIG_LIBS_FLAGS for
> {curl,sdl}-config.
>
>
> Changes since v2:
> - remove trailing reference to cURL in the SDL patch (Stefan Hajnoczi)
> - sent to qemu-devel and cc qemu-trivial (Peter Maydell, Stefan)
> - fix type in the name of the new variable
>
> Changes since v1:
> - drop the spice fix, it is not needed (bad env locally)
> - drop the added --static to calls to pkg-config, as it's already in the
> wrapper (Stefan Hajnoczi)
Any more discussion around this?
I'm happy with the patches.
Stefan
^ permalink raw reply [flat|nested] 10+ messages in thread