Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: tools: fix a regression issue that gcc can't link to pthread

Reproduce:
ray@hr-bak:~/usb$ make -C tools/usb/
make: Entering directory `/home/ray/usb/tools/usb'
gcc -Wall -Wextra -g -lpthread -I../include -o testusb testusb.c
/tmp/cc0EMxfy.o: In function `main':
/home/ray/usb/tools/usb/testusb.c:508: undefined reference to `pthread_create'
/home/ray/usb/tools/usb/testusb.c:531: undefined reference to `pthread_join'
collect2: error: ld returned 1 exit status
make: *** [testusb] Error 1
make: Leaving directory `/home/ray/usb/tools/usb'

Comments:
In the latest version (4.7.3) of gcc compiler, it requres that
libraries must follow the object or source files like below:

"gcc hello.c -lpthread" instead of "gcc -lpthread hello.c"

And it isn't encountered at gcc version 4.7.2.
So this patch fix to move the pthread option after testusb.c.

Signed-off-by: Huang Rui <ray.huang@amd.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Huang Rui and committed by
Greg Kroah-Hartman
cb292ce2 eee52f9e

+3 -2
+3 -2
tools/usb/Makefile
··· 3 3 CC = $(CROSS_COMPILE)gcc 4 4 PTHREAD_LIBS = -lpthread 5 5 WARNINGS = -Wall -Wextra 6 - CFLAGS = $(WARNINGS) -g $(PTHREAD_LIBS) -I../include 6 + CFLAGS = $(WARNINGS) -g -I../include 7 + LDFLAGS = $(PTHREAD_LIBS) 7 8 8 9 all: testusb ffs-test 9 10 %: %.c 10 - $(CC) $(CFLAGS) -o $@ $^ 11 + $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) 11 12 12 13 clean: 13 14 $(RM) testusb ffs-test