ACC Compiler Tools

The ACC compiler tools primarily consist of two utilities: accmake and tacc, extensions to the GNU make utility and the gcc compiler respectively. accmake is to be used in place of the make utility, and tacc to be that of the cc compiler. W explain how to use tacc and accmake in detail as follows.

The tacc compiler

Basic features:

tacc, stands for the Toronto ACC Compiler, extends the UNIX C compiler to support both the compilation and the weaving of of aspects and regular C files. It is intended as a replacement of the UNIX C compiler by supporting a large majority of the GNU gcc compiler flags. tacc recognizes any file extension suffixes understood by gcc such as ".c" and ".cc" and requires the aspectc extension to be ".acc".

tacc distinguishes between two modes of operation in compiling C-based programs: sequential compilation and batch compilation. In the sequential compilation mode, C files are first compiled into object files in turn. The object files are linked into an archive or a binary at a later time. In the batch compilation mode, a binary is generated as a result of each compilation request.

Weaving in the batch mode.

In the batch mode, ACC files need to be explicitly supplied on the command line to get woven into the specified C files. Let us look at some examples:

a. regular C compilation:

tacc foo.c bar.c -> generates a.out

tacc -o bin foo.c bar.c -> generates bin

b. weaving compilation: tacc foo.c bar.c aspect1.acc -> generates a.out with aspect functionalities in aspect.acc

tacc -o bin foo.c bar.c aspect.acc -> generates bin with aspect functionalities in aspect.acc

tacc -o bin *.c *.acc -> a short-hand form generates bin with aspect functionalities

Weaving in the sequential mode.

The sequential mode is for compiling large C projects with multiple and often hierarchical directories. In such projects, tacc can weave the explicitly specified aspects supplied on the compile line. In such cases, the linking of aspect object files have also to be explicitly specified.

For example:

a. Explicit sequential compilation compile only : tacc -c foo.c bar.c aspect1.acc -> generates foo.o bar.o and aspect1.o

link only : tacc -o bin foo.o bar.o aspect1.o -> generates bin with functionalities in aspect1.acc

or link this way: tacc -o bin *.o

To reduce the redundancy in writing compile rules to explicitly specify what aspects to weave for every C file, tacc uses a visibility mechanism so that tacc will automatically gather ACC files that are VISIBLE to the current C file. This feature is turned on whenever a sequential compile is done without explicitly specifying any aspects to weave. In the simplest case, tacc will include all the aspects located in the current directory.

For example, the same compilation in case a above can be done by writing:

tacc -c foo.c bar.c -> generates foo.o bar.o with aspect1.o in a hidden place

tacc -o bin foo.o bar.o -> generates bin with the functionalities in aspect1.acc if aspect1.acc is in the same directory of foo.c and bar.c.

Note, for this to work, you need to set an environment variable SRCROOT to point to the root location of the source tree of your project.

Aspects can also affect C files in multiple directories, which leads to the advanced tacc features that we will explain in the next section.

Advanced feature:

tacc automatically gathers ACC files that are visible to the current C file being compiled. We distinguish two levels of visibility for ACC files: global and local, the former are to be woven to all files in the project, and latter parts of the source tree. Due to the compilation complexity of C files, we also orthogonally distinguish between simple and complex aspects, the former consist of only ACC files and the latter coexists with regular C files as part of the functionality supported by the aspects. This gives us four different types of aspects: global simple aspects, global complex aspects, local simple aspects, and local complex aspects. We now explain each of the type in turn:

Global simple aspects

Global simple aspects refer to aspect modules: 1. do not depend on the data structures and functions in the base system; 2. are applied to all the sources of the base system. To weave global aspects, the environment variable GAPATH (stands for global aspect path) must be set to point to the root location of the global aspect file source tree. If the aspects do not use other library headers, there is no need to perform any extra steps except using accmake to kick off the build process.

However, if the aspects use additional libraries and need to expand library header files, a file, [name].include needs to be included in the aspect directory to indicate the search paths. For instance, if the aspect files use glib and X11 libraries, a file, e.g., example.include, is required to have the following lines:
-I../../glib2.0/include
-I/usr/X11/include

Local simple aspects

Local simple aspects refer to the aspect modules that are intended to be woven to specific parts of the source tree of the base system. Different from global simple aspects, local simple aspects have dependencies on the data types defined in the base system, hence, require the access to the compilation settings of the base system.

The compilation settings in a large C project is complex, as in a hierarchical build structure, each directory can have different compile and linkage settings. For this reason, for local simple aspects that are co-located with other base system files, i.e., do not have a dedicated directory, tacc compiles these aspects by inheriting the same set of compiler flags used to compile regular C files in that directory.

If these simple aspects are placed in a dedicated directory, tacc requires the developer to write make utilities that would incorporate this directory into the overall build structure of the whole project. A common approach is to create an empty C file, dummy.c, and write a make file to compile this C file with the flags necessary to allow acc to find the necessary headers.

Local aspects are subject to the current and sibling rule used by tacc to weave aspects into certain parts of the source tree because full type analysis prior to weaving is not performed. The aspect developers must observe the current and sibling rule used by tacc for their aspects to be woven into the right files.

The current and sibling rule states that an aspect is woven into the following two kinds of C files:

  1. files in the same directory;
  2. files in the sibling directories of the residing directoryand their sub-directories.

Equivalently, tacc will not weave aspects into C files in the sub-directories of the current compiling directories, neither to files in the parent directory.

This rule is illustrated in the below figure in which the shaded area shows files affected by the aspect module.

sibling-rule.jpg

Global complex aspects

Global complex aspects refer to a complex functionality implemented as a mixture of aspect files and a hierarchy of regular C files. These files reside in a dedicated directory. In this situation, the developer is responsible for writing regular make files to compile C files in the directory. To weave aspects into the base system, the developer needs to set the environment variable GAPATH to point to the root of the global aspect source tree.

Local complex aspects

Local complex aspects refer to local aspects are implemented as a mixture of aspects and regular C files. tacc also assumes that these files are in a separate and dedicated directory. Similar to global ones, the developer needs to write make files to integrate the directory into the build process of the whole project. Aspects are compiled using the same set of flags specified in the make file in that directory. They are woven into the rest of the system following the afore-mentioned current and sibling rule.

accmake

accmake is the drop-in replacement of the conventional make utility. There are three additional features performed transparently to the functionalities of make.

  1. Automatically compile the global simple aspects before the base system is compiled.
  2. When invoked with "clean", remove the intermediate files generated for aspects before invoking the regular "make clean".
  3. (New). accmake will generate warning messages for any advices that do not match any target C code, if the conventional "-Wall" flag is used in the compile line.

Success Stories

We have successfully used the weave adapters to adapt the build process of Nut/OS, an open-source embedded real-time operating system, ORBIT2, an IPC middleware for the GNOME Linux Desktop environment, and GCC 4.0.xx.

Quick Start

  1. Make sure you have perl and gcc installed, and put the directory "$ACCINSTALL/bin" are on the path.
  2. Export SRCROOT to point to the root directory of the target project.
  3. If your project uses autoconf to manage compilation, export the CC environment variable to point to tacc.
  4. Use accmake instead of make.
  5. Export GAPATH to the directory where global simple aspects reside.

Bugs and feedback

For any bugs and feedbacks regarding these adapters, please contact us.

Topic attachments
I Attachment Action Size Date Who Comment
jpgjpg sibling-rule.jpg manage 16.7 K 2007-05-29 - 16:25 CharlesZhang  
Topic revision: r10 - 2007-07-24 - 06:55:21 - CharlesZhang
 
Copyright © Middleware Systems Research Group. Send feedback