Surprise using DMD as replacement C compiler

Lance Bachmeier no at spam.net
Thu Feb 29 21:27:13 UTC 2024


On Thursday, 29 February 2024 at 20:58:22 UTC, Carl Sturtivant 
wrote:
> On Thursday, 29 February 2024 at 20:40:34 UTC, Richard (Rikki) 
> Andrew Cattermole wrote:
>> Looks like we don't have a dmd specific CC variable.
>>
>> https://github.com/dlang/dmd/blob/03f149760f53926d1c411d646f87894569fb1948/compiler/src/dmd/link.d#L480
>>
>> ```sh
>> DMD_CC=$CC
>> CC=dmd
>> ```
>
> I wanted CC=dmd in the build because it's now a C compiler, and 
> that's what I am using it for. And it's handy when replacing a 
> compiler for an existing C project.
>
> I just didn't expect dmd to confuse itself with its paired C 
> compiler. Only a tiny change needed to fix this, as it happens 
> on exactly one occasion, when CC=dmd and then dmd should ignore 
> CC. That way there's no effect on the rest of the world.
>
> The issue of whether to have a DMD_CC can then be regarded as a 
> separate matter.
>
> I submitted a precise bug report.
> https://issues.dlang.org/show_bug.cgi?id=24424

I think Rikki is suggesting replacing

```
const(char)* cc = getenv("CC");
```

with

```
const(char)* cc = getenv("DMD_CC");
if (!cc) {
   const(char)* cc = getenv("CC");
}
```

or something like that. Then you'd set `DMD_CC` to whatever `cc` 
should be used inside DMD.


More information about the Digitalmars-d mailing list