[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

2. The Frontend

This chapter describes vc, the frontend for vbcc. It knows how to deal with different file types and optimization settings and will call the compiler, assembler and linker. It is not recommended to call the different translation-phases directly. vc provides an easy-to-use interface which is mostly compatible to Unix cc.


2.1 Usage

The general syntax for calling vc

 
    vc [options] file1 file2 ...

processes all files according to their suffix and links all objects together (unless any of ‘-E’, ‘-S’, ‘-c’ is specified). The following file types are recognized:

.c

C source

.i

already preprocessed C source

.scs

assembly source to be fed to the scheduler

.asm
.s

assembly source

.obj
.o

object file

Usually pattern matching is supported - however this depends on the port and the host system.

The options recognized by vc are:

-v

Verbose mode. Prints all commands before executing them.

-vv

Very verbose. Displays some internals as well.

-Ox

Sets the optimization level.
-O0 is equivalent to -O=0.
-O will activate some optimizations (at the moment -O=991).
-O2 will activate most optimizations (at the moment -O=1023 -schedule).
-O3 will activate all optimizations (at the moment -O=~0 -schedule).
-O4 will activate full cross-module-optimization.

Also, -O3 will activate cross-module-optimizations. All source files specified on the command line will be passed to the compiler at once. Only one assembly/object-file will be produced (by default the name is the name of the first source file with corresponding suffix).

When compiling with -O4 and -c vbcc will not produce real object files but special files containing all necessary information to defer optimization and code-generation to link-time. This is useful to provide all files of a project to the optimizer and make full use of cross-module optimizations. Note that you must use vc to do the linking. vc will detect and handle these files correctly. They can not be linked directly. Also, make sure to pass all relevant compiler options also to the linker-command.

Higher values may or may not activate even more optimizations. The default is -O=1. It is also possible to specify an exact value with -O=n. However, I do not recommend this unless you know exactly what you are doing.

-o file

Save the target as ‘file’ (default for executables is ‘a.out’).

-E

Save the preprocessed C sources with .i suffix.

-S

Do not assemble. Save the compiled files with .asm suffix.

-SCS

Do not schedule. Save the compiled files with .scs suffix.

-c

Do not link. Save the compiled files with .o suffix.

-k

Keep all intermediate files. By default all generated files except the source files and the targets are deleted.

-Dstr

#define a preprocessor symbol, e.g. -DAMIGA or -DCPU=68000. The former syntax is equivalent to:

 
 #define AMIGA 1

The latter form is equivalent to:

 
 #define CPU 68000
-Ipath

Add ‘path’ to the include-search-path.

-lulib

Link with library ‘ulib’.

-Lpath

Add ‘path’ to the library-search-path. This is passed through to the linker.

-static

Instruct the linker to link against static libraries. This may override the default to link against dynamic libraries first.

-nostdlib

Do not link with standard-startup/libraries. Useful only for people who know what they are doing.

-notmpfile

Do not use names from tmpnam() for temporary files.

-schedule

Invoke the instruction-scheduler, if available.

+file

Use ‘file’ as config-file.

All other options are passed through to vbcc.


2.2 Configuration

vc needs a config file to know how to call all the translation phases (compiler, assembler, linker). Unless a different file is specified using the ‘+’-option, it will look for a file ‘vc.config’ (‘vc.cfg’ for DOS/Windows).

On AmigaOS vc will search in the current directory, in ‘ENV:’ and ‘VBCC:’.

On Unix vc will search in the current directory followed by ‘/etc/’.

On DOS/Windows it will search in the current directory.

If the config file was not found in the default search-paths and an environment variable $VBCC is set, vc will also look in $VBCC/config’.

Once a config file is found, it will be treated as a collection of additional command line arguments. Every line of the file will be used as one argument. So no quoting shall be used and furthermore must each argument be placed on its own line.

The following options can be used to tell vc how to call the translation phases (they will usually be contained in the config-file):

-pp=string

The preprocessor will be called like in printf(string,opts,infile,outfile), e.g. the default for vcpp searching the includes in ‘vinclude:’ and defining __STDC__) is ‘-pp=vcpp -Ivinclude: -D__STDC__=1 %s %s %s’. Note that there is an internal preprocessor, called ucpp, since V0.8, you usually don’t need this option any more.

-cc=string

For the compiler. Note that you cannot use vc to call another compiler than vbcc. But you can call different versions of vbcc this way, e.g.: ‘-cc=vbccm68k -quiet’ or ‘-cc=vbcci386 -quiet

-isc=string

The same for the scheduler, e.g.: ‘-isc=vscppc -quiet %s %s’ Omit, if there is no scheduler for the architecture.

-as=string

The same for the assembler, e.g.: ‘-as=vasmm68k_mot -quiet -Fhunk -phxass -opt-pea -opt-clr %s -o %s’ or ‘-as=as %s -o %s

-rm=string

This is the string for the delete command and takes only one argument, e.g. ‘-rm=delete quiet %s’ or ‘-rm=rm %s

-ld=string

This is for the linker and takes three arguments. The first one are the object files (separated by spaces), the second one the user specified libraries and the last one the name of the resulting executable. This has to link with proper startup-code and c-libraries, e.g.: ‘-ld=vlink -x -Bstatic -Cvbcc -nostdlib -Lvlibos3: vlibos3:startup.o %s %s -lvc -o %s’ or ‘-ld=ld /usr/lib/crt0.o %s %s -lc -o %s

-l2=string

The same like -ld, but standard-startup and -libraries should not be linked; used when -nostdlib is specified.

-ldnodb=string

This option string is inserted in the linker command before specifying the libraries, whenever an executable without debugging information and symbols should be created (AKA as a ’stripped’ executable).

-ldstatic=string

This option string is inserted in the linker command before specifying the libraries when static linking was requested with option ‘-static’.

All those strings should tell the command to omit any output apart from error messages if possible. However for every of those options there exists one with an additional ‘v’, i.e. ‘-ppv=’, ‘-asv=’, etc. which should produce some output, if possible. If vc is invoked with the ‘-vv’ option the verbose commands will be called, if not the quiet ones will be used.

-ul=string

Format for additional libraries specified with ‘-l<lib>’. The result of printf(string,lib) will be added to the command invoking the linker. Examples are: ‘-ul=vlib:%s.lib’ or ‘-ul=-l%s


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by vb on January 3, 2015 using texi2html 1.82.