Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 621732 - media-libs/mesa-17.1.2 fails to build with LTO and -Wl,--as-needed (undefined reference to `pthread_create')
Summary: media-libs/mesa-17.1.2 fails to build with LTO and -Wl,--as-needed (undefined...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo X packagers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: lto
  Show dependency tree
 
Reported: 2017-06-14 11:40 UTC by Markus Walter
Modified: 2024-03-11 22:46 UTC (History)
5 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
emerge --info (info.txt,7.66 KB, text/plain)
2017-06-14 11:40 UTC, Markus Walter
Details
build log (bzipped) (mesa-17.1.2:20170614-092013.log.bz2,19.34 KB, application/x-bzip)
2017-06-14 11:40 UTC, Markus Walter
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Walter 2017-06-14 11:40:00 UTC
Created attachment 476322 [details]
emerge --info

On my hardened ~amd64 system I see the following build failure for mesa. This is happening for quite some time (last successful merge was for mesa-17.0.4). Any hints on what to do?

libtool: link: x86_64-pc-linux-gnu-g++ -fvisibility=hidden -Werror=pointer-arith -Werror=vla -O2 -pipe -march=native -finline-functions -floop-nest-optimize -flto=4 -Wall -fno-math-errno -fno-trapping-math -Wl,-O1 -Wl,--as-needed -o glsl_compiler glsl/main.o  glsl/.libs/libstandalone.a -lz -lpthread
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/libstdc++.so: undefined reference to `pthread_create'
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/libstdc++.so: undefined reference to `pthread_once'
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/libstdc++.so: undefined reference to `pthread_join'
Comment 1 Markus Walter 2017-06-14 11:40:49 UTC
Created attachment 476324 [details]
build log (bzipped)
Comment 2 Alexander Tsoy 2017-06-14 16:55:25 UTC
Does it build with LTO disabled?
Comment 3 Markus Walter 2017-06-14 17:12:21 UTC
Indeed disabling LTO made the issue go away.

I must have missed this in one debugging round and then thought that I checked it.
Comment 4 David Kredba 2017-06-14 19:49:28 UTC
Try please to add '-Wl,--no-as-needed' before -lpthread so it becomes

x86_64-pc-linux-gnu-g++ -fvisibility=hidden -Werror=pointer-arith -Werror=vla -O2 -pipe -march=native -finline-functions -floop-nest-optimize -flto=4 -Wall -fno-math-errno -fno-trapping-math -Wl,-O1 -Wl,--as-needed -o glsl_compiler glsl/main.o  glsl/.libs/libstandalone.a -lz -Wl,--no-as-needed -lpthread
Comment 5 Markus Walter 2017-06-15 07:35:10 UTC
(In reply to David Kredba from comment #4)
> Try please to add '-Wl,--no-as-needed' before -lpthread so it becomes
> 
> x86_64-pc-linux-gnu-g++ -fvisibility=hidden -Werror=pointer-arith
> -Werror=vla -O2 -pipe -march=native -finline-functions -floop-nest-optimize
> -flto=4 -Wall -fno-math-errno -fno-trapping-math -Wl,-O1 -Wl,--as-needed -o
> glsl_compiler glsl/main.o  glsl/.libs/libstandalone.a -lz -Wl,--no-as-needed
> -lpthread

This worked too. :)

However I have no idea how to convince the Makefile to add this programmatically (I just ran the command by hand).
Comment 6 David Kredba 2017-07-02 08:54:04 UTC
Mesa added -pthread to PTHREAD_LIBS in the "Bug 101071 - compiling glsl fails with undefined reference to `pthread_create' "(https://bugs.freedesktop.org/show_bug.cgi?id=101071).
Comment 7 Matt Turner gentoo-dev 2017-08-07 19:28:23 UTC
This is fixed in mesa-17.1.4.