Skip to content
tpo edited this page Apr 29, 2012 · 6 revisions

The AS Build Process for mixed C - ST Projects

Intro and disclaimer

When buildin AS projects that containe mixed C and ST code (f.ex. some Libraries are in C, some in ST, some C Libraries have .fun files, some don't export any ST interface), the build process can fail in mysterious ways.

This page aims to document how AS builds projects in order to understand the process better and be able to fix AS build problems. The text here represents grey-box reverse engineering, that is the AS build process is semy transparent, because it partly uses tools such as gnu make and can be configured to leave traces of the build process behind. As such the information presented here is based on educated guesswork and can be inacurate. Please improve the docu if you find a problem with it.

Analysing the build process

In the "Physical View -> Properties -> Compilation" you can add a "-save-temps" switch to the "Additional compile options" field. This results in gcc not cleaning up intermediate files, which can help you finding out how things were compiled.

Additionaly AS itself leaves behind .mak (Makefile) and other kinds of files in the Temp/ directory which lets you see how AS compiled and linked the parts of your project.

The AS build process

AS will build libraries and link Task in the order they appear in the CPU.sw configuration. If there are any dependencies that you are unable to correctly communicate to AS, you can use this explicit ordering to impose them during the build process.

What AS does first is to create .h files from the various .fun, .typ and .var files. That means that Temp/Includes is populated first during the build process. Which means that your C libraries do have access to those generates headers during their build.

Next AS will build the libraries.

It seems that AS will link libraries that contain .typ, .var or .fun files, in other words libraries with an ST interface, against all pure (without ST interface) C libraries. That means that pure C libraries must occur before any ST-interface-libraries, in the CPU.sw list, otherwise they will not yet be built and the build will fail with a link error.

Since AS is allway linking ST-interface C libraries with all pure C libraries it is also including all headers of those pure C libraries during the compilation of those ST-interface C libraries.

Best practice

  • always place pure C libraries before ST-interface C libraries and ST libraries in the CPU.sw configuration
Clone this wiki locally