From 5165bf7571e49ae950608b4eeabdc3f0620e0ce4 Mon Sep 17 00:00:00 2001 From: Daniel T Chen 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 Signed-off-by: Daniel T Chen --- 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