All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix liblvm2cmd.so linking order for --as-needed builds
@ 2010-09-01 15:35 Diego Elio Pettenò
  2010-10-12 13:55 ` Zdenek Kabelac
  0 siblings, 1 reply; 7+ messages in thread
From: Diego Elio Pettenò @ 2010-09-01 15:35 UTC (permalink / raw)
  To: lvm-devel

Hi all,

I'm attaching a patch that fix the linking of liblvm2cmd.so so that it
actually links to the libraries it needs... with the original Makefile,
the linking order is such that ld drops all the libraries, linking only
libc at the end... this in turn will cause undefined references to floor
when the library is loaded in (see http://bugs.gentoo.org/335205 for
reference).

HTH!

-- 
Diego Elio Petten? ? ?Flameeyes?
http://blog.flameeyes.eu/

If you found a .asc file in this mail and know not what it is,
it's a GnuPG digital signature: http://www.gnupg.org/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: lvm2-2.02.73-asneeded.patch
Type: text/x-patch
Size: 640 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/lvm-devel/attachments/20100901/d3186f81/attachment.bin>

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

* [PATCH] Fix liblvm2cmd.so linking order for --as-needed builds
  2010-09-01 15:35 [PATCH] Fix liblvm2cmd.so linking order for --as-needed builds Diego Elio Pettenò
@ 2010-10-12 13:55 ` Zdenek Kabelac
  2010-10-12 14:26   ` Diego Elio Pettenò
  0 siblings, 1 reply; 7+ messages in thread
From: Zdenek Kabelac @ 2010-10-12 13:55 UTC (permalink / raw)
  To: lvm-devel

Dne 1.9.2010 17:37, Diego Elio Petten? napsal(a):
> Hi all,
> 
> I'm attaching a patch that fix the linking of liblvm2cmd.so so that it
> actually links to the libraries it needs... with the original Makefile,
> the linking order is such that ld drops all the libraries, linking only
> libc at the end... this in turn will cause undefined references to floor
> when the library is loaded in (see http://bugs.gentoo.org/335205 for
> reference).

The last occurrence of  CLDWHOLEARCHIVE in tools/Makefile.in seems to be
dropped by this Alasdair's commit:

Author: Alasdair Kergon <agk@redhat.com>
Date:   Thu Feb 2 19:16:47 2006 +0000

Which seems to in somewhat history.

So this patch doesn't look like upstream related - rather some local 'gentoo'
cooking patch ?   Is gentoo doing their own build rules?

If the upstream still has any linking problem - please report problems/patches
against upstream CVS/git repository.


Zdenek



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

* [PATCH] Fix liblvm2cmd.so linking order for --as-needed builds
  2010-10-12 13:55 ` Zdenek Kabelac
@ 2010-10-12 14:26   ` Diego Elio Pettenò
  2010-10-12 14:57     ` Zdenek Kabelac
  2010-11-30 10:31     ` Zdenek Kabelac
  0 siblings, 2 replies; 7+ messages in thread
From: Diego Elio Pettenò @ 2010-10-12 14:26 UTC (permalink / raw)
  To: lvm-devel

Il giorno mar, 12/10/2010 alle 15.55 +0200, Zdenek Kabelac ha scritto:
> The last occurrence of  CLDWHOLEARCHIVE in tools/Makefile.in seems to be
> dropped by this Alasdair's commit:

Uh?

liblvm2cmd.$(LIB_SUFFIX): liblvm2cmd.a $(LDDEPS)
        $(CC) -shared -Wl,-soname,$@.$(LIB_VERSION) \
        $(CFLAGS) $(CLDFLAGS) -o $@ $(LVMLIBS) $(LIBS) \
                @CLDWHOLEARCHIVE@ liblvm2cmd.a @CLDNOWHOLEARCHIVE@

this is in 

commit 39429d390515de9a375979274bc61d787ea9a0cb
Author: Zdenek Kabelac <zkabelac@redhat.com>
Date:   Fri Oct 8 15:03:21 2010 +0000

Did I get the wrong GIT repository?


-- 
Diego Elio Petten? ? ?Flameeyes?
http://blog.flameeyes.eu/

If you found a .asc file in this mail and know not what it is,
it's a GnuPG digital signature: http://www.gnupg.org/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: This is a digitally signed message part
URL: <http://listman.redhat.com/archives/lvm-devel/attachments/20101012/07353e75/attachment.sig>

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

* [PATCH] Fix liblvm2cmd.so linking order for --as-needed builds
  2010-10-12 14:26   ` Diego Elio Pettenò
@ 2010-10-12 14:57     ` Zdenek Kabelac
  2010-10-12 15:15       ` Przemyslaw Iskra
  2010-11-30 10:31     ` Zdenek Kabelac
  1 sibling, 1 reply; 7+ messages in thread
From: Zdenek Kabelac @ 2010-10-12 14:57 UTC (permalink / raw)
  To: lvm-devel

Dne 12.10.2010 16:20, Diego Elio Petten? napsal(a):
> Il giorno mar, 12/10/2010 alle 15.55 +0200, Zdenek Kabelac ha scritto:
>> The last occurrence of  CLDWHOLEARCHIVE in tools/Makefile.in seems to be
>> dropped by this Alasdair's commit:
> 
> Uh?
> 
> liblvm2cmd.$(LIB_SUFFIX): liblvm2cmd.a $(LDDEPS)
>         $(CC) -shared -Wl,-soname,$@.$(LIB_VERSION) \
>         $(CFLAGS) $(CLDFLAGS) -o $@ $(LVMLIBS) $(LIBS) \
>                 @CLDWHOLEARCHIVE@ liblvm2cmd.a @CLDNOWHOLEARCHIVE@
> 
> this is in 
> 
> commit 39429d390515de9a375979274bc61d787ea9a0cb
> Author: Zdenek Kabelac <zkabelac@redhat.com>
> Date:   Fri Oct 8 15:03:21 2010 +0000
> 
> Did I get the wrong GIT repository?

Ooops sorry - my bad - I've been working with non-master git branch looking
for some older bug.


Hmm - ok - I'll need to take a look on this.


Zdenek



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

* [PATCH] Fix liblvm2cmd.so linking order for --as-needed builds
  2010-10-12 14:57     ` Zdenek Kabelac
@ 2010-10-12 15:15       ` Przemyslaw Iskra
  2010-10-15  9:50         ` Zdenek Kabelac
  0 siblings, 1 reply; 7+ messages in thread
From: Przemyslaw Iskra @ 2010-10-12 15:15 UTC (permalink / raw)
  To: lvm-devel

On Tue, Oct 12, 2010 at 04:57:31PM +0200, Zdenek Kabelac wrote:

> Hmm - ok - I'll need to take a look on this.

The Makefile should be fixed, but...

Why not just drop floor() usage (which is misused anyways) ?
Without it the whole -lm won't be needed.
I've sent a patch for this some time ago, resending it here.
[May be a bit outdated if configure.in changed]


-- 
 ____  Sparky{PI] -- Przemyslaw _  ___  _  _  ......... LANG...Pl,Ca,Es,En
/____) ___  ___  _ _ || Iskra  |  | _ \| |  | : WWW...ppcrcd.pld-linux.org
\____\| -_)'___| ||^'||//\\// <   |  _/| |  | : WWW2..............rsget.pl
(____/||   (_-_|_||  ||\\ ||   |_ |_|  |_| _| : Mail..sparky@pld-linux.org
-------------- next part --------------
>From ab3a151bdae8566fddbd91cdc86c600083890f59 Mon Sep 17 00:00:00 2001
From: Przemyslaw Iskra <sparky@pld-linux.org>
Date: Fri, 30 Jul 2010 18:45:43 +0200
Subject: [PATCH] Don't use floor() in _bitset_with_random_bits

Use _even_rand() function instead of floor() in
_bitset_with_random_bits(). floor() function is missing in dietlibc (on
architectures other than x86). Moreover using floor() to clip rand
results does not assure even result distribution.
_even_rand() uses integer arithmetic only and is designed to return evenly
distributed results.

Signed-off-by: Przemyslaw Iskra <sparky@pld-linux.org>
---
 configure.in            |    3 +--
 lib/metadata/metadata.c |   16 +++++++++++++++-
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/configure.in b/configure.in
index bd56136..6f6c67e 100644
--- a/configure.in
+++ b/configure.in
@@ -125,8 +125,7 @@ AC_STRUCT_TM
 
 ################################################################################
 dnl -- Check for functions
-AC_SEARCH_LIBS([floor], [m], , [AC_MSG_ERROR(bailing out)])
-AC_CHECK_FUNCS([floor ftruncate gethostname getpagesize \
+AC_CHECK_FUNCS([ftruncate gethostname getpagesize \
   gettimeofday memset mkdir mkfifo rmdir munmap nl_langinfo setenv setlocale \
   strcasecmp strchr strcspn strspn strdup strncasecmp strerror strrchr \
   strstr strtol strtoul uname], , [AC_MSG_ERROR(bailing out)])
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 07222a7..6ee7731 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -1018,6 +1018,20 @@ static int _recalc_extents(uint32_t *extents, const char *desc1,
 	return 1;
 }
 
+/* return random integer in [0,max) interval */
+static unsigned _even_rand( unsigned *seed, unsigned max )
+{
+	unsigned r, ret;
+
+	/* make sure distribution is even */
+	do {
+		r = (unsigned) rand_r( seed );
+		ret = r % max;
+	} while ( r - ret > RAND_MAX - max );
+
+	return ret;
+}
+
 static dm_bitset_t _bitset_with_random_bits(struct dm_pool *mem, uint32_t num_bits,
 					    uint32_t num_set_bits, unsigned *seed)
 {
@@ -1040,7 +1054,7 @@ static dm_bitset_t _bitset_with_random_bits(struct dm_pool *mem, uint32_t num_bi
 	/* Perform loop num_set_bits times, selecting one bit each time */
 	while (i++ < num_bits) {
 		/* Select a random bit between 0 and (i-1) inclusive. */
-		bit_selected = (unsigned) floor(i * (rand_r(seed) / (RAND_MAX + 1.0)));
+		bit_selected = _even_rand( seed, i );
 
 		/*
 		 * If the bit was already set, set the new bit that became
-- 
1.7.1


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

* [PATCH] Fix liblvm2cmd.so linking order for --as-needed builds
  2010-10-12 15:15       ` Przemyslaw Iskra
@ 2010-10-15  9:50         ` Zdenek Kabelac
  0 siblings, 0 replies; 7+ messages in thread
From: Zdenek Kabelac @ 2010-10-15  9:50 UTC (permalink / raw)
  To: lvm-devel

Dne 12.10.2010 17:15, Przemyslaw Iskra napsal(a):
> On Tue, Oct 12, 2010 at 04:57:31PM +0200, Zdenek Kabelac wrote:
> 
>> Hmm - ok - I'll need to take a look on this.
> 
> The Makefile should be fixed, but...
> 
> Why not just drop floor() usage (which is misused anyways) ?
> Without it the whole -lm won't be needed.
> I've sent a patch for this some time ago, resending it here.
> [May be a bit outdated if configure.in changed]
> 

Ok, both patches (Makefile.in, metadata.c) are now upstream.

Zdenek



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

* [PATCH] Fix liblvm2cmd.so linking order for --as-needed builds
  2010-10-12 14:26   ` Diego Elio Pettenò
  2010-10-12 14:57     ` Zdenek Kabelac
@ 2010-11-30 10:31     ` Zdenek Kabelac
  1 sibling, 0 replies; 7+ messages in thread
From: Zdenek Kabelac @ 2010-11-30 10:31 UTC (permalink / raw)
  To: lvm-devel

Dne 12.10.2010 16:20, Diego Elio Petten? napsal(a):
> Il giorno mar, 12/10/2010 alle 15.55 +0200, Zdenek Kabelac ha scritto:
>> The last occurrence of  CLDWHOLEARCHIVE in tools/Makefile.in seems to be
>> dropped by this Alasdair's commit:
> 
> Uh?
> 
> liblvm2cmd.$(LIB_SUFFIX): liblvm2cmd.a $(LDDEPS)
>         $(CC) -shared -Wl,-soname,$@.$(LIB_VERSION) \
>         $(CFLAGS) $(CLDFLAGS) -o $@ $(LVMLIBS) $(LIBS) \
>                 @CLDWHOLEARCHIVE@ liblvm2cmd.a @CLDNOWHOLEARCHIVE@
> 
> this is in 
> 
> commit 39429d390515de9a375979274bc61d787ea9a0cb
> Author: Zdenek Kabelac <zkabelac@redhat.com>
> Date:   Fri Oct 8 15:03:21 2010 +0000
> 
> Did I get the wrong GIT repository?
> 


f5c395ad (Alasdair Kergon   2008-11-14 20:59:56 +0000 151)
liblvm2cmd.$(LIB_SUFFIX): liblvm2cmd.a $(LDDEPS)
16d70487 (Zdenek Kabelac    2010-05-11 08:34:38 +0000 152)      $(CC) -shared
-Wl,-soname,$@.$(LIB_VERSION) \
d54db501 (Zdenek Kabelac    2010-10-15 09:41:21 +0000 153)
$(CFLAGS) $(CLDFLAGS) -o $@ \
d54db501 (Zdenek Kabelac    2010-10-15 09:41:21 +0000 154)
@CLDWHOLEARCHIVE@ liblvm2cmd.a @CLDNOWHOLEARCHIVE@ \
d54db501 (Zdenek Kabelac    2010-10-15 09:41:21 +0000 155)
$(LVMLIBS) $(LIBS)

---

liblvm2cmd.$(LIB_SUFFIX): liblvm2cmd.a $(LDDEPS)
	$(CC) -shared -Wl,-soname,$@.$(LIB_VERSION) \
		$(CFLAGS) $(CLDFLAGS) -o $@ \
		@CLDWHOLEARCHIVE@ liblvm2cmd.a @CLDNOWHOLEARCHIVE@ \
		$(LVMLIBS) $(LIBS)

---

commit d54db5013b9ff5ebdf7cc3747b78e0cc39f72b39
Author: Zdenek Kabelac <zkabelac@redhat.com>
Date:   Fri Oct 15 09:41:21 2010 +0000

    Fix linking order for liblvm2cmd

    Reorder linked libraries so we better support --as-needed linker flag used
    by some distributions (i.e. Gentoo).

    Patch suggested by Diego Elio Petten? <flameeyes <at> gmail.com>

---


I suppose this should be fixing reported problem ?

Zdenek



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

end of thread, other threads:[~2010-11-30 10:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-01 15:35 [PATCH] Fix liblvm2cmd.so linking order for --as-needed builds Diego Elio Pettenò
2010-10-12 13:55 ` Zdenek Kabelac
2010-10-12 14:26   ` Diego Elio Pettenò
2010-10-12 14:57     ` Zdenek Kabelac
2010-10-12 15:15       ` Przemyslaw Iskra
2010-10-15  9:50         ` Zdenek Kabelac
2010-11-30 10:31     ` Zdenek Kabelac

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.