Fix liblvm2cmd.so linking order for --as-needed builds
PATCH 1/1 Fix liblvm2cmd.so linking order for --as-needed builds
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!
Signature · 13 lines
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>
PATCH 1/1 Fix liblvm2cmd.so linking order for --as-needed builds
Dne 1.9.2010 17:37, Diego Elio Petten? napsal(a):
Quoted 8 lines
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 <[email protected]> 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
PATCH 1/1 Fix liblvm2cmd.so linking order for --as-needed builds
Il giorno mar, 12/10/2010 alle 15.55 +0200, Zdenek Kabelac ha scritto:
Quoted 2 lines
The last occurrence of CLDWHOLEARCHIVE in
tools/Makefile.inseems 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 <[email protected]> Date: Fri Oct 8 15:03:21 2010 +0000
Did I get the wrong GIT repository?
Signature · 13 lines
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>
PATCH 1/1 Fix liblvm2cmd.so linking order for --as-needed builds
Dne 12.10.2010 16:20, Diego Elio Petten? napsal(a):
Quoted 11 lines
Il giorno mar, 12/10/2010 alle 15.55 +0200, Zdenek Kabelac ha scritto:
Quoted 2 lines
The last occurrence of CLDWHOLEARCHIVE in
tools/Makefile.inseems 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@
Quoted 7 lines
this is in
commit
39429d390515de9a375979274bc61d787ea9a0cbAuthor: Zdenek Kabelac <[email protected]> Date: Fri Oct 8 15:03:21 2010 +0000Did 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
PATCH 1/1 Fix liblvm2cmd.so linking order for --as-needed builds
Quoted 1 line · Zdenek Kabelac
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]
Signature · 5 lines
____ Sparky{PI] -- Przemyslaw _ ___ _ _ ......... LANG...Pl,Ca,Es,En
/____) ___ ___ _ _ || Iskra | | _ \| | | : WWW...ppcrcd.pld-linux.org
\____\| -_)'___| ||^'||//\\// < | _/| | | : WWW2..............rsget.pl
(____/|| (_-_|_|| ||\\ || |_ |_| |_| _| : [email protected]
-------------- next part --------------Quoted 1 line
From
ab3a151bdae8566fddbd91cdc86c600083890f59Mon Sep 17 00:00:00 2001
From: Przemyslaw Iskra <[email protected]>
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.
--- configure.in | 3 +-- lib/metadata/metadata.c | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-)
configure.in +1 -2
@@ -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)])
lib/metadata/metadata.c +15 -1
@@ -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
Signature · 1 line
1.7.1
PATCH 1/1 Fix liblvm2cmd.so linking order for --as-needed builds
Dne 12.10.2010 17:15, Przemyslaw Iskra napsal(a):
Quoted 11 lines · Zdenek Kabelac
Quoted 2 lines
Hmm - ok - I'll need to take a look on this.
The
Makefileshould 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
PATCH 1/1 Fix liblvm2cmd.so linking order for --as-needed builds
In reply to Diego Elio PettenòDne 12.10.2010 16:20, Diego Elio Petten? napsal(a):
Quoted 11 lines
Il giorno mar, 12/10/2010 alle 15.55 +0200, Zdenek Kabelac ha scritto:
Quoted 2 lines
The last occurrence of CLDWHOLEARCHIVE in
tools/Makefile.inseems 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@
Quoted 8 lines
this is in
commit
39429d390515de9a375979274bc61d787ea9a0cbAuthor: Zdenek Kabelac <[email protected]> Date: Fri Oct 8 15:03:21 2010 +0000Did 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 <[email protected]> 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