The backtrace/debugging documentation (see URL for this bug) currently doesn't refer to changing FEATURES/CFLAGS per-package via /etc/portage/env. I think it'd be very handy to have this information in the document to make it easier for people to build debug versions of a particular package (rather than having them build it separately without using portage). An example of expanded documentation may include the requirement to install "debugedit", the "installsources" FEATURE and how to change the CFLAGS/FEATURES from within /etc/portage/env. An example of an entry in /etc/portage/env (zmedico kindly helped me out with this example for glibc): <zmedico> cat /etc/portage/env/sys-libs/glibc <zmedico> if [[ ${EBUILD_PHASE} != depend ]] && ! hasq splitdebug ${FEATURES} ; then <zmedico> einfo "bashrc is enabling splitdebug for glibc" <zmedico> export FEATURES="${FEATURES} installsources splitdebug" <zmedico> export CFLAGS="${CFLAGS} -ggdb" <zmedico> fi The reason I ask for these changes is that I couldn't find much information on this topic when searching with Google and it would make the backtrace documentation far easier for people to understand and put into practice.
*** Bug 200254 has been marked as a duplicate of this bug. ***
Setting per-package CFLAGS and FEATURES is not in any way officially supported, so I don't think it should be suggested in any of our documentation. This has come up before on the forums, and I had to put it into the compilation doc (http://www.gentoo.org/doc/en/gcc-optimization.xml#doc_chap3_sect5) because of it. See http://forums.gentoo.org/viewtopic-t-613247.html; it's an internal Portage feature, not something that users should be setting. (http://forums.gentoo.org/viewtopic-p-3832057.html#3832057)
I agree with nightmorph. The day that we can do this more easily, without having to deal with EBUILD_PHASE, I'll see to add it. As it is, it's too much an hack to document it in proper documents.
(In reply to comment #3) > I agree with nightmorph. The day that we can do this more easily, without > having to deal with EBUILD_PHASE, I'll see to add it. As it is, it's too much > an hack to document it in proper documents. Why would you need to deal with EBUILD_PHASE?
I got this from solar for /etc/portage/bashrc (modded a bit for efficiency since it's run unconditionally): if [[ $EBUILD_PHASE = setup && " $FEATURES " = *' debug '* ]]; then DEBUG=yes RESTRICT+=' nostrip' export CFLAGS="${CFLAGS/-fomit-frame-pointer/} -g3" export CXXFLAGS="${CXXFLAGS/-fomit-frame-pointer/} -g3" export LDFLAGS="${LDFLAGS} -ggdb" fi Posted here for other users: http://forums.gentoo.org/viewtopic-p-4554194.html#4554194 This works, but apparently we should be doing this with pre/post hooks, so it's not a definitive solution.
In sys-apps/portage-2.1.4_rc10 there is an "Ebuild Phase Hooks" section in chapter 1 of the documentation that is installed at /usr/share/doc/portage-2.1.4_rc10/html/index.html when the "doc" USE flag is enabled. See DOC_SYMLINKS_DIR in `man make.conf` if you want bookmarkable symlinks for installed html docs like these. Here's how I enable a debug build for glibc now, without any EBUILD_PHASE references: $ cat /etc/portage/env/sys-libs/glibc pre_pkg_setup() { local x for x in installsources splitdebug ; do if ! hasq ${x} ${FEATURES} ; then elog "bashrc is adding ${x} to FEATURES for ${PN}" FEATURES="${FEATURES} ${x}" fi done if ! hasq -ggdb ${CFLAGS} ; then elog "bashrc is adding \"-ggdb\" to CFLAGS for ${PN}" CFLAGS="${CFLAGS} -ggdb" fi }