D.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 x86 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 either I80386, I80486, or PENTIUM to match the processor you are using.

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

-DCPU=I80386

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

#define CPU I80386

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 and C++ Modules

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

% cc386 -DCPU=I80386 -I $WIND_BASE/target/h -fno-builtin -0 \ 
-mno-486 -fno-defer-pop -nostdinc -c applic.lang_id

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

cc386
Required; use cc386 for all supported x86 processors.

-DCPU=I80386
Required; defines the CPU type for the i386. If you are using another CPU type, specify the appropriate value (see Defining the CPU Type).

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

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

-O
Optional; performs standard optimizations. Note that optimization is not supported for the Pentium.

-mno-486
Required for the i386; generates optimized code for the i386. For the i486, the compiler automatically generates optimized code; no additional flags are required.

-fno-defer-pop
Required; pops the arguments to each subroutine call as soon as that subroutine returns.

-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.

-fvolatile
Optional; considers all memory references through pointers to be volatile.

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

applic.lang_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 run-time support can use to call the objects' constructors and destructors. For details, see the VxWorks Programmer's Guide: C++ Development.


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.