Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Error: declaration expected, not 'foreach'" when building with LDC on Fedora #370

Closed
szpak opened this issue Nov 26, 2018 · 7 comments
Closed

Comments

@szpak
Copy link
Contributor

szpak commented Nov 26, 2018

I have tried to build LixD on Fedora 27 with LDC and the compilation itself fails with:

$ dub build -b release
Fetching optional 0.6.3 (getting selected version)...
Fetching enumap 0.4.2 (getting selected version)...
Fetching libinputvisitor 1.2.2 (getting selected version)...
Fetching bolts 0.7.1 (getting selected version)...
Fetching taggedalgebraic 0.10.11 (getting selected version)...
Fetching derelict-enet 4.1.0 (getting selected version)...
Fetching derelict-util 3.0.0-beta.2 (getting selected version)...
Fetching unit-threaded 0.7.52 (getting selected version)...
Fetching silly 0.8.0 (getting selected version)...
Fetching sdlang-d 0.10.4 (getting selected version)...
Fetching allegro 4.0.3+5.2.0 (getting selected version)...
Performing "release" build using ldc2 for x86_64.
allegro 4.0.3+5.2.0: building configuration "no-libs"...
derelict-util 3.0.0-beta.2: building configuration "library"...
derelict-enet 4.1.0: building configuration "library"...
enumap 0.4.2: building configuration "library"...
bolts 0.7.1: building configuration "library"...
/home/foobar/.dub/packages/bolts-0.7.1/bolts/source/bolts/meta.d(190,12): Error: declaration expected, not 'foreach'
/home/foobar/.dub/packages/bolts-0.7.1/bolts/source/bolts/meta.d(190,38): Error: no identifier for declarator Seqs[1 .. __dollar]
/home/foobar/.dub/packages/bolts-0.7.1/bolts/source/bolts/meta.d(190,38): Error: declaration expected, not ')'
/home/foobar/.dub/packages/bolts-0.7.1/bolts/source/bolts/meta.d(208,1): Error: unrecognized declaration
ldc2 failed with exit code 1.

My LDC is not in the newest version (however, I haven't found a minimal required version):

$ ldmd2 --version
LDC - the LLVM D compiler (1.4.0):
  based on DMD v2.074.1 and LLVM 4.0.1
  built with LDC - the LLVM D compiler (1.4.0)
  Default target: x86_64-unknown-linux-gnu
  Host CPU: sandybridge
  http://dlang.org - http://wiki.dlang.org/LDC

  Registered Targets:
(...)

Other libs should be installed with matching versions. I have no experience with D. Somehow related to #333.

@szpak szpak changed the title Error: declaration expected, not 'foreach when building with ldc on Fedora "Error: declaration expected, not 'foreach'" when building with ldc on Fedora Nov 26, 2018
@szpak szpak changed the title "Error: declaration expected, not 'foreach'" when building with ldc on Fedora "Error: declaration expected, not 'foreach'" when building with LDC on Fedora Nov 26, 2018
@SimonN
Copy link
Owner

SimonN commented Nov 26, 2018

Thanks!

From the ldmd2 --version output, I conjecture that the compiler version is too old: That LDC version is based on DMD 2.074. D (the language) occasionally introduces new features with minor releases of the reference compiler DMD, which is at 2.083.0.

The exact failure is: In a dependency of Lix, your LDC trips over static foreach, a feature introduced into D in late 2017.

But Fedora 27 offers no newer LDC than what you have. Ideas:

We could also try to build older versions of Lix that use older dependencies and thus don't rely on new D features. E.g., especially the dependency Optional >= 0.6 requires nearly cutting-edge D. But it would be a guessing game and reintroduce old bugs (which might break the build in other ways). I'd recommend the bullet points above first.

@szpak
Copy link
Contributor Author

szpak commented Nov 26, 2018

That Fedora is really old, there is no need to support it. I will try to build it on Fedora 29 with ldc-1.11.0.

@SimonN
Copy link
Owner

SimonN commented Nov 26, 2018

Yes, that's worth a try. LDC 1.11 is based on DMD 2.081.2 and should work; I know that LDC based on DMD 2.082 works.

There's a small chance that LDC based on DMD 2.081.2 is still too old because Optional relies on cutting-edge D. In that case, you could try to build Lix commit d667af7 instead of master; then, Lix depends on Optional 0.4 instead of 0.6.

@szpak
Copy link
Contributor Author

szpak commented Nov 28, 2018

I was able to build it from master on Fedora 29 with:

$ ldc2 --version
LDC - the LLVM D compiler (1.11.0):
  based on DMD v2.081.2 and LLVM 6.0.1
  built with LDC - the LLVM D compiler (1.11.0)
  Default target: x86_64-unknown-linux-gnu
  Host CPU: haswell
  http://dlang.org - http://wiki.dlang.org/LDC

One more note for the Fedora users. It was required to install (in addition to allegro5-devel) also allegro5-addon-{acodec,image,audio,ttf}-devel.

Thanks for you help.

@szpak szpak closed this as completed Nov 28, 2018
@SimonN
Copy link
Owner

SimonN commented Nov 28, 2018

Thanks for the good report! Seems like Fedora packages the addons separately. I'll add your findings to the build notes.

@alexmyczko
Copy link
Contributor

I have: LDC - the LLVM D compiler (1.12.0):
based on DMD v2.082.1 and LLVM 6.0.1
built with LDC - the LLVM D compiler (1.12.0)
get the same error

@SimonN
Copy link
Owner

SimonN commented Nov 29, 2018

That compiler is even newer than szpak's, thus it's strange that you still get an error for static foreach.

Can you post the full build log?

Idea: dub prefers DMD over LDC or LDC2. Do you get a line à la Performing "release" build using ldc2 for x86_64. ? You can force compilation with LDC2 via dub <otherSwitches> --compiler=ldc2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants