-fPIC (-qpic)

Pragma equivalent

None.

Purpose

Generates position-independent code required for use in shared libraries.

Syntax

Read syntax diagramSkip visual syntax diagram
        .-no-PIC-.   
>>- -f--+-PIC----+---------------------------------------------><

Read syntax diagramSkip visual syntax diagram
        .-nopic-.   
>>- -q--+-pic---+----------------------------------------------><

Defaults

  • , or -fno-PIC, or -qnopic

Usage

When -fPIC (-qpic) is in effect, the compiler generates position-independent code.

If a thread local storage (TLS) model is not specified, the position-independent code setting determines the default TLS model:
  • When -fno-PIC (-qnopic) is in effect, the default TLS model is local-exec.
  • When -fPIC (-qpic) is in effect, the default TLS model is general-dynamic.

If the initial-exec TLS model is in effect, different code sequences are used depending on different position-independent code settings.

You must compile all the compilation units that are not part of a shared library with -fno-PIC (-qnopic) and that are part of a shared library with -fPIC (-qpic).

Predefined macros

None.

Examples

To compile a shared library libmylib.so, use the following commands:
xlc mylib.c -fPIC -c -o mylib.o 
xlc -shared mylib -o libmylib.so.1

Related information



Voice your opinion on getting help information Ask IBM compiler experts a technical question in the IBM XL compilers forum Reach out to us