D is our last hope

Steven Schveighoffer schveiguy at gmail.com
Tue Dec 19 23:20:49 UTC 2023


On Tuesday, 19 December 2023 at 20:48:04 UTC, FeepingCreature 
wrote:
> On Tuesday, 19 December 2023 at 20:37:02 UTC, Walter Bright 
> wrote:
>> On 12/19/2023 12:07 PM, FeepingCreature wrote:
>>> figure out a way to dogfood Phobos, it's insane that the 
>>> premier project in the language refuses to use its stdlib)
>>
>> There is a good reason for that. It's very difficult to debug 
>> the compiler when the reason it is failing is a code gen bug 
>> that is breaking Phobos in some unknown way. Debugging Phobos 
>> is (unfortunately) difficult because too much of Phobos 
>> imports every other module in Phobos. (We'd like to fix that 
>> for the next iteration of Phobos.)
>>
>> It's hard to port dmd to a new platform when it relies on 
>> Phobos and Phobos is not working on the new platform, a 
>> chicken-and-egg problem.
>>
>> In order for our ease of debugging, we keep dmd's dependence 
>> on other code at a minimum.
>
> This makes little sense to me. You wouldn't *start* by making 
> DMD run on the new platform, but the port would start with a 
> cross-build from your old platform to the new platform, surely? 
> I'd want to have the testsuite and every other tool passing on 
> the new platform before I even try running DMD natively. And 
> this problem only arises when you try to run DMD natively from 
> the start, right? Or am I misunderstanding?

With some made-up version numbers:

Let's say dmd-0.2 only builds correctly with phobos-0.1, dmd-0.3 
only builds correctly with phobos-0.2, and dmd-0.4 builds 
correctly with phobos-0.3, and due to a weird bug in phobos-0.2 
it builds against it, but crashes.

This means the only *reliable* way to bootstrap dmd-0.50 is to 
first build dmd-0.1, then use it to build dmd-0.2, etc. until you 
catch up. While this might seem like a reasonable choice, it's 
also very brittle (and unnecessarily so).

Since phobos is changing every version, and we don't want to hold 
back that progress (or bug fixes), it's better to have a *subset* 
of library that we can maintain separately, and with the front 
end, and we know it only changes infrequently, and we can ensure 
it builds correctly with some large range of compilers. This 
means bootstrapping is much faster, and more reliable. I'd much 
prefer this over that.

An alternative universe where phobos is versioned separately from 
dmd might have been an answer, but we don't have that situation.

Keep in mind that gdc has the *requirement* that you can build 
the compiler with the last 3 versions. We can't break that, 
regardless of how good the dogfood is.

-Steve


More information about the Digitalmars-d mailing list