DMD and 64-bit

Jonathan M Davis jmdavisProg at gmx.com
Sat Feb 19 18:49:48 PST 2011


On Saturday 19 February 2011 18:27:17 Daniel Gibson wrote:
> Am 20.02.2011 03:22, schrieb Jonathan M Davis:
> > On Saturday 19 February 2011 16:21:05 Nick Sabalausky wrote:
> >> "Jonathan M Davis"<jmdavisProg at gmx.com>  wrote in message
> >> news:mailman.1787.1298108224.4748.digitalmars-d at puremagic.com...
> >> 
> >>> On Saturday 19 February 2011 01:12:25 Russel Winder wrote:
> >>>> Am I correct in assuming that DMD generates 32-bit by default and that
> >>>> for 64-bit you have to give the -m64 option?
> >>>> 
> >>>> Is the eventual plan to use the natural word length of the platform as
> >>>> the default, i.e. 32-bit on 32-bit and 64-bit on 64-bit, with the
> >>>> option to force something different using the -m option à la GCC?
> >>> 
> >>> 32 bit is the default for now. I don't know what Walter intends to do
> >>> in the
> >>> long run. If it were like gcc, then the default platform would be the
> >>> platform
> >>> which the compiler is built for (which is exactly what it's doing right
> >>> now),
> >>> but as far as I know, Walter has no plans to port dmd to x86_64.
> >>> 
> >>> So, for now 32 bit is the default. It may or may not change later to be
> >>> the
> >>> platform that you're building on. Ideally though, it would be like gcc
> >>> and we'd
> >>> actually get a 64 bit version of dmd at some point.
> >> 
> >> I don't mean this as "anti-64bit" trolling, just a genuine question, but
> >> what would be the point of a 64-bit build of DMD? (Note: I'm talking
> >> about host, not target). Just to compile projects that have (on the
> >> order of) gigabytes of source?
> > 
> > 1. Pure 64-bit systems don't run 32-bit programs unless they're
> > statically linked. You can't currently use dmd on a pure 64-bit system.
> > You either have to have a multilib system (which I'd argue you really
> > should be doing anyway, but it can be annoying) or you have to have a
> > chrooted 32-bit environment to run it in (yuck). And even if you _can_
> > have a multilib system, it's still nice to have as many programs
> > natively 64-bit as possible - especially since it reduces the number of
> > stray 32-bit libraries that you have to have installed.
> > 
> > 2. dmd uses a lot of memory. It's trivial to write a program which causes
> > dmd to run out of memory - especially when using a lot of templates or
> > CTFE. Now, a good chunk of that is caused by dmd bugs and not an
> > intrinsic need for more memory, but it could still be very useful to
> > have dmd be able to go beyond the 32-bit memory barrier.
> 
> This would however promote the development of programs that can be
> compiled on (for?) 64bit only. Not sure if this is desirable, especially
> as long as there's only 64bit support on Linux but not Windows/OSX (What
> about FreeBSD? Is it supported yet? Is it much different from Linux in
> this regard?)

Is there much difference between making it so that you can have programs which 
can only be compiled on a 64-bit platform and programs which can only be run on 
a 64-bit platform? One of the big reasons that people want 64-bit support is 
precisely so that they can run programs which _can't_ run within the memory 
limits that 32-bit platforms have. The only difference here would be that then 
you'd have programs which couldn't be compiled on a 32-bit system. And 
particularly once CTFE is to the point that it can do all of SafeD (as is the 
eventual goal), then _of course_ you're going to get into situations where a 64-
bit program won't compile in 32-bit land.

Now, given the fact that dmd is so poor with memory, having a 64-bit version at 
this point would make it too easy to write a program which is _intended_ to work 
on both 32- bit and 64-bit systems only compilable on 64-bit systems, so that 
would be bad, but once dmd's memory problems have been solved, that wouldn't be 
an issue, and I would hope that fixing dmd's memory problems would be a higher 
priority than getting a dmd 64-bit executable.

As for the state of FreeBSD, I don't know. FreeBSD isn't exactly well-tested in 
general, so even if it's _supposed_ to work, it may not. And there isn't 
currently an actual FreeBSD release of dmd, so I have no idea what it's state 
is. It may or may not be supposed to work with 64-bit right now. Walter does 
have some interest in FreeBSD, but when very few people around here use it and 
we have no autotester for FreeBSD, it makes it kind of hard to test.

- Jonathan M Davis


More information about the Digitalmars-d mailing list