All of lore.kernel.org
 help / color / mirror / Atom feed
* fix dmsetup link failure with --enable-static_link on Debian unstable
@ 2007-08-10 19:49 Jim Meyering
  2007-08-10 20:06 ` Alasdair G Kergon
  0 siblings, 1 reply; 4+ messages in thread
From: Jim Meyering @ 2007-08-10 19:49 UTC (permalink / raw)
  To: device-mapper development

Configuring with --enable-static_link on Debian unstable
makes dmsetup fail to link:

    /usr/lib/gcc/i486-linux-gnu/4.1.3/../../../../lib/libselinux.a(setrans_client.o): In function `fini_context_translations':
    /build/buildd/libselinux-2.0.15/src/setrans_client.c:208: undefined reference to `pthread_mutex_lock'
    ...
    /usr/lib/gcc/i486-linux-gnu/4.1.3/libgcc_eh.a(unwind-dw2-fde-glibc.o): In function `__deregister_frame_info_bases':
    (.text+0x100e): undefined reference to `pthread_mutex_lock'
    ...
    collect2: ld returned 1 exit status
    make[1]: *** [dmsetup.static] Error 1
    make[1]: Leaving directory `/media/sda4/home/meyering/work/co/git-mirror/device-mapper/dmsetup'
    make: *** [dmsetup] Error 2

Here's the patch I'm using:

diff --git a/configure.in b/configure.in
index f57de3f..c1870f3 100644
--- a/configure.in
+++ b/configure.in
@@ -239,8 +239,22 @@ if test x$SELINUX = xyes; then
 	else
 		AC_MSG_WARN(Disabling selinux)
 	fi
+
+	# With --enable-static_link and selinux, linking dmsetup fails
+	# on at least Debian unstable due to unsatisfied references to
+	# pthread_mutex_lock and _unlock.  See if we need -lpthread.
+	if test $STATIC_LINK = yes; then
+		dm_saved_libs=$LIBS
+		LIBS="$LIBS -static"
+		AC_SEARCH_LIBS([pthread_mutex_lock], [pthread],
+		  [test "$ac_cv_search_pthread_mutex_lock" = "none required" ||
+				LIB_PTHREAD=-lpthread])
+		AC_SUBST([LIB_PTHREAD])
+		LIBS=$dm_saved_libs
+	fi
 fi

+
 ################################################################################
 dnl -- Check for getopt
 AC_CHECK_HEADERS(getopt.h, AC_DEFINE([HAVE_GETOPTLONG], 1, [Define to 1 if getopt_long is available.]))
diff --git a/dmsetup/Makefile.in b/dmsetup/Makefile.in
index 2dcedc7..b63c6f7 100644
--- a/dmsetup/Makefile.in
+++ b/dmsetup/Makefile.in
@@ -18,6 +18,7 @@ VPATH = @srcdir@
 
 TARGETS = dmsetup
 INSTALL_TYPE = install_dynamic
+LIB_PTHREAD = @LIB_PTHREAD@
 
 ifeq ("@STATIC_LINK@", "yes")
   TARGETS += dmsetup.static
@@ -35,7 +36,8 @@ dmsetup: $(OBJECTS) $(interfacedir)/libdevmapper.$(LIB_SUFFIX)
 
 dmsetup.static: $(OBJECTS) $(interfacedir)/libdevmapper.a
 	$(CC) -o $@ $(OBJECTS) $(CFLAGS) $(LDFLAGS) -static \
-	      -L$(interfacedir) -L$(DESTDIR)/lib -ldevmapper $(LIBS)
+	      -L$(interfacedir) -L$(DESTDIR)/lib -ldevmapper $(LIBS) \
+	      $(LIB_PTHREAD)
 
 install: $(INSTALL_TYPE)
 

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

* Re: fix dmsetup link failure with --enable-static_link on Debian unstable
  2007-08-10 19:49 fix dmsetup link failure with --enable-static_link on Debian unstable Jim Meyering
@ 2007-08-10 20:06 ` Alasdair G Kergon
  2007-08-10 20:08   ` Alasdair G Kergon
  2007-08-11  8:49   ` Jim Meyering
  0 siblings, 2 replies; 4+ messages in thread
From: Alasdair G Kergon @ 2007-08-10 20:06 UTC (permalink / raw)
  To: device-mapper development

On Fri, Aug 10, 2007 at 09:49:34PM +0200, Jim Meyering wrote:
> Configuring with --enable-static_link on Debian unstable
> makes dmsetup fail to link:
 
Only if dmeventd is enabled?  If so, the check must take that into account.
If not, I'm curious what's pulling that in.

Alasdair
-- 
agk@redhat.com

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

* Re: fix dmsetup link failure with --enable-static_link on Debian unstable
  2007-08-10 20:06 ` Alasdair G Kergon
@ 2007-08-10 20:08   ` Alasdair G Kergon
  2007-08-11  8:49   ` Jim Meyering
  1 sibling, 0 replies; 4+ messages in thread
From: Alasdair G Kergon @ 2007-08-10 20:08 UTC (permalink / raw)
  To: device-mapper development

On Fri, Aug 10, 2007 at 09:06:24PM +0100, Alasdair G Kergon wrote:
> Only if dmeventd is enabled?  If so, the check must take that into account.
> If not, I'm curious what's pulling that in.
 
If it's selinux, then restrict pulling it in to the cases when selinux
is enabled.

Alasdair
-- 
agk@redhat.com

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

* Re: fix dmsetup link failure with --enable-static_link on Debian unstable
  2007-08-10 20:06 ` Alasdair G Kergon
  2007-08-10 20:08   ` Alasdair G Kergon
@ 2007-08-11  8:49   ` Jim Meyering
  1 sibling, 0 replies; 4+ messages in thread
From: Jim Meyering @ 2007-08-11  8:49 UTC (permalink / raw)
  To: device-mapper development; +Cc: Alasdair G Kergon

Alasdair G Kergon <agk@redhat.com> wrote:
> On Fri, Aug 10, 2007 at 09:49:34PM +0200, Jim Meyering wrote:
>> Configuring with --enable-static_link on Debian unstable
>> makes dmsetup fail to link:
>
> Only if dmeventd is enabled?  If so, the check must take that into account.
> If not, I'm curious what's pulling that in.

The link failure occurs regardless of whether dmeventd is enabled.
As you could see from the diagnostics, it is SELinux-related.
Build with "make LIBS=" (to attempt linking without -lselinux),
and you see which functions:

  ../lib/ioctl/libdevmapper.a(libdm-common.o): In function `dm_set_selinux_context':
  libdm-common.c:(.text+0x571): undefined reference to `is_selinux_enabled'
  libdm-common.c:(.text+0x58d): undefined reference to `matchpathcon'
  libdm-common.c:(.text+0x5dd): undefined reference to `lsetfilecon'
  libdm-common.c:(.text+0x5ec): undefined reference to `freecon'
  libdm-common.c:(.text+0x659): undefined reference to `freecon'
  collect2: ld returned 1 exit status
  make[1]: *** [dmsetup.static] Error 1

The test introduced by my initial patch was run only if $SELINUX = yes
(the default), by virtue of being in that if-block.  The one below
further restricts it to run only if $HAVE_SELINUX is also "yes".

If it's ok to commit this now, let me know what version of autoconf
to use when regenerating "configure".

diff --git a/configure.in b/configure.in
index f57de3f..924aa86 100644
--- a/configure.in
+++ b/configure.in
@@ -239,6 +239,18 @@ if test x$SELINUX = xyes; then
 	else
 		AC_MSG_WARN(Disabling selinux)
 	fi
+
+	# With --enable-static_link and selinux enabled, linking dmsetup
+	# fails on at least Debian unstable due to unsatisfied references
+	# to pthread_mutex_lock and _unlock.  See if we need -lpthread.
+	if test "$STATIC_LINK-$HAVE_SELINUX" = yes-yes; then
+		dm_saved_libs=$LIBS
+		LIBS="$LIBS -static"
+		AC_SEARCH_LIBS([pthread_mutex_lock], [pthread],
+		  [test "$ac_cv_search_pthread_mutex_lock" = "none required" ||
+				LIB_PTHREAD=-lpthread])
+		LIBS=$dm_saved_libs
+	fi
 fi
 
 ################################################################################
@@ -413,6 +425,7 @@ AC_SUBST(DEVICE_GID)
 AC_SUBST(DEVICE_MODE)
 AC_SUBST(DMEVENTD)
 AC_SUBST(PKGCONFIG)
+AC_SUBST([LIB_PTHREAD])
 
 ################################################################################
 dnl -- First and last lines should not contain files to generate in order to 
diff --git a/dmsetup/Makefile.in b/dmsetup/Makefile.in
index 2dcedc7..b63c6f7 100644
--- a/dmsetup/Makefile.in
+++ b/dmsetup/Makefile.in
@@ -18,6 +18,7 @@ VPATH = @srcdir@
 
 TARGETS = dmsetup
 INSTALL_TYPE = install_dynamic
+LIB_PTHREAD = @LIB_PTHREAD@
 
 ifeq ("@STATIC_LINK@", "yes")
   TARGETS += dmsetup.static
@@ -35,7 +36,8 @@ dmsetup: $(OBJECTS) $(interfacedir)/libdevmapper.$(LIB_SUFFIX)
 
 dmsetup.static: $(OBJECTS) $(interfacedir)/libdevmapper.a
 	$(CC) -o $@ $(OBJECTS) $(CFLAGS) $(LDFLAGS) -static \
-	      -L$(interfacedir) -L$(DESTDIR)/lib -ldevmapper $(LIBS)
+	      -L$(interfacedir) -L$(DESTDIR)/lib -ldevmapper $(LIBS) \
+	      $(LIB_PTHREAD)
 
 install: $(INSTALL_TYPE)
 

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

end of thread, other threads:[~2007-08-11  8:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-10 19:49 fix dmsetup link failure with --enable-static_link on Debian unstable Jim Meyering
2007-08-10 20:06 ` Alasdair G Kergon
2007-08-10 20:08   ` Alasdair G Kergon
2007-08-11  8:49   ` Jim Meyering

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.