dmd: Module X conflicts with itself (Was: Re: RDMD on Windows)

Nick Sabalausky a at a.a
Sun Aug 22 13:41:21 PDT 2010


"Andrej Mitrovic" <andrej.mitrovich at gmail.com> wrote in message 
news:i4rnl4$2396$1 at digitalmars.com...
> Well then I think I've found some new bugs in RDMD & xfbuild:
>
> Files:
> root/main.d
> root/socket.d
>
> main.d:
> module main;
>
> import alt.socket;
>
> void main()
> {
>    foo();
> }
>
> socket.d:
> module alt.socket;
>
> import std.stdio : writeln;
>
> void foo()
> {
>    writeln("test");
> }
>
> $ RDMD main.d
>
> main.d(2): Error: module socket is in file 'alt\socket.d' which cannot be 
> read
> import path[0] = .
> import path[1] = C:\DMD\dmd2\windows\bin\..\..\src\phobos
> import path[2] = C:\DMD\dmd2\windows\bin\..\..\src\druntime\import
>
>
> $ xfbuild +o=main.exe main.d socket.d
>
> main.d(4): Error: module socket is in file 'alt\socket.d' which cannot be 
> read
> import path[0] = C:\DMD\dmd2\windows\bin\..\..\src\phobos
> import path[1] = C:\DMD\dmd2\windows\bin\..\..\src\druntime\import
> Build failed: 'dmd @xfbuild.a00e00.rsp' returned 1.
>
> DSSS fails as well.
>
> But DMD works:
>
> $ dmd main.d socket.d
> $ main.exe
>> test
>

Hmm, yea that's not going to work with those tools. The whole point of those 
tools is that you can give them the file with main(), and then they'll 
figure out all the files that need to be passed to DMD. The only way they 
can realistically do that is by assuming package names are directory names 
and module names are file names.

Since your "socket.d" is in a package named "alt", but *not* in a directory 
called "alt", those tools have absolutely no way to find "socket.d". If you 
just run DMD directly, then there's no need to programmatically find 
"socket.d", since you've already said where to find it.

There's only two ways for those tools to find a file if it's in a directory 
named *differently* than the package name (or to find a file with a 
different name from the module name) without venturing into fuzzy 
guesswork-territory:

1. Search the whole filesystem (obviously ain't gonna happen, and really, 
this is fuzzy guesswork-territory anyway).

2. Have an option so you can tell it "assume that directory '{someDir}' is a 
possible location for package '{some.package}' " (Ie, kinda like "-I", but 
for packages other than just "package root"). This could be done, but 
frankly I see little, if any, use for that kind of flexibility other than 
obfuscation, so this is not likely to happen either.

What you *can* do, is put "socket.d" in a directory named "alt", and then 
put directoy "alt" **anywhere** in the filesystem you want, and then pass in 
"-I{directoryThatContaininsAlt}". *That* should work (Although that *is* 
currently broken in RDMD, which gave me some trouble the other day, but I 
filed a patch for it here: 
http://d.puremagic.com/issues/show_bug.cgi?id=4672 )




More information about the Digitalmars-d-learn mailing list