www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - rdmd

reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
I just changed rdmd to not use popen() anymore, so it should work on 
Windows. I can't get to compile it with wine due to some toolchain 
issues with the upcoming dmd 2.031 that Walter is looking into.

If somebody could please try to compile and run it on Windows and let me 
know how it works, I'd be grateful.

http://dsource.org/projects/phobos/browser/trunk/tools/rdmd.d?format=txt


Thanks in advance,

Andrei
Jul 05 2009
parent reply "Adam D. Ruppe" <destructionator gmail.com> writes:
Forgive me for being a bit chatty in this message. I'm typing it up
as I try the program.



I got a bunch of optlink errors when running rdmd on my Vista laptop.

rdmd itself compiled perfectly. The file I tried to compile was a import
std.stdin; hello world program. Nothing special. Compiling it with
dmd hello.d works as expected.

Anyway, here's the output:


==============

c:\Users\me\Desktop>rdmd --chatty hello.d
chdir "." && dmd  -v -o- "hello.d" >hello.d.deps
dmd  -of"C:\Users\me\AppData\Local\Temp/.rdmd\hello.d.ED85692521C0A87990BB1B70BE
E0046C" -od"C:\Users\me\AppData\Local\Temp/.rdmd\rdmd-hello.d-ED85692521C0A87990
BB1B70BEE0046C" "hello.d"
OPTLINK (R) for Win32  Release 8.00.1
Copyright (C) Digital Mars 1989-2004  All rights reserved.
OPTLINK : Warning 9: Unknown Option : .RDMD\RDMD
OPTLINK : Warning 9: Unknown Option : HELLO.D
OPTLINK : Warning 9: Unknown Option : ED85692521C0A87990BB1B70BEE0046C\HELLO.D
OPTLINK : Warning 9: Unknown Option : .RDMD\HELLO.D.ED85692521C0A87990BB1B70BEE0
046C
user32.def(0) : Error 2: File Not Found user32.def
--- errorlevel 1

c:\Users\me\Desktop>dmd hello.d

c:\Users\me\Desktop>hello
Hello, world!

===========================


And the fix seems trivial enough. Notice how the errors start when it sees
a / in the path.

On line 195 and 196 of rdmd.d, change the /'s to \'s.


Not out of the woods yet!

=============


c:\Users\me\Desktop>rdmd --chatty hello.d
chdir "." && dmd  -v -o- "hello.d" >hello.d.deps
dmd  -of"C:\Users\me\AppData\Local\Temp\.rdmd\hello.d.ED85692521C0A87990BB1B70BE
E0046C" -od"C:\Users\me\AppData\Local\Temp\.rdmd\rdmd-hello.d-ED85692521C0A87990
BB1B70BEE0046C" "hello.d"
OPTLINK (R) for Win32  Release 8.00.1
Copyright (C) Digital Mars 1989-2004  All rights reserved.
C:\Users\me\AppData\Local\Temp\.rdmd\rdmd-hello.d-ED85692521C0A87990BB1B70BEE004
6C\hello.d
 Error 2: File Not Found C:\Users\me\AppData\Local\Temp\.rdmd\rdmd-hello.d-ED856
92521C0A87990BB1B70BEE0046C\hello.d
--- errorlevel 1

===========


OPTLINK can't find the object file. Looking at the temp folder, that's
because it isn't there under that name - it is hello.d.obj instead.

I tried running rdmd hello (without the .d) and got the same result.

But copying the file to the different name works:

cd tmp/rdmd/whatever
copy hello.d.obj hello.d
popd
rdmd hello.d

Hello world!

So it is a filename woe.

... though clearing the files and doing the same thing again gives me this:

c:\Users\me\Desktop>rdmd --chatty hello.d
chdir "." && dmd  -v -o- "hello.d" >hello.d.deps
dmd  -of"C:\Users\me\AppData\Local\Temp\.rdmd\hello.d.ED85692521C0A87990BB1B70BE
E0046C" -od"C:\Users\me\AppData\Local\Temp\.rdmd\rdmd-hello.d-ED85692521C0A87990
BB1B70BEE0046C" "hello.d"
std.file.FileException: In std\file.d(689), data file C:\Users\me\AppData\Local\
Temp\.rdmd\rdmd-hello.d-ED85692521C0A87990BB1B70BEE0046C: The operation complete
d successfully.

That might be a phobos bug.


Then running the program once more executes the program:


c:\Users\me\Desktop>rdmd --chatty hello.d
chdir "." && dmd  -v -o- "hello.d" >hello.d.deps

c:\Users\me\Desktop>Hello, world!


(A bit strange that it puts out the prompt before the program's output,
 but everything works.)



Anyway, exception on success is weird, but back to the first problem:
hello.d - file not found.

Looking at the source to try and figure this out. Line 281 (function d2obj)
has a potential bug: it assumes the object file is .o.
On Windows, it will be .obj.



I wonder if dmd is sending the wrong filename to link? Running

rdmd -v --chatty hello

Snipping most the output......

======

c:\dm\bin\link.exe "C:\Users\me\AppData\Local\Temp\.rdmd\rdmd-hello.d-ED85692521
C0A87990BB1B70BEE0046C\hello.d","C:\Users\me\AppData\Local\Temp\.rdmd\hello.d.ED
85692521C0A87990BB1B70BEE0046C",,user32+kernel32/noi;

==========



DMD might be making the mistake here. It takes hello.d on its command line,
outputs hello.d.obj, then doesn't inform link of the new .obj extension.


Aside from the little things noted above, rdmd looks like it should be
correct. Is dmd's behavior here expected, or is that a bug?


Little things I'm noticing:

rdmd --man doesn't work on my box either. (no web browser is in my PATH, so
partially my fault, but I don't think one is in the path on a normal Windows
install, so something else should probably be done for this.)

And the file it outputs if I fix the object file manually doesn't have
the .exe extension. It works when I run it from the command line, but
without the .exe, the Windows gui will get lost.





I've gotta run and take care of some other stuff. I'll attack it again
next time I'm free.



-- 
Adam D. Ruppe
http://arsdnet.net
Jul 05 2009
parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
Adam D. Ruppe wrote:
[great feedback]
 I've gotta run and take care of some other stuff. I'll attack it again
 next time I'm free.
Thanks! I committed again minding all of your comments but I guess I won't be able to port the program a l'aveugle. I'd appreciate if you (and/or others) would give it a second shot. Andrei
Jul 05 2009
next sibling parent reply "Adam D. Ruppe" <destructionator gmail.com> writes:
Almost there, but not quite. Once again, it compiles without error, but
we have errors.

A quick note: you can leave auto off if you write const? like

const variable = whatever;

Cool!

On topic now.

First problem is the path separator again:

=======

c:\Users\me\Desktop>rdmd --chatty hello.d
chdir "." && dmd  -v -o- "hello.d" >hello.d.deps
dmd  -of"C:\Users\me\AppData\Local\Temp;.rdmd\hello.d.ED85692521C0A87990BB1B70BE
E0046C.exe" -od"C:\Users\me\AppData\Local\Temp;.rdmd\rdmd-hello.d-ED85692521C0A8
7990BB1B70BEE0046C" "hello.d"
OPTLINK (R) for Win32  Release 8.00.1
Copyright (C) Digital Mars 1989-2004  All rights reserved.
C:\Users\me\AppData\Local\Temp.obj
 Error 2: File Not Found C:\Users\me\AppData\Local\Temp.obj
--- errorlevel 1

=======

Notice how it is a semicolon. Changing pathsep to just sep on line 207 fixes
this. (Perhaps the names in std.path should be changed. pathsep and sep are
a bit too similar. pathsep is the character to separate multiple paths, 
like in /bin:/usr/bin. sep is the directory separator.)

Fixing that brings us back to almost the same problem as before.. but it
is opposite now:

whatever: file not found

Coming out of link.exe. The file is created with the .obj extension, but
now link is looking for the file without it :S


(I wish Windows would stop bugging me about rebooting for updates. I'll
 do it when I get around to it! Bah!)

=====

Sidetrack:

That weird exception thrown about the operation completing successfully
is a bug in Phobos's rmdir() function. The reason, from MSDN RemoveDirectory():

Return Value
If the function succeeds, the return value is nonzero. If the function fails,
the return value is zero.



Yeah.... silly Microsoft. (Now I understand why this is so common on
The Daily WTF!)

Anyway, to fix it, I just stuck a ! before the
functions in std.file lines 689 and 690. There might be other little
problems like that. Next weekend or something I'll see about going through
the Windows calls and making sure they are all correct.


===========

OK, back to the disappearing .obj. I don't understand why it's doing that...

Let me copy/paste the output again:

c:\Users\me\Desktop>rdmd -v --chatty hello.d
chdir "." && dmd -v -v -o- "hello.d" >hello.d.deps
dmd -v -of"C:\Users\me\AppData\Local\Temp\.rdmd\hello.d.ED85692521C0A87990BB1B70
BEE0046C.exe" -od"C:\Users\me\AppData\Local\Temp\.rdmd\rdmd-hello.d-ED85692521C0
A87990BB1B70BEE0046C" "hello.d"
*snip*
c:\dm\bin\link.exe "C:\Users\me\AppData\Local\Temp\.rdmd\rdmd-hello.d-ED85692521
C0A87990BB1B70BEE0046C\hello.d.ED85692521C0A87990BB1B70BEE0046C","C:\Users\me\Ap
pData\Local\Temp\.rdmd\hello.d.ED85692521C0A87990BB1B70BEE0046C.exe",,user32+ker
nel32/noi;
OPTLINK (R) for Win32  Release 8.00.1
Copyright (C) Digital Mars 1989-2004  All rights reserved.
C:\Users\me\AppData\Local\Temp\.rdmd\rdmd-hello.d-ED85692521C0A87990BB1B70BEE004
6C\hello.d.ED85692521C0A87990BB1B70BEE0046C
 Error 2: File Not Found C:\Users\me\AppData\Local\Temp\.rdmd\rdmd-hello.d-ED856
92521C0A87990BB1B70BEE0046C\hello.d.ED85692521C0A87990BB1B70BEE0046C
--- errorlevel 1




Do you have any idea what's going on there?



=============


Finally, on a tangential note, I'm part owner of a young VPS company.
If I can talk the other owners into letting you have access to a Windows
Server 2003 machine that you can log into remotely and use for some
D testing, would that be useful to you?

Windows remote desktop performs pretty well, and with the Linux rdesktop
program, you can integrate your clipboard and files from your Linux
box. (That's actually how I use my Vista computer when I'm home. I just
rdesktop into it from Linux, and have access to both systems.)

Wine is great, but for some of these cases, having a real Windows machine
is a real help. 2k3 is very similar to XP, so it would make a decent testbed
for D development.

If you're interested, I'll see if I can get it set up tomorrow and email
you privately with the access details.


-- 
Adam D. Ruppe
http://arsdnet.net
Jul 05 2009
parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
Adam D. Ruppe wrote:
 c:\Users\me\Desktop>rdmd --chatty hello.d
 chdir "." && dmd  -v -o- "hello.d" >hello.d.deps
 dmd  -of"C:\Users\me\AppData\Local\Temp;.rdmd\hello.d.ED85692521C0A87990BB1B70BE
 E0046C.exe" -od"C:\Users\me\AppData\Local\Temp;.rdmd\rdmd-hello.d-ED85692521C0A8
 7990BB1B70BEE0046C" "hello.d"
 OPTLINK (R) for Win32  Release 8.00.1
 Copyright (C) Digital Mars 1989-2004  All rights reserved.
 C:\Users\me\AppData\Local\Temp.obj
  Error 2: File Not Found C:\Users\me\AppData\Local\Temp.obj
 --- errorlevel 1
 
 =======
 
 Notice how it is a semicolon. Changing pathsep to just sep on line 207 fixes
 this. (Perhaps the names in std.path should be changed. pathsep and sep are
 a bit too similar. pathsep is the character to separate multiple paths, 
 like in /bin:/usr/bin. sep is the directory separator.)
Damn. Sorry, I could have detected that on my side too.
 Fixing that brings us back to almost the same problem as before.. but it
 is opposite now:
 
 whatever: file not found
 
 Coming out of link.exe. The file is created with the .obj extension, but
 now link is looking for the file without it :S
That's odd.
 (I wish Windows would stop bugging me about rebooting for updates. I'll
  do it when I get around to it! Bah!)
 =====
 
 Sidetrack:
 
 That weird exception thrown about the operation completing successfully
 is a bug in Phobos's rmdir() function. The reason, from MSDN RemoveDirectory():
 
 Return Value
 If the function succeeds, the return value is nonzero. If the function fails,
the return value is zero.

 Yeah.... silly Microsoft. (Now I understand why this is so common on
 The Daily WTF!)
 
 Anyway, to fix it, I just stuck a ! before the
 functions in std.file lines 689 and 690. There might be other little
 problems like that. Next weekend or something I'll see about going through
 the Windows calls and making sure they are all correct.
Fixed (not in the coming release though, the toothpaste is out of the tube already)... thanks, and thanks in advance for any other bugs you might find.
 ===========
 
 OK, back to the disappearing .obj. I don't understand why it's doing that...
 
 Let me copy/paste the output again:
 
 c:\Users\me\Desktop>rdmd -v --chatty hello.d
 chdir "." && dmd -v -v -o- "hello.d" >hello.d.deps
 dmd -v -of"C:\Users\me\AppData\Local\Temp\.rdmd\hello.d.ED85692521C0A87990BB1B70
 BEE0046C.exe" -od"C:\Users\me\AppData\Local\Temp\.rdmd\rdmd-hello.d-ED85692521C0
 A87990BB1B70BEE0046C" "hello.d"
 *snip*
 c:\dm\bin\link.exe "C:\Users\me\AppData\Local\Temp\.rdmd\rdmd-hello.d-ED85692521
 C0A87990BB1B70BEE0046C\hello.d.ED85692521C0A87990BB1B70BEE0046C","C:\Users\me\Ap
 pData\Local\Temp\.rdmd\hello.d.ED85692521C0A87990BB1B70BEE0046C.exe",,user32+ker
 nel32/noi;
 OPTLINK (R) for Win32  Release 8.00.1
 Copyright (C) Digital Mars 1989-2004  All rights reserved.
 C:\Users\me\AppData\Local\Temp\.rdmd\rdmd-hello.d-ED85692521C0A87990BB1B70BEE004
 6C\hello.d.ED85692521C0A87990BB1B70BEE0046C
  Error 2: File Not Found
C:\Users\me\AppData\Local\Temp\.rdmd\rdmd-hello.d-ED856
 92521C0A87990BB1B70BEE0046C\hello.d.ED85692521C0A87990BB1B70BEE0046C
 --- errorlevel 1
 
 
 
 
 Do you have any idea what's going on there?
I suspect link.exe has trouble with that long path including the oddly named \.rdmd\ in there. Could you please could paste the dmd invocation command in your prompt and then progressively simplifying the path names until you get something that works?
 =============
 
 
 Finally, on a tangential note, I'm part owner of a young VPS company.
 If I can talk the other owners into letting you have access to a Windows
 Server 2003 machine that you can log into remotely and use for some
 D testing, would that be useful to you?

 Windows remote desktop performs pretty well, and with the Linux rdesktop
 program, you can integrate your clipboard and files from your Linux
 box. (That's actually how I use my Vista computer when I'm home. I just
 rdesktop into it from Linux, and have access to both systems.)
 
 Wine is great, but for some of these cases, having a real Windows machine
 is a real help. 2k3 is very similar to XP, so it would make a decent testbed
 for D development.
 
 If you're interested, I'll see if I can get it set up tomorrow and email
 you privately with the access details.
I think that would be absolutely great, but only if it's absolutely no hassle for you to set up. By the way, does Windows Server 2003 offer some command-line access (a la ssh) in addition to rdesktop (which is indeed very nice)? Command-line access would allow me to automate builds and tests. Thanks much! Andrei
Jul 05 2009
parent reply "Adam D. Ruppe" <destructionator gmail.com> writes:
On Sun, Jul 05, 2009 at 08:40:01PM -0500, Andrei Alexandrescu wrote:
 I suspect link.exe has trouble with that long path including the oddly 
 named \.rdmd\ in there. Could you please could paste the dmd invocation 
 command in your prompt and then progressively simplifying the path names 
 until you get something that works?
Yeah, that's the area. I think I got it. link apparently doesn't like the dots in the output filename. dmd -of"C:\Users\me\AppData\Local\Temp\.rdmd\hello.d.ED85692521C0A8799 BB1B70BEE0046C.exe" -od"C:\Users\me\AppData\Local\Temp\.rdmd\rdmd-hello.d-ED85692521C0A 7990BB1B70BEE0046C" "hello.d" This fails with the weird error. dmd -of"C:\Users\me\AppData\Local\Temp\.rdmd\hello-d-ED85692521C0A8799 BB1B70BEE0046C.exe" -od"C:\Users\me\AppData\Local\Temp\.rdmd\rdmd-hello.d-ED85692521C0A 7990BB1B70BEE0046C" "hello.d" This works! The dot in the .rdmd is ok, but not the ones in the actual filename. Simple fix for this: rdmd.d line 160 and 161 can be changed to: exe = join(myOwnTmpDir, std.string.replace(root, ".", "-")) ~ '-' ~ hash(root, compilerFlags); And then it works. Let me try it with a slightly less trivial program. Uh oh. Actually, no... that's a bug in my program. But it didn't give an error message. In getDependencies(), if depsExitCode !=0, it should probably print some kind of message explaining why it is exiting. (In my case, it was a typo in the program causing a compile error.) The last few lines of dmd's output would probably be a good choice. But then, I fix my stupid bug, and it works! Yay, I think we did it.
 I think that would be absolutely great, but only if it's absolutely no 
 hassle for you to set up. 
None at all. I'll email you tomorrow night with the info.
 By the way, does Windows Server 2003 offer 
 some command-line access (a la ssh) in addition to rdesktop (which is 
 indeed very nice)? Command-line access would allow me to automate builds 
 and tests.
Yes. Windows has a telnet server built in that I can turn on and there is an OpenSSH port I can set up - I did this on my Vista computer and it works pretty well. It is kinda weird on the vista box actually, since I also installed bash and other gnu apps on it. It is a bit buggy, but feels a lot like unix, while still running Windows. Take a look at this copy/pasta to get the idea: ========== me arsd:~$ ssh 192.168.1.5 me 192.168.1.5's password: Welcome to the SUA utilities. DISPLAY=vista-laptop:10.0 me vista-laptop:~$ cmd Microsoft Windows [Version 6.0.6001] Copyright (c) 2006 Microsoft Corporation. All rights reserved. C:\Users\me>dir \dm\src dir \dm\src Volume in drive C is WinVista Volume Serial Number is F279-BA30 Directory of C:\dm\src 06/25/2009 04:59 PM <DIR> . 06/25/2009 04:59 PM <DIR> .. 06/25/2009 05:38 PM <DIR> dmd 07/05/2009 07:05 PM <DIR> druntime 07/05/2009 07:06 PM <DIR> phobos 0 File(s) 0 bytes 5 Dir(s) 31,099,404,288 bytes free C:\Users\me> =========== Pretty fun stuff. This same functionality will basically work on 2k3 too. -- Adam D. Ruppe http://arsdnet.net
Jul 05 2009
parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
Adam D. Ruppe wrote:
 On Sun, Jul 05, 2009 at 08:40:01PM -0500, Andrei Alexandrescu wrote:
 I suspect link.exe has trouble with that long path including the oddly 
 named \.rdmd\ in there. Could you please could paste the dmd invocation 
 command in your prompt and then progressively simplifying the path names 
 until you get something that works?
Yeah, that's the area. I think I got it. link apparently doesn't like the dots in the output filename. dmd -of"C:\Users\me\AppData\Local\Temp\.rdmd\hello.d.ED85692521C0A8799 BB1B70BEE0046C.exe" -od"C:\Users\me\AppData\Local\Temp\.rdmd\rdmd-hello.d-ED85692521C0A 7990BB1B70BEE0046C" "hello.d" This fails with the weird error. dmd -of"C:\Users\me\AppData\Local\Temp\.rdmd\hello-d-ED85692521C0A8799 BB1B70BEE0046C.exe" -od"C:\Users\me\AppData\Local\Temp\.rdmd\rdmd-hello.d-ED85692521C0A 7990BB1B70BEE0046C" "hello.d" This works! The dot in the .rdmd is ok, but not the ones in the actual filename. Simple fix for this: rdmd.d line 160 and 161 can be changed to: exe = join(myOwnTmpDir, std.string.replace(root, ".", "-")) ~ '-' ~ hash(root, compilerFlags); And then it works.
Great, incorporated your fix and checked it in.
 Let me try it with a slightly less trivial program. Uh oh. Actually, no...
 that's a bug in my program. But it didn't give an error message.
 
 In getDependencies(), if depsExitCode !=0, it should probably print some
 kind of message explaining why it is exiting. (In my case, it was a typo
 in the program causing a compile error.) The last few lines of dmd's
 output would probably be a good choice.
Oh, indeed. In fact I'll print the entire file, at least for now: if (depsExitCode) { if (exists(depsFilename)) { stderr.writeln(readText(depsFilename)); } exit(depsExitCode); }
 But then, I fix my stupid bug, and it works!
 
 
 Yay, I think we did it.
Awesome, thanks. I credited you in rdmd.d.
 I think that would be absolutely great, but only if it's absolutely no 
 hassle for you to set up. 
None at all. I'll email you tomorrow night with the info.
 By the way, does Windows Server 2003 offer 
 some command-line access (a la ssh) in addition to rdesktop (which is 
 indeed very nice)? Command-line access would allow me to automate builds 
 and tests.
Yes. Windows has a telnet server built in that I can turn on
[snip]
 Pretty fun stuff. This same functionality will basically work on 2k3 too.
Fun indeed. Thank you. Andrei
Jul 05 2009
parent "Adam D. Ruppe" <destructionator gmail.com> writes:
On Sun, Jul 05, 2009 at 10:21:56PM -0500, Andrei Alexandrescu wrote:
 Oh, indeed. In fact I'll print the entire file, at least for now:
Nice, the new D release read my mind: Bugzilla 3080: dmd should output compilation errors to stderr, not stdout That should solve the program naturally, assuming all works well. stdout can be redirected, leaving stderr to still print the messages.
 Awesome, thanks. I credited you in rdmd.d.
Thanks. -- Adam D. Ruppe http://arsdnet.net
Jul 06 2009
prev sibling parent reply "Adam D. Ruppe" <destructionator gmail.com> writes:
On Sun, Jul 05, 2009 at 07:46:27PM -0400, Adam D. Ruppe wrote:
 Anyway, to fix it, I just stuck a ! before the
 functions in std.file lines 689 and 690. 
I was just looking at this again, and this is NOT the right way to fix it. In fact, recompiling everything cleanly with the new version of dmd works correctly. What phobos does in dmd 2.031 is the *right* thing. If you committed my change to the phobos repository, please revert it. I must have messed up something awfully yesterday to get what I saw. Sorry about that. -- Adam D. Ruppe http://arsdnet.net
Jul 06 2009
parent Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
Adam D. Ruppe wrote:
 On Sun, Jul 05, 2009 at 07:46:27PM -0400, Adam D. Ruppe wrote:
 Anyway, to fix it, I just stuck a ! before the
 functions in std.file lines 689 and 690. 
I was just looking at this again, and this is NOT the right way to fix it. In fact, recompiling everything cleanly with the new version of dmd works correctly. What phobos does in dmd 2.031 is the *right* thing. If you committed my change to the phobos repository, please revert it. I must have messed up something awfully yesterday to get what I saw. Sorry about that.
Got it, thanks. FYI 2.031 does not include the wrong change. Andrei
Jul 06 2009