Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 571036 - media-libs/mesa [debug] fails to build on musl due to missing execinfo.h
Summary: media-libs/mesa [debug] fails to build on musl due to missing execinfo.h
Status: CONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Unspecified (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo musl team
URL:
Whiteboard:
Keywords:
Depends on: 570838
Blocks: musl-porting 716422 571220
  Show dependency tree
 
Reported: 2016-01-06 08:27 UTC by tt_1
Modified: 2020-04-06 08:42 UTC (History)
3 users (show)

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


Attachments
output of emerge --info (emerge-info,5.07 KB, text/plain)
2016-01-06 08:27 UTC, tt_1
Details
compressed build.log (mesa-11.0.6-missing-execinfo.log.gz,7.71 KB, application/gzip)
2016-01-06 08:30 UTC, tt_1
Details
patch to ad header-check (add-exexinfo-header-check.patch,652 bytes, patch)
2016-01-12 20:55 UTC, tt_1
Details | Diff
patch to eventually bypass the bug (gl_gentable.py.patch,625 bytes, patch)
2016-01-12 21:01 UTC, tt_1
Details | Diff
patch ready for upstrem (mesa-11.0.6-musl-fix-execinfo.patch,1.27 KB, application/mbox)
2016-02-08 20:32 UTC, tt_1
Details
diff for the ebuild (ebuild.diff,518 bytes, patch)
2016-02-08 20:51 UTC, tt_1
Details | Diff
mesa-11.1.2 and mesa-11.0.6 execinfo patch (mesa-11-execinfo.patch,2.99 KB, patch)
2016-03-10 00:33 UTC, Aric Belsito
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description tt_1 2016-01-06 08:27:54 UTC
Created attachment 422054 [details]
output of emerge --info

I stepped into this one while debugging firefox. 

output of emerge -pv mesa

Calculating dependencies... done!
[ebuild   R    ] media-libs/mesa-11.0.6::gentoo  USE="classic debug* dri3 egl gallium gbm llvm nptl pax_kernel pic udev -bindist -d3d9 -gles1 -gles2 -opencl (-openmax) -osmesa (-selinux) -vaapi (-vdpau) -wayland -xa -xvmc" VIDEO_CARDS="nouveau (-freedreno) -i915 -i965 -ilo -intel -r100 -r200 -r300 -r600 -radeon -radeonsi (-vmware)" 0 KiB
Comment 1 tt_1 2016-01-06 08:30:13 UTC
Created attachment 422056 [details]
compressed build.log

/var/tmp/portage/media-libs/mesa-11.0.6/work/mesa-11.0.6/src/mapi/glapi/glapi_gentable.c:44:22: fatal error: execinfo.h: No such file or directory
 #include <execinfo.h>

this doesn't happen without debug useflag due to 

#ifdef USE_BACKTRACE
#include <execinfo.h>
#endif

in glapi_gentable.c
Comment 2 Anthony Basile gentoo-dev 2016-01-06 12:51:52 UTC
A similar issue came up with uclibc.  Take a look at bug #425042.  I approached the problem incorrectly there and fell into the trap of checking for __GLIBC__ and __UCLIBC__ which is what most code does.  But this is wrong minded and musl doesn't define a __MUSL__ on purpose.  The proper way to fix this is to check for execinfo.h in configure.ac, set some #define and then check for it in the code.

So, in the configure file do

AC_CHECK_HEADERS([execinfo.h])

and then in the C code do

#ifdef HAVE_EXECINFO_H
...
#endif

Make sure that config.h is included at the top of the C.  Of course, make sure to rip out any of the __GLIBC__ and __UCLIBC__ that are trying to protect the backtrace code.

If you like and you find it fun, try making a patch and we'll submit it upstream.
Comment 3 tt_1 2016-01-12 20:55:00 UTC
Created attachment 422744 [details, diff]
patch to ad header-check

This is a patch to implement a check for the presence of execinfo.h during configure. I'm not yet really sure about the rest though.
Comment 4 tt_1 2016-01-12 21:01:57 UTC
Created attachment 422746 [details, diff]
patch to eventually bypass the bug

This is what Felix suggested to do. It seems to fix the compile issue for me, but I have no idea what it would do on a glibc system or if it would suit upstream.
Comment 5 Anthony Basile gentoo-dev 2016-02-06 21:02:31 UTC
(In reply to tt_1 from comment #4)
> Created attachment 422746 [details, diff] [details, diff]
> patch to eventually bypass the bug
> 
> This is what Felix suggested to do. It seems to fix the compile issue for
> me, but I have no idea what it would do on a glibc system or if it would
> suit upstream.

That patch should be fine on all systems.  Build systems should move away from __CYGWIN__ style check and to direct checks of the components they need.  The best example here is __UCLIBC__ where checking if that macro is defined is deceiving since uclibc is configurable.  So some uclibc systems might HAVE_EXECINFO_H while others might not. Testing for __UCLIBC__ when you want to know if you HAVE_EXECINFO_H is wrong minded.  I've been guilty of this myself.
Comment 6 Anthony Basile gentoo-dev 2016-02-06 21:04:17 UTC
(In reply to tt_1 from comment #3)
> Created attachment 422744 [details, diff] [details, diff]
> patch to ad header-check
> 
> This is a patch to implement a check for the presence of execinfo.h during
> configure. I'm not yet really sure about the rest though.

It is sufficient to do just

+AC_CHECK_HEADERS([execinfo.h])

since if this macro passes, then it defines HAVE_EXECINFO_H for you.  Check that it works though since there might be some subtlety.
Comment 7 tt_1 2016-02-08 20:32:59 UTC
Created attachment 425000 [details]
patch ready for upstrem

like this?
Comment 8 tt_1 2016-02-08 20:51:59 UTC
Created attachment 425006 [details, diff]
diff for the ebuild

the ebuild needs a little adjustment
Comment 9 Aric Belsito 2016-03-10 00:33:02 UTC
Created attachment 427852 [details, diff]
mesa-11.1.2 and mesa-11.0.6 execinfo patch

Here's a modified version of @tt_1's patch that removes the old __GLIBC__ && !__UCLIBC__ checks.
Comment 10 Felix Janda 2016-03-12 11:55:09 UTC
wrt Comment 9:
I don't think it's necessary to patch intel_regions.c. The code is
essentially commented out. Except for that it looks good to me. With
the part for glapi_gentable.c removed (glapi_gentable.c is generated
by gl_gentable.py), the patch applies cleanly to mesa git. It would be
cool if you could git-send-email it to mesa-dev@lists.freedesktop.org.

wrt Comment 6:
AC_CHECK_HEADERS will define HAVE_EXECINFO_H make configure.status
substitute HAVE_EXECINFO_H everywhere, but that's it, since there is no
configure header.
Comment 11 Aric Belsito 2016-03-12 21:08:21 UTC
(In reply to Felix Janda from comment #10)
> wrt Comment 9:
> I don't think it's necessary to patch intel_regions.c. The code is
> essentially commented out. Except for that it looks good to me. With
> the part for glapi_gentable.c removed (glapi_gentable.c is generated
> by gl_gentable.py), the patch applies cleanly to mesa git. It would be
> cool if you could git-send-email it to mesa-dev@lists.freedesktop.org.

Alright. I'll remove those pieces and submit it upstream.
Comment 12 tt_1 2017-02-23 08:55:09 UTC
What happened with the patch? Has it been sent to upstream?
Comment 13 Aric Belsito 2017-03-17 06:36:36 UTC
I submitted it, and it was ignored -- I'm not sure how to get the maintainers to notice it.
Comment 14 Felix Janda 2017-03-17 23:04:41 UTC
Aric, thanks for submitting the patch upstream!
(It can be seen here: https://patchwork.freedesktop.org/patch/76803/)

https://mesa.freedesktop.org/submittingpatches.html has some advice
on submitting patches. (Check out scripts/get_reviewer.pl.)
Comment 15 Anthony Basile gentoo-dev 2017-03-18 05:55:43 UTC
(In reply to Aric Belsito from comment #13)
> I submitted it, and it was ignored -- I'm not sure how to get the
> maintainers to notice it.

mattst88 might be able to help you.  i think he's upstream with mesa.