www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Why is the fPIC switch missing?

reply Emmanuelle <VuLXn6DBW PPtUm7TvV6nsw.com> writes:
Hello. My problem is exactly what it says on the title: my dmd 
(windows 7, x64) doesn't seem to have -fPIC:

---
 dmd -fPIC
Error: unrecognized switch '-fPIC' run `dmd` to print the compiler manual run `dmd -man` to open browser on manual --- `dmd --help` also doesn't have anything about fPIC. Sorry if I'm being dense but why is that? Is it only available on Linux? Thank you!
Sep 22 2019
next sibling parent reply Emmanuelle <VuLXn6DBW PPtUm7TvV6nsw.com> writes:
Forgot to say: dmd v2.088.0. Also, weirdly enough, `dmd 
--version` outputs `DMD32 D Compiler v2.088.0-dirty`. Why is 
"dirty" there?
Sep 22 2019
parent Daniel Kozak <kozzi11 gmail.com> writes:
On Mon, Sep 23, 2019 at 3:35 AM Emmanuelle via Digitalmars-d-learn
<digitalmars-d-learn puremagic.com> wrote:
 Forgot to say: dmd v2.088.0. Also, weirdly enough, `dmd
 --version` outputs `DMD32 D Compiler v2.088.0-dirty`. Why is
 "dirty" there?
https://forum.dlang.org/post/qqxmnoshytmzflviwhcz forum.dlang.org
Sep 22 2019
prev sibling next sibling parent Daniel Kozak <kozzi11 gmail.com> writes:
On Mon, Sep 23, 2019 at 3:35 AM Emmanuelle via Digitalmars-d-learn
<digitalmars-d-learn puremagic.com> wrote:
 Hello. My problem is exactly what it says on the title: my dmd
 (windows 7, x64) doesn't seem to have -fPIC:

 ---
 dmd -fPIC
Error: unrecognized switch '-fPIC' run `dmd` to print the compiler manual run `dmd -man` to open browser on manual --- `dmd --help` also doesn't have anything about fPIC. Sorry if I'm being dense but why is that? Is it only available on Linux? Thank you!
It seems it is not available for windows and MacOS: https://github.com/dlang/dmd/blob/639c67162b2be90ebf8dc9a9f8118cb2a9606569/src/dmd/cli.d#L323
Sep 22 2019
prev sibling parent reply Boris Carvajal <boris2.9 gmail.com> writes:
On Monday, 23 September 2019 at 01:31:03 UTC, Emmanuelle wrote:
 Hello. My problem is exactly what it says on the title: my dmd 
 (windows 7, x64) doesn't seem to have -fPIC:
I think it's not needed. The generated code on Windows is always position independent. Still, DMD should warn about it and keep compiling like GCC, not fail miserably.
Sep 23 2019
next sibling parent IGotD- <nise nise.com> writes:
On Monday, 23 September 2019 at 08:19:35 UTC, Boris Carvajal 
wrote:
 On Monday, 23 September 2019 at 01:31:03 UTC, Emmanuelle wrote:
 Hello. My problem is exactly what it says on the title: my dmd 
 (windows 7, x64) doesn't seem to have -fPIC:
I think it's not needed. The generated code on Windows is always position independent. Still, DMD should warn about it and keep compiling like GCC, not fail miserably.
Is PIC really enabled by default for Windows 32-bit binaries.
Sep 23 2019
prev sibling parent Vladimir Panteleev <thecybershadow.lists gmail.com> writes:
On Monday, 23 September 2019 at 08:19:35 UTC, Boris Carvajal 
wrote:
 On Monday, 23 September 2019 at 01:31:03 UTC, Emmanuelle wrote:
 Hello. My problem is exactly what it says on the title: my dmd 
 (windows 7, x64) doesn't seem to have -fPIC:
I think it's not needed. The generated code on Windows is always position independent.
I believe Windows uses relocations. Relocations require patching the image after loading using a relocation table. Position-independent code does not require relocations, it is ready to run from any address straight after loading. This allows multiple copies of programs or libraries to be loaded at the same time in different processes at different addresses (with ASLR), but share their physical memory pages.
Sep 23 2019