www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Dub issue with D-Scanner (libdmd)

I am trying to fix dub compilation of D-Scanner for the fork that 
uses libdmd 
[[1]](https://github.com/dlang-community/D-Scanner/pull/971). 
Executing just `dub build` yields this error:

```
collect2: error: ld returned 1 exit status
Error: undefined reference to `ModuleInfo for dmd.iasm`
Error: undefined reference to 
`dmd.iasm.asmSemantic(dmd.dsymbol.CAsmDeclaration, 
dmd.dscope.Scope*)`
        referenced from 
`_ZN22DsymbolSemanticVisitor5visitEP15CAsmDeclaration`
Error: undefined reference to `ModuleInfo for dmd.iasm`
Error: undefined reference to 
`dmd.iasm.asmSemantic(dmd.statement.AsmStatement, 
dmd.dscope.Scope*)`
        referenced from `void 
dmd.statementsem.statementSemanticVisit(dmd.statement.Statement, 
dmd.dscope.Scope*).visitAsm(dmd.statement.AsmStatement)`
Error: undefined reference to `initializer for 
dmd.astenums.Edition`
        perhaps a library needs to be added with the `-L` flag or 
`pragma(lib, ...)`
Error: linker exited with status 1
```

Adding the missing files in `dub.sdl` solved the issue:

```
- excludedSourceFiles "compiler/src/dmd/iasm/*"
+ excludedSourceFiles "compiler/src/dmd/iasm/dmd*"
```

Now there is a new error showing up:

```
collect2: error: ld returned 1 exit status
Error: undefined reference to `structalign_t::setPack()`
        referenced from `void 
dmd.cparse.CParser!(dmd.astcodegen.ASTCodegen).CParser.cparseDeclspec(ref
dmd.cparse.CParser!(dmd.astcodegen.ASTCodegen).CParser.Specifier)`
Error: undefined reference to `structalign_t::setPack()`
        referenced from `void 
dmd.cparse.CParser!(dmd.astcodegen.ASTCodegen).CParser.cparseGnuAttribute(ref
dmd.cparse.CParser!(dmd.astcodegen.ASTCodegen).CParser.Specifier)`
Error: undefined reference to `structalign_t::setAlignas()`
        referenced from `dmd.dsymbol.Dsymbol 
dmd.cparse.CParser!(dmd.astcodegen.ASTCodegen).CParser.applySpecifier(
md.dsymbol.Dsymbol, ref
dmd.cparse.CParser!(dmd.astcodegen.ASTCodegen).CParser.Specifier)`
Error: undefined reference to `structalign_t::setPack()`
        referenced from `nothrow void 
dmd.cparse.CParser!(dmd.astcodegen.ASTCodegen).CParser.pragmaPa
k(dmd.location.Loc, bool).setPackAlign(ref const(dmd.tokens.Token))`
Error: undefined reference to `initializer for 
dmd.astenums.Edition`
        perhaps a library needs to be added with the `-L` flag or 
`pragma(lib, ...)`
Error: linker exited with status 1
```

This made me think the file that defines `structalign_t` 
(`astenums.d`) is somehow ignored, but from the `dub.sdl` file it 
looks like it's not the case.

Do you have any idea how to sort this out? Perhaps there is 
something more to consider to make the fork compilable via dub?
Sep 14