alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ALSA: lib: Fix static linking of libasound
@ 2010-12-28 21:46 Daniel Chen
  2011-01-01 15:07 ` Jaroslav Kysela
  0 siblings, 1 reply; 7+ messages in thread
From: Daniel Chen @ 2010-12-28 21:46 UTC (permalink / raw)
  To: Takashi Iwai, Jaroslav Kysela; +Cc: alsa-devel

[-- Attachment #1: Type: text/plain, Size: 145 bytes --]

Hi,

Attached is a patch from Samuel Thibault that fixes static linking of
libasound.a (forwarded from Debian bug report #522544).

Thanks,
-Dan

[-- Attachment #2: 0001-ALSA-lib-Fix-static-linking-of-libasound.patch --]
[-- Type: text/x-diff, Size: 2845 bytes --]

From 5165bf7571e49ae950608b4eeabdc3f0620e0ce4 Mon Sep 17 00:00:00 2001
From: Daniel T Chen <crimsun@ubuntu.com>
Date: Tue, 28 Dec 2010 16:36:16 -0500
Subject: [PATCH] ALSA: lib: Fix static linking of libasound

BugLink: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=522544

In Debian BTS #522544, Samuel Thibault reports that
snd_dlsym("_snd_ctl_hw_open") fails at runtime for a statically-linked
libasound and later follows up, "Actually it's worse, it's a building
design bug: .a files for sublibraries are created, and then assembled in
both a PIC .so and a static .a. The attached patch makes alsa always
include the linking tricks needed for static linking."

Here is Samuel's patch rediffed against current alsa-lib master HEAD.

Reported-and-tested-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Signed-off-by: Daniel T Chen <crimsun@ubuntu.com>
---
 include/global.h |   14 ++------------
 src/dlmisc.c     |    2 --
 2 files changed, 2 insertions(+), 14 deletions(-)

diff --git a/include/global.h b/include/global.h
index 3e3680f..d3a27c8 100644
--- a/include/global.h
+++ b/include/global.h
@@ -51,17 +51,8 @@ const char *snd_asoundlib_version(void);
 #define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
 #endif
 
-#ifdef PIC /* dynamic build */
-
 /** \hideinitializer \brief Helper macro for #SND_DLSYM_BUILD_VERSION. */
-#define __SND_DLSYM_VERSION(name, version) _ ## name ## version
-/**
- * \hideinitializer
- * \brief Appends the build version to the name of a versioned dynamic symbol.
- */
-#define SND_DLSYM_BUILD_VERSION(name, version) char __SND_DLSYM_VERSION(name, version);
-
-#else /* static build */
+#define __SND_DLSYM_DYN_VERSION(name, version) _ ## name ## version
 
 struct snd_dlsym_link {
 	struct snd_dlsym_link *next;
@@ -78,6 +69,7 @@ extern struct snd_dlsym_link *snd_dlsym_start;
  * \brief Appends the build version to the name of a versioned dynamic symbol.
  */
 #define SND_DLSYM_BUILD_VERSION(name, version) \
+  char __SND_DLSYM_DYN_VERSION(name, version); \
   static struct snd_dlsym_link __SND_DLSYM_VERSION(snd_dlsym_, name, version); \
   void __SND_DLSYM_VERSION(snd_dlsym_constructor_, name, version) (void) __attribute__ ((constructor)); \
   void __SND_DLSYM_VERSION(snd_dlsym_constructor_, name, version) (void) { \
@@ -87,8 +79,6 @@ extern struct snd_dlsym_link *snd_dlsym_start;
     snd_dlsym_start = &__SND_DLSYM_VERSION(snd_dlsym_, name, version); \
   }
 
-#endif
-
 #ifndef __STRING
 /** \brief Return 'x' argument as string */
 #define __STRING(x)     #x
diff --git a/src/dlmisc.c b/src/dlmisc.c
index ecbbe8d..b0b23b1 100644
--- a/src/dlmisc.c
+++ b/src/dlmisc.c
@@ -34,10 +34,8 @@
 #endif
 
 #ifndef DOC_HIDDEN
-#ifndef PIC
 struct snd_dlsym_link *snd_dlsym_start = NULL;
 #endif
-#endif
 
 /**
  * \brief Opens a dynamic library - ALSA wrapper for \c dlopen.
-- 
1.7.1


[-- Attachment #3: Type: text/plain, Size: 160 bytes --]

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] ALSA: lib: Fix static linking of libasound
  2010-12-28 21:46 [PATCH] ALSA: lib: Fix static linking of libasound Daniel Chen
@ 2011-01-01 15:07 ` Jaroslav Kysela
  2011-01-01 17:41   ` Daniel Chen
  2011-01-03 17:03   ` Why is snd_pcm_hw_params_set_format() not setting the format at all? Philip Chu
  0 siblings, 2 replies; 7+ messages in thread
From: Jaroslav Kysela @ 2011-01-01 15:07 UTC (permalink / raw)
  To: Daniel Chen; +Cc: Takashi Iwai, alsa-devel

On Tue, 28 Dec 2010, Daniel Chen wrote:

> Hi,
>
> Attached is a patch from Samuel Thibault that fixes static linking of
> libasound.a (forwarded from Debian bug report #522544).

Is any reason to ignore this configure settings mentined in the INSTALL 
file for the static library build?

./configure --enable-shared=no --enable-static=yes

It's mainly libtool issue and having static hacks in the dynamic library 
does not make much sense.

 						Jaroslav

-----
Jaroslav Kysela <perex@perex.cz>
Linux Kernel Sound Maintainer
ALSA Project, Red Hat, Inc.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] ALSA: lib: Fix static linking of libasound
  2011-01-01 15:07 ` Jaroslav Kysela
@ 2011-01-01 17:41   ` Daniel Chen
  2011-01-01 23:42     ` Jaroslav Kysela
  2011-01-03 17:03   ` Why is snd_pcm_hw_params_set_format() not setting the format at all? Philip Chu
  1 sibling, 1 reply; 7+ messages in thread
From: Daniel Chen @ 2011-01-01 17:41 UTC (permalink / raw)
  To: Jaroslav Kysela; +Cc: Takashi Iwai, alsa-devel

On Sat, Jan 1, 2011 at 10:07 AM, Jaroslav Kysela <perex@perex.cz> wrote:
> Is any reason to ignore this configure settings mentined in the INSTALL file
> for the static library build?
>
> ./configure --enable-shared=no --enable-static=yes
>
> It's mainly libtool issue and having static hacks in the dynamic library
> does not make much sense.

According to Samuel in the Debian bug report, "when both static &
dynamic linking is enabled, automake gets it wrong and uses only the
dynamic objects."

Is the best course of action here to do a two-pass build, one with
"--enable-shared=no --enable-static=yes" and another with
"--enable-shared=yes --enable-static=no", simply copying the desired
libasound.a from the second pass?

Thanks,
-Dan

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] ALSA: lib: Fix static linking of libasound
  2011-01-01 17:41   ` Daniel Chen
@ 2011-01-01 23:42     ` Jaroslav Kysela
  2011-01-03 10:50       ` Colin Guthrie
  0 siblings, 1 reply; 7+ messages in thread
From: Jaroslav Kysela @ 2011-01-01 23:42 UTC (permalink / raw)
  To: Daniel Chen; +Cc: Takashi Iwai, alsa-devel

On Sat, 1 Jan 2011, Daniel Chen wrote:

> On Sat, Jan 1, 2011 at 10:07 AM, Jaroslav Kysela <perex@perex.cz> wrote:
>> Is any reason to ignore this configure settings mentined in the INSTALL file
>> for the static library build?
>>
>> ./configure --enable-shared=no --enable-static=yes
>>
>> It's mainly libtool issue and having static hacks in the dynamic library
>> does not make much sense.
>
> According to Samuel in the Debian bug report, "when both static &
> dynamic linking is enabled, automake gets it wrong and uses only the
> dynamic objects."
>
> Is the best course of action here to do a two-pass build, one with
> "--enable-shared=no --enable-static=yes" and another with
> "--enable-shared=yes --enable-static=no", simply copying the desired
> libasound.a from the second pass?

Yes, I believe, it's the right way to compile both types of library 
binaries.

 					Jaroslav

-----
Jaroslav Kysela <perex@perex.cz>
Linux Kernel Sound Maintainer
ALSA Project, Red Hat, Inc.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] ALSA: lib: Fix static linking of libasound
  2011-01-01 23:42     ` Jaroslav Kysela
@ 2011-01-03 10:50       ` Colin Guthrie
  0 siblings, 0 replies; 7+ messages in thread
From: Colin Guthrie @ 2011-01-03 10:50 UTC (permalink / raw)
  To: alsa-devel

'Twas brillig, and Jaroslav Kysela at 01/01/11 23:42 did gyre and gimble:
> On Sat, 1 Jan 2011, Daniel Chen wrote:
> 
>> On Sat, Jan 1, 2011 at 10:07 AM, Jaroslav Kysela <perex@perex.cz> wrote:
>>> Is any reason to ignore this configure settings mentined in the INSTALL file
>>> for the static library build?
>>>
>>> ./configure --enable-shared=no --enable-static=yes
>>>
>>> It's mainly libtool issue and having static hacks in the dynamic library
>>> does not make much sense.
>>
>> According to Samuel in the Debian bug report, "when both static &
>> dynamic linking is enabled, automake gets it wrong and uses only the
>> dynamic objects."
>>
>> Is the best course of action here to do a two-pass build, one with
>> "--enable-shared=no --enable-static=yes" and another with
>> "--enable-shared=yes --enable-static=no", simply copying the desired
>> libasound.a from the second pass?
> 
> Yes, I believe, it's the right way to compile both types of library 
> binaries.

Shouldn't the argument then be one that is mutually exclusive then?

e.g. --build-type=[shared||static]

Col


-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mageia Contributor [http://www.mageia.org/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Why is snd_pcm_hw_params_set_format() not setting the format at all?
  2011-01-01 15:07 ` Jaroslav Kysela
  2011-01-01 17:41   ` Daniel Chen
@ 2011-01-03 17:03   ` Philip Chu
  2011-01-03 17:08     ` Jaroslav Kysela
  1 sibling, 1 reply; 7+ messages in thread
From: Philip Chu @ 2011-01-03 17:03 UTC (permalink / raw)
  To: alsa-devel

When I call snd_pcm_hw_params_set_format() to set up a new format, it seems to call following in order and none of them is setting up the format bit?

snd_pcm_hw_params_set_format() -> snd_pcm_hw_param_set() -> _snd_pcm_hw_param_set() -> snd_mask_refine_set() -> snd_mask_single() + snd_mask_leave()

I am using "plughw:0,0" as the device name, and I think it is using pcm_plugin.c for the master and pcm_hw.c for the slave?
If I can use pcm_plug.c, then it should finally call snd_mask_set() from another function snd_pcm_hw_params() with the following call order:

snd_pcm_hw_params -> _snd_pcm_hw_params -> pcm->ops->hw_params() which is snd_pcm_plug_hw_params() -> snd_pcm_plug_hw_refine_schange -> snd_pcm_format_mask_set -> snd_mask_set 

In order to use pcm_plug.c, how do I setup the device name? 

Thanks,
Philip

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Why is snd_pcm_hw_params_set_format() not setting the format at all?
  2011-01-03 17:03   ` Why is snd_pcm_hw_params_set_format() not setting the format at all? Philip Chu
@ 2011-01-03 17:08     ` Jaroslav Kysela
  0 siblings, 0 replies; 7+ messages in thread
From: Jaroslav Kysela @ 2011-01-03 17:08 UTC (permalink / raw)
  To: Philip Chu; +Cc: alsa-devel

On Mon, 3 Jan 2011, Philip Chu wrote:

> When I call snd_pcm_hw_params_set_format() to set up a new format, it seems to call following in order and none of them is setting up the format bit?
>
> snd_pcm_hw_params_set_format() -> snd_pcm_hw_param_set() -> _snd_pcm_hw_param_set() -> snd_mask_refine_set() -> snd_mask_single() + snd_mask_leave()

Please, post or analyze snd_pcm_hw_params_dump() output before and after 
snd_pcm_hw_params_set_format() call.

 						Jaroslav

-----
Jaroslav Kysela <perex@perex.cz>
Linux Kernel Sound Maintainer
ALSA Project, Red Hat, Inc.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-01-03 17:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-28 21:46 [PATCH] ALSA: lib: Fix static linking of libasound Daniel Chen
2011-01-01 15:07 ` Jaroslav Kysela
2011-01-01 17:41   ` Daniel Chen
2011-01-01 23:42     ` Jaroslav Kysela
2011-01-03 10:50       ` Colin Guthrie
2011-01-03 17:03   ` Why is snd_pcm_hw_params_set_format() not setting the format at all? Philip Chu
2011-01-03 17:08     ` Jaroslav Kysela

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).