From patchwork Sun Dec 16 17:01:55 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yann E. MORIN" X-Patchwork-Id: 206732 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from hemlock.osuosl.org (hemlock.osuosl.org [140.211.166.133]) by ozlabs.org (Postfix) with ESMTP id 806CD2C009B for ; Mon, 17 Dec 2012 04:04:44 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id B2116A00D6; Sun, 16 Dec 2012 17:04:43 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id IkvaEJQ+dUFc; Sun, 16 Dec 2012 17:04:33 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id 458DDA00F9; Sun, 16 Dec 2012 17:03:34 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (whitealder.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 581798F74B for ; Sun, 16 Dec 2012 17:02:55 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id D338280C1B for ; Sun, 16 Dec 2012 17:02:49 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Jtu7-tJDBOwT for ; Sun, 16 Dec 2012 17:02:48 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wg0-f43.google.com (mail-wg0-f43.google.com [74.125.82.43]) by whitealder.osuosl.org (Postfix) with ESMTPS id 2BCC080C10 for ; Sun, 16 Dec 2012 17:02:48 +0000 (UTC) Received: by mail-wg0-f43.google.com with SMTP id e12so2204778wge.10 for ; Sun, 16 Dec 2012 09:02:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:in-reply-to:references; bh=sPJpYjz9InuQZIvwoRzicpr9ppruFCtfuVcgwbGoqyg=; b=nOyq4rFirzCrddCJ3cbsc2UED3P+KYWXBcbVQOG3QJRUXTf3VYTlit/qU64UfIFW0A EYaCe55v4npjiJiqWxBTjnlSm+YK9yBR8EdM4BWmhT0DaZEuD7Daq9zBcBU6sO+Zxoqd DctBpH4pAlFiaggqw4s7j9EFBOdwG0HloduI1WjkeHP9QVmACGQw7oQk5EW5twcPFIEl Ycn/9hR+CetPfkt3RIuW4014LgofLgleskGkCWTL5PFibTboGnZdmYCwh2RKy5it3/3Q qg86xPAvN0Xfqi6+/1ZltXdrfKRzSJrpE3bbh37mhEPH6jo+4gVj6M4/PubRFWmNwR89 jt1g== Received: by 10.194.92.180 with SMTP id cn20mr12744433wjb.51.1355677366522; Sun, 16 Dec 2012 09:02:46 -0800 (PST) Received: from localhost.localdomain (ARennes-256-1-41-119.w90-32.abo.wanadoo.fr. [90.32.24.119]) by mx.google.com with ESMTPS id w5sm7363031wif.11.2012.12.16.09.02.44 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 16 Dec 2012 09:02:45 -0800 (PST) From: "Yann E. MORIN" To: buildroot@busybox.net Date: Sun, 16 Dec 2012 18:01:55 +0100 Message-Id: <2fc3655574313a23489d70e1d777c710866b63b7.1355677144.git.yann.morin.1998@free.fr> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: References: In-Reply-To: References: Cc: "Yann E. MORIN" Subject: [Buildroot] [PATCH 26/27] package/qemu: enable a static build X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: buildroot-bounces@busybox.net Signed-off-by: "Yann E. MORIN" --- It can be useful to have a statically-linked QEMU (especially the linux-user and bsd-user emulators) to avoid run-time issues with dynamically-loaded libraries. There is an issue where QEMU could not be able to properly (re)map libraries in memory due to some overlap between its own memory mappings and the mappings of the user application being translated (it's a complex issue, so don't count on me to properly explain it, I did not understood it completely either... :-/ ). --- package/qemu/Config.in | 48 +++++++++++++++++++---- package/qemu/qemu-static-curl.patch | 72 +++++++++++++++++++++++++++++++++++ package/qemu/qemu-static-sdl.patch | 54 ++++++++++++++++++++++++++ package/qemu/qemu.mk | 4 ++ 4 files changed, 170 insertions(+), 8 deletions(-) create mode 100644 package/qemu/qemu-static-curl.patch create mode 100644 package/qemu/qemu-static-sdl.patch diff --git a/package/qemu/Config.in b/package/qemu/Config.in index 435775a..f88a1f4 100644 --- a/package/qemu/Config.in +++ b/package/qemu/Config.in @@ -99,11 +99,11 @@ config BR2_PACKAGE_QEMU_VNC_JPEG config BR2_PACKAGE_QEMU_VNC_TLS bool "TLS encryption" depends on BR2_PACKAGE_QEMU_VNC - depends on !BR2_PREFER_STATIC_LIB + depends on !BR2_PACKAGE_QEMU_STATIC select BR2_PACKAGE_GNUTLS comment "VNC TLS encryption does not work for static link" - depends on BR2_PACKAGE_QEMU_VNC && BR2_PREFER_STATIC_LIB + depends on BR2_PACKAGE_QEMU_VNC && BR2_PACKAGE_QEMU_STATIC config BR2_PACKAGE_QEMU_SDL bool "Enable SDL frontend" @@ -126,11 +126,21 @@ config BR2_PACKAGE_QEMU_CURSES config BR2_PACKAGE_QEMU_SPICE bool "Enable Spice frontend" depends on BR2_PACKAGE_SPICE + depends on !BR2_PACKAGE_QEMU_STATIC || BR2_PREFER_STATIC_LIB help Say 'y' here to have QEMU support Spice as a (VNC-like) frontend. -comment "Spice support requires spice-server" - depends on !BR2_PACKAGE_SPICE + Note: + Spice links against alsa-libs, but alsa-libs can't be built both + shared and static at the same time, so we can not link with a + static spice to get a static QEMU (BR2_PACKAGE_QEMU_STATIC) if + buildroot as a whole does not also build only static libraries + (BR2_PREFER_STATIC_LIB). + +if !BR2_PACKAGE_SPICE || ( BR2_PACKAGE_QEMU_STATIC && !BR2_PREFER_STATIC_LIB ) +comment "Spice support requires spice-server, and does not work for a static" +comment "build of QEMU unless BR2_PREFER_STATIC_LIB is set, too" +endif comment "Block backends" @@ -150,14 +160,10 @@ config BR2_PACKAGE_QEMU_VIRTFS config BR2_PACKAGE_QEMU_CURL bool "Enable remote block-devices using cURL" - depends on !BR2_PREFER_STATIC_LIB select BR2_PACKAGE_LIBCURL help Say 'y' to access remote block-devices using libcurl. -comment "cURL support is not possible with static linking" - depends on BR2_PREFER_STATIC_LIB - config BR2_PACKAGE_QEMU_ISCSI bool "Enable remote block-devices using iSCSI" select BR2_PACKAGE_LIBISCSI @@ -238,6 +244,24 @@ config BR2_PACKAGE_QEMU_SOUND_SDL Note: this is only for system emulation, not user emulation. +<<<<<<< HEAD +======= +# Alsa can not build both shared and static libs at the same time. +# But we may want to build QEMU staticaly, even though the global +# BR2_PREFER_STATIC_LIB is not set. Disable that case. +config BR2_PACKAGE_QEMU_SOUND_ALSA + bool "Enable sound via alsa" + depends on !BR2_PACKAGE_QEMU_STATIC || BR2_PREFER_STATIC_LIB + select BR2_PACKAGE_ALSA_LIB + help + Say 'y' here to have QEMU play sound from the VMs via alsa. + + Note: this is only for system emulation, not user emulation. + +comment "Alsa sound static link works only if BR2_PREFER_STATIC is set" + depends on BR2_PACKAGE_QEMU_STATIC && !BR2_PREFER_STATIC_LIB + +>>>>>>> dd73234... package/qemu: enable a static build comment "Misc. features" config BR2_PACKAGE_QEMU_UUID @@ -296,4 +320,12 @@ config BR2_PACKAGE_QEMU_KEYMAPS - 'de fr* en-*' for german, french and english keymaps - and so on (see the QEMU source for all supported keymaps) +config BR2_PREFER_STATIC_LIB + select BR2_PACKAGE_QEMU_STATIC + +config BR2_PACKAGE_QEMU_STATIC + bool "Build statically" + help + Build static qemu executable(s). + endif # BR2_PACKAGE_QEMU diff --git a/package/qemu/qemu-static-curl.patch b/package/qemu/qemu-static-curl.patch new file mode 100644 index 0000000..0029d7d --- /dev/null +++ b/package/qemu/qemu-static-curl.patch @@ -0,0 +1,72 @@ +configure: fix detection for cURL libs when static linking + +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 takend + care of in the wrapper), or $QEMU_XXX_CONFIG_LIBS_FLAGS for + curl-config. + +Signed-off-by: "Yann E. MORIN" + +--- +Patch sent upstream: + http://lists.nongnu.org/archive/html/qemu-trivial/2012-08/msg00165.html + +diff --git a/configure b/configure +index d97fd81..e6a7c14 100755 +--- a/configure ++++ b/configure +@@ -101,7 +101,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". +@@ -580,6 +580,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" + ;; +@@ -1977,8 +1978,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 +@@ -1987,7 +1990,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" diff --git a/package/qemu/qemu-static-sdl.patch b/package/qemu/qemu-static-sdl.patch new file mode 100644 index 0000000..59e4a60 --- /dev/null +++ b/package/qemu/qemu-static-sdl.patch @@ -0,0 +1,54 @@ +configure: fix detection for SDL libs when static linking + +Currently, configure checks for SDL libs with either pkg-config (the +default), or with sdl-config (as a fallback). + +As for cURL (previous patch), 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 + - curl-config uses: --static-libs + +Fix that by using the previously introduced $QEMU_XXX_CONFIG_LIBS_FLAGS +variable, the way ot 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" + +--- +Patch sent upstream: + http://lists.nongnu.org/archive/html/qemu-trivial/2012-08/msg00166.html + +diff --git a/configure b/configure +index e6a7c14..6bfedc7 100755 +--- a/configure ++++ b/configure +@@ -1547,9 +1547,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 +@@ -1569,11 +1571,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 diff --git a/package/qemu/qemu.mk b/package/qemu/qemu.mk index 1913c19..267d7b9 100644 --- a/package/qemu/qemu.mk +++ b/package/qemu/qemu.mk @@ -268,6 +268,10 @@ else QEMU_OPTS += --disable-docs endif +ifeq ($(BR2_PACKAGE_QEMU_STATIC),y) +QEMU_OPTS += --static +endif + # Post-install removal of unwanted keymaps: # - if we want 'all', we do nothing; # - if we want none, we completely remove the keymap dir