October 31, 2016 Re: strange -fPIC compilation error | ||||
---|---|---|---|---|
| ||||
Dne 31.10.2016 v 20:20 Charles Hixson via Digitalmars-d-learn napsal(a):
> ...
>
> but
> dmd -defaultlib=libphobos2.so -fPIC test.d
> works. It shouldn't be required (as in the default /etc/dmd.conf should handle it correctly, but I can deal with it now.
It should work, it is possible that you have some another dmd.conf somewhere?
|
October 31, 2016 Re: strange -fPIC compilation error | ||||
---|---|---|---|---|
| ||||
On 10/31/2016 12:31 PM, Daniel Kozak via Digitalmars-d-learn wrote:
> Dne 31.10.2016 v 20:20 Charles Hixson via Digitalmars-d-learn napsal(a):
>
>> ...
>>
>> but
>> dmd -defaultlib=libphobos2.so -fPIC test.d
>> works. It shouldn't be required (as in the default /etc/dmd.conf should handle it correctly, but I can deal with it now.
>
> It should work, it is possible that you have some another dmd.conf somewhere?
>
>
I did have a couple lying around, but they worked fine in the past, and renaming them didn't fix, or even just change, anything. I've still got some others on my backup partition, but I can't imagine that they would be in use.
One of them was there because I had a few macros that were specified in an external ddoc file that was used by one project, e.g.
|
November 01, 2016 Re: strange -fPIC compilation error | ||||
---|---|---|---|---|
| ||||
Posted in reply to Charles Hixson | On Monday, 31 October 2016 at 19:20:21 UTC, Charles Hixson wrote:
> but
> dmd -defaultlib=libphobos2.so -fPIC test.d
> works. It shouldn't be required (as in the default /etc/dmd.conf should handle it correctly, but I can deal with it now.
The need to manually add this to dmd.conf is a very recent development and only on specific systems. I expect at some point they will either become the default or, better, the installer scripts will have to detect if they are necessary.
|
November 01, 2016 Re: strange -fPIC compilation error | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike Parker | On Tuesday, 1 November 2016 at 07:15:19 UTC, Mike Parker wrote:
>> but
>> dmd -defaultlib=libphobos2.so -fPIC test.d
>> works. It shouldn't be required (as in the default /etc/dmd.conf should handle it correctly, but I can deal with it now.
Can this be fed as parameters to the DMD call (programmatically) instead of manual editing of dmd.conf?
|
November 01, 2016 Re: strange -fPIC compilation error | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nordlöw | On 11/01/2016 12:52 AM, Nordlöw via Digitalmars-d-learn wrote:
> On Tuesday, 1 November 2016 at 07:15:19 UTC, Mike Parker wrote:
>>> but
>>> dmd -defaultlib=libphobos2.so -fPIC test.d
>>> works. It shouldn't be required (as in the default /etc/dmd.conf should handle it correctly, but I can deal with it now.
>
> Can this be fed as parameters to the DMD call (programmatically) instead of manual editing of dmd.conf?
>
I did feed it into the dmd call programmatically. Thus:
dmd -defaultlib=libphobos2.so -fPIC test.d
I'm reluctant to edit the dmd.conf file as I don't really understand the syntax...and I have to be root to do the editing.
|
November 01, 2016 Re: strange -fPIC compilation error | ||||
---|---|---|---|---|
| ||||
Posted in reply to Charles Hixson | On Tuesday, 1 November 2016 at 17:23:54 UTC, Charles Hixson wrote: > On 11/01/2016 12:52 AM, Nordlöw via Digitalmars-d-learn wrote: >> On Tuesday, 1 November 2016 at 07:15:19 UTC, Mike Parker wrote: >>>> but >>>> dmd -defaultlib=libphobos2.so -fPIC test.d >>>> works. It shouldn't be required (as in the default /etc/dmd.conf should handle it correctly, but I can deal with it now. >> >> Can this be fed as parameters to the DMD call (programmatically) instead of manual editing of dmd.conf? >> > I did feed it into the dmd call programmatically. Thus: > dmd -defaultlib=libphobos2.so -fPIC test.d > > I'm reluctant to edit the dmd.conf file as I don't really understand the syntax...and I have to be root to do the editing. https://dlang.org/dmd-linux.html#dmd-conf You can copy dmd.conf to the current working directory and try out changes there. That will only affect the current program. Then you can move it to your home directory. |
November 01, 2016 Re: strange -fPIC compilation error | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sebastien Alaiwan | On Monday, 31 October 2016 at 07:16:50 UTC, Sebastien Alaiwan wrote:
> Hello,
> From GCC 6.2, -fpie is becoming the default setting at compile and at link time.
> As dmd uses GCC to link, now the code needs to be compiled with a special option.
> Which means you need, at the moment, to add the following options to your dmd.conf:
> -defaultlib=libphobos2.so -fPIC
> (the change from GCC is related to security and address space randomization).
So does this mean it's now impossible to compile statically until this gets fixed?
|
November 01, 2016 Re: strange -fPIC compilation error | ||||
---|---|---|---|---|
| ||||
Posted in reply to bachmeier | On 11/01/2016 10:34 AM, bachmeier via Digitalmars-d-learn wrote:
> On Tuesday, 1 November 2016 at 17:23:54 UTC, Charles Hixson wrote:
>> On 11/01/2016 12:52 AM, Nordlöw via Digitalmars-d-learn wrote:
>>> On Tuesday, 1 November 2016 at 07:15:19 UTC, Mike Parker wrote:
>>>>> but
>>>>> dmd -defaultlib=libphobos2.so -fPIC test.d
>>>>> works. It shouldn't be required (as in the default /etc/dmd.conf should handle it correctly, but I can deal with it now.
>>>
>>> Can this be fed as parameters to the DMD call (programmatically) instead of manual editing of dmd.conf?
>>>
>> I did feed it into the dmd call programmatically. Thus:
>> dmd -defaultlib=libphobos2.so -fPIC test.d
>>
>> I'm reluctant to edit the dmd.conf file as I don't really understand the syntax...and I have to be root to do the editing.
>
> https://dlang.org/dmd-linux.html#dmd-conf
>
> You can copy dmd.conf to the current working directory and try out changes there. That will only affect the current program. Then you can move it to your home directory.
>
I'll probably do that eventually...but for now I'm just pasting a comment at the start of each file that tells how to compile it, e.g.:
//ldc2 -Dddocs -c msg.d <<-- no documentation generated
//dmd -Dddocs -c msg.d
//rdmd -main -Dddocs -unittest -defaultlib=libphobos2.so -fPIC msg.d
|
November 01, 2016 Re: strange -fPIC compilation error | ||||
---|---|---|---|---|
| ||||
Posted in reply to TheGag96 | On Tuesday, 1 November 2016 at 18:13:32 UTC, TheGag96 wrote:
> On Monday, 31 October 2016 at 07:16:50 UTC, Sebastien Alaiwan wrote:
>> Hello,
>> From GCC 6.2, -fpie is becoming the default setting at compile and at link time.
>> As dmd uses GCC to link, now the code needs to be compiled with a special option.
>> Which means you need, at the moment, to add the following options to your dmd.conf:
>> -defaultlib=libphobos2.so -fPIC
>> (the change from GCC is related to security and address space randomization).
>
> So does this mean it's now impossible to compile statically until this gets fixed?
It's impossible with the default `libphobos2.a`. I didn't try, but I'm quite confident that if you clone the Phobos repository and rebuild the library yourself with -fPIC, you can then link it statically to PIE executables.
|
Copyright © 1999-2021 by the D Language Foundation