www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - DMD, Wine and MinGW

reply ketmar via Digitalmars-d <digitalmars-d puremagic.com> writes:
Hello.

it seems that current dmd.exe segfaults in Wine (at least on my
GNU/Linux x86 box, with freshly created WINEPREFIX), which forces me to
switch between windoze VM and working environment if i want to write
some win32 program (and i have to :-( ).

so i have a bunch of questions:
1. does anybody observes the same behavior with Wine?
2. does anybody tried to build dmd.exe with MinGW (this is not related
to crashes, i think, but i like to build dmd.exe with cross-compiler)?
3. does anybody thought about allowing each dmd version to create all
kind of object files on any platform, and how much is this wanted?

as for "3": i know that i need a linker too, which is not ported (and
will not be). yet i seen some attempts to rewrite optlink in D, and if
windows version of dmd will be able to generte proper COFFs (is
-ms32coff doing that already?), it will be possible to use MinGW linker
and cross-linker with it.

allowing dmd to utilize MinGW toolchain will open some possibilities
for those who either already has MinGW and don't want to use DMC, or
for those who doing cross-compiles. as dmd alread can be build with
GCC, i don't think that this will take alot of efforts.

actually, i made bare-bones "mingw.mak", and made some source fixes
here and there, and now i got "dmd.exe" compiled with MinGW
cross-compiler. it shows dmd help when i launch it with wine, but
crashes when i'm trying to compile "hello world" (the "official" dmd
crashes with it too). as i don't have windows box to check it, i don't
know if it really works.

maybe someone already messed with MinGW builds, so i can shamelessly
steal his build scripts and fixes? i can publish mine, but i don't know
if it works at all, as i wrote ealier.

i know that gdc and ldc has some windows versions, but i need dmd, so
they are out of set of choices, alas.
Jan 18 2015
next sibling parent reply "Joakim" <dlang joakim.fea.st> writes:
On Sunday, 18 January 2015 at 16:32:54 UTC, ketmar via 
Digitalmars-d wrote:
 Hello.

 it seems that current dmd.exe segfaults in Wine (at least on my
 GNU/Linux x86 box, with freshly created WINEPREFIX), which 
 forces me to
 switch between windoze VM and working environment if i want to 
 write
 some win32 program (and i have to :-( ).

 so i have a bunch of questions:
 1. does anybody observes the same behavior with Wine?
I used dmd under Wine years ago and didn't have a problem building a small utility, no recent use though.
 2. does anybody tried to build dmd.exe with MinGW (this is not 
 related
 to crashes, i think, but i like to build dmd.exe with 
 cross-compiler)?
Not me.
 3. does anybody thought about allowing each dmd version to 
 create all
 kind of object files on any platform, and how much is this 
 wanted?
Yes, Rainer had a pull that started dmd along this path by changing the command-line options, but Walter didn't want dmd to give any indication that cross-compiling was supported without the rest of the work done so he vetoed it: https://github.com/D-Programming-Language/dmd/pull/3542 I can't imagine that it's _that_ hard to go the rest of the way by turning all the current target preprocessor macros into runtime logic and filling in what few OS-specific gaps are necessary, especially for a single host/target pair. I've considered doing it but don't really have a need for it, so I held off. ddmd might make the job easier, to the extent the frontend won't rely on host headers anymore.
 as for "3": i know that i need a linker too, which is not 
 ported (and
 will not be). yet i seen some attempts to rewrite optlink in D, 
 and if
 windows version of dmd will be able to generte proper COFFs (is
 -ms32coff doing that already?), it will be possible to use 
 MinGW linker
 and cross-linker with it.
Yes, dmd generates 32-bit COFF right now and I'm sure you can find a cross-linker that will work.
 allowing dmd to utilize MinGW toolchain will open some 
 possibilities
 for those who either already has MinGW and don't want to use 
 DMC, or
 for those who doing cross-compiles. as dmd alread can be build 
 with
 GCC, i don't think that this will take alot of efforts.

 actually, i made bare-bones "mingw.mak", and made some source 
 fixes
 here and there, and now i got "dmd.exe" compiled with MinGW
 cross-compiler. it shows dmd help when i launch it with wine, 
 but
 crashes when i'm trying to compile "hello world" (the 
 "official" dmd
 crashes with it too). as i don't have windows box to check it, 
 i don't
 know if it really works.
You can install Win7 for four months without a license, whether in a VM or spare partition. I've done that before, sometimes wiping and installing on top after four months to start the timer again. ;) Maybe Win8 allows the same, or you can test on the Win10 Preview.
Jan 18 2015
parent ketmar via Digitalmars-d <digitalmars-d puremagic.com> writes:
On Sun, 18 Jan 2015 17:32:28 +0000
Joakim via Digitalmars-d <digitalmars-d puremagic.com> wrote:

 I used dmd under Wine years ago and didn't have a problem=20
 building a small utility, no recent use though.
the strange thing is that is sometimes works... once in a while it is able to build "hello.d", but most of the time it crashing. as it crashing with "-c" and even with "-c -o-", i assume that this is a subtle bug in dmd. but to debug it i first have to build it with MinGW. ;-)
 3. does anybody thought about allowing each dmd version to=20
 create all
 kind of object files on any platform, and how much is this=20
 wanted?
=20 Yes, Rainer had a pull that started dmd along this path by=20 changing the command-line options, but Walter didn't want dmd to=20 give any indication that cross-compiling was supported without=20 the rest of the work done so he vetoed it: =20 https://github.com/D-Programming-Language/dmd/pull/3542
ah, i see. this is more ambitious that what i want. ;-) i talked about merely changing the output object file formats, so one can specify if dmd will output OMF, or COFF, or...
 Yes, dmd generates 32-bit COFF right now and I'm sure you can=20
 find a cross-linker that will work.
if i made dmd itself work under Wine. ;-) actually, optlink has no problems with wine, and it's ok for me.
 You can install Win7 for four months without a license, whether=20
 in a VM or spare partition.  I've done that before, sometimes=20
 wiping and installing on top after four months to start the timer=20
 again. ;) Maybe Win8 allows the same, or you can test on the=20
 Win10 Preview.
alas, they want too much memory and HDD space. %-( for now i think that i will simply fallback to C for my needs (hate it! hate it! oh, how much i hate it now! ;-). p.s. i managed to sucessfully compile "hello world" with MinGW-built dmd.exe on my mate's windows box. there was a bug with "%lld" and "%llu" which MinGW doesn't support, but after i fixed that with macro hackery, my "hello.exe" says "hi!" to me. ;-) yet it still not working under wine. but now i'm at least sure that it works, so i can try to debug that crash.
Jan 18 2015
prev sibling next sibling parent "ketmar" <ketmar ketmar.no-ip.org> writes:
and i found what is wrong here. ah, not exactly *what* is wrong, 
but *where* it goes mad: it's "root/async.c". i don't know what 
Wine did wrong there, but it keep crashing in that threaded 
reader. and *sometimes* it works. i turned that messy thingy off, 
and voila! dmd.exe is not crashing under Wine anymore.

how that thing is supposed to work at all? ah, anyway, burn it 
with fire! let the holy cleansing flame purify it!

p.s. can we have a command line switch to turn that abomination 
off?

p.p.s. can i haz cheezburger?
Jan 18 2015
prev sibling parent "ketmar" <ketmar ketmar.no-ip.org> writes:
for those who may be interested, i put my dirty hack there: 
https://issues.dlang.org/show_bug.cgi?id=14008

feel free to not use it.
Jan 19 2015