All of lore.kernel.org
 help / color / mirror / Atom feed
* [Resend PATCH] tools/usb: fix a makefile bug
@ 2012-05-14  3:17 Du, ChangbinX
  2012-05-14  4:20 ` 'gregkh@linuxfoundation.org'
  0 siblings, 1 reply; 2+ messages in thread
From: Du, ChangbinX @ 2012-05-14  3:17 UTC (permalink / raw)
  To: 'gregkh@linuxfoundation.org'
  Cc: 'mina86@mina86.com',
	Fleming, Matt, 'balbi@ti.com', 'hpa@zytor.com',
	'linux-kernel@vger.kernel.org',
	'linux-usb@vger.kernel.org'

I try to compile tools/usb foler, but got below error(gcc version
4.6.3):
	tools/usb/testusb.c:516: undefined reference to `pthread_create'
	tools/usb/testusb.c:541: undefined reference to `pthread_join'
The reason is the makefile puts source files behind of compiler option
"-l". For gcc(and clang), it reads compiler options in order from left
to right. When compiler gets a source file, it starts parsing it and try
to resolve all symbols invoked. If compiler can not resolve a symbol, it
will read --remain-- options and try get a definition of the symbol. So,
if we put source file behind of "-l" option, the specified library will
not work.

Signed-off-by: Du Changbin <changbinx.du@intel.com>
---
 tools/usb/Makefile |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/usb/Makefile b/tools/usb/Makefile
index 396d6c4..e1cfd19 100644
--- a/tools/usb/Makefile
+++ b/tools/usb/Makefile
@@ -7,7 +7,7 @@ CFLAGS = $(WARNINGS) -g $(PTHREAD_LIBS) -I../include
 
 all: testusb ffs-test
 %: %.c
-	$(CC) $(CFLAGS) -o $@ $^
+	$(CC) $^ $(CFLAGS) -o $@
 
 clean:
 	$(RM) testusb ffs-test
-- 
1.7.9.5


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

* Re: [Resend PATCH] tools/usb: fix a makefile bug
  2012-05-14  3:17 [Resend PATCH] tools/usb: fix a makefile bug Du, ChangbinX
@ 2012-05-14  4:20 ` 'gregkh@linuxfoundation.org'
  0 siblings, 0 replies; 2+ messages in thread
From: 'gregkh@linuxfoundation.org' @ 2012-05-14  4:20 UTC (permalink / raw)
  To: Du, ChangbinX
  Cc: 'mina86@mina86.com',
	Fleming, Matt, 'balbi@ti.com', 'hpa@zytor.com',
	'linux-kernel@vger.kernel.org',
	'linux-usb@vger.kernel.org'

On Mon, May 14, 2012 at 03:17:42AM +0000, Du, ChangbinX wrote:
> I try to compile tools/usb foler, but got below error(gcc version
> 4.6.3):
> 	tools/usb/testusb.c:516: undefined reference to `pthread_create'
> 	tools/usb/testusb.c:541: undefined reference to `pthread_join'
> The reason is the makefile puts source files behind of compiler option
> "-l". For gcc(and clang), it reads compiler options in order from left
> to right. When compiler gets a source file, it starts parsing it and try
> to resolve all symbols invoked. If compiler can not resolve a symbol, it
> will read --remain-- options and try get a definition of the symbol. So,
> if we put source file behind of "-l" option, the specified library will
> not work.
> 
> Signed-off-by: Du Changbin <changbinx.du@intel.com>

I think that's a regression in your version of gcc, as 4.6.2 here works
just fine with no errors.

What distro's version of gcc are you using here?  What changed between
4.6.2 and 4.6.3 that would do this?

I just tried 4.5.3 and it worked just fine as well.

I'm thinking something might be messed up on your end here, and this
patch isn't really needed.

thanks,

greg k-h

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

end of thread, other threads:[~2012-05-14  4:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-14  3:17 [Resend PATCH] tools/usb: fix a makefile bug Du, ChangbinX
2012-05-14  4:20 ` 'gregkh@linuxfoundation.org'

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.