September 09, 2012 Re: D and SCons [ was Re: bigint <-> python long ] | ||||
---|---|---|---|---|
| ||||
Posted in reply to Russel Winder | Am Sat, 08 Sep 2012 16:25:49 +0100
schrieb Russel Winder <russel@winder.org.uk>:
> On Sat, 2012-09-08 at 07:20 -0700, Ellery Newcomer wrote: […]
> > Okay, here: https://bitbucket.org/ariovistus/deimos-elfutils/overview
> >
> > I have some code with a working makefile and a nonworking SConstruct file.
> >
> > I believe the issue is the header files have pragma(lib, X) in them, and a single call to dmd links the appropriate lib in, but scons' link step loses that information.
> >
> > Do you have any intention of supporting pragma(lib) in scons?
>
> If that is valid Dv2 and SCons doesn't deal with it then the SCons D tools are broken and need fixing.
>
> Is there a tiny project replicating this that I can turn into a unit/system test. The red so caused will necessitate action :-)
>
Please note that pragma(lib) is an evil feature. For example it will
never work in gdc.
|
September 09, 2012 Re: D and SCons [ was Re: bigint <-> python long ] | ||||
---|---|---|---|---|
| ||||
Posted in reply to Johannes Pfau Attachments:
| On Sun, 2012-09-09 at 10:15 +0200, Johannes Pfau wrote: […] > Please note that pragma(lib) is an evil feature. For example it will > never work in gdc. So this is a DMD-only (*) feature and not a feature of the D programming language per se? (*) and hence LDC. -- Russel. ============================================================================= Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder@ekiga.net 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel@winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder |
September 09, 2012 Re: D and SCons | ||||
---|---|---|---|---|
| ||||
Posted in reply to Johannes Pfau | Johannes Pfau:
> pragma(lib) is an evil feature. For example it will never work in gdc.
Do you know why it's impossible to implement it in GDC?
And if it's impossible to implement in GDC, then maybe it's
better to ask Walter to deprecate its usage in general.
Bye,
bearophile
|
September 09, 2012 Re: D and SCons | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | Am Sun, 09 Sep 2012 13:53:23 +0200
schrieb " bearophile" <bearophileHUGS@lycos.com>:
>
> Do you know why it's impossible to implement it in GDC?
>
> And if it's impossible to implement in GDC, then maybe it's better to ask Walter to deprecate its usage in general.
>
> Bye,
> bearophile
IIRC this is the reason:
GCC programs are always split into 2 executables, for gdc it's 'gdc'
and 'cc1d' (for c it's gcc and cc1, etc).
This allows the gcc executable to compile d sources, you can actually call gcc file.d and it'll invoke cc1d.
cc1d parses the source files and compiles code, so cc1d is the
tool which knows about pragma(lib). but cc1d is not responsible for
linking, linking is done by gdc. And IIRC there's no easy, portable way
to pass the information from cc1d to gdc.
So putting linker flags in source file doesn't fit gcc very well.
Note that it may not work with dmd either when linking incrementally. Putting linker flags into source files is just not a good idea:
test1.d
----
pragma(lib, "curl");
----
test2.d
----
import std.net.curl;
import test1;
void main()
{
Curl c;
}
----
dmd test1.d test2.d //OK
dmd test1.d -c
dmd test2.d test1.o //FAIL
|
September 09, 2012 Re: D and SCons | ||||
---|---|---|---|---|
| ||||
Posted in reply to Johannes Pfau | Johannes Pfau:
> Putting linker flags into source files is just not a good idea:
Thank you for the explanation. Then maybe we should deprecate pragma(lib).
Bye,
bearophile
|
September 09, 2012 Re: D and SCons | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | On Sunday, 9 September 2012 at 14:26:48 UTC, bearophile wrote:
> Thank you for the explanation. Then maybe we should deprecate pragma(lib).
If it doesn't work, there's no difference between having it and not - you have to do it yourself anyway. So deprecation accomplishes nothing except breaking it for the people who *do* use it.
At least the pragma could be printed out to the user (treat it like pragma(msg) where lib isn't supported?) or read by some other tool even if the compiler doesn't use it.
|
September 09, 2012 Re: D and SCons | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | On 09/09/2012 07:27 AM, bearophile wrote: > Johannes Pfau: > >> Putting linker flags into source files is just not a good idea: > > Thank you for the explanation. Then maybe we should deprecate pragma(lib). > > Bye, > bearophile Similar to pragmas in C and C++, D pragmas allow language extensions: "Pragmas are a way to pass special information to the compiler and to add vendor specific extensions to D." http://dlang.org/pragma.html Ali |
September 09, 2012 Re: D and SCons | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ali Çehreli Attachments:
| On Sun, 2012-09-09 at 08:05 -0700, Ali Çehreli wrote: […] > Similar to pragmas in C and C++, D pragmas allow language extensions: "Pragmas are a way to pass special information to the compiler and to add vendor specific extensions to D." > > http://dlang.org/pragma.html This states that: pragma(lib, "blah.lib") is a part of the D language and not just a DMD extension. This means that the code is platform specific (due to extensions embedded in code) as well as predicating that the toolchain will deal with explicit toolchain information in the source code. Personally I would say that putting dependencies such as this in the source code is anathema, it is the role of the build framework to deal with this. That way you can deal with the platform specific extensions and naming as well as toolchain issues. These dependencies are link time not source time ones. So I am with Johannes, pragma(lib,…) is "evil" and should be removed. -- Russel. ============================================================================= Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder@ekiga.net 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel@winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder |
September 09, 2012 Re: D and SCons | ||||
---|---|---|---|---|
| ||||
Posted in reply to Russel Winder | On 09/09/2012 08:48 AM, Russel Winder wrote: > On Sun, 2012-09-09 at 08:05 -0700, Ali Çehreli wrote: >> >> http://dlang.org/pragma.html > > This states that: > > pragma(lib, "blah.lib") > > is a part of the D language and not just a DMD extension. I hadn't read that far. :*) > Personally I would say that putting dependencies such as this in the > source code is anathema, it is the role of the build framework to deal > with this. Agreed. Ali |
September 09, 2012 Re: D and SCons [ was Re: bigint <-> python long ] | ||||
---|---|---|---|---|
| ||||
Posted in reply to Johannes Pfau | On 9/9/2012 1:15 AM, Johannes Pfau wrote:
> Am Sat, 08 Sep 2012 16:25:49 +0100
> schrieb Russel Winder <russel@winder.org.uk>:
>
>> On Sat, 2012-09-08 at 07:20 -0700, Ellery Newcomer wrote: […]
>>> Okay, here: https://bitbucket.org/ariovistus/deimos-elfutils/overview
>>>
>>> I have some code with a working makefile and a nonworking SConstruct file.
>>>
>>> I believe the issue is the header files have pragma(lib, X) in them, and a single call to dmd links the appropriate lib in, but scons' link step loses that information.
>>>
>>> Do you have any intention of supporting pragma(lib) in scons?
>>
>> If that is valid Dv2 and SCons doesn't deal with it then the SCons D tools are broken and need fixing.
>>
>> Is there a tiny project replicating this that I can turn into a unit/system test. The red so caused will necessitate action :-)
>>
>
> Please note that pragma(lib) is an evil feature. For example it will
> never work in gdc.
>
It's not impossible and never is rather defeatist. Using the frontend as is and grabing the json output, part of which includes the pragmas, would be easy. Then invoking gdc with the appropriate options to get the library linked in. rdmd is a good example of this sort of process.
|
Copyright © 1999-2021 by the D Language Foundation