Skip to contentSkip to conversation

scrub: fix build failure by restoring proper library ordering

PATCH In review [email protected] 3 participants 3 messages Nov 7, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scrub: fix build failure by restoring proper library ordering

From: Sergei Trofimovich <[email protected]>

$ LDFLAGS=-static make
gcc -lpthread -g -O0 -o btrfs btrfs.o btrfs_cmds.o scrub.o \
        ctree.o disk-io.o radix-tree.o extent-tree.o print-tree.o root-tree.o dir-item.o file-item.o inode-item.o inode-map.o crc32c.o rbtree.o extent-cache.o extent_io.o volumes.o utils.o btrfs-list.o btrfslabel.o -static -luuid
scrub.o: In function `scrub_write_progress':
/home/slyfox/linux-2.6-um-x86_64-fs/btrfs-progs-unstable/scrub.c:752: undefined reference to `pthread_mutex_lock'
/home/slyfox/linux-2.6-um-x86_64-fs/btrfs-progs-unstable/scrub.c:758: undefined reference to `pthread_setcancelstate'
/home/slyfox/linux-2.6-um-x86_64-fs/btrfs-progs-unstable/scrub.c:783: undefined reference to `pthread_mutex_unlock'
/home/slyfox/linux-2.6-um-x86_64-fs/btrfs-progs-unstable/scrub.c:787: undefined reference to `pthread_setcancelstate'
---
 Makefile |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
Makefile +2 -2
index edee1a0..4d498b9 100644
@@ -36,8 +36,8 @@ version:
 	bash version.sh
 
 btrfs: $(objects) btrfs.o btrfs_cmds.o scrub.o
-	$(CC) -lpthread $(CFLAGS) -o btrfs btrfs.o btrfs_cmds.o scrub.o \
-		$(objects) $(LDFLAGS) $(LIBS)
+	$(CC) $(CFLAGS) -o btrfs btrfs.o btrfs_cmds.o scrub.o \
+		$(objects) $(LDFLAGS) $(LIBS) -lpthread
 
 btrfsctl: $(objects) btrfsctl.o
 	$(CC) $(CFLAGS) -o btrfsctl btrfsctl.o $(objects) $(LDFLAGS) $(LIBS)
Signature · 1 line
1.7.3.4
#1 lore raw

Makefile version: · line 40

Quoted 5 lines · On Mon, Nov 07, 2011 at 10:19:33AM +0300, [email protected] wrote:

btrfs: $(objects) btrfs.o btrfs_cmds.o scrub.o

Makefile +2 -2
-	$(CC) -lpthread $(CFLAGS) -o btrfs btrfs.o btrfs_cmds.o scrub.o \
-		$(objects) $(LDFLAGS) $(LIBS)
+	$(CC) $(CFLAGS) -o btrfs btrfs.o btrfs_cmds.o scrub.o \
+		$(objects) $(LDFLAGS) $(LIBS) -lpthread

No, it's "-pthread", adds both preprocessor and linker flags.

david

#2 lore raw

Hi David,

Quoted 8 lines · David Sterba

Makefile version: · line 40

Quoted 5 lines · On Mon, Nov 07, 2011 at 10:19:33AM +0300, [email protected] wrote:

btrfs: $(objects) btrfs.o btrfs_cmds.o scrub.o

Makefile +2 -2
-	$(CC) -lpthread $(CFLAGS) -o btrfs btrfs.o btrfs_cmds.o scrub.o \
-		$(objects) $(LDFLAGS) $(LIBS)
+	$(CC) $(CFLAGS) -o btrfs btrfs.o btrfs_cmds.o scrub.o \
+		$(objects) $(LDFLAGS) $(LIBS) -lpthread

No, it's "-pthread", adds both preprocessor and linker flags.

It seems to do the right thing on x86_64, although...

If I'm reading my gcc manpage right, it is telling me to use -pthread only for ia64 on HPUX, powerpc and sparc. (gcc 4.4.5 that is)

-Jan