-W

Category

Compiler customization

Pragma equivalent

None.

Purpose

Passes the listed options to a component that is executed during compilation.

Syntax

Read syntax diagramSkip visual syntax diagram
               .-----------.   
               V           |   
>>- -W--+-a-+----,--option-+-----------------------------------><
        +-b-+                  
        +-c-+                  
        +-C-+                  
        +-d-+                  
        +-E-+                  
        +-f-+                  
        +-I-+                  
        +-L-+                  
        +-l-+                  
        +-m-+                  
        '-p-'                  

Parameters

option
Any option that is valid for the component to which it is being passed. Spaces must not appear before the option.

The following table shows the correspondence between -W parameters and the component executable names:

Parameter Description Executable name
a Assembler as
b Low-level optimizer xlCcode
c Compiler front end xlcentry, xlCentry
C++ only C C++ compiler front end xlCentry
d Disassembler dis
E CreateExportList utility CreateExportList
C++ only f c++filt utility c++filt
I High-level optimizer, compile step ipa
L High-level optimizer, link step ipa
l Linker ld
C++ only m Linkage helper munch
p Preprocessor n/a

Usage

In the string following the -W option, use a comma as the separator for each option, and do not include any spaces. If you need to include a character that is special to the shell in the option string, precede the character with a backslash. For example, if you use the -W option in the configuration file, you can use the escape sequence backslash comma (\,) to represent a comma in the parameter string.

You do not need the -W option to pass most options to the linker ld; unrecognized command-line options, except -q options, are passed to it automatically. Only linker options with the same letters as compiler options, such as -v or -S, strictly require -W.

By default, static objects are initialized in the order of priority specified by #pragma priority or the -qpriority (C++ only) option. You can use -Wm option to control the initialization order of the objects with the same priorities. Specifying -Wm -c instructs the compiler to initialize object files with the same priority in the order in which the files were given on the command line during linking into the library and the static objects within the files are initialized according to their declaration order.-Wm -r option, however, specifies that the object files with the same priority are to be initialized in the opposite order in which they were encountered during the linking phase.

Predefined macros

None.

Examples

To compile the file file.c and pass the linker option -berok to the linker, enter the following command:
xlc -Wl,-berok file.c
To compile the file uses_many_symbols.c and the assembly file produces_warnings.s so that produces_warnings.s is assembled with the assembler option -x (issue warnings and produce cross-reference), and the object files are linked with the option -s (write list of object files and strip final executable file), issue the following command:.
xlc -Wa,-x -Wl,-s produces_warnings.s uses_many_symbols.c 

Related information