B.2   Building Applications

The Tornado 2.0 project facility is correctly preconfigured for building WRS BSPs. However, if you choose not to use the project facility or if you need to customize your build, you may need the information in the following sections. This includes a configuration constant, an environment variable, and compiler options that together specify the information the GNU toolkit requires to compile correctly for SPARC and SPARClite targets.

Defining the CPU Type

Setting the preprocessor variable CPU ensures that VxWorks and your applications build with the appropriate architecture-specific features enabled. Define this variable to SPARC for both the SPARC and SPARClite processors.

For example, to define CPU for a SPARC on the compiler command line, specify the following command-line option when you invoke the compiler:

-DCPU=SPARC

To provide the same information in a header or source file instead, include the following line in the file:

#define CPU SPARC

Configuring the GNU ToolKit Environment

Tornado includes the GNU compiler and associated tools. Tornado is configured to use these tools by default. No change is required to the execution path, because the compilation chain is installed in the same bin directory as the other Tornado executables.

Compiling C or C++ Modules

The following is an example of a compiler command line for SPARClite cross-development. The file to be compiled in this example has a base name of applic.

% ccsparc -DCPU=SPARC -I $WIND_BASE/target/h -O2 -nostdinc \ 
-fno-builtin -msparclite -msoft-float -c applic.language_id

The options shown in the example have the following meanings:1

-DCPU=SPARC
Required; defines the CPU type. Use SPARClite for SPARClite processors.

-I $WIND_BASE/target/h
Required; includes VxWorks header files. (Additional -I flags may be included to specify other header files.)

-O2
Optional; performs level 2 optimization.

-nostdinc
Required; searches only the directory(ies) specified with the -I flag (see above) and the current directory for header files. Does not search host-system include files.

-fno-builtin
Required; uses library calls even for common library subroutines.

-msparclite
Required for SPARClite; generates SPARClite-specific code.

-msoft-float
Optional; generates software floating point library calls, rather than hardware floating point instructions. For more information, see USS Floating-Point Emulation Library,

-c
Required; specifies that the module is to be compiled only, and not linked for execution under the host.

applic.language_id
Required; the file(s) to compile. For C compilation, specify a suffix of .c. For C++ compilation, specify a suffix of .cpp. The output is an unlinked object module in a.out format with the suffix .o; for the example, the output is applic.o.

During C++ compilation, the compiled object module (applic.o) is munched. Munching is the process of scanning an object module for non-local static objects, and generating data structures that VxWorks can use to call the objects' constructors and destructors. See the VxWorks Programmer's Guide: C++ Development for details


1:  For more information on these and other compiler options, see the GNU ToolKit User's Guide. WRS supports compiler options used in building WRS software; a list of these options is included in the Guide. Other options are not supported, although they are available with the tools as shipped.