-fPIC (-qpic)
Category
Pragma equivalent
None.
Purpose
Generates position-independent code required for use in shared libraries.
Syntax
.-no-PIC-. >>- -f--+-PIC----+---------------------------------------------><
.-nopic-. >>- -q--+-pic---+----------------------------------------------><
Defaults
- -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