Support checking for ignored CFLAGS using -frecord-gcc-switches.
authorMichał Górny <mgorny@gentoo.org>
Wed, 21 Dec 2011 16:10:17 +0000 (17:10 +0100)
committerZac Medico <zmedico@gentoo.org>
Wed, 21 Dec 2011 19:29:58 +0000 (11:29 -0800)
bin/misc-functions.sh
cnf/make.conf
man/ebuild.5
man/make.conf.5

index 358288932cb908d9aac4f89f94b4816c934390d6..b536a63e97015b9ede3a709889951be923a7837f 100755 (executable)
@@ -308,6 +308,46 @@ install_qa_check() {
                        sleep 1
                fi
 
+               # Check for files built without respecting CFLAGS
+               if [[ "${CFLAGS}" == *-frecord-gcc-switches* ]] && [[ "${PN}" != *-bin ]] ; then
+                       qa_var="QA_DT_SWITCHES_${ARCH/-/_}"
+                       eval "[[ -n \${!qa_var} ]] && QA_DT_SWITCHES=(\"\${${qa_var}[@]}\")"
+                       f=$(scanelf -qyRF '%k %p' -k \!.GCC.command.line "${ED}" | sed -e "s:\!.GCC.command.line ::")
+                       if [[ -n ${f} ]] ; then
+                               echo "${f}" > "${T}"/scanelf-ignored-CFLAGS.log
+                               if [ "${QA_STRICT_DT_SWITCHES-unset}" == unset ] ; then
+                                       if [[ ${#QA_DT_SWITCHES[@]} -gt 1 ]] ; then
+                                               for x in "${QA_DT_SWITCHES[@]}" ; do
+                                                       sed -e "s#^${x#/}\$##" -i "${T}"/scanelf-ignored-CFLAGS.log
+                                               done
+                                       else
+                                               local shopts=$-
+                                               set -o noglob
+                                               for x in ${QA_DT_SWITCHES} ; do
+                                                       sed -e "s#^${x#/}\$##" -i "${T}"/scanelf-ignored-CFLAGS.log
+                                               done
+                                               set +o noglob
+                                               set -${shopts}
+                                       fi
+                               fi
+                               # Filter anything under /usr/lib/debug/ in order to avoid
+                               # duplicate warnings for splitdebug files.
+                               sed -e "s#^usr/lib/debug/.*##" -e "/^\$/d" -e "s#^#/#" \
+                                       -i "${T}"/scanelf-ignored-CFLAGS.log
+                               f=$(<"${T}"/scanelf-ignored-CFLAGS.log)
+                               if [[ -n ${f} ]] ; then
+                                       vecho -ne '\n'
+                                       eqawarn "${BAD}QA Notice: Files built without respecting CFLAGS have been detected${NORMAL}"
+                                       eqawarn " Please include the following list of files in your report:"
+                                       eqawarn "${f}"
+                                       vecho -ne '\n'
+                                       sleep 1
+                               else
+                                       rm -f "${T}"/scanelf-ignored-CFLAGS.log
+                               fi
+                       fi
+               fi
+
                # Check for files built without respecting LDFLAGS
                if [[ "${LDFLAGS}" == *,--hash-style=gnu* ]] && [[ "${PN}" != *-bin ]] ; then
                        qa_var="QA_DT_HASH_${ARCH/-/_}"
index ef570bcb417cc35e07d3aa6f13c8aa9155ecead4..aecb6336f0607989e3145d62206da6241a67b606 100644 (file)
@@ -32,6 +32,9 @@
 # package (and in some cases the libraries it uses) at default optimizations
 # before reporting errors to developers.
 #
+# If your gcc supports it, you can add -frecord-gcc-switches in order to enable
+# CFLAGS ignorance checking for ebuilds.
+#
 # Please refer to the GCC manual for a list of possible values.
 #
 #CFLAGS="-O2 -pipe"
index 2d58c9e6161d80dc2830d51bb808e55662124916..1216ac171ef84a98ef446c9e17e1d1c1e0c571c2 100644 (file)
@@ -602,6 +602,15 @@ This should contain a list of file paths, relative to the image directory, of
 files that contain writable and executable segments.  These are rare.
 The paths may contain fnmatch patterns.
 .TP
+\fBQA_DT_SWITCHES\fR
+This should contain a list of file paths, relative to the image directory, of
+files that do not contain .GCC.command.line sections. The paths may contain
+regular expressions with escape\-quoted special characters.
+.br
+This variable is intended to be used on files of binary packages which ignore
+CFLAGS variable.
+.TP
+.TP
 \fBQA_DT_HASH\fR
 This should contain a list of file paths, relative to the image directory, of
 files that contain .hash sections. The paths may contain regular expressions
index 76adfe2ce0f7a704556f790cbec7a1d7fb450ee6..f9d69b71bf1eb1f7272f65c23b65ce2bdd65dc04 100644 (file)
@@ -814,6 +814,10 @@ settings from ebuilds.  See also \fBebuild\fR(5).
 Set this to cause portage to ignore any \fIQA_TEXTREL\fR override
 settings from ebuilds.  See also \fBebuild\fR(5).
 .TP
+\fBQA_STRICT_DT_SWITCHES = \fI"set"\fR
+Set this to cause portage to ignore any \fIQA_DT_SWITCHES\fR override
+settings from ebuilds.  See also \fBebuild\fR(5).
+.TP
 \fBQA_STRICT_DT_HASH = \fI"set"\fR
 Set this to cause portage to ignore any \fIQA_DT_HASH\fR override
 settings from ebuilds.  See also \fBebuild\fR(5).