Skip to contentSkip to conversation

spaceman: Add missing link to libuuid

PATCH In review Khem Raj 3 participants 11 messages Sep 7, 2017 – Sep 9, 2017

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/1 spaceman: Add missing link to libuuid

When uuid is enabled then we see linking failures with gold linker e.g.

libxfs/.libs/libxfs.so: error: undefined reference to 'uuid_compare' libxfs/.libs/libxfs.so: error: undefined reference to 'uuid_copy' clang-5.0: error: linker command failed with exit code 1 (use -v to see invocation)

---
 spaceman/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
spaceman/Makefile +1 -1
index 95ec3c0..060e0af 100644
@@ -9,7 +9,7 @@ LTCOMMAND = xfs_spaceman
 HFILES = init.h space.h
 CFILES = init.c file.c prealloc.c trim.c
 
-LLDLIBS = $(LIBXCMD)
+LLDLIBS = $(LIBXCMD) $(LIBUUID)
 LTDEPENDENCIES = $(LIBXCMD)
 LLDFLAGS = -static
 
Signature · 1 line
2.14.1
#1 lore raw
Quoted 5 lines · Khem Raj

When uuid is enabled then we see linking failures with gold linker e.g.

libxfs/.libs/libxfs.so: error: undefined reference to 'uuid_compare' libxfs/.libs/libxfs.so: error: undefined reference to 'uuid_copy' clang-5.0: error: linker command failed with exit code 1 (use -v to see invocation)

That's libxfs, not xfs_spaceman....

Quoted 11 lines
---
 spaceman/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
spaceman/Makefile +0 -0
index 95ec3c0..060e0af 100644

spaceman/Makefile LTCOMMAND = xfs_spaceman · line 12

Quoted 5 lines
spaceman/Makefile +1 -1
@@ -9,7 +9,7 @@ LTCOMMAND = xfs_spaceman
 HFILES = init.h space.h
 CFILES = init.c file.c prealloc.c trim.c
 
-LLDLIBS = $(LIBXCMD)
+LLDLIBS = $(LIBXCMD) $(LIBUUID)

And spaceman doesn't link against libxfs, nor does libxcmd or spaceman use uuids so I don't see why this fixes a problem with libxfs...

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]
author
#2 lore raw
Quoted 8 lines · Dave Chinner
Quoted 5 lines · Khem Raj

When uuid is enabled then we see linking failures with gold linker e.g.

libxfs/.libs/libxfs.so: error: undefined reference to 'uuid_compare' libxfs/.libs/libxfs.so: error: undefined reference to 'uuid_copy' clang-5.0: error: linker command failed with exit code 1 (use -v to see invocation)

That's libxfs, not xfs_spaceman....

yes its libxfs but its linking spaceman, I chopped the error logs too much I guess.

Quoted 15 lines
Quoted 15 lines
---
 spaceman/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
spaceman/Makefile +0 -0
index 95ec3c0..060e0af 100644
@@ -9,7 +9,7 @@ LTCOMMAND = xfs_spaceman
 HFILES = init.h space.h
 CFILES = init.c file.c prealloc.c trim.c
 
Quoted 6 lines

spaceman/Makefile LTCOMMAND = xfs_spaceman · line 12

Quoted 2 lines
spaceman/Makefile +1 -1
-LLDLIBS = $(LIBXCMD)
+LLDLIBS = $(LIBXCMD) $(LIBUUID)

And spaceman doesn't link against libxfs, nor does libxcmd or spaceman use uuids so I don't see why this fixes a problem with libxfs...

I was just following what other binaries were doing, otherwise I agree libuuid should appear in DT_NEEDED flags in libxfs.so so linkers can pull it in automatically.

try using

LDFLAGS = "-fuse-ld=gold" if you want to reproduce the problem on your end.

Quoted 7 lines

Cheers,

Dave.
--
Dave Chinner
[email protected]

#3 lore raw
Quoted 4 lines · Khem Raj
Quoted 3 lines · Dave Chinner
Quoted 2 lines · Khem Raj

When uuid is enabled then we see linking failures with gold linker e.g.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

libxfs/.libs/libxfs.so: error: undefined reference to 'uuid_compare' libxfs/.libs/libxfs.so: error: undefined reference to 'uuid_copy' clang-5.0: error: linker command failed with exit code 1 (use -v to see invocation)

That's libxfs, not xfs_spaceman....

yes its libxfs but its linking spaceman, I chopped the error logs too much I guess.

xfs_spaceman does not link against libuuid:

$ ldd spaceman/xfs_spaceman 
	linux-vdso.so.1 (0x00007ffca4f68000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fa36f358000)
	/lib64/ld-linux-x86-64.so.2 (0x00007fa36f6f7000)

Nor libxfs - if it linked against libxfs, it would have to pull in 4 other libraries, including libuuid:

$ ldd repair/xfs_repair 
	linux-vdso.so.1 (0x00007ffd96bb4000)
	libuuid.so.1 => /lib/x86_64-linux-gnu/libuuid.so.1 (0x00007f5da2d4f000)
	librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f5da2b47000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f5da292a000)
	libblkid.so.1 => /lib/x86_64-linux-gnu/libblkid.so.1 (0x00007f5da26e4000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f5da2345000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f5da2f54000)

So whatever build error you are having has nothing to do with xfs_spaceman. Have you installed all the necessary libraries?

Quoted 20 lines
Quoted 13 lines
Quoted 13 lines
---
 spaceman/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
spaceman/Makefile +0 -0
index 95ec3c0..060e0af 100644
@@ -9,7 +9,7 @@ LTCOMMAND = xfs_spaceman
 HFILES = init.h space.h
 CFILES = init.c file.c prealloc.c trim.c
 
Quoted 6 lines

spaceman/Makefile LTCOMMAND = xfs_spaceman · line 12

Quoted 2 lines
spaceman/Makefile +1 -1
-LLDLIBS = $(LIBXCMD)
+LLDLIBS = $(LIBXCMD) $(LIBUUID)

And spaceman doesn't link against libxfs, nor does libxcmd or spaceman use uuids so I don't see why this fixes a problem with libxfs...

Quoted 7 lines

I was just following what other binaries were doing, otherwise I agree libuuid should appear in DT_NEEDED flags in libxfs.so so linkers can pull it in automatically.

try using

LDFLAGS = "-fuse-ld=gold" if you want to reproduce the problem on your end.

$ gold -V
GNU gold (GNU Binutils for Debian 2.29) 1.14
$ make distclean
....
$ LDFLAGS="-fuse-ld=gold" make -j8 Q=
....
[LD]     xfs_spaceman
/bin/bash ../libtool --quiet --tag=CC --mode=link gcc -o xfs_spaceman -fuse-ld=gold -fuse-ld=gold  -fuse-ld=gold  -fuse-ld=gold -static  init.o file.o prealloc.o trim.o freesp.o   ../libxcmd/libxcmd.la
.....
$ ldd spaceman/xfs_spaceman 
	linux-vdso.so.1 (0x00007ffc943e4000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f2def2e2000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f2def681000)

TOT builds just fine here on debian unstable using the gold linker, and again this shows that spaceman does not link against libuuid.

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]
author
#4 lore raw
In reply to Dave Chinner

Hi Dave

Quoted 23 lines · Dave Chinner
Quoted 5 lines · Khem Raj

When uuid is enabled then we see linking failures with gold linker e.g.

libxfs/.libs/libxfs.so: error: undefined reference to 'uuid_compare' libxfs/.libs/libxfs.so: error: undefined reference to 'uuid_copy' clang-5.0: error: linker command failed with exit code 1 (use -v to see invocation)

That's libxfs, not xfs_spaceman....

Quoted 14 lines
---
 spaceman/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
spaceman/Makefile +0 -0
index 95ec3c0..060e0af 100644
@@ -9,7 +9,7 @@ LTCOMMAND = xfs_spaceman
 HFILES = init.h space.h
 CFILES = init.c file.c prealloc.c trim.c
 
Quoted 7 lines

spaceman/Makefile LTCOMMAND = xfs_spaceman · line 12

Quoted 2 lines
spaceman/Makefile +1 -1
-LLDLIBS = $(LIBXCMD)
+LLDLIBS = $(LIBXCMD) $(LIBUUID)

And spaceman doesn't link against libxfs, nor does libxcmd or spaceman use uuids so I don't see why this fixes a problem with libxfs...

I am building with --disable-static, I wonder if thats not a supported configuration
for xfsprogs

Quoted 6 lines

Cheers,

Dave.
--
Dave Chinner
[email protected]

#5 lore raw
Quoted 34 lines · Khem Raj

Hi Dave

Quoted 23 lines · Dave Chinner
Quoted 5 lines · Khem Raj

When uuid is enabled then we see linking failures with gold linker e.g.

libxfs/.libs/libxfs.so: error: undefined reference to 'uuid_compare' libxfs/.libs/libxfs.so: error: undefined reference to 'uuid_copy' clang-5.0: error: linker command failed with exit code 1 (use -v to see invocation)

That's libxfs, not xfs_spaceman....

Quoted 14 lines
---
 spaceman/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
spaceman/Makefile +0 -0
index 95ec3c0..060e0af 100644
@@ -9,7 +9,7 @@ LTCOMMAND = xfs_spaceman
 HFILES = init.h space.h
 CFILES = init.c file.c prealloc.c trim.c
 
Quoted 7 lines

spaceman/Makefile LTCOMMAND = xfs_spaceman · line 12

Quoted 2 lines
spaceman/Makefile +1 -1
-LLDLIBS = $(LIBXCMD)
+LLDLIBS = $(LIBXCMD) $(LIBUUID)

And spaceman doesn't link against libxfs, nor does libxcmd or spaceman use uuids so I don't see why this fixes a problem with libxfs...

Quoted 3 lines

I am building with --disable-static, I wonder if thats not a supported configuration
for xfsprogs

Still doesn't make spaceman link against libxfs or use uuids ;)

I guess I'd suggest starting w/ x86 and a standard toolchain, make --disable-static work for you there (I see that it does need some fixups), then try things w/ the alternate toolchain and see if more work is needed.

-Eric

author
#6 lore raw
Quoted 39 lines · Eric Sandeen
Quoted 34 lines · Khem Raj

Hi Dave

Quoted 23 lines · Dave Chinner
Quoted 5 lines · Khem Raj

When uuid is enabled then we see linking failures with gold linker e.g.

libxfs/.libs/libxfs.so: error: undefined reference to 'uuid_compare' libxfs/.libs/libxfs.so: error: undefined reference to 'uuid_copy' clang-5.0: error: linker command failed with exit code 1 (use -v to see invocation)

That's libxfs, not xfs_spaceman....

Quoted 14 lines
---
 spaceman/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
spaceman/Makefile +0 -0
index 95ec3c0..060e0af 100644
@@ -9,7 +9,7 @@ LTCOMMAND = xfs_spaceman
 HFILES = init.h space.h
 CFILES = init.c file.c prealloc.c trim.c
 
Quoted 7 lines

spaceman/Makefile LTCOMMAND = xfs_spaceman · line 12

Quoted 2 lines
spaceman/Makefile +1 -1
-LLDLIBS = $(LIBXCMD)
+LLDLIBS = $(LIBXCMD) $(LIBUUID)

And spaceman doesn't link against libxfs, nor does libxcmd or spaceman use uuids so I don't see why this fixes a problem with libxfs...

Quoted 3 lines

I am building with --disable-static, I wonder if thats not a supported configuration
for xfsprogs

Quoted 6 lines

Still doesn't make spaceman link against libxfs or use uuids ;)

I guess I'd suggest starting w/ x86 and a standard toolchain, make --disable-static work for you there (I see that it does need some fixups), then try things w/ the alternate toolchain and see if more work is needed.

I do see indirect dependency though
libxcmd needs platform_findsizes symbol
from libxfs

I agree, there is some work needed to get it going with --disable-static

Quoted 2 lines

-Eric

#7 lore raw
In reply to Khem Raj
Quoted 34 lines · Khem Raj

Hi Dave

Quoted 23 lines · Dave Chinner
Quoted 5 lines · Khem Raj

When uuid is enabled then we see linking failures with gold linker e.g.

libxfs/.libs/libxfs.so: error: undefined reference to 'uuid_compare' libxfs/.libs/libxfs.so: error: undefined reference to 'uuid_copy' clang-5.0: error: linker command failed with exit code 1 (use -v to see invocation)

That's libxfs, not xfs_spaceman....

Quoted 14 lines
---
 spaceman/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
spaceman/Makefile +0 -0
index 95ec3c0..060e0af 100644
@@ -9,7 +9,7 @@ LTCOMMAND = xfs_spaceman
 HFILES = init.h space.h
 CFILES = init.c file.c prealloc.c trim.c
 
Quoted 7 lines

spaceman/Makefile LTCOMMAND = xfs_spaceman · line 12

Quoted 2 lines
spaceman/Makefile +1 -1
-LLDLIBS = $(LIBXCMD)
+LLDLIBS = $(LIBXCMD) $(LIBUUID)

And spaceman doesn't link against libxfs, nor does libxcmd or spaceman use uuids so I don't see why this fixes a problem with libxfs...

Quoted 3 lines

I am building with --disable-static, I wonder if thats not a supported configuration
for xfsprogs

For what reason?

xfsprogs links it's internal libraries statically while it links to system libraries dynamically. We do not expose internal libraries like libxfs and libxcmd outside the build environment, and so dynamic linking of them doesn't make any sense because they won't be installed on any system you ship the binaries to....

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]
author
#8 lore raw
Quoted 35 lines · Dave Chinner
Quoted 34 lines · Khem Raj

Hi Dave

Quoted 30 lines · Dave Chinner
Quoted 5 lines · Khem Raj

When uuid is enabled then we see linking failures with gold linker e.g.

libxfs/.libs/libxfs.so: error: undefined reference to 'uuid_compare' libxfs/.libs/libxfs.so: error: undefined reference to 'uuid_copy' clang-5.0: error: linker command failed with exit code 1 (use -v to see invocation)

That's libxfs, not xfs_spaceman....

Quoted 11 lines
---
 spaceman/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
spaceman/Makefile +0 -0
index 95ec3c0..060e0af 100644

spaceman/Makefile LTCOMMAND = xfs_spaceman · line 12

Quoted 5 lines
spaceman/Makefile +1 -1
@@ -9,7 +9,7 @@ LTCOMMAND = xfs_spaceman
 HFILES = init.h space.h
 CFILES = init.c file.c prealloc.c trim.c
 
-LLDLIBS = $(LIBXCMD)
+LLDLIBS = $(LIBXCMD) $(LIBUUID)

And spaceman doesn't link against libxfs, nor does libxcmd or spaceman use uuids so I don't see why this fixes a problem with libxfs...

Quoted 6 lines
Quoted 3 lines

I am building with --disable-static, I wonder if thats not a supported configuration
for xfsprogs

For what reason?

this is the distro policy under which I am trying to compile. No other reason.

Quoted 6 lines

xfsprogs links it's internal libraries statically while it links to system libraries dynamically. We do not expose internal libraries like libxfs and libxcmd outside the build environment, and so dynamic linking of them doesn't make any sense because they won't be installed on any system you ship the binaries to....

Thats what I needed to know. I will remove --disable-static and both patches I sent I no more needed.

Quoted 6 lines

Cheers,

Dave.
--
Dave Chinner
[email protected]

#9 lore raw
Quoted 36 lines · Khem Raj
Quoted 35 lines · Dave Chinner
Quoted 34 lines · Khem Raj

Hi Dave

Quoted 30 lines · Dave Chinner
Quoted 5 lines · Khem Raj

When uuid is enabled then we see linking failures with gold linker e.g.

libxfs/.libs/libxfs.so: error: undefined reference to 'uuid_compare' libxfs/.libs/libxfs.so: error: undefined reference to 'uuid_copy' clang-5.0: error: linker command failed with exit code 1 (use -v to see invocation)

That's libxfs, not xfs_spaceman....

Quoted 11 lines
---
 spaceman/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
spaceman/Makefile +0 -0
index 95ec3c0..060e0af 100644

spaceman/Makefile LTCOMMAND = xfs_spaceman · line 12

Quoted 5 lines
spaceman/Makefile +1 -1
@@ -9,7 +9,7 @@ LTCOMMAND = xfs_spaceman
 HFILES = init.h space.h
 CFILES = init.c file.c prealloc.c trim.c
 
-LLDLIBS = $(LIBXCMD)
+LLDLIBS = $(LIBXCMD) $(LIBUUID)

And spaceman doesn't link against libxfs, nor does libxcmd or spaceman use uuids so I don't see why this fixes a problem with libxfs...

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

I am building with --disable-static, I wonder if thats not a supported configuration
for xfsprogs

For what reason?

this is the distro policy under which I am trying to compile. No other reason.

which distro has this policy?

There are certainly policies against static linking with /external/ libraries, because if libfoo has an exploit, you'd have to find every static linker and fix it, rather than just libfoo.

But I can't imagine a policy that says a project cannot statically link with its own /internal/ libraries which are never distributed separately.

-Eric

author
#10 lore raw
Quoted 41 lines · Eric Sandeen
Quoted 40 lines · Khem Raj
Quoted 39 lines · Dave Chinner
Quoted 37 lines · Khem Raj

Hi Dave

Quoted 23 lines · Dave Chinner
Quoted 5 lines · Khem Raj

When uuid is enabled then we see linking failures with gold linker e.g.

libxfs/.libs/libxfs.so: error: undefined reference to 'uuid_compare' libxfs/.libs/libxfs.so: error: undefined reference to 'uuid_copy' clang-5.0: error: linker command failed with exit code 1 (use -v to see invocation)

That's libxfs, not xfs_spaceman....

Quoted 14 lines
---
 spaceman/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
spaceman/Makefile +0 -0
index 95ec3c0..060e0af 100644
@@ -9,7 +9,7 @@ LTCOMMAND = xfs_spaceman
 HFILES = init.h space.h
 CFILES = init.c file.c prealloc.c trim.c
 
Quoted 7 lines

spaceman/Makefile LTCOMMAND = xfs_spaceman · line 12

Quoted 2 lines
spaceman/Makefile +1 -1
-LLDLIBS = $(LIBXCMD)
+LLDLIBS = $(LIBXCMD) $(LIBUUID)

And spaceman doesn't link against libxfs, nor does libxcmd or spaceman use uuids so I don't see why this fixes a problem with libxfs...

I am building with --disable-static, I wonder if thats not a supported configuration
for xfsprogs

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

For what reason?

this is the distro policy under which I am trying to compile. No other reason.

which distro has this policy?

Custom distro based on yocto

Quoted 9 lines

There are certainly policies against static linking with /external/ libraries, because if libfoo has an exploit, you'd have to find every static linker and fix it, rather than just libfoo.

But I can't imagine a policy that says a project cannot statically link with its own /internal/ libraries which are never distributed separately.

I think you are right, in this case we should just make --disable-static to be no op or unsupported option in configure

Quoted 2 lines

-Eric