Setting up and building a project

Background: The Cyclone with Inference build process

The Cyclone with Inference compiler, cyclone-inf, compiles a folder worth of code in two stages. First, it scans each source file looking for pointers subject to inference, introducing a "constraint variable" for each, and for pieces of code that impose constraints on those cvars. It writes a summary of the constraints and cvars to the cvars file and a new source file annotated with the cvars into in its work area (the .cych subdirectory).

On the second pass, the compiler reads the cvars file and makes a decision on each cvar; currently, it decides whether to make each pointer thin or fat. Then it rereads the annotated source files and substitutes in the decisions it made; the resulting ordinary Cyclone code goes to the downstream components of the compiler.

Creating a project

Cyclone with Inference currently does not have its own project type. Use a Standard C Project as your Cyclone project; you'll get the C toolkit's integration with make and other features, such as running executables, that are useful for Cyclone as well as C.

Note that the compiler compiles and performs inference on a folder of code at a time; it knows nothing about Eclipse projects. An Eclipse project usually consists of a single folder of code at the top level. However, if you wish, you may put several folders into the same project; the cycinf-plugin and the compiler will treat each folder independently. However, extra work will be required to set up recursive building.

Files and editors

Cyclone source files use the .cyc extension; the .cyh extension is recommended for Cyclone header files to distinguish them from C header files. .cyc and .cyh files will open in the Cyclone Editor, which is integrated with the inference-related features but lacks many of the niceties of the C editor, such as syntax coloring. You may want to use the C editor to write and edit Cyclone files (ignoring "syntax errors" caused by Cyclone-specific constructs) and the Cyclone editor when you are examining the results of inference.

The plugin's make-based build system

The Cyclone plugin includes two Makefiles that are helpful for building Cyclone projects. If you right-click a project and select Cyclone -> Set Up Make Building, the plugin will write the cycinf make library (cycinf.mk) and a simple template Makefile into the project; you must enter the names of your source files into the Makefile. You can then use the C plugin's make builder, which is integrated with Eclipse's project building system, so the ordinary Eclipse menu options and shortcuts will build your Cyclone with Inference project. The C Build Console will show the output of make and cyclone-inf.

Right now, cyclone-inf's support for recompiling single files is unreliable, so the build system essentially recompiles everything whenever any source file changes. cycinf.mk may be changed in the future in response to improvements to the compiler. Set Up Make Building always writes the newest cycinf.mk but does not overwrite Makefile if it exists.

Automatic building

If you like automatic building, configure your make projects (including cycinf projects) for it by enabling Build on resource save (Auto Build). This option is found in the new project wizard and in the C/C++ Make Project page of the project properties. Then enable automatic building for the workspace by checking Project -> Build Automatically; the Cyclone compiler will be called up whenever you save a file. If you combine automatic building with Watch Inference Data (discussed later), you can see the effects of a program change on inference decisions in seconds.