<div dir="ltr">Hi folks,<div><br></div><div>I recently noticed that clang and GCC differ on the default PIE/PIC flags. In particular, clang doesn't default to PIE/PIC on Linux x86-64, and GCC does.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><font face="monospace">$ clang++ a.cpp && readelf -l a.out | egrep '(LOAD|VirtAddr)'<br>  Type           Offset             VirtAddr           PhysAddr<br>  LOAD           0x0000000000000000 0x0000000000400000 0x0000000000400000</font><br></blockquote><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><font face="monospace">$ g++ a.cpp && readelf -l a.out | egrep '(LOAD|VirtAddr)'<br>  Type           Offset             VirtAddr           PhysAddr</font></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><font face="monospace">  LOAD           0x0000000000000000 0x0000000000000000 0x0000000000000000 </font></blockquote><div><br></div><div>Are there any concerns about changing the clang default to emit PIC and pass PIE to the linker?<br></div><div><br></div><div>Also, using `clang++ -fPIC -fPIE <...>` doesn't emit a PIE. Any opponents to making `-fPIE` imply passing `-pie` to the linker?</div><div><br></div><div>- Mitch.</div></div>