Previous: GGC Roots, Up: Type Information


16.3 Source Files Containing Type Information

Whenever you add GTY markers to a new source file, there are three things you need to do:

  1. You need to add the file to the list of source files the type machinery scans. There are three cases:
    1. For a back-end file, this is usually done automatically; if not, you should add it to target_gtfiles in the appropriate port's entries in config.gcc.
    2. For files shared by all front ends, this is done by adding the filename to the GTFILES variable in Makefile.in.
    3. For any other file used by a front end, this is done by adding the filename to the gtfiles variable defined in config-lang.in. For C, the file is c-config-lang.in. This list should include all files that have GTY macros in them that are used in that front end, other than those defined in the previous list items. For example, it is common for front end writers to use c-common.c and other files from the C front end, and these should be included in the gtfiles variable for such front ends.
  2. If the file was a header file, you'll need to check that it's included in the right place to be visible to the generated files. For a back-end header file, this should be done automatically. For a front-end header file, it needs to be included by the same file that includes gtype-lang.h. For other header files, it needs to be included in gtype-desc.c, which is a generated file, so add it to ifiles in open_base_file in gengtype.c.

    For source files that aren't header files, the machinery will generate a header file that should be included in the source file you just changed. The file will be called gt-path.h where path is the pathname relative to the gcc directory with slashes replaced by -, so for example the header file to be included in objc/objc-parse.c is called gt-objc-objc-parse.c. The generated header file should be included after everything else in the source file. Don't forget to mention this file as a dependency in the Makefile!

  3. If a new gt-path.h file is needed, you need to arrange to add a Makefile rule that will ensure this file can be built. This is done by making it a dependency of s-gtype, like this:
         
         gt-path.h : s-gtype ; @true
    

For language frontends, there is another file that needs to be included somewhere. It will be called gtype-lang.h, where lang is the name of the subdirectory the language is contained in. It will need Makefile rules just like the other generated files.