Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clang -fPIC compiler option explained

Tags:

clang

Would someone please explain what the -fPIC option does. I can't seem to find references to it, yet I've seen it in use. I believe it has something to do with the memory allocation/space the executable will use, but would appreciate something more tangible.

Cheers,
Nap

like image 527
gone Avatar asked Apr 22 '14 16:04

gone


People also ask

What is option in Clang?

clang supports the -std option, which changes what language mode clang uses. The supported modes for C are c89, gnu89, c94, c99, gnu99 and various aliases for those modes. If no -std option is specified, clang defaults to gnu99 mode.

How does Clang compiler work?

Like many other compilers design, Clang compiler has three phase: The front end that parses source code, checking it for errors, and builds a language-specific Abstract Syntax Tree (AST) to represent the input code. The optimizer: its goal is to do some optimization on the AST generated by the front end.

What compiler does Clang use?

Clang uses the LLVM compiler as its back end and it has been included in the release of the LLVM since the LLVM 2.6. Clang is also built to be a drop-in replacement for GCC command. In its design, the Clang compiler has been constructed to work very similarly to GCC to ensure that portability is maximized.

What is option in GCC?

When you invoke GCC, it normally does preprocessing, compilation, assembly and linking. The "overall options" allow you to stop this process at an intermediate stage. For example, the -c option says not to run the linker. Then the output consists of object files output by the assembler.


1 Answers

these are the references you are looking for:

https://gcc.gnu.org/onlinedocs/gcc-4.0.4/gccint/PIC.html

like image 135
Bots Fab Avatar answered Sep 16 '22 12:09

Bots Fab