Thread overview
Installed with sudo apt-get install gdc in Ubuntu 18.04 - Can't compile a simple program.
2 days ago
James Blachly
2 days ago
James Blachly
August 06
Hello everyone,

I just installed GDC with sudo apt-get install gdc and I can't compile a simple hello world program. I get e.g. static foreach errors:

/usr/local/include/d/core/internal/hash.d:333:16: error: basic type expected, not foreach
         static foreach (i; 0 .. T.sizeof / size_t.sizeof)

Any idea? Before about a month I used to compile hundeds of lines but I don't remember how..

Thanks,
Stefanos
August 06
On Tuesday, 6 August 2019 at 11:45:50 UTC, Stefanos Baziotis wrote:
> Hello everyone,
>
> I just installed GDC with sudo apt-get install gdc and I can't compile a simple hello world program. I get e.g. static foreach errors:
>
> /usr/local/include/d/core/internal/hash.d:333:16: error: basic type expected, not foreach
>          static foreach (i; 0 .. T.sizeof / size_t.sizeof)
>
> Any idea? Before about a month I used to compile hundeds of lines but I don't remember how..
>
> Thanks,
> Stefanos

At least gdc from gcc9 doesn't support static foreach, probably it's reading imports from other d compiler install.
August 06
On Tuesday, 6 August 2019 at 12:02:05 UTC, Boris Carvajal wrote:
> At least gdc from gcc9 doesn't support static foreach, probably it's reading imports from other d compiler install.

Yes it seems so. I installed LDC from source recently, maybe that made the conflict. I don't know how to fix it but thanks anyway.

Stefanos
August 06
Am Tue, 06 Aug 2019 12:22:56 +0000 schrieb Stefanos Baziotis:

> On Tuesday, 6 August 2019 at 12:02:05 UTC, Boris Carvajal wrote:
>> At least gdc from gcc9 doesn't support static foreach, probably it's reading imports from other d compiler install.
> 
> Yes it seems so. I installed LDC from source recently, maybe that made the conflict. I don't know how to fix it but thanks anyway.
> 
> Stefanos

gdc includes everything in /usr/include/d automatically. The assumption is that distributions will only install global D files there which are compiler-independent, just like in /usr/include.

Unfortunately dmd and/or ldc still seem to install their druntime/phobos D files there, so you likely need to remove these files from /usr/include/ d (the best way is to use the uninstall procedure matching the way you installed it).



-- 
Johannes
August 06
On Tuesday, 6 August 2019 at 16:38:56 UTC, Johannes Pfau wrote:
>
> gdc includes everything in /usr/include/d automatically. The assumption is that distributions will only install global D files there which are compiler-independent, just like in /usr/include.
>
> Unfortunately dmd and/or ldc still seem to install their druntime/phobos D files there, so you likely need to remove these files from /usr/include/ d (the best way is to use the uninstall procedure matching the way you installed it).

The problem is that the way I installed them is by building
LDC with ninja. And I don't know how this can be reverted. I've searched online,
but apparently if something is installed without a package manager, then "Good Luck". :P
August 07
On Tue, 6 Aug 2019 at 19:15, Stefanos Baziotis via D.gnu <d.gnu@puremagic.com> wrote:
>
> On Tuesday, 6 August 2019 at 16:38:56 UTC, Johannes Pfau wrote:
> >
> > gdc includes everything in /usr/include/d automatically. The assumption is that distributions will only install global D files there which are compiler-independent, just like in /usr/include.
> >
> > Unfortunately dmd and/or ldc still seem to install their druntime/phobos D files there, so you likely need to remove these files from /usr/include/ d (the best way is to use the uninstall procedure matching the way you installed it).
>
> The problem is that the way I installed them is by building
> LDC with ninja. And I don't know how this can be reverted. I've
> searched online,
> but apparently if something is installed without a package
> manager, then "Good Luck". :P

Maybe ldc should be fixed to install compiler-specific modules inside a compiler-specific directory?  There may be a configure switch to control that.

-- 
Iain
August 07
On Wednesday, 7 August 2019 at 05:54:58 UTC, Iain Buclaw wrote:
>
> Maybe ldc should be fixed to install compiler-specific modules inside a compiler-specific directory?  There may be a configure switch to control that.
>

It seems there is. I was not aware of the problem when installing so I did
not configure it.

For anyone else trying to install LDC from source, in the CMake
cmdline, with the INCLUDE_INSTALL_DIR one can set
where phobos and druntime will be installed [1].

[1] https://wiki.dlang.org/Building_LDC_from_source#Useful_CMake_variables


2 days ago
On 8/6/19 7:45 AM, Stefanos Baziotis wrote:
> Hello everyone,
> 
> I just installed GDC with sudo apt-get install gdc and I can't compile a simple hello world program. I get e.g. static foreach errors:

I also have just installed GDC via apt on Ubuntu18 and cannot compile my codebase (via dub build --compiler=gdc). However, I am getting a different error related to symbols:

../intervaltree/.dub/build/library-release-debug-linux.posix-x86_64-gdc_2068-CAF4B0AA644EFF0EF2E4C805B972A804/libintervaltree.a:(minfo+0x20): multiple definition of `_D12intervaltree7avltree11__moduleRefZ'
/tmp/ccNVyy2Z.o:(minfo+0xe0): first defined here
../intervaltree/.dub/build/library-release-debug-linux.posix-x86_64-gdc_2068-CAF4B0AA644EFF0EF2E4C805B972A804/libintervaltree.a:(.data+0x80): multiple definition of `_D12intervaltree7avltree12__ModuleInfoZ'
/tmp/ccNVyy2Z.o:(.data+0x2c0): first defined here
collect2: error: ld returned 1 exit status
gdc failed with exit code 1.


This codebase compiles fine with dmd2 and ldc2, neither of which is installed at the system level. This is a clean VM.

Since I have version() sprinkled all throughout the code, and the error relates to a symbol that should not even be present (avltree) , I am wondering if GDC is correctly honoring the version() markers in the code. Why else would the avltree symbol appear if it is 100% version()ed out?

2 days ago
On 8/18/19 11:20 AM, James Blachly wrote:
> ../intervaltree/.dub/build/library-release-debug-linux.posix-x86_64-gdc_2068-CAF4B0AA644EFF0EF2E4C805B972A804/libintervaltree.a:(minfo+0x20): multiple definition of `_D12intervaltree7avltree11__moduleRefZ'
> /tmp/ccNVyy2Z.o:(minfo+0xe0): first defined here
> ../intervaltree/.dub/build/library-release-debug-linux.posix-x86_64-gdc_2068-CAF4B0AA644EFF0EF2E4C805B972A804/libintervaltree.a:(.data+0x80): multiple definition of `_D12intervaltree7avltree12__ModuleInfoZ'
> /tmp/ccNVyy2Z.o:(.data+0x2c0): first defined here
> collect2: error: ld returned 1 exit status
> gdc failed with exit code 1.

Problem solved -- I had identical module file under a different path; DMD and LDC merged them into a single symbol/code, while GDC generated and emitted them separately, resulting in a linker error.

This also means I have successfully compiled with GDC for the first time. Glad that it was painlessly available via apt-get.