Thread overview
Why is the fPIC switch missing?
Sep 23, 2019
Emmanuelle
Sep 23, 2019
Emmanuelle
Sep 23, 2019
Daniel Kozak
Sep 23, 2019
Daniel Kozak
Sep 23, 2019
Boris Carvajal
Sep 23, 2019
IGotD-
Sep 23, 2019
Vladimir Panteleev
September 23, 2019
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!
September 23, 2019
Forgot to say: dmd v2.088.0. Also, weirdly enough, `dmd --version` outputs `DMD32 D Compiler v2.088.0-dirty`. Why is "dirty" there?
September 23, 2019
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
September 23, 2019
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
September 23, 2019
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.
September 23, 2019
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.
September 23, 2019
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.