[next] [prev] [prev-tail] [tail] [up]

### 6.11 Project management and compiler options

Project management in Pascal is much easier than with C. The compiler knows from the source which units, sources etc. it needs. So the Free Pascal IDE does not need a full featured project manager like some C development environments offer, nevertheless there are some settings in the IDE which apply to projects.

#### The primary file

Without a primary file the IDE compiles/runs the source of the active window when a program is started. If a primary file is specified, the IDE compiles/runs always this source, even if another source window is active. With the menu item ”Compile--Primary file...” a file dialog can be opened where the primary file can be selected. Only the menu item ”Compile--Compile” compiles still the active window, this is useful if a large project is being edited, and only the syntax of the current source should be checked.

The menu item ”Compiler--Clear primary file” restores the default behaviour of the IDE, i.e. the ’compile’ and ’run’ commands apply to the active window.

#### The directory dialog

In the directory dialog, the directories can be specified where the compiler should look for units, libraries, object files. It also says where the output files should be stored. Multiple directories (except for the output directory) can be entered, separated by semicolons. The directories dialog is shown in figure (6.21).

Figure 6.21: | The directories configuration dialog

The following directories can be specified:

EXE & PPU directories
  Specifies where the compiled units and executables will go. (-FE, (see page 5.1) on the command line.)
Object directories
  Specifies where the compiler looks for external object files. (-Fo, (see page 5.1) on the command line.)
Library directories
  Specifies where the compiler (more exactly, the linker) looks for external libraries. (-Fl, (see page 5.1) on the command line.)
Include directories
  Specifies where the compiler will look for include files, included with the {$i } directive. (-Fi, (see page 5.1) or -I, (see page 5.1) on the command line.)
Unit directories
  Specifies where the compiler will look for compiled units. The compiler always looks first in the current directory, and also in some standard directories. (-Fu, (see page 5.1) on the command line.)

#### The target operating system

The menu item ”Compile--Target” allows to specify the target operating system for which the sources will be compiled. Changing the target doesn’t affect any compiler switches or directories. It does affect some defines defined by the compiler. The settings here correspond to the option -T, (see page 5.1) on the command-line. The compilation target dialog is shown in figure (6.22).

Figure 6.22: | The compilation target dialog

The following targets can be set:

Dos (go32v1)
  This switch will dissapear in time as this target is no longer being maintained.
Dos (go32v2)
  Compile for D O S, using version 2 of the Go32 extender.
FreeBSD
  Compile for FR E EBSD.
Linux
  Compile for L I N U X.
OS/2
  Compile for OS/2 (using the EMX extender)
Win32
  Compile for windows 32 bit.

The currently selected target operating system is shown in the menu item in the ”Compile” menu. Standard this should be the operating system for which the IDE was compiled.

#### Compiler options

The menu ”Options--Compiler” allows to set other options that affect the compilers behaviour. When this menu item is chosen, a dialog pops up that displays several tabs.

There are 5 tabs:

Syntax
  Here options can be set that affect the various syntax aspects of the code. They correspond mostly to the -S option on the command line (section 5.1, page 82).
Code generation
  These options control the generated code; they are mostly concerned with the -C and -X command-line options.
Verbose
  These set the verbosity of the compiler when compiling. The messages of the compiler are shown in the compiler messages window (can be called with F12).
Browser
  options concerning the generated browser information. Browser information needs to be generated for the symbol browser to work.
Assembler
  Options concerning the reading of assembler blocks (-R on the command line) and the generated assembler (-A on the command line)

Under the tab pages, the Conditional defines entry box is visible; here symbols to define can be entered. The symbols should be separated with semicolons. The syntax tab of the compiler options dialog is shown in figure (6.23).

Figure 6.23: | The syntax options tab

In this dialog, the following options can be set:

Delphi 2 extensions on
  Enables the use of classes and exceptions (-Sd, (see page 5.1) on the command-line).
C-like operators
  Allows the use of some extended operators such as +=, -= etc. (-Sc, (see page 5.1) on the command-line).
Stop after first error
  when checked, the compiler stops after the first error. Normally the compiler continues compiling till a fatal error is reached. (-Se, (see page 5.1) on the command-line)
Allow label and goto
  Allow the use of label declarations and goto statements (-Sg, (see page 5.1) on the command line).
C++ styled inline
  allows the use of inlined functions (-Sc, (see page 5.1) on the command-line).
TP/BP 7.0 compatibility
  Try to be more Turbo Pascal compatible (-So, (see page 5.1) on the command-line).
Delphi compatibility
  try to be more Delphicompatible (-Sd, (see page 5.1) on the command-line).
Allow STATIC in objects
  Allow the Static modifier for object methods (-St, (see page 5.1) on the command-line)
Strict var-strings
  Not used.
Extended syntax
  Not used.
Allow MMX operations
  Allow MMX operations.

The code generation tab of the compiler options dialog is shown in figure (6.24).

Figure 6.24: | The code generation options tab

In this dialog, the following options can be set:

Run-time checks
  Controls what run-time checking code is generated. If such a check fails, a run-time error is generated. the following checking code can be generated:
  Range checking
    Code that checks the results of enumeration and subset type operations is generated (-Cr, (see page 5.1) command-line option)
  Stack checking
    Code that checks whether the stack limit is not reached is generated (-Cs, (see page 5.1) command-line option)
  I/O checking
    Code that checks the result of IO operations is generated. (-Ci, (see page 5.1) command-line option).
  Integer overflow checking
    The result of integer operations is checked (-Co, (see page 5.1) command-line option)
Target processor
  Set the target process for optimizations. The compiler can use different optimizations for different processors. This corresponds to the Op option.
  i386/i486
    Code is optimized for less than Pentium processors.
  Pentium/pentiumMMX
    Code is optimized for Pentium processors.
  PPro/PII/c6x86/K6
    Code is optimized for Pentium pro and higher processors.
Optimizations
  What optimizations should be used when compiling:
  Generate faster code
    Corresponds to the -OG command-line option.
  Generate smaller code
    Corresponds to the -Og command-line option.
  Use register variables
    Corresponds to the -Or command-line option.
  Uncertain optimizations
    Corresponds to the -Ou command-line option.
  Level 1 optimizations
    Corresponds to the O1 command-line option.
  Level 2 optimizations
    Corresponds to the O1 command-line option.

More information on these switches can be found in section 5.1, page 78. The verbose tab of the compiler options dialog is shown in figure (6.25).

Figure 6.25: | The verbosity options tab

In this dialog, the following verbosity options (-v, (see page 5.1) on the command-line) can be set:

Warnings
  Generate warnings, corresponds to -vw on the command-line.
Notes
  Generate notes, corresponds to -vn on the command-line.
Hints
  Generate hints, corresponds to -vh on the command-line.
General info
  Generate general information, corresponds to -vi on the command-line.
User,tried info
  Generate information on used and tried files. Corresponds to -vut on the command-line.
All
  Switch on full verbosity. Corresponds to -va on the command-line.
Show all procedure if error
  If an error using overloaded procedure occurs, show all procedures. Corresponds to -vb on the command-line.

The browser tab of the compiler options dialog is shown in figure (6.26).

Figure 6.26: | The browser options tab

In this dialog, the browser options can be set:

No browser
  (default) no browser information is generated by the compiler.
Only global browser
  Browser information is generated for global symbols only, i.e. symbols defined not in a procedure or function (-b on the command-line)
Local and global browser
  Browser information is generated for all symbols, i.e. also for symbols that are defined in procedures or functions (-bl on the command-line)

Remark: If no browser information is generated, the symbol browser of the IDE will not work. The assembler tab of the compiler options dialog is shown in figure (6.27).

Figure 6.27: | The assembler options tab

In this dialog, the assembler reader and writer options can be set:

Assembler reader
  This allows to set the style of the assembler blocks in the sources:
  Direct assembler
    The assembler blocks are copied as-is to the output (-Rdirect on the command-line).
  AT&T assembler
    The assembler is written in AT&T style assembler (-Ratt on the command-line).
  Intel style assembler
    The assembler is written in Intel style assembler blocks (-Rintel on the command-line).

  remark that this option is global, but locally the assembler style can be changed with compiler directives.

Assembler info
  When writing assembler files, this option decides which extra information is written to the assembler file in comments:
  List source
    The source lines are written to the assembler files together with the generated assembler (-al on the command line).
  List register allocation
    The compilers internal register allocation/deallocation information is written to the assembler file (-ar on the command-line).
  List temp allocation
    The temporary register allocation/deallocation is written to the assembler file. (-at on the command-line).

  The latter two of these options are mainly useful for debugging the compiler itself, it should be rarely necessary to use these.

Assembler output
  This option tells the compiler what assembler output should be generated.
  Use default output
    This depends on the target.
  Use GNU as
    assemble using G N U as (-Aas on the command-line).
  Use NASM coff
    produce NASM coff assembler (go32v2, -Anasmcoff on the command-line)
  Use NASM elf
    produce NASM elf assembler (L I N U X, -Anasmelf on the command-line).
  Use NASM obj
    produce NASM obj assembler (-Anasmobj on the command-line).
  Use MASM
    produce MASM (Microsoft assembler) assembler (-Amasm on the command-line).
  Use TASM
    produce TASM (Turbo Assembler) assembler (-Atasm on the command-line).
  Use coff
    Write binary coff files directly using the internal assembler (go32v2, -Acoff on the command-line).
  Use pecoff
    Write binary pecoff files files directly using the internal writer. (Win32)

#### Linker options

The linker options can be set in the menu ”Options--Linker”. It allows to determine how libraries and units are linked, and how the linker should be called. The linker options dialog is shown in figure (6.28).

Figure 6.28: | The linker options dialog

The following options can be set:

Call linker after
  If this option is set then a script is written which calls the linker. This corresponds to the -s, (see page 5.1) on the command-line.
Preferred library type
  With this option, the type of library to be linked in can be set:
  Target default
    This depends on the platform.
  Dynamic libraries
    Tries to link in units in dynamical libraries. (option -XD on the command-line)
  Static libraries
    Tries to link in units in statical libraries. (option -XS on the command-line)
  Smart libraries
    Tries to link in units in smartlinked libraries. (option -XX on the command-line)

#### Memory sizes

The memory sizes dialog (reachable via ”options--Memory sizes”) allows to enter the memory sizes for the project. The memory sizes dialog is shown in figure (6.29).

Figure 6.29: | The memory sizes dialog

The following sizes can be entered:

Stack size
  Sets the size of the stack in bytes; (option -Cs on the command line). This size may be ignored on some systems.
Heap size
  Sets the size of the heap in bytes; (option -Ch on the command-line). Note that the heap grows dynamically as much as the OS allows.

#### Debug options

In the debug options dialog some options for inclusion of debug information in the binary can be set; it is also possible to add additional compiler options in this dialog. The debug options dialog is shown in figure (6.30).

Figure 6.30: | The debug options dialog

The following options can be set:

Debugging information
  tells the compiler which debug information should be compiled in. One of following options can be chosen:
  Strip all debug symbols from executable
    Will strip all debug nd symbol information from the binary. (option -Xs on the command-line).
  Generate debug symbol information
    include debug information in the binary (option -g on the command-line). Please note that no debug information for units in the Run-Time Library will be included, unless a version of the RTL compiled with debug information is available. Only units specific to the current project will have debug information included.
  Generate also backtrace lines information
    Will compile with debug information, and will additionally include the lineinfo unit in the binary, so in case of an error the backtrace will contain the filenames and linenumbers of procedures in the call-stack. (Option -gl on the command-line)
Profiling switches
  Tells the compiler whether or not profile code should be included in the binary.
  No profile information
    Has no effect, as it is the default.
  Generate Profile code for gprof
    If checked, profiling code is included in the binary (option -p on the command-line).
Addition compiler args
  Here arbitrary options can be entered as they would be entered on the command-line, they will be passed on to the compiler as typed here.
Debuggee redirection
  If checked, an attempt will be made to redirect the output of the program being debugged to another window (terminal).

#### The switches mode

The IDE allows to save a set of compiler settings under a common name; it provides 3 names under which the switches can be saved:

Normal
  For normal (fast) compilation.
Debug
  For debugging; intended to set most debug switches on. Also useful for setting conditional defines that e.g. allow to include some debug code.
release
  For a compile of the program as it should be released, debug information should be off, the binary should be stripped, and optimizations should be used.

Selecting one of these modes will load the compiler options as they were saved the last time the selected mode was active, i.e. it doesn’t specifically set or unset options.

When setting and saving compiler options, be sure to select the correct switch mode first; it makes little sense to set debug options while the release switch is active. The switches mode dialog is shown in figure (6.31).

Figure 6.31: | The switches mode dialog

[next] [prev] [prev-tail] [front] [up]