Thread overview
gdc --version doesn't indicate which D front-end version it's compatible with
January 28

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).

January 28

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).

Just seen https://forum.dlang.org/thread/nuphsvwkdlygdcxaihwf@forum.dlang.org about D 2.098 being in GCC, still can't tell if that's what I have based on the output though.

January 28
On Friday, 28 January 2022 at 17:42:25 UTC, singingbush wrote:
> 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).

It is more complicated than that because gdc has a bunch of backported things from newer versions too.

You might be best off just trying it and seeing if your code works.
January 28

On Friday, 28 January 2022 at 17:45:32 UTC, singingbush wrote:

> >

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).

This would be indeed nice. But so far we have to compile and run the following code:

import std.stdio, std.compiler;

void main()
{
  writeln(version_major, ".", version_minor);
}

It's ironic that I have exactly the opposite problem. I need to check for the backend version from inside of the running program, and this isn't easy. I resorted to using this hack:

// GDC11 was the first version to start supporting getTargetInfo traits
bool detect_gdc11()
{
  version(GNU) { return __traits(compiles, __traits(getTargetInfo, "cppStd")); }
  else return false;
}
>

Just seen https://forum.dlang.org/thread/nuphsvwkdlygdcxaihwf@forum.dlang.org about D 2.098 being in GCC, still can't tell if that's what I have based on the output though.

It landed in the git repository and is going to be released as part of GDC 12.

January 28

Seems I cannot use gdc currently. It turns out that gdc-11.2.1 (which is the one in Fedora 35 repo) still has D frontend at 2.076 and I have multiple dependencies that cannot compile with that version. Hopefully when GDC 12 lands projects will start testing against it in their CI builds.

January 30

On Friday, 28 January 2022 at 17:42:25 UTC, singingbush wrote:

>

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).

It might be a silly question: If the compiler includes old version Dlang. So how about compiling with new version of Phobos source files. Will it compile take too long, huh?

One more question but it will be irrelevant: If we leave DMD out of the question; other compilers throwing an error when compiling with "-version=test1" etc. I guess only DMD supports it?

Thanks...

January 30

On Sunday, 30 January 2022 at 17:41:21 UTC, Salih Dincer wrote:

>

On Friday, 28 January 2022 at 17:42:25 UTC, singingbush wrote:

>

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).

It might be a silly question: If the compiler includes old version Dlang. So how about compiling with new version of Phobos source files. Will it compile take too long, huh?

Phobos source files are included in the GDC source tree. Compiling GDC (actually GCC with C, C++, Objective C, Fortran, D and a bunch of other bells and whistles) takes more than one hour on my computer.

$ gdc-12.0.1 --version
gdc-12.0.1 (Gentoo 12.0.1, commit d1182631ee73f3c7efeb5e70e6caa2da064df984) 12.0.1 20220130 (experimental)
Copyright (C) 2022 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.

Just as the message says, it's an experimental build from git. Various bugs may be expected in both D frontend and GCC backend. But it's good enough as a preview of the new features.

I doubt that compiling the newest Phobos with the old GDC 11 is going to work smoothly. If this was the case, then newer Phobos would have been already bundled with GDC 11.

>

One more question but it will be irrelevant: If we leave DMD out of the question; other compilers throwing an error when compiling with "-version=test1" etc. I guess only DMD supports it?

It's "-fversion=test1" for GDC.

February 22

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:

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;