D and SCons
Johannes Pfau
nospam at example.com
Sun Sep 9 06:51:25 PDT 2012
Am Sun, 09 Sep 2012 13:53:23 +0200
schrieb " bearophile" <bearophileHUGS at 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
More information about the Digitalmars-d-learn
mailing list