# OneFile

### About

`OneFile` is a tool for mangling C source files. For historical reasons, the `502.gcc_r` benchmark in
the SPEC CPU2017 suite can only compile C programs that exist in a single compilation unit. Most large
and interesting programs are designed to be modular and are saved in multiple files which splits the 
compilation process into several compilation units. Therefore, `OneFile` attempts to transform
multiple-compilation-units programs into single-compilation-unit programs.

### Usage

```
OneFile <outfile>
```

To use `OneFile` you need to be in a directory which contains a directory named `src`. The `src` directory
must contain the C source files that are to be transformed into a single-compilation-unit program

The parameter `outfile` is the name of the single-compilation-unit program. E.g. the name of the resulting
C file.

### Limitations

`OneFile` successfully created single compilation units for the code source used for the `505.mcf_r` and `519.lbm_r` from the SPEC CPU 2017 benchmark suite and for `johnripper`, password cracker. These benchmarks have a simple source-code organization: all the .c and .h files are in the root directory, and hence there are no files with the same name.

There are some known limitations of this tool. One problem we encountered was that different .h files which had the same name. It wasn't a problem for the original c project we were attempted to convert since the .h were placed in different folders. However, when placing them at the root of the directory, this became a problem.

Another known issue is the need to address compilations that contain macro definitions. At the moment, `OneFile` calls gcc without any -D flags. However, it is known that certain compilations require the definition of macros in order to compile correctly. This has not been addressed.

There are some cases in which a definition is placed out of order and a unsatisfied dependency will cause the program to fail. `OneFile` will warn the user when this happens and the user will be required to manually inspect the code.

### Where can I get more information about how it works

The `OneFile` tool is a piece of the collection of new workloads for the SPEC CPU 2017 benchmark suite
designed at the University of Alberta with collaboration from Universidade de Campinas in Brazil. Please visit
the website to read the detailed report which includes a walkthrough of the program.
