E.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 the MIPS 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 be R3000 (for the MIPS R3000 or R3500), R4000 (for the R4200 or R4600), or R4650 (for the MIPS R4640 or R4650).

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

-DCPU=R3000

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

#define CPU R3000

All VxWorks makefiles pass along the definition of this variable to the compiler. You can define CPU on the make command line as follows:

% make CPU=R3000 ...

You can also set the definition directly in a makefile, with the following line:

CPU=R3000

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 R3000 cross-development. The file to be compiled in this example has a base name of applic.

% ccmips -DCPU=R3000 -I/usr/vw/h -mcpu=r3000 -O2 -funroll-loops \ 
-nostdinc -G 0 -c applic.c

This is an example for the R4000:

% ccmips -DCPU=R4000 -I/usr/vw/h -mcpu=r4000 -mips3 -mgp32 \ 
-mfp32 -O2 -funroll-loops -nostdinc -G 0 -c applic.c

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

-DCPU=R3000
Required; defines the CPU type for the R3000 or R3500. For the R4200 or R4600, specify R4000. For the R4640 or R4650, specify R4650.

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

-mcpu=r3000
Required; tells the compiler to produce code for the R3000 or R3500. For the R4200 or R4600, specify r4000. For the R4640 or R4650, specify r4650.

-mips3
Required for R4000 targets (R4200 and R4600) and R4650 targets (R4640 and R4650); tells the compiler to issue instructions from level 3 of the MIPS ISA (64-bit instructions). This compiler option does not apply to R3000 or R3500 targets.

-mfp32
Required for R4000 and R4650 targets; tells compiler to issue instructions assuming that fp registers are 32 bits, required for compatibility with mathALib.

-mgp32
Required for R4000 and R4650 targets in code which makes calls to varargs functions provided by VxWorks (printf( ), sprintf( ), and so forth); tells the compiler to issue instructions assuming that all general-purpose registers are 32 bits.

-msingle-float
Required for R4640 and R4650; tells the compiler to assume that the floating-point processor supports only single-precision operations.

-m4650
Required for R4650 targets; sets -msingle-float and -mmad2 flags.

-O2
Optional; tells the compiler to use level 2 optimization.


*

NOTE: To specify optimization for use with GDB, use the -O0 flag.

-funroll-loops
Optional; tells the compiler to use loop unrolling optimization.

-nostdinc
Required; searches only the directories specified with the -I flag (see above) and the current directory for header files.

-msoft-float
Required for software emulation, tells the compiler to issue library callouts for floating point. For more information, see Floating-Point Support.

-G 0
Required; tells the compiler not to use the global pointer. For more information, see Gprel Addressing.

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

The output is an unlinked object module in ELF format with the suffix .o; for the example above, the output would be applic.o.

The default for ccmips is big-endian (set explicitly with -EB) and defines MIPSEB. Tornado does not support little-endian; do not use -EL. Users should not define either MIPSEB or MIPSEL.


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.

2:  Consult GNU Toolkit User's Guide.