[sdc] linker problems when building programs with sdc

Joseph Rushton Wakeling via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Oct 22 13:32:37 PDT 2015


... or, it turns out, sdc doesn't like it when you forget to rewrite
`void main()` as `int main()`, and its error messages are still in the cryptic 
stage :-P

Onwards and upwards, then ... :-)

On 18/10/15 19:58, Joseph Rushton Wakeling via Digitalmars-d-learn wrote:
> Turns out even `return 42;` is a bit heavy-duty.  I do really like the way that
> sdc is obviously hooking into llvm's error reporting mechanism, though:
>
> $ ./sdc nohello.d
> ; ModuleID = 'nohello.d'
>
> define i32 @_Dmain() {
>    br label %body
>
> body:                                             ; preds = %0
>    call void @_D7nohello4mainFMZv()
>    ret i32 0
> }
>
> define void @_D7nohello4mainFMZv() {
>
> body:                                             ; No predecessors!
> }
> nohello.d:3:4: error: d.ir.error.ErrorExpression is not supported
>      return 42;
>      ^~~~~~~~~~
> d.exception.CompileException at libd/src/d/exception.d(15):
> d.ir.error.ErrorExpression is not supported
> ----------------
> ./sdc(llvm.c.core.__LLVMOpaqueValue*
> util.visitor.dispatchImpl!(_D1d4llvm10expression13ExpressionGen5visitMFC1d2ir10expression10ExpressionZ14__funcliteral2FC1d2ir10expression10ExpressionZPS4llvm1c4core17__LLVMOpaqueValue,
> d.llvm.expression.ExpressionGen, d.ir.expression.Expression).dispatchImpl(ref
> d.llvm.expression.ExpressionGen, d.ir.expression.Expression)+0x538) [0x138fae0]
> ./sdc(llvm.c.core.__LLVMOpaqueValue*
> util.visitor.dispatch!(_D1d4llvm10expression13ExpressionGen5visitMFC1d2ir10expression10ExpressionZ14__funcliteral2FC1d2ir10expression10ExpressionZPS4llvm1c4core17__LLVMOpaqueValue,
> d.llvm.expression.ExpressionGen, d.ir.expression.Expression).dispatch(ref
> d.llvm.expression.ExpressionGen, d.ir.expression.Expression)+0x1d) [0x138f5a5]
> ./sdc(llvm.c.core.__LLVMOpaqueValue*
> d.llvm.expression.ExpressionGen.visit(d.ir.expression.Expression)+0x55) [0x137ec55]
> ./sdc(llvm.c.core.__LLVMOpaqueValue*
> d.llvm.statement.StatementGen.genExpression(d.ir.expression.Expression)+0x3f)
> [0x138a627]
> ./sdc(void
> d.llvm.statement.StatementGen.visit(d.ast.statement.ReturnStatement!(d.ir.expression.Expression,
> d.ir.statement.Statement).ReturnStatement)+0x75) [0x138b1bd]
> ./sdc(void
> util.visitor.__T12dispatchImplS294util7visitor14__funcliteral6TS1d4llvm9statement12StatementGenTC1d2ir9statement9StatementZ.dispatchImpl(ref
> d.llvm.statement.StatementGen, d.ir.statement.Statement)+0x274) [0x13907ac]
> ./sdc(void
> util.visitor.__T8dispatchS294util7visitor14__funcliteral6TS1d4llvm9statement12StatementGenTC1d2ir9statement9StatementZ.dispatch(ref
> d.llvm.statement.StatementGen, d.ir.statement.Statement)+0x1d) [0x1390535]
> ./sdc(void d.llvm.statement.StatementGen.visit(d.ir.statement.Statement)+0x55)
> [0x138a4ad]
> ./sdc(void
> d.llvm.statement.StatementGen.visit(d.ast.statement.BlockStatement!(d.ir.statement.Statement).BlockStatement)+0xc2)
> [0x138ad3a]
> ./sdc(void d.llvm.local.LocalGen.genBody(d.ir.symbol.Function,
> llvm.c.core.__LLVMOpaqueValue*)+0xbb8) [0x1388730]
> ./sdc(bool d.llvm.local.LocalGen.maybeDefine(d.ir.symbol.Function,
> llvm.c.core.__LLVMOpaqueValue*)+0x10e) [0x1387b56]
> ./sdc(llvm.c.core.__LLVMOpaqueValue*
> d.llvm.local.LocalGen.define(d.ir.symbol.Function)+0x8e) [0x138798e]
> ./sdc(llvm.c.core.__LLVMOpaqueValue*
> d.llvm.global.GlobalGen.define(d.ir.symbol.Function)+0x15b) [0x13860cb]
> ./sdc(void d.llvm.global.GlobalGen.define(d.ir.symbol.Symbol)+0xd0) [0x1385db8]
> ./sdc(d.ir.symbol.Module
> d.llvm.codegen.CodeGenPass.visit(d.ir.symbol.Module)+0xe2) [0x132c0f2]
> ./sdc(void d.llvm.backend.LLVMBackend.emitObject(d.ir.symbol.Module[],
> immutable(char)[])+0xd1) [0x1328c79]
> ./sdc(void sdc.sdc.SDC.codeGen(immutable(char)[])+0x87) [0x12c7d17]
> ./sdc(void sdc.sdc.SDC.codeGen(immutable(char)[], immutable(char)[])+0x74)
> [0x12c7d94]
> ./sdc(_Dmain+0x59a) [0x12be462]
> /opt/dmd/lib64/libphobos2.so.0.68(_D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZ9__lambda1MFZv+0x28)
> [0x7f7c02d54ee8]
> /opt/dmd/lib64/libphobos2.so.0.68(void rt.dmain2._d_run_main(int, char**, extern
> (C) int function(char[][])*).tryExec(scope void delegate())+0x2d) [0x7f7c02d54e2d]
> /opt/dmd/lib64/libphobos2.so.0.68(void rt.dmain2._d_run_main(int, char**, extern
> (C) int function(char[][])*).runAll()+0x2d) [0x7f7c02d54e8d]
> /opt/dmd/lib64/libphobos2.so.0.68(void rt.dmain2._d_run_main(int, char**, extern
> (C) int function(char[][])*).tryExec(scope void delegate())+0x2d) [0x7f7c02d54e2d]
> /opt/dmd/lib64/libphobos2.so.0.68(_d_run_main+0x1e7) [0x7f7c02d54da7]
> ./sdc(main+0x20) [0x12c7708]
> /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0) [0x7f7c0173fa40]
>
>



More information about the Digitalmars-d-learn mailing list