Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 641808 - media-libs/mesa-17.3.0 fails with -flto
Summary: media-libs/mesa-17.3.0 fails with -flto
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:
: 647090 663494 (view as bug list)
Depends on:
Blocks: lto
  Show dependency tree
 
Reported: 2017-12-20 13:21 UTC by cryptopsy
Modified: 2019-07-09 18:47 UTC (History)
12 users (show)

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


Attachments
emerge --info (info,3.23 KB, text/plain)
2017-12-20 13:21 UTC, cryptopsy
Details
build.log (media-libs_mesa-17.3.0_20171220-151249.log.bz2,30.68 KB, application/x-bzip)
2017-12-20 13:26 UTC, cryptopsy
Details
workaround-flto-build-failure.patch (workaround-flto-build-failure.patch,338 bytes, patch)
2018-03-14 03:54 UTC, Alexander Miller
Details | Diff
mesa-18.2-glapi-no-flto.patch (file_641808.txt,365 bytes, patch)
2018-11-11 18:00 UTC, Alexander Miller
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description cryptopsy 2017-12-20 13:21:47 UTC
Created attachment 511180 [details]
emerge --info

libtool: link: ( cd "glsl/.libs" && rm -f "libstandalone.la" && ln -s "../libstandalone.la" "libstandalone.la" )
/bin/sh ../../libtool  --tag=CXX   --mode=link x86_64-pc-linux-gnu-g++ -m32 -fvisibility=hidden -Werror=vla -O2 -pipe -march=native -flto -Wall -fno-math-errno -fno-trapping-math   -Wl,-O1 -Wl,--as-needed -o glsl_compiler glsl/main.o glsl/libstandalone.la  
libtool: link: x86_64-pc-linux-gnu-g++ -m32 -fvisibility=hidden -Werror=vla -O2 -pipe -march=native -flto -Wall -fno-math-errno -fno-trapping-math -Wl,-O1 -Wl,--as-needed -o glsl_compiler glsl/main.o  glsl/.libs/libstandalone.a -lz -lpthread -pthread
/usr/lib/gcc/x86_64-pc-linux-gnu/6.4.0/32/libstdc++.so: undefined reference to `pthread_create'
/usr/lib/gcc/x86_64-pc-linux-gnu/6.4.0/32/libstdc++.so: undefined reference to `pthread_once'
/usr/lib/gcc/x86_64-pc-linux-gnu/6.4.0/32/libstdc++.so: undefined reference to `pthread_join'
collect2: error: ld returned 1 exit status
make[4]: *** [Makefile:2133: glsl_compiler] Error 1
make[4]: Leaving directory '/tmp/.portage/portage/media-libs/mesa-17.3.0/work/mesa-17.3.0-abi_x86_32.x86/src/compiler'
make[3]: *** [Makefile:1569: all] Error 2
make[3]: Leaving directory '/tmp/.portage/portage/media-libs/mesa-17.3.0/work/mesa-17.3.0-abi_x86_32.x86/src/compiler'
make[2]: *** [Makefile:861: all-recursive] Error 1
make[2]: Leaving directory '/tmp/.portage/portage/media-libs/mesa-17.3.0/work/mesa-17.3.0-abi_x86_32.x86/src'
make[1]: *** [Makefile:652: all] Error 2
make[1]: Leaving directory '/tmp/.portage/portage/media-libs/mesa-17.3.0/work/mesa-17.3.0-abi_x86_32.x86/src'
make: *** [Makefile:659: all-recursive] Error 1
 * ERROR: media-libs/mesa-17.3.0::gentoo failed (compile phase):
 *   emake failed
 * 
 * If you need support, post the output of `emerge --info '=media-libs/mesa-17.3.0::gentoo'`,
 * the complete build log and the output of `emerge -pqv '=media-libs/mesa-17.3.0::gentoo'`.
 * The complete build log is located at '/tmp/.portage/logs/media-libs:mesa-17.3.0:20171220-151249.log'.
 * For convenience, a symlink to the build log is located at '/tmp/.portage/portage/media-libs/mesa-17.3.0/temp/build.log'.
 * The ebuild environment file is located at '/tmp/.portage/portage/media-libs/mesa-17.3.0/temp/environment'.
 * Working directory: '/tmp/.portage/portage/media-libs/mesa-17.3.0/work/mesa-17.3.0-abi_x86_32.x86'
 * S: '/tmp/.portage/portage/media-libs/mesa-17.3.0/work/mesa-17.3.0'
Comment 1 cryptopsy 2017-12-20 13:26:29 UTC
Created attachment 511182 [details]
build.log
Comment 2 Balázs Kalmár 2018-01-27 07:22:52 UTC
happens for me since mesa 17.1
only workaround that worked is: LDFLAGS="-Wl,-O1 -Wl,--no-as-needed" emerge -a1 mesa
(source: http://gcc.1065356.n8.nabble.com/LTO-cannot-find-pthread-create-and-friends-td1359045.html )
Comment 3 Matt Turner gentoo-dev 2018-03-01 06:59:42 UTC
*** Bug 647090 has been marked as a duplicate of this bug. ***
Comment 4 Alexander Miller 2018-03-14 03:54:29 UTC
Created attachment 523842 [details, diff]
workaround-flto-build-failure.patch

Here is a slightly less invasive workaround which doesn't disable --as-needed entirely, it only links libpthread with --no-as-needed into glsl_compiler. It's still an ugly hack, though.
Comment 5 cryptopsy 2018-03-23 12:01:31 UTC
same problem in 18.0.0-rc5
Comment 6 n05ph3r42 2018-04-08 13:52:33 UTC
can confirm 
mesa 18.0.0 
CFLAGS="-march=ivybridge -mfpmath=both -mavx -maes -flto -fno-fat-lto-objects -ftree-vectorize -fomit-frame-pointer -O2 -pipe"

emrge --info 
https://paste.pound-python.org/show/69yCuOn4VjMTlaSWrHEW/
emerge --pqv
https://paste.pound-python.org/show/NmzmhSehMWUoAC6VTbS9/

libtool: link: x86_64-pc-linux-gnu-g++ -fvisibility=hidden -Werror=pointer-arith -Werror=vla -march=ivybridge -mfpmath=both -mavx -maes -flto -fno-fat-lto-objects -ftree-vectorize -fomit-frame-pointer -O2 -pipe -Wall -fno-math-errno -fno-trapping-math -Wl,-O1 -Wl,--as-needed -o glsl_compiler glsl/main.o  glsl/.libs/libstandalone.a -lz -lpthread -pthread
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/libstdc++.so: undefined reference to `pthread_create'
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/libstdc++.so: undefined reference to `pthread_once'
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/libstdc++.so: undefined reference to `pthread_join'
collect2: error: ld returned 1 exit status
make[4]: *** [Makefile:2357: glsl_compiler] Error 1
make[4]: Leaving directory '/var/tmp/portage/media-libs/mesa-18.0.0/work/mesa-18.0.0-abi_x86_64.amd64/src/compiler'
make[3]: *** [Makefile:1788: all] Error 2
make[3]: Leaving directory '/var/tmp/portage/media-libs/mesa-18.0.0/work/mesa-18.0.0-abi_x86_64.amd64/src/compiler'
make[2]: *** [Makefile:873: all-recursive] Error 1
make[2]: Leaving directory '/var/tmp/portage/media-libs/mesa-18.0.0/work/mesa-18.0.0-abi_x86_64.amd64/src'
make[1]: *** [Makefile:658: all] Error 2
make[1]: Leaving directory '/var/tmp/portage/media-libs/mesa-18.0.0/work/mesa-18.0.0-abi_x86_64.amd64/src'
make: *** [Makefile:666: all-recursive] Error 1
 * ERROR: media-libs/mesa-18.0.0::gentoo failed (compile phase)
Comment 7 n05ph3r42 2018-04-16 13:39:55 UTC
Switched to

CFLAGS="-march=sandybridge -mfpmath=both -mavx -maes -O2 -pipe -pthread -fuse-ld=gold -flto=8 -fomit-frame-pointer -ftree-vectorize"

Creating 

/etc/portage/env/force_CXXFLAGS_LDFLAGS.conf :
EXTRA_CXXFLAGS="${CXXFLAGS}"
EXTRA_LFLAGS="${LDFLAGS}"

and

/etc/portage/package.env :
media-libs/mesa force_CXXFLAGS_LDFLAGS.conf

solved issue.
Comment 8 cryptopsy 2018-04-28 14:51:55 UTC
it is stricly due to -flto.
CFLAGS="-march=native" #works 
CFLAGS="-march=native -flto" #fails
Comment 9 Petross404(Petros S) 2018-07-24 15:35:31 UTC
(In reply to cryptopsy from comment #8)
> it is stricly due to -flto.
> CFLAGS="-march=native" #works 
> CFLAGS="-march=native -flto" #fails

You may want to try -flto-partition=none in package.env for mesa with LTO.
Comment 10 Matt Turner gentoo-dev 2018-08-15 23:09:04 UTC
*** Bug 663494 has been marked as a duplicate of this bug. ***
Comment 11 Klaus Kusche 2018-08-18 07:02:51 UTC
Many link errors when linking libGL with lto which are not pthread-related.
gcc-7.3.0-r3, media-libs/mesa-18.2.0_rc3
Emerges without errors with no-lto.

/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /var/portage/.tmp/cc9fdJmO.ltrans1.ltrans.o: in function `MakeContextCurrent':
<artificial>:(.text+0xa33d): undefined reference to `glGetString'
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: <artificial>:(.text+0xa347): undefined reference to `glGetString'
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /var/portage/.tmp/cc9fdJmO.ltrans2.ltrans.o: in function `driCopySubBuffer':
<artificial>:(.text+0x6120): undefined reference to `glFlush'
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /var/portage/.tmp/cc9fdJmO.ltrans2.ltrans.o: in function `driSwapBuffers':
<artificial>:(.text+0x6164): undefined reference to `glFlush'
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /var/portage/.tmp/cc9fdJmO.ltrans2.ltrans.o: in function `driswSwapBuffers':
<artificial>:(.text+0x61a4): undefined reference to `glFlush'
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /var/portage/.tmp/cc9fdJmO.ltrans2.ltrans.o: in function `driswCopySubBuffer':
<artificial>:(.text+0x6220): undefined reference to `glFlush'
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /var/portage/.tmp/cc9fdJmO.ltrans2.ltrans.o: in function `dri2CopySubBuffer':
<artificial>:(.text+0x7351): undefined reference to `glFlush'
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /var/portage/.tmp/cc9fdJmO.ltrans2.ltrans.o:<artificial>:(.text+0x93b6): more u
ndefined references to `glFlush' follow
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /var/portage/.tmp/cc9fdJmO.ltrans4.ltrans.o: in function `DRI_glXUseXFont':
<artificial>:(.text+0x2ca1): undefined reference to `glGetIntegerv'
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: <artificial>:(.text+0x2cb0): undefined reference to `glGetIntegerv'
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: <artificial>:(.text+0x2cbf): undefined reference to `glGetIntegerv'
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: <artificial>:(.text+0x2cce): undefined reference to `glGetIntegerv'
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: <artificial>:(.text+0x2cdd): undefined reference to `glGetIntegerv'
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /var/portage/.tmp/cc9fdJmO.ltrans4.ltrans.o:<artificial>:(.text+0x2cec): more u
ndefined references to `glGetIntegerv' follow
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /var/portage/.tmp/cc9fdJmO.ltrans4.ltrans.o: in function `DRI_glXUseXFont':
<artificial>:(.text+0x2cf8): undefined reference to `glPixelStorei'
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: <artificial>:(.text+0x2d04): undefined reference to `glPixelStorei'
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: <artificial>:(.text+0x2d10): undefined reference to `glPixelStorei'
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: <artificial>:(.text+0x2d1c): undefined reference to `glPixelStorei'
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: <artificial>:(.text+0x2d28): undefined reference to `glPixelStorei'
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /var/portage/.tmp/cc9fdJmO.ltrans4.ltrans.o:<artificial>:(.text+0x2d37): more undefined references to `glPixelStorei' follow
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /var/portage/.tmp/cc9fdJmO.ltrans4.ltrans.o: in function `DRI_glXUseXFont':
<artificial>:(.text+0x2e1e): undefined reference to `glNewList'
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: <artificial>:(.text+0x2e3b): undefined reference to `glBitmap'
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: <artificial>:(.text+0x2e44): undefined reference to `glEndList'
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: <artificial>:(.text+0x2e7f): undefined reference to `glPixelStorei'
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: <artificial>:(.text+0x2e8d): undefined reference to `glPixelStorei'
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: <artificial>:(.text+0x2e9b): undefined reference to `glPixelStorei'
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: <artificial>:(.text+0x2ea9): undefined reference to `glPixelStorei'
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: <artificial>:(.text+0x2eb7): undefined reference to `glPixelStorei'
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /var/portage/.tmp/cc9fdJmO.ltrans4.ltrans.o:<artificial>:(.text+0x2ec5): more undefined references to `glPixelStorei' follow
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /var/portage/.tmp/cc9fdJmO.ltrans4.ltrans.o: in function `DRI_glXUseXFont':
<artificial>:(.text+0x2f62): undefined reference to `glNewList'
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: <artificial>:(.text+0x2f9c): undefined reference to `glBitmap'
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: <artificial>:(.text+0x2fa1): undefined reference to `glEndList'
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: <artificial>:(.text+0x31a8): undefined reference to `glBitmap'
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: <artificial>:(.text+0x3297): undefined reference to `glNewList'
collect2: error: ld returned 1 exit status
Comment 12 Guillaume Ceccarelli 2018-08-20 20:14:40 UTC
I'm also seeing LTO-related issues, on mesa-18.2.0_rc3 using GCC 8.2.0-r2 with binutils-2.31.1 and the bfd linker.
however, mesa-18.1.6 compiles fine with LTO (without -Wl,--as-needed)

USE="classic dri3 egl gallium gbm llvm pax_kernel -d3d9 -debug -gles1 -gles2 -lm_sensors% -opencl -osmesa -pic (-selinux) -test% -unwind -vaapi -valgrind -vdpau -vulkan -wayland -xa -xvmc (-bindist%) (-nptl%*) (-openmax%)"
VIDEO_CARDS="intel nouveau radeon radeonsi (-freedreno) -i915 -i965 (-imx) -r100 -r200 -r300 -r600 (-vc4) -virgl (-vivante) -vmware"

Errors with mesa-18.2.0_rc3 below (toggling -flto-partition=none didn't help):

/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /var/tmp/portage/media-libs/mesa-18.2.0_rc3/temp/cc3nHKvf.ltrans0.ltrans.o: in function `driCopySubBuffer':
<artificial>:(.text+0x941): undefined reference to `glFlush'
/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /var/tmp/portage/media-libs/mesa-18.2.0_rc3/temp/cc3nHKvf.ltrans0.ltrans.o: in function `driSwapBuffers':
<artificial>:(.text+0x991): undefined reference to `glFlush'
/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /var/tmp/portage/media-libs/mesa-18.2.0_rc3/temp/cc3nHKvf.ltrans0.ltrans.o: in function `dri2Flush.constprop.11':
<artificial>:(.text+0x9f86): undefined reference to `glFlush'
/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /var/tmp/portage/media-libs/mesa-18.2.0_rc3/temp/cc3nHKvf.ltrans1.ltrans.o: in function `driswSwapBuffers':
<artificial>:(.text+0x4211): undefined reference to `glFlush'
/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /var/tmp/portage/media-libs/mesa-18.2.0_rc3/temp/cc3nHKvf.ltrans1.ltrans.o: in function `driswCopySubBuffer':
<artificial>:(.text+0x4261): undefined reference to `glFlush'
/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /var/tmp/portage/media-libs/mesa-18.2.0_rc3/temp/cc3nHKvf.ltrans1.ltrans.o: in function `DRI_glXUseXFont':
<artificial>:(.text+0x61b9): undefined reference to `glGetIntegerv'
/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: <artificial>:(.text+0x61c8): undefined reference to `glGetIntegerv'
/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: <artificial>:(.text+0x61d7): undefined reference to `glGetIntegerv'
/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: <artificial>:(.text+0x61e6): undefined reference to `glGetIntegerv'
/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: <artificial>:(.text+0x61f5): undefined reference to `glGetIntegerv'
/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /var/tmp/portage/media-libs/mesa-18.2.0_rc3/temp/cc3nHKvf.ltrans1.ltrans.o:<artificial>:(.text+0x6204): more undefined references to `glGetIntegerv' follow
/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /var/tmp/portage/media-libs/mesa-18.2.0_rc3/temp/cc3nHKvf.ltrans1.ltrans.o: in function `DRI_glXUseXFont':
<artificial>:(.text+0x6210): undefined reference to `glPixelStorei'
/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: <artificial>:(.text+0x621c): undefined reference to `glPixelStorei'
/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: <artificial>:(.text+0x6228): undefined reference to `glPixelStorei'
/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: <artificial>:(.text+0x6234): undefined reference to `glPixelStorei'
/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: <artificial>:(.text+0x6240): undefined reference to `glPixelStorei'
/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /var/tmp/portage/media-libs/mesa-18.2.0_rc3/temp/cc3nHKvf.ltrans1.ltrans.o:<artificial>:(.text+0x624f): more undefined references to `glPixelStorei' follow
/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /var/tmp/portage/media-libs/mesa-18.2.0_rc3/temp/cc3nHKvf.ltrans1.ltrans.o: in function `DRI_glXUseXFont':
<artificial>:(.text+0x6352): undefined reference to `glNewList'
/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: <artificial>:(.text+0x6387): undefined reference to `glBitmap'
/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: <artificial>:(.text+0x638c): undefined reference to `glEndList'
/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: <artificial>:(.text+0x65cc): undefined reference to `glBitmap'
/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: <artificial>:(.text+0x65d1): undefined reference to `glEndList'
/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: <artificial>:(.text+0x6611): undefined reference to `glPixelStorei'
/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: <artificial>:(.text+0x661f): undefined reference to `glPixelStorei'
/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: <artificial>:(.text+0x662d): undefined reference to `glPixelStorei'
/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: <artificial>:(.text+0x663b): undefined reference to `glPixelStorei'
/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: <artificial>:(.text+0x6649): undefined reference to `glPixelStorei'
/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /var/tmp/portage/media-libs/mesa-18.2.0_rc3/temp/cc3nHKvf.ltrans1.ltrans.o:<artificial>:(.text+0x6657): more undefined references to `glPixelStorei' follow
/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /var/tmp/portage/media-libs/mesa-18.2.0_rc3/temp/cc3nHKvf.ltrans3.ltrans.o: in function `MakeContextCurrent':
<artificial>:(.text+0xe917): undefined reference to `glGetString'
/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: <artificial>:(.text+0xe921): undefined reference to `glGetString'
Comment 13 Alexander Miller 2018-11-11 18:00:53 UTC
Created attachment 554856 [details, diff]
mesa-18.2-glapi-no-flto.patch

Why has bug 663494 been marked as a duplicate of this bug?
It's a different issue.

Anyway, the entry points of the GL API that are reported as "undefined
reference" errors are defined in global asm statements (in headers
included from src/mapi/entry.c). Since gcc doesn't parse asm statements,
these symbols are invisible in LTO objects. I.e., the file must be
compiled without LTO. The attached patch adds the necessary flag for
the relevant target.

Unfortunately this isn't enough for multilib builds. The way meson.eclass
sets up the cross file for the non-default ABIs makes it impossible to
override CFLAGS. I had to change _meson_create_cross_file() such that
it appends C{PP,}FLAGS to "c" (the compiler) instead of using "c_args".
With that change and the patch I could successfully build
media-libs/mesa-18.2.4 on a multilib system.
Comment 14 Matt Turner gentoo-dev 2019-07-09 18:47:45 UTC
mesa-19.1.2 builds for me with CFLAGS="-O2 -march=native -pipe -flto" CXXFLAGS="$CFLAGS" on gcc-8.3.0-r1.