Thread overview
gdc broken by ldc-phobos-devel on Fedora
Nov 20
mipri
November 20
Howdy,

This was the case in Fedora 30, and is now the case in Fedora 31.
RPMs are available for gdc and for ldc2, but when both are
installed gdc can't compile anything as it tries to load a version
of phobos installed by ldc2 which has features gdc doesn't yet
support. For someone who's decided to just use gdc for a project,
they have the easy fix of just uninstalling ldc2, but I'd expect
that someone evaluating D as a language will be interested in
comparing the different compilers, so all the compilers will be
installed--and then only dmd and ldc will be functional.

As commands:

  dnf install gcc-gdc ldc
  echo 'void main() { import std.stdio; writeln("hello"); }' > hello.d
  gdc hello.d

This will fail due to ldc-phobos-devel's files in /usr/include/d:

/usr/include/d/core/internal/hash.d:426:16: error: basic type expected, not foreach
  426 |         static foreach (i; 0 .. T.sizeof / size_t.sizeof)
      |                ^
/usr/include/d/core/internal/hash.d:426:16: error: no identifier for declarator _error_
  426 |         static foreach (i; 0 .. T.sizeof / size_t.sizeof)
      |                ^
/usr/include/d/core/internal/traits.d:175:12: error: declaration expected, not 'foreach'
  175 |     static foreach (Ti; T)
      |            ^
/usr/include/d/core/internal/traits.d:175:26: error: no identifier for declarator T
  175 |     static foreach (Ti; T)
      |                          ^
/usr/include/d/core/internal/traits.d:175:26: error: declaration expected, not ')'
  175 |     static foreach (Ti; T)
      |                          ^
/usr/include/d/core/internal/traits.d:182:5: error: unrecognized declaration
  182 |     }
      |     ^

gdc installs its own files into path[1] but prefers /usr/include/d:

import path[0] = /usr/include/d
import path[1] = /usr/lib/gcc/x86_64-redhat-linux/9/include/d

and I haven't found a way, in gdc's manpage or in (the much less
examined) gcc documentation, to skip the first path. I'm also not
sure what a proper fix would be. Maybe the ldc rpm should be
updated to install phobos into a similarly ldc-specific directory.
Maybe a gdc update will happen soon and ldc's phobos files will be
acceptable to it.

Mainly I want to mention it here so that people can find it and not
just think that gdc is broken on Fedora, like I thought for a good
while.

November 21
Nothing much that can be done here except get the package maintainer to fix the installation paths of ldc.

The phobos/druntime sources will always differ between each compiler runtime library as there're many local changes that aren't accepted in upstream.

--
Iain

-------- Original Message --------
On Nov 20, 2019, 10:51 PM, mipri via D.gnu < d.gnu@puremagic.com> wrote:
Howdy,
This was the case in Fedora 30, and is now the case in Fedora 31.
RPMs are available for gdc and for ldc2, but when both are
installed gdc can't compile anything as it tries to load a version
of phobos installed by ldc2 which has features gdc doesn't yet
support. For someone who's decided to just use gdc for a project,
they have the easy fix of just uninstalling ldc2, but I'd expect
that someone evaluating D as a language will be interested in
comparing the different compilers, so all the compilers will be
installed--and then only dmd and ldc will be functional.
As commands:
dnf install gcc-gdc ldc
echo 'void main() { import std.stdio; writeln("hello"); }' >
hello.d
gdc hello.d
This will fail due to ldc-phobos-devel's files in /usr/include/d:
/usr/include/d/core/internal/hash.d:426:16: error: basic type
expected, not foreach
426 | static foreach (i; 0 .. T.sizeof / size_t.sizeof)
| ^
/usr/include/d/core/internal/hash.d:426:16: error: no identifier
for declarator _error_
426 | static foreach (i; 0 .. T.sizeof / size_t.sizeof)
| ^
/usr/include/d/core/internal/traits.d:175:12: error: declaration
expected, not 'foreach'
175 | static foreach (Ti; T)
| ^
/usr/include/d/core/internal/traits.d:175:26: error: no
identifier for declarator T
175 | static foreach (Ti; T)
| ^
/usr/include/d/core/internal/traits.d:175:26: error: declaration
expected, not ')'
175 | static foreach (Ti; T)
| ^
/usr/include/d/core/internal/traits.d:182:5: error: unrecognized
declaration
182 | }
| ^
gdc installs its own files into path[1] but prefers
/usr/include/d:
import path[0] = /usr/include/d
import path[1] = /usr/lib/gcc/x86_64-redhat-linux/9/include/d
and I haven't found a way, in gdc's manpage or in (the much less
examined) gcc documentation, to skip the first path. I'm also not
sure what a proper fix would be. Maybe the ldc rpm should be
updated to install phobos into a similarly ldc-specific directory.
Maybe a gdc update will happen soon and ldc's phobos files will be
acceptable to it.
Mainly I want to mention it here so that people can find it and
not
just think that gdc is broken on Fedora, like I thought for a good
while.
November 21
On Wednesday, 20 November 2019 at 21:51:58 UTC, mipri wrote:
> Howdy,
>
> This was the case in Fedora 30, and is now the case in Fedora 31.
> RPMs are available for gdc and for ldc2, but when both are
> installed gdc can't compile anything as it tries to load a version
> of phobos installed by ldc2 which has features gdc doesn't yet
> support. For someone who's decided to just use gdc for a project,
> they have the easy fix of just uninstalling ldc2, but I'd expect
> that someone evaluating D as a language will be interested in
> comparing the different compilers, so all the compilers will be
> installed--and then only dmd and ldc will be functional.

That's why we explicitly set the LDC include path in Debian: https://salsa.debian.org/d-team/ldc/blob/master/debian/rules#L15
This is a bug in Fedora, you could file an issue with the package at Fedora and ask them to do the same as Debian for include paths.
(we do set the path explicitly as linked, and also apply this patch: https://salsa.debian.org/d-team/ldc/blob/master/debian/patches/02_ldc_include_path.diff

Cheers,
    Matthias