rpm-build/scripts
Alexey Tourbin 50a5ad7320 cpp.req: recover missing once-only pushes using -dI
Hierarchical processing makes cpp.req more susceptible to "once-only
header" optimization.  To demonstrate the problem, I've implemented
some debugging facilities.  Here is how <gtk/gtk.h> is processed.

$ cpp.req -vv /usr/include/gtk-2.0/gtk/gtk.h
[...]
  Include gdk/gdk.h
+ Push /usr/include/gtk-2.0/gdk/gdk.h
    Include gdk/gdkapplaunchcontext.h
+   Push /usr/include/gtk-2.0/gdk/gdkapplaunchcontext.h
      Include gio/gio.h
!     Push /usr/include/glib-2.0/gio/gio.h
        Include gio/giotypes.h
        Push /usr/include/glib-2.0/gio/giotypes.h
          Include gio/gioenums.h
          Push /usr/include/glib-2.0/gio/gioenums.h
            Include glib-object.h
            Push /usr/include/glib-2.0/glib-object.h
              Include gobject/gbinding.h
              Push /usr/include/glib-2.0/gobject/gbinding.h
                Include glib.h
                Push /usr/include/glib-2.0/glib.h
[...]
+               Push /usr/include/gtk-2.0/gtk/gtkdebug.h
                  Include glib.h
                Pop
[...]
recovered glib.h -> /usr/include/glib-2.0/glib.h
recovered stdarg.h -> /usr/lib64/gcc/x86_64-alt-linux/4.5.3/include/stdarg.h
recovered time.h -> /usr/include/time.h
recovered glib-object.h -> /usr/include/glib-2.0/glib-object.h

In the output, "Include" lines annotate "#include" instructions which
are about to be processed by cpp; "Push" and "Pop" annotate actual
file operations performed by cpp.  Technically, "Include" annotations
are enabled via -dI option which installs cb_include callback in
gcc/c-ppoutput.c; "Push" and "Pop" are triggered in the guts of the
libcpp library.  The library has hardcoded optimization against repeated
inclusions.  According to "info cpp", "It remembers when a header file
has a wrapper #ifndef.  If a subsequent #include specifies that header,
and the macro in the #ifndef is still defined, it does not bother to
rescan the file at all."  (See should_stack_file in libcpp/files.c.)

This means that, normally, each "Include" should be followed by a
corresponding "Push".  However, due to "once-only header" optimization,
some includes are not followed by a push.  This means that the file
has already been pushed, and it happens to use a wrapper #ifndef.
Note that, in the output, this is exactly the case with <glib2.h>.

Also note that, in the output, files internal to the package are marked
with "+" on the left.  They are tracked down to the first non-packaged
file, which makes a dependency; these files are marked with "!".  The
problem with <glib2.h> is then that it gets first included in an
external file.  Later it is also included in an internal file, but
a "Push" is not triggered.  And since the internal file is subordinate
to <gtk/gtk.h> and is not going to be processed on its own, the
dependency on <glib2.h> is lost.

To recover missing pushes, we have to associate each include with the
first-time push.  In other words, we need a table which maintains a
(header -> filename) mapping; in the above example, the table will
contain (glib.h -> /usr/include/glib-2.0/glib.h).  Using this table,
we can ascertain that each internal #include produced a result.

Now, this might still have some corner cases: includes with
non-canonical header names probably will not be recovered, and it is not
clear whether <foo.h> and "foo.h" should be processed differently.
It works well enough in simple cases, though.
2012-02-19 18:23:24 +04:00
..
.provides.sh find-package: renamed FindByPath -> FindByFile 2010-04-08 11:24:55 +04:00
0common-files.req.list 0common-files.req.list: remove /etc/sysctl.d 2011-12-13 14:55:50 +00:00
0ldconfig.filetrigger 0ldconfig.filetrigger: simplified system library check 2008-11-12 05:10:51 +03:00
brp-adjust_libraries.in Removed cvsid tags. 2006-05-14 17:05:34 +04:00
brp-alt.in brp: introduce /usr/lib/rpm/brp.d directory 2012-01-25 14:16:15 +00:00
brp-bytecompile_python.in introduce brp-hardlink_pyo_pyc (splitted from brp-bytecompile_python) 2012-01-25 14:23:12 +00:00
brp-cleanup.in brp-cleanup: perl cleanup routines moved to rpm-build-perl 2011-10-21 01:27:51 +04:00
brp-compress.in scripts/brp-compress.in: Avoid non-standard info directories (ALT#19993) 2009-05-20 21:51:11 +00:00
brp-debuginfo.in brp-debuginfo: pass LD_ORIGIN_PATH=/usr/bin to eu-strip 2011-02-05 23:34:11 +03:00
brp-fix-perms.in scripts: use 'chmod -c' 2008-05-05 02:36:14 +04:00
brp-fixup.in fixup-desktop: new file that does trivial fixes in desktop files 2011-05-13 21:43:39 +00:00
brp-hardlink_pyo_pyc.in introduce brp-hardlink_pyo_pyc (splitted from brp-bytecompile_python) 2012-01-25 14:23:12 +00:00
brp-verify_elf.in verify-elf: do not descend into /usr/lib/debug 2011-01-30 03:11:30 +03:00
brp-verify-info.in Implement info files verification 2009-05-20 23:25:58 +00:00
compress_files.in scripts: Replace paths to basic programs with their names 2008-02-29 12:30:29 +00:00
cpp.req.files cpp.req: new dependency generator for header files 2011-02-27 03:51:26 +03:00
cpp.req.in cpp.req: recover missing once-only pushes using -dI 2012-02-19 18:23:24 +04:00
debuginfo.prov.files implemented debuginfo.req and debuginfo.prov 2011-02-04 02:55:25 +03:00
debuginfo.prov.in implemented debuginfo.req and debuginfo.prov 2011-02-04 02:55:25 +03:00
debuginfo.req.files implemented debuginfo.req and debuginfo.prov 2011-02-04 02:55:25 +03:00
debuginfo.req.in debuginfo.req: fix handling of exotic sonames written as pathnames (ALT#26247) 2011-09-07 23:28:18 +00:00
files.req.files.in files.req: reserve second field in *-files.req.list for owner package name 2008-06-17 08:05:10 +04:00
files.req.in files.req: added description and copyright 2008-06-22 11:52:53 +04:00
find-debuginfo-files.in find-debuginfo-files: fix packaging of symlinks 2011-12-06 15:04:05 +00:00
find-lang.in find-lang: handle more exotic GNOME help locale directories (ALT#26417) 2011-12-01 02:08:29 +00:00
find-package.in find-package: prune generic devel deps like gcc4.x in HOST_PKG mode 2011-02-27 06:29:15 +03:00
find-scriptlet-requires.in find-requires, find-scriptlet-requires: enabled FINDPACKAGE-COMMANDS output 2010-04-08 11:24:58 +04:00
fixup-binconfig.in scripts: introduced tmpdir.sh 2011-09-22 02:58:59 +04:00
fixup-desktop.awk fixup-desktop: new file that does trivial fixes in desktop files 2011-05-13 21:43:39 +00:00
fixup-desktop.in scripts: introduced tmpdir.sh 2011-09-22 02:58:59 +04:00
fixup-libraries fixup-libraries: Enhance recognition of ELF executables 2008-10-19 23:56:49 +00:00
fixup-libtool.in fixup-libtool, fixup-pkgconfig: Quote substitution text (ALT#11437) 2008-07-07 22:07:40 +00:00
fixup-pkgconfig.in scripts: introduced tmpdir.sh 2011-09-22 02:58:59 +04:00
functions scripts/functions: invoke av_action with </dev/null 2010-10-04 02:13:53 +04:00
ldd.in ldd.in: added --bindings option 2010-10-01 01:57:35 +04:00
lib.prov.files scripts/*.files: Use single quotes for constant strings 2007-11-10 20:47:01 +00:00
lib.prov.in lib.req, lib.prov: simplify leading number check in ProvidedSymbols 2011-02-06 03:42:15 +03:00
lib.req.files lib.req.files: check "uses shared libs" as well as "dynamically linked", for klibc binaries 2008-02-19 00:22:23 +03:00
lib.req.in scripts: introduced tmpdir.sh 2011-09-22 02:58:59 +04:00
Makefile.am introduce brp-hardlink_pyo_pyc (splitted from brp-bytecompile_python) 2012-01-25 14:23:12 +00:00
pam.prov.files scripts/pam.*.files: Optimize filename check 2007-11-10 20:47:03 +00:00
pam.prov.in adapted pam.req and pam.prov 2007-03-12 15:06:07 +03:00
pam.req.files scripts/pam.*.files: Optimize filename check 2007-11-10 20:47:03 +00:00
pam.req.in pam.req.in: Handle lines with conditional controls 2009-06-26 00:17:19 +00:00
pkgconfig.req.files scripts/*.files: Use single quotes for constant strings 2007-11-10 20:47:01 +00:00
pkgconfig.req.in Revert "pkgconfig.req: pass --print-requires-private to pkg-config" 2011-02-27 03:39:08 +03:00
pkgconfiglib.req.in cpp.req: disable for gcc 2011-02-27 07:17:15 +03:00
posttrans-filetriggers.in posttrans-filetriggers: minor changes 2008-11-12 05:10:51 +03:00
rpm2cpio.sh rpm2cpio.sh: output raw/compressed cpio stream 2009-09-24 12:35:42 +04:00
rpmlib.req.files.in Revert "rpmlib.req: generate rpmlib(PosttransFiletriggers) dependency for /usr/lib/rpm/*.filetrigger" 2008-11-25 15:37:14 +00:00
rpmlib.req.in Revert "rpmlib.req: generate rpmlib(PosttransFiletriggers) dependency for /usr/lib/rpm/*.filetrigger" 2008-11-25 15:37:14 +00:00
shebang.req.files scripts/*.req.files: Fix "not executable" wording 2007-11-10 20:47:02 +00:00
shebang.req.in shebang.req (ShebangReq): fix the check for absolute pathname (ALT#23716) 2010-07-03 00:23:03 +00:00
shell.prov.files adapted shell.req and shell.prov 2007-03-11 15:00:23 +03:00
shell.prov.in adapted shell.req and shell.prov 2007-03-11 15:00:23 +03:00
shell.req.files shell.req.files: adjusted /bin/ash pattern 2009-06-21 00:20:31 +04:00
shell.req.in shell.req: avoid 'type -t' call for paths 2011-02-09 06:31:40 +03:00
shlib.req.awk Add shlib.req.awk 2006-01-11 00:39:39 +00:00
static.req.files factored static.req 2007-03-11 15:00:35 +03:00
static.req.in factored static.req 2007-03-11 15:00:35 +03:00
symlinks.req.files symlinks.req.files: do all symbolic links (will emit file-level dependencies for targets under RPM_BUILD_ROOT) 2007-12-03 14:22:54 +03:00
symlinks.req.in symlinks.req: do only one single step of symlink resolution 2007-11-17 10:52:57 +03:00
tmpdir.sh scripts: introduced tmpdir.sh 2011-09-22 02:58:59 +04:00
verify-elf.in verify-elf: move check for rpath, stack and unresolved symbols to separate functions 2011-12-12 16:27:52 +00:00