]> www.infradead.org Git - mtd-utils.git/commit
ubi-tests: fix pthreads linking
authorBrian Norris <computersforpeace@gmail.com>
Sun, 25 Nov 2012 07:26:09 +0000 (23:26 -0800)
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Mon, 3 Dec 2012 13:16:55 +0000 (15:16 +0200)
commit3835899b3b29904eede98e0c22973a430c9cb1f9
treea0d8af79f9c4420af3b38a6378121c69ce0c58cc
parent7343528e5821c69224000ed7cfd3e8aaf47b7a93
ubi-tests: fix pthreads linking

Technically, '-l' linker options should be included only after the
objects which must link to the library. So when we include '-lpthread'
in the LDFLAGS variable, it gets placed too early (i.e., before the
io_paral.o object), and so the pthread linkage never occurs. The
following error probably only shows up with linkers that don't link
pthreads by default.

$ make tests V=1
...
gcc -I../../ubi-utils//include -I ../../include -lpthread -Wall -Wextra -Wwrite-strings -Wno-sign-compare -ffunction-sections -fdata-sections -Wl,--gc-sections   -g -o /home/norris/git/mtd-utils/tests/ubi-tests/io_paral /home/norris/git/mtd-utils/tests/ubi-tests/io_paral.o /home/norris/git/mtd-utils/tests/ubi-tests/helpers.o libubi.a
/home/norris/git/mtd-utils/tests/ubi-tests/io_paral.o: In function `main':
/home/norris/git/mtd-utils/tests/ubi-tests/io_paral.c:287: undefined reference to `pthread_create'
/home/norris/git/mtd-utils/tests/ubi-tests/io_paral.c:295: undefined reference to `pthread_create'
/home/norris/git/mtd-utils/tests/ubi-tests/io_paral.c:303: undefined reference to `pthread_join'
collect2: ld returned 1 exit status
make[2]: *** [/home/norris/git/mtd-utils/tests/ubi-tests/io_paral] Error 1
...

$ ld --version
GNU ld (GNU Binutils for Ubuntu) 2.22
...
$ gcc --version
gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
...

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
tests/ubi-tests/Makefile