ObjC/ObjC++: Move ObjC callbacks into their own header to fix pointless rebuilds of lots of files when they change

Nicola Pero nicola.pero@meta-innovation.com
Sat Dec 4 00:30:00 GMT 2010


This patch fixes a problem I keep having when working on the Objective-C/Objective-C++
frontends, which is that any, no-matter-how-trivial, change to the ObjC callbacks
triggers a rebuild of a mass of completely unrelated files (such as i386.c,
tree-ssa-mudflap.c, etc).

This is because the ObjC front-end callbacks, which are implemented in objc-act.c
and stub-objc.c and used by some files in the C/C++ frontend, are declared
in c-common.h which is included by c-tree.h which is included by lots of files.

This patch moves the ObjC front-end callback declarations into a separate c-family/c-objc.h
file, which is then only included in the relevant C/C++ frontend files.

With this change, the rebuilding performed when I touch an ObjC front-end callback
goes down from 5m30s to 3m30s (approx, on my machine).

This benefits everyone else too (not just myself) because when I commit a bug fix that
touches the ObjC front-end callbacks, the time it takes other people to update/rebuild
their trees will go down by the same amount. :-)

It also just makes sense to have the ObjC frontend callbacks in a separate file and
include it only in the files that use them.

Ok to commit ?

Thanks

PS: There is a slight disadvantage in doing this, which is that if we want to add
a new ObjC callback function and use it in some other file in gcc/ or gcc/cp/ where
we don't have ObjC callbacks yet, we need to add the #include, and update the corresponding
makefile.  But I looked at my previous patches and that never happened with the C frontend,
and happened a couple of times only with C++ frontend (where it is unlikely to happen again
because we now have hooks in most files); instead, the reduction in rebuild times
would have made my life easier when working on so many of the patches ... and will keep
applying to many more future patches ... so I'll go with that. :-)

In gcc/:
2010-12-03  Nicola Pero  <nicola.pero@meta-innovation.com>

        * c-family/c-common.h: Removed the declarations of all the objc_
        callbacks, and moved them into c-objc.h.  Removed
        objc_ivar_visibility_kind and moved it into c-objc.h.
        * c-family/c-objc.h: New file.
        * c-family/c-common.c: Include c-objc.h.
        * c-family/c-format.c: Same change.
        * c-family/stub-objc.c: Same change.
        * c-decl.c: Include c-family/c-objc.h.
        * c-parser.c: Same change.
        * c-typeck.c: Same change.
        * c-config-lang.in (gtfiles): Added c-family/c-objc.h.
        * Makefile.in (c-decl.o): Depend on c-family/c-objc.h.
        (c-parser.o): same change.
        (c-typeck.o): Same change.
        (c-family/c-format.o): Same change.
        (c-family/stub-objc.o): Same change.
        (c-family/c-common.o): Same change.
        (PLUGIN_HEADERS): Added c-family/c-objc.h.

In gcc/cp/:
2010-12-03  Nicola Pero  <nicola.pero@meta-innovation.com>

        * call.c: Include c-family/c-objc.h.
        * decl.c: Same change.
        * decl2.c: Same change.
        * error.c: Same change.
        * lex.c: Same change.
        * parser.c: Same change.
        * pt.c: Same change.
        * semantics.c: Same change.
        * typeck.c: Same change.
        * Make-lang.in (cp/decl.o): Depend on c-family/c-objc.h.
        (cp/decl2.o): Same change.
        (cp/call.o): Same change.
        (cp/error.o): Same change.
        (cp/lex.o): Same change.
        (cp/parser.o): Same change.
        (cp/pt.o): Same change.
        (cp/semantics.o): Same change.
        (cp/typeck.o): Same change.
        * config-lang.in (gtfiles): Added c-family/c-objc.h.

In gcc/objc/:
2010-12-03  Nicola Pero  <nicola.pero@meta-innovation.com>

        * objc-act.c: Include c-family/c-objc.h.
        * objc-lang.c: Same change.
        * Make-lang.in (objc/objc-act.o): Depend on
        c-family/c-objc.h.
        (objc/objc-lang.o): Same change.
        * config-lang.in (gtfiles): Added c-family/c-objc.h.

In gcc/objcp/:
2010-12-03  Nicola Pero  <nicola.pero@meta-innovation.com>

        * config-lang.in (gtfiles): Added c-family/c-objc.h.
        * Make-lang.in (objcp/objcp-act.o): Depend on
        c-family/c-objc.h.
        (objcp/objcp-lang.o): Same change.
        (objcp/objcp-decl.o): Same change.
        * objcp-lang.c: Include c-family/c-objc.h.
        * objcp-decl.c: Same change.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch.txt
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20101204/2c4ddc72/attachment.txt>


More information about the Gcc-patches mailing list