Bug 361253 - [s390x] ex_clone.c:42: undefined reference to `pthread_create'
Summary: [s390x] ex_clone.c:42: undefined reference to `pthread_create'
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (show other bugs)
Version: 3.11 SVN
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-03-31 21:48 UTC by dann frazier
Modified: 2016-09-20 12:35 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Move -lpthread to end of linker command line (432 bytes, patch)
2016-03-31 21:51 UTC, dann frazier
Details

Note You need to log in before you can comment on or make changes to this bug.
Description dann frazier 2016-03-31 21:48:13 UTC
'make regtest' on trunk currently fails on Ubuntu 16.04/s390x.

gcc -Winline -Wall -Wshadow -Wno-long-long -g -fno-stack-protector   -m64   -lpthread  -o ex_clone ex_clone.o  
ex_clone.o: In function `main':
/home/ubuntu/valgrind/none/tests/s390x/ex_clone.c:42: undefined reference to `pthread_create'
/home/ubuntu/valgrind/none/tests/s390x/ex_clone.c:57: undefined reference to `pthread_join'
collect2: error: ld returned 1 exit status
Makefile:1324: recipe for target 'ex_clone' failed



Reproducible: Always

Steps to Reproduce:
1. Install Ubuntu 16.04 on an s390x system
2. svn clone svn://svn.valgrind.org/valgrind/trunk valgrind
3. cd valgrind; ./autogen.sh; ./configure; make regtest


Actual Results:  
gcc -Winline -Wall -Wshadow -Wno-long-long -g -fno-stack-protector   -m64   -lpthread  -o ex_clone ex_clone.o  
ex_clone.o: In function `main':
/home/ubuntu/valgrind/none/tests/s390x/ex_clone.c:42: undefined reference to `pthread_create'
/home/ubuntu/valgrind/none/tests/s390x/ex_clone.c:57: undefined reference to `pthread_join'
collect2: error: ld returned 1 exit status
Makefile:1324: recipe for target 'ex_clone' failed

Expected Results:  
Successful build.
Comment 1 dann frazier 2016-03-31 21:51:00 UTC
Created attachment 98183 [details]
Move -lpthread to end of linker command line
Comment 2 Christian Borntraeger 2016-09-20 12:21:59 UTC
I can certaiinly apply this patch, but I am puzzled. 

why does

gcc  -Winline -Wall -Wshadow -Wno-long-long -g -fno-stack-protector   -m64   -o ex_clone none/tests/s390x/ex_clone.o -lpthread 

work
and
gcc  -Winline -Wall -Wshadow -Wno-long-long -g -fno-stack-protector   -m64   -lpthread -o ex_clone none/tests/s390x/ex_clone.o
does not?
Comment 3 Christian Borntraeger 2016-09-20 12:32:19 UTC
OK, seems that library ordering does indeed matter.
applied as r15970