improved behavior on debug safety crash

* instead of emitting a breakpoint for a debug safety crash,
   zig calls a panic function which prints an error message
   and a stack trace and then calls abort.
 * on freestanding OS, this panic function has a default
   implementation of a simple infinite loop.
 * users can override the panic implementation by providing
   `pub fn panic(message: []const u8) -> unreachable { }`
 * workaround for LLVM segfaulting when you try to use cold
   calling convention on ARM.

closes #245
This commit is contained in:
Andrew Kelley
2017-02-06 03:10:32 -05:00
parent 28f63b8a4f
commit 07a71fc322
10 changed files with 254 additions and 63 deletions

View File

@@ -3878,20 +3878,10 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo
if (arg0_value == irb->codegen->invalid_instruction)
return arg0_value;
if (exec_fn_entry(irb->exec)) {
add_node_error(irb->codegen, node, buf_sprintf("import valid only at global scope"));
return irb->codegen->invalid_instruction;
}
return ir_build_import(irb, scope, node, arg0_value);
}
case BuiltinFnIdCImport:
{
if (exec_fn_entry(irb->exec)) {
add_node_error(irb->codegen, node, buf_sprintf("C import valid only at global scope"));
return irb->codegen->invalid_instruction;
}
return ir_build_c_import(irb, scope, node);
}
case BuiltinFnIdCInclude: