gdc --version doesn't indicate which D front-end version it's compatible with

WebFreak001 d.forum at webfreak.org
Tue Feb 22 12:45:52 UTC 2022


On Friday, 28 January 2022 at 17:42:25 UTC, singingbush wrote:
> not sure where is best placed for this but on my Fedora system 
> running `gdc --version` gives me pretty much the same output as 
> `gcc --version`
>
> GDC:
>
> ```
> $ gdc --version
> gdc (GCC) 11.2.1 20211203 (Red Hat 11.2.1-7)
> Copyright (C) 2021 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.  
> There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A 
> PARTICULAR PURPOSE.
> ```
>
> GCC:
>
> ```
> $ gcc --version
> gcc (GCC) 11.2.1 20211203 (Red Hat 11.2.1-7)
> Copyright (C) 2021 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.  
> There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A 
> PARTICULAR PURPOSE.
> ```
>
> It would be far more helpful if running `gdc --version` gave 
> some indication of the version of D it's aligned to (which was 
> 2.076 last time I checked).

If you want to do this automated you can run

     echo | gdc -xd -fsyntax-only -v -

see how code-d does it: 
https://github.com/Pure-D/code-d/blob/master/src/compilers.ts#L637

Then you can fetch from the output the GCC version, DMD-FE 
version and import paths using these regexes:

```js
const gdcVersionRegex = /^gcc version\s+v?(\d+(?:\.\d+)+)/gm;
const gdcFeVersionRegex = /^version\s+v?(\d+(?:\.\d+)+)/gm;
const gdcImportPathRegex = /^import path\s*\[\d+\]\s*=\s*(.+)/gm;
```


More information about the D.gnu mailing list