Surprise using DMD as replacement C compiler

Carl Sturtivant sturtivant at gmail.com
Thu Feb 29 22:59:21 UTC 2024


On Thursday, 29 February 2024 at 21:52:50 UTC, Richard (Rikki) 
Andrew Cattermole wrote:
>> What you're proposing would prevent infinite recursion, 
>> wouldn't it? Maybe I'm missing something. The source of the 
>> problem is grabbing the `CC` environment variable inside 
>> link.d.
>
> No.
>
> DMD_CC=dmd
>
> That'll still be recursive.

Yes, so here's a combined proposal for the underlying logic 
(pseudo-code):
```
cc = getenv("DMD_CC")

if( cc=="" || cc=="dmd" ){  // DMD_CC effectively undefined
   cc = getenv("CC")

   if( cc=="" || cc=="dmd" ) {  // CC effectively undefined as well
     cc = platform_default_compiler
   }
}
assert( cc!="dmd" )
```



More information about the Digitalmars-d mailing list