[LTP] Use of -pthread

Cyril Hrubis chrubis@suse.cz
Thu May 11 10:10:06 CEST 2017


Hi!
> sge@oststbldvm09 ltp $ find . -name Makefile|xargs grep -- -pthread
> ./lib/newlib_tests/Makefile:test08: CFLAGS+=-pthread
> ./lib/newlib_tests/Makefile:test09: CFLAGS+=-pthread
> ./lib/tests/Makefile:tst_cleanup_once: CFLAGS += -pthread
> ./testcases/kernel/mem/hugetlb/hugemmap/Makefile:hugemmap06: CFLAGS+=-pthread
> ./testcases/kernel/security/dirtyc0w/Makefile:dirtyc0w_child: CFLAGS+=-pthread
> ./testcases/kernel/syscalls/futex/Makefile:futex_wait03: CFLAGS+=-pthread
> ./testcases/kernel/syscalls/futex/Makefile:futex_wake02: CFLAGS+=-pthread
> ./testcases/kernel/syscalls/futex/Makefile:futex_wake04: CFLAGS+=-pthread
> ./testcases/kernel/syscalls/sched_getattr/Makefile:CFLAGS                       += -pthread
> ./testcases/kernel/syscalls/sched_setattr/Makefile:CFLAGS                       += -pthread
> ./testcases/kernel/syscalls/signal/Makefile:signal06: CFLAGS+=-pthread
> 
> 
> Other tests (50+) use:
> 
> LDLIBS += -lpthread
> 
> Instead. 
> 
> Any reason for the difference?

Likely only historical. The only correct way how to link against
libpthread is -pthread in CFLAGS (as it's written in any pthread_*
manual page). Adding -lpthread into LDLIBS may work most of the time but
will fail rarely.

The uses of -lpthread should be replaced with -pthread.

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list