Commit Graph

490 Commits

Author SHA1 Message Date
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
Alexey Tourbin
e4835167bb cpp.req: hierarchical processing - fewer errors and major speedup
I have to admit that cpp.req can be slow and often fails in an ugly
manner.  To address these issues, this change introduces "hierarchical
processing".  Consider the package libgtk+2-devel.  Only a few header
files from this package can be included directly, and these files in
turn include other "private" headers which are protected against direct
inclusion.  The idea is then that only those few files with the highest
rank have to be processed explicitly, and most of the "private" files
can be processed implicitly as they are included on behalf of
higher-ranking files.

To implement the idea, somehow we have to sort the files by their rank.
This probably has to involve some guesswork.  However, assigning higher
ranks to shorter filenames seems to produce nice guesses.  More precisely,
files are sorted by shorter directory names and then by shorter basenames.
Another possible criteria which is not currently implemented is also to
take into account the number of path components in a directory name.

The result is pretty amazing: the amount of time needed to process
libgtk+2-devel headers is reduced from 150s to 5s.  Notably <gtk/gtk.h>
includes 241 packaged files.  This is also due to other optimizations:
packaged files are excluded from dependencies early on, and each
required filename gets passed to FindPackage only once.
2012-02-19 09:13:44 +04:00
Vitaly Kuznetsov
ca5b17e03c introduce brp-hardlink_pyo_pyc (splitted from brp-bytecompile_python)
Hardlinking identical .pyo and .pyc files splitted from brp-bytecompile_python to
brp-hardlink_pyo_pyc to make this brp work for python3 files (generated by separate
brp-bytecompile_python3).
2012-01-25 14:23:12 +00:00
Vitaly Kuznetsov
a771af0403 brp: introduce /usr/lib/rpm/brp.d directory
Made it possible for third party packages to have their own brp-* scripts. All
existent brp-* scripts migrated to /usr/lib/rpm/brp.d, brp-alt taught to execute
all from this directory in alphabetical order. All brp-* scripts obligated to
have three digit prefix (to specify execution order) and .brp suffix.
2012-01-25 14:16:15 +00:00
3a6b8bd83b 0common-files.req.list: remove /etc/sysctl.d
/etc/sysctl.d is going to be added to filesystem package.

This reverts commit bec54ac071.
2011-12-13 14:55:50 +00:00
820414df17 verify-elf: move check for rpath, stack and unresolved symbols to separate functions 2011-12-12 16:27:52 +00:00
c66e9c38e4 verify-elf: more RPATH checks
Check RPATH for non-ascii symbols, invalid absolute and relative paths,
and standard library directories.
2011-12-10 21:51:42 +00:00
6eea0604ad verify-elf: Rewrite error reporting code 2011-12-10 17:50:11 +00:00
9e73931c30 find-debuginfo-files: fix packaging of symlinks
Package only those /usr/lib/debug/* symlinks that complement the package
being processed and point to debuginfo regular files which are going to
be packaged along with these symlinks.

The most obvious consequence of this change is that library symlinks for
use of ld(1) will not result to their
/usr/lib/debug/usr/lib*/libNAME.so.debug counterparts to be packaged.
2011-12-06 15:04:05 +00:00
bf54b11cf4 cpp.req: do not insist on trying c++ mode when c++ support is not installed
When plain cpp check fails, cpp.req tries to process the same file in
c++ mode, which requires c++ support to be installed.  As result, when
c++ support is not installed, cpp.req clutter the log with vain attempts
to process files in c++ mode.  This change reduces the noise by checking
whether c++ support is actually available.
2011-12-04 21:25:53 +00:00
016617f027 find-lang: handle more exotic GNOME help locale directories (ALT#26417) 2011-12-01 02:08:29 +00:00
Alexey Tourbin
7dea69eca4 brp-cleanup: perl cleanup routines moved to rpm-build-perl 2011-10-21 01:27:51 +04:00
19d7160080 find-lang: handle %_datadir/help/%lang/%name subdirectories (ALT#26417) 2011-10-10 21:54:07 +00:00
ae55da575e find-lang: add support for GNOME >= 3.2 help files location (ALT#26417) 2011-10-06 20:38:04 +00:00
Alexey Tourbin
4d747a6312 removed brp-strip & related macros 2011-09-23 03:36:28 +04:00
Alexey Tourbin
8af14dd777 cpp.req: track included files down to the first external file
Some header files have protection against being included into user
code directly.  This means that, when processing such files, cpp
is going to fail, and some dependencies probably will be missing.

/usr/include/gtk-2.0/gtk/gtkaccessible.h:
    20  #if defined(GTK_DISABLE_SINGLE_INCLUDES) && !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
    21  #error "Only <gtk/gtk.h> can be included directly."
    22  #endif
    23
    24  #ifndef __GTK_ACCESSIBLE_H__
    25  #define __GTK_ACCESSIBLE_H__
    26
    27  #include <atk/atk.h>
    28  #include <gtk/gtkwidget.h>

To remedy the problem, we should, as per the above example, process
gtk/gtk.h dependencies recursively.  Dependencies which we now attribute
to gtk/gtk.h are: 1) files which are packaged within the same subpackage
- these dependencies will be optimized out later by rpm; 2) the first
file not packaged into this subpackage, which is atk/atk.h.  Files below
atk/atk.h are not processed.

    Packaged?     Stack
                +---------------------+
        +       | gtk/gtk.h           |
                +---------------------+
        +       | gtk/gtkaccessible.h | <- SPmark
                +---------------------+
        -       | atk/atk.h           |
                +---------------------+
                | ...                 |

Also note that packaged files in cpp output should not be identified by
filenames, since filenames in the output will be possibly non-canonical.
Therefore I use standard unix technique to identify files by (dev,ino).

/usr/include/boost/spirit/home/support/detail/lexer/containers/ptr_vector.hpp:
     9  #include "../size_t.hpp"
2011-09-22 03:08:14 +04:00
Alexey Tourbin
cf9820cea4 cpp.req: simplify filename handling in cpp output 2011-09-22 03:08:11 +04:00
Alexey Tourbin
3d7945aad6 scripts: introduced tmpdir.sh 2011-09-22 02:58:59 +04:00
Alexey Tourbin
36d69f322f cpp.req: process subpackage *.pc files before other *.pc files
This helps to handle subtle cases like separate *-gtk2-devel
and *-gtk3-devel subpackages.

RPM_BUILD_ROOT=$PWD RPM_SUBPACKAGE_NAME=libgtk3vnc-devel /usr/lib/rpm/cpp.req $PWD/usr/include/gtk-vnc-2.0/vnc*.h
RPM_BUILD_ROOT=$PWD RPM_SUBPACKAGE_NAME=libgtk3vnc-devel ~/git.alt/rpm/scripts/cpp.req.in $PWD/usr/include/gtk-vnc-2.0/vnc*.h
@@ -1,6 +1,6 @@
-libgtk+2-devel
-/usr/include/gtk-vnc-1.0/vncgrabsequence.h
+libgtk+3-devel
+/usr/include/gtk-vnc-2.0/vncgrabsequence.h
 glib2-devel
 glib2-devel
-libgtk+2-devel
+libgtk+3-devel
 /usr/include/gvnc-1.0/vncbaseframebuffer.h
2011-09-18 05:27:41 +04:00
925d594b1b debuginfo.req: fix handling of exotic sonames written as pathnames (ALT#26247) 2011-09-07 23:28:18 +00:00
caad5da212 verify-elf: Add /lib/../lib64 to the list of prohibited RPATH elements 2011-09-07 21:44:34 +00:00
7eea54be91 fixup-desktop: edit files inplace (ALT#25645) 2011-05-20 15:10:41 +00:00
d0efa0675e scripts: cleanup exit/signal handlers 2011-05-14 18:17:53 +00:00
Igor Vlasenko
2b3028a966 fixup-desktop: new file that does trivial fixes in desktop files
Some of the fixes for the freedesktop .desktop files are so routine
and trivial that they better be performed by script.
2011-05-13 21:43:39 +00:00
Alexey Tourbin
808184893c cpp.req: disable for gcc 2011-02-27 07:17:15 +03:00
Alexey Tourbin
91d73ac0ae find-package: prune generic devel deps like gcc4.x in HOST_PKG mode 2011-02-27 06:29:15 +03:00
Alexey Tourbin
3df5f4ac6d cpp.req: try to enter c++ mode after the first failure 2011-02-27 05:34:23 +03:00
Alexey Tourbin
5bce334b5e cpp.req: new dependency generator for header files 2011-02-27 03:51:26 +03:00
Alexey Tourbin
a9278eb466 Revert "pkgconfig.req: pass --print-requires-private to pkg-config"
This reverts commit 2fc9a40da8.
2011-02-27 03:39:08 +03:00
Alexey Tourbin
9b87852e0f shell.req: avoid 'type -t' call for paths
This is to improve 'buildreq -bi' support: 'type -t' will stat
absolute paths and buildreq will make self-dependency.  Note
that in the next command PATH is nullified to avoid stat/search
for regular commands.
2011-02-09 06:31:40 +03:00
Alexey Tourbin
0cf73c5886 lib.req, lib.prov: simplify leading number check in ProvidedSymbols 2011-02-06 03:42:15 +03:00
Alexey Tourbin
a405f7c61e lib.req: indirect functions need dependency on rtld(GNU_IFUNC) 2011-02-06 03:38:32 +03:00
Alexey Tourbin
033bb95511 brp-debuginfo: pass LD_ORIGIN_PATH=/usr/bin to eu-strip
This is the same as with eu-findtextrel and eu-elflint; eu-strip
needs to load EBL backend only with --strip-debug, though.
2011-02-05 23:34:11 +03:00
Alexey Tourbin
c1cccab3d8 debuginfo.req: avoid repeated "not yet debuginfo-enabled" warnings 2011-02-05 04:11:46 +03:00
Alexey Tourbin
91656ccf79 brp-debuginfo: hopefully fixed hardlink support
Note that 'sh -e' mode is unreliable when the last pipeline command
is non-simple command (such as while loop).  So the script was somehow
failing on hardlinks and it went unnoticed.  I choose to replace
pipe-to-while with a temporary file for now.
2011-02-05 01:27:25 +03:00
Alexey Tourbin
614b27b4d1 brp-debuginfo: added /usr/src to prune_paths 2011-02-05 01:27:23 +03:00
Alexey Tourbin
83147e6c03 implemented debuginfo.req and debuginfo.prov 2011-02-04 02:55:25 +03:00
Alexey Tourbin
845fefb64f brp-debuginfo: recognize $RPM_BRP_STRIP_DEBUG and $RPM_BRP_STRIP_NONE
This finally provides missing strip controls.  Note that even with
STRIP_NONE, the file will be edited with debugedit.  So there is no
way to bypass brp-debuginfo completely (and maybe we should tolerate
debugedit failures with STRIP_NONE).  But there is also an advantage:
/usr/src/debug sources will be installed even for non-stripped files!
This is why sources are now associated with .debuginfo/src/"$f"
instead of .debuginfo/src/"$debugf".
2011-02-03 11:30:45 +03:00
Alexey Tourbin
f90e69d3f1 find-debuginfo-files: create /usr/lib/debug/.build-id/ links
It might seem that build-id links should be created in brp-debuginfo.
However, there are corner cases: in brp-debugino, it is not yet known
which files are going to be packaged.  This might be a problem when a
few identical files or hardlinks are created under buildroot: it is
possible create a symbolic link to a "wrong" file which will not be
packaged.

The solution is create build-id links in find-debuginfo-files: the link
will point to the first packaged file with the given build-id.  However,
note that find-debuginfo-files is not part of the install stage, and
should remain "reenterable" (so that e.g. rpm -bl can be executed
multiple times).  This means that the script should not make assumptions
whether the links have already been created.
2011-02-03 09:07:54 +03:00
Alexey Tourbin
3132ca2851 4.0.4-alt100.15
- build/files.c (runPkgScript): New helper function for autodep-like scripts.
- build/files.c (makeDebugInfo): Implemented automatic *-debuginfo packages.
- find-debuginfo-files: Initial revision, makes *-debuginfo %files list.
- GROUPS: added Development/Debug.
- build/interdep.c: Initial revision, inter-package analysis and optimizations.
- build/interdep.c: Prune /usr/src/debug dups among dependent subpackages.
2011-01-31 07:34:46 +03:00
Alexey Tourbin
f0be1f05f3 find-debuginfo-files: make %dir list for /usr/lib/debug and /usr/src/debug 2011-01-31 03:31:12 +03:00
Alexey Tourbin
88e69e89fd find-debuginfo-files: initial revision 2011-01-31 03:24:01 +03:00
Alexey Tourbin
0f284964f3 4.0.4-alt100.14
- debugedit.c: Imported from rpm.org.
- brp-debuginfo: Initial revision, replaces brp-strip.
- verify-elf: Do not descend into /usr/lib/debug.
- build/checkFiles.c: Skip /usr/lib/debug and /usr/src/debug for now.
- platform.in: Always use -g in %optflags.
2011-01-30 04:20:31 +03:00
Alexey Tourbin
f41c1bffca brp-debuginfo: preserve timestamps 2011-01-30 03:35:57 +03:00
Alexey Tourbin
4bdee95777 brp-debuginfo: handle sources 2011-01-30 03:32:08 +03:00
Alexey Tourbin
78a1d2b844 brp-debuginfo: make symbolic links 2011-01-30 03:32:06 +03:00
Alexey Tourbin
e0572f5d41 verify-elf: do not descend into /usr/lib/debug 2011-01-30 03:11:30 +03:00
Alexey Tourbin
f13cfad5f8 brp-debuginfo: intial revision, replaces brp-strip 2011-01-30 03:10:15 +03:00
Alexey Tourbin
d3c57d3ee4 build/checkFiles.c: reimplemented checkFiles() using fts(3) 2011-01-15 11:48:33 +03:00
0d030af93f find-lang (FIND_MAN): support man page paths with more than one symbol after dot (ALT#24466) 2010-11-01 22:36:09 +00:00