Skip to content

Gracefully fail on missing object.d declarations #552

@JinShil

Description

@JinShil

This is likely caused by the fact that I incrementally porting the D runtime to a cortex-m processor. Therefore, I have not included some of the necessary types from object.d and friends. Nevertheless, the compiler should not crash and I depend on the compiler messages to know what I am missing.

The code causing this error is attached.

Compile with: ldc2 -march=thumb -mcpu=cortex-m4 -v -v-cg -vv -c start.d object.d rt/sections.d
** Full Output **

ldc2 -march=thumb -mcpu=cortex-m4 -v -v-cg -vv -c start.d object.d rt/sections.d              
config    /etc/ldc2.conf
Targeting 'thumb-unknown-linux-gnu' (CPU 'cortex-m4' with features '')
Building type: real
parse     start
parse     object
parse     sections
importall start
importall object
importall sections
semantic  start
Building type: uint
semantic  object
semantic  sections
semantic2 start
semantic2 object
semantic2 sections
semantic3 start
semantic3 object
semantic3 sections
code      start
Generating module: start
codegen: start (start.d)
* resetting 50 Dsymbols
* Final data layout: e-p:32:32:32-S32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:32:64-f16:16:16-f32:32:32-f64:32:64-f128:128:128-v64:32:64-v128:32:128-a0:0:32-n32
* WARNING: Unknown ABI, guessing...
* *** Initializing D runtime declarations ***
* * building runtime module
* * Building type: char[]
* * * Building type: char
* * Building type: wchar[]
* * * Building type: wchar
* * Building type: dchar[]
* * * Building type: dchar
* * Building type: object.Object
* * * Building class type object.Object @ object.d(9)
* * * * Instance size: 8
* * * * Building vtbl type for class object.Object
* * * * * Building type: object.TypeInfo_Class
* * * * * * Building class type object.TypeInfo_Class @ object.d(40)
* * * * * * * Instance size: 16
* * * * * * * adding default initializer for struct field name
* * * * * * * Building type: string
* * * * * * * Building vtbl type for class object.TypeInfo_Class
* * * * * * * * Adding type of object.Object.toString
* * * * * * * * isMember = this is: object.Object
* * * * * * * * DtoFunctionType(string())
* * * * * * * * * Final function type: { i32, i8* } (%object.Object*)
* * * * * * * class type: %object.TypeInfo_Class = type { %object.TypeInfo_Class.__vtbl*, i8*, { i32, i8* } }
* * * * * Adding type of object.Object.toString
* * * * * isMember = this is: object.Object
* * * * * DtoFunctionType(string())
* * * * * * Final function type: { i32, i8* } (%object.Object*)
* * * * class type: %object.Object = type { %object.Object.__vtbl*, i8* }
* * Building type: object.TypeInfo
* * * Building class type object.TypeInfo @ object.d(33)
* * * * Instance size: 8
* * * * Building vtbl type for class object.TypeInfo
* * * * * Adding type of object.Object.toString
* * * * * isMember = this is: object.Object
* * * * * DtoFunctionType(string())
* * * * * * Final function type: { i32, i8* } (%object.Object*)
* * * * class type: %object.TypeInfo = type { %object.TypeInfo.__vtbl*, i8* }
* * Building type: object.TypeInfo_AssociativeArray
* * * Building class type object.TypeInfo_AssociativeArray @ object.d(45)
* * * * Instance size: 8
* * * * Building vtbl type for class object.TypeInfo_AssociativeArray
* * * * * Adding type of object.Object.toString
* * * * * isMember = this is: object.Object
* * * * * DtoFunctionType(string())
* * * * * * Final function type: { i32, i8* } (%object.Object*)
* * * * class type: %object.TypeInfo_AssociativeArray = type { %object.TypeInfo_AssociativeArray.__vtbl*, i8* }
* * Building type: ModuleInfo
* * * Building struct type object.ModuleInfo @ object.d(21)
* * * * adding default initializer for struct field x
* * * * Building type: uint[16u]
* * * * final struct type: %object.ModuleInfo = type { [16 x i32] }
* * Building type: void(in Object)
* * * DtoFunctionType(void(in Object))
* * * * Building type: void
* * * * Final function type: void (%object.Object*)
* Ignoring Dsymbol::codegen for start.object
* VarDeclaration::codegen(): 'start.ResetHandler'
* * DtoResolveVariable(start.ResetHandler)
* * * data segment
* * * parent: start (module)
* * * Building type: void function()
* * * * Building type: void()
* * * * * DtoFunctionType(void())
* * * * * * Final function type: void ()
* * * @_D5start12ResetHandleryPFZv = external constant void ()*
* * data segment
* * Variable not available externally: ResetHandler
* * const expression initializer
* * DtoConstExpInit(targetType = immutable(void function()), exp = & OnReset)
* * * SymOffExp::toConstElem: & OnReset @ immutable(void function())
* * * * Building type: void()
* * * * * DtoFunctionType(void())
* * * * * * Final function type: void ()
* * * * DtoResolveFunction(start.OnReset): start.d(11)
* * * * * DtoDeclareFunction(start.OnReset): start.d(11)
* * * * * * DtoFunctionType(void())
* * * * * * * Final function type: void ()
* * * * * * func = 
declare fastcc void @_D5start7OnResetFZv()

* * @_D5start12ResetHandleryPFZv = constant void ()* @_D5start7OnResetFZv
* Building type: void(int command, void* message)
* * DtoFunctionType(void(int command, void* message))
* * * Building type: int
* * * Building type: void*
* * * Final function type: void (i32, i8*)
* DtoResolveFunction(start.SendCommand): start.d(6)
* * DtoDeclareFunction(start.SendCommand): start.d(6)
* * * DtoFunctionType(void(int command, void* message))
* * * * Final function type: void (i32, i8*)
* * * func = 
declare fastcc void @_D5start11SendCommandFiPvZv(i32, i8*)

* DtoDefineFunction(start.SendCommand): start.d(6)
* * Doing function body for: SendCommand
* * Function not available externally: SendCommand
* * DtoCreateNestedContext for SendCommand
* * * DtoCreateNestedContextType for SendCommand
* * CompoundStatement::toIR(): 
* * * CompoundStatement::toIR(): start.d(7)
* DtoDefineFunction(start.OnReset): start.d(11)
* * Doing function body for: OnReset
* * Function not available externally: OnReset
* * DtoCreateNestedContext for OnReset
* * * DtoCreateNestedContextType for OnReset
* * CompoundStatement::toIR(): 
* * * ForStatement::toIR(): start.d(13)
* * * * Expression::toElemDtor(): true
* * * * * IntegerExp::toElem: true @ bool
* * * * * * IntegerExp::toConstElem: true @ bool
* * * * * * * Building type: bool
* * * * * * * value = i1 true
* * * * ScopeStatement::toIR(): start.d(14)
* * * * * CompoundStatement::toIR(): start.d(14)
* * * * * * ExpStatement::toIR(): start.d(16)
* * * * * * * Expression::toElemDtor(): uint[3u] message = [2u, cast(uint)"hello\x0d\x0a", 7u];

* * * * * * * * DeclarationExp::toElem: uint[3u] message = [2u, cast(uint)"hello\x0d\x0a", 7u];
 | T=void
* * * * * * * * * DtoDeclarationExp: message
* * * * * * * * * * VarDeclaration
* * * * * * * * * * vdtype = uint[3u]
* * * * * * * * * * * Building type: uint[3u]
* * * * * * * * * * * llvm value for decl:   %message = alloca [3 x i32], align 4
* * * * * * * * * * * expression initializer
* * * * * * * * * * * AssignExp::toElem: message[] = [2u, cast(uint)"hello\x0d\x0a", 7u] | (uint[])(uint[] = const(uint[]))
* * * * * * * * * * * * performing static array literal assignment
* * * * * * * * * * * * VarExp::toElem: message @ uint[3u]
* * * * * * * * * * * * * DtoSymbolAddress ('message' of type 'uint[3u]')
* * * * * * * * * * * * * * a normal variable
* * * * * * * * * * * * IntegerExp::toElem: 2u @ const(uint)
* * * * * * * * * * * * * IntegerExp::toConstElem: 2u @ const(uint)
* * * * * * * * * * * * * * value = i32 2
* * * * * * * * * * * * DtoAssign()
* * * * * * * * * * * * * lhs:   %tmp = getelementptr [3 x i32]* %message, i32 0, i32 0
* * * * * * * * * * * * * rhs: i32 2
* * * * * * * * * * * * CastExp::toElem: cast(uint)"hello\x0d\x0a" @ const(uint)
* * * * * * * * * * * * * StringExp::toElem: "hello\x0d\x0a" @ immutable(char)*
* * * * * * * * * * * * * * type: [8 x i8]
* * * * * * * * * * * * * * init: [8 x i8] c"hello\0D\0A\00"
* * * * * * * * * * * * * Casting from 'immutable(char)*' to 'uint'
* * * * * * * * * * * * * repainting from 'uint' to 'const(uint)'
* * * * * * * * * * * * DtoAssign()
* * * * * * * * * * * * * lhs:   %tmp2 = getelementptr [3 x i32]* %message, i32 0, i32 1
* * * * * * * * * * * * * rhs:   %tmp1 = ptrtoint i8* getelementptr inbounds ([8 x i8]* @.str, i32 0, i32 0) to i32
* * * * * * * * * * * * IntegerExp::toElem: 7u @ const(uint)
* * * * * * * * * * * * * IntegerExp::toConstElem: 7u @ const(uint)
* * * * * * * * * * * * * * value = i32 7
* * * * * * * * * * * * DtoAssign()
* * * * * * * * * * * * * lhs:   %tmp3 = getelementptr [3 x i32]* %message, i32 0, i32 2
* * * * * * * * * * * * * rhs: i32 7
* * * * * * * * * * * * SliceExp::toElem: message[] @ uint[]
* * * * * * * * * * * * * VarExp::toElem: message @ uint[3u]
* * * * * * * * * * * * * * DtoSymbolAddress ('message' of type 'uint[3u]')
* * * * * * * * * * * * * * * a normal variable
* * * * * * * * * * * * * DtoArrayPtr
* * * * * * * * * * * * * Building type: uint*
* * * * * * ExpStatement::toIR(): start.d(24)
* * * * * * * Expression::toElemDtor(): SendCommand(5, & message)
* * * * * * * * CallExp::toElem: SendCommand(5, & message) @ void
* * * * * * * * * VarExp::toElem: SendCommand @ void(int command, void* message)
* * * * * * * * * * DtoSymbolAddress ('SendCommand' of type 'void(int command, void* message)')
* * * * * * * * * * * FuncDeclaration
* * * * * * * * * DtoCallFunction()
* * * * * * * * * * doing normal arguments
* * * * * * * * * * Arguments so far: (0)
* * * * * * * * * * Function type: void(int command, void* message)
* * * * * * * * * * DtoArgument
* * * * * * * * * * * IntegerExp::toElem: 5 @ int
* * * * * * * * * * * * IntegerExp::toConstElem: 5 @ int
* * * * * * * * * * * * * value = i32 5
* * * * * * * * * * DtoArgument
* * * * * * * * * * * SymOffExp::toElem: & message @ void*
* * * * * * * * * * * * DtoSymbolAddress ('message' of type 'uint[3u]')
* * * * * * * * * * * * * a normal variable
* * * * * * * * * * * * Casting from 'uint[3u]*' to 'void*'
* * * * * * * * * * * * * src:   %message = alloca [3 x i32], align 4
* * * * * * * * * * * * * to type: i8*
* Resolving struct type: ModuleInfo (object.d(21))
* Building type: ModuleInfo*
Verifying module...
* Verification passed!
Writing object file to: start.o

code      object
Generating module: object
codegen: object (object.d)
* resetting 50 Dsymbols
* Final data layout: e-p:32:32:32-S32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:32:64-f16:16:16-f32:32:32-f64:32:64-f128:128:128-v64:32:64-v128:32:128-a0:0:32-n32
* WARNING: Unknown ABI, guessing...
* *** Initializing D runtime declarations ***
* Ignoring Dsymbol::codegen for object.object
* Ignoring Dsymbol::codegen for object.string
* ClassDeclaration::codegen: 'object.Object'
* * DtoResolveClass(object.Object): object.d(9)
* * Building type: string()
* * * DtoFunctionType(string())
* * * * Final function type: { i32, i8* } ()
* * DtoResolveFunction(object.Object.toString): object.d(13)
* * * DtoDeclareFunction(object.Object.toString): object.d(13)
* * * * isMember = this is: object.Object
* * * * DtoFunctionType(string())
* * * * * Final function type: { i32, i8* } (%object.Object*)
* * * * func = 
declare fastcc { i32, i8* } @_D6object6Object8toStringMFZAya(%object.Object*)

* * DtoDefineFunction(object.Object.toString): object.d(13)
* * * Doing function body for: toString
* * * Function not available externally: toString
* * * DtoCreateNestedContext for toString
* * * * DtoCreateNestedContextType for toString
* * * CompoundStatement::toIR(): 
* * * * ExpStatement::toIR(): 
* * * * * Expression::toElemDtor(): assert(this, "null this")
* * * * * * AssertExp::toElem: assert(this, "null this")
* * * * * * * ThisExp::toElem: this @ object.Object
* * * * * * * * normal this exp
* * * * * * * Casting from 'object.Object' to 'bool'
* * * * * * * * DtoCastClass(object.Object, bool)
* * * * * * * * * to bool
* * * * * * * StringExp::toElem: "null this" @ char[]
* * * * * * * * type: [10 x i8]
* * * * * * * * init: [10 x i8] c"null this\00"
* * * * * * * calling class invariant
* * * * ReturnStatement::toIR(): object.d(15)
* * * * * Expression::toElemDtor(): (**this).name
* * * * * * DotVarExp::toElem: (**this).name @ string
* * * * * * * PtrExp::toElem: **this @ object.TypeInfo_Class
* * * * * * * * PtrExp::toElem: *this @ TypeInfo_Class*
* * * * * * * * * ThisExp::toElem: this @ object.Object
* * * * * * * * * * normal this exp
0  ldc2            0x000000000132b002 llvm::sys::PrintStackTrace(_IO_FILE*) + 34
1  ldc2            0x000000000132ae69
2  libpthread.so.0 0x00007f15e3c51870
3  ldc2            0x00000000006fe3ea PtrExp::toElem(IRState*) + 202
4  ldc2            0x00000000006fe490 PtrExp::toElem(IRState*) + 368
5  ldc2            0x00000000006fe628 DotVarExp::toElem(IRState*) + 184
6  ldc2            0x00000000006fbb4c Expression::toElemDtor(IRState*) + 556
7  ldc2            0x00000000006ba1c0 ReturnStatement::toIR(IRState*) + 832
8  ldc2            0x00000000006b9e49 CompoundStatement::toIR(IRState*) + 89
9  ldc2            0x00000000006ce5bf DtoDefineFunction(FuncDeclaration*) + 1775
10 ldc2            0x00000000006e6d44 ClassDeclaration::codegen(IRState*) + 148
11 ldc2            0x00000000006dcba4 Module::genLLVMModule(llvm::LLVMContext&) + 676
12 ldc2            0x00000000005cf9bb main + 8059
13 libc.so.6       0x00007f15e2e97bc5 __libc_start_main + 245
14 ldc2            0x00000000005f0245
Segmentation fault (core dumped)

Host computer is Arch Linux 64-bit

LDC - the LLVM D compiler (0.12.1):
based on DMD v2.063.2 and LLVM 3.3
Default target: x86_64-unknown-linux-gnu
Host CPU: corei7

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions