first pass at zig build system

* `zig build --export [obj|lib|exe]` changed to `zig build_obj`,
   `zig build_lib` and `zig build_exe` respectively.
 * `--name` parameter is optional when it can be inferred from the
   root source filename. closes #207
 * `zig build` now looks for `build.zig` which interacts with
   `std.build.Builder` to describe the targets, and then the zig
   build system prints TODO: build these targets. See #204
 * add `@bitcast` which is mainly used for pointer reinterpret
   casting and make explicit casting not do pointer reinterpretation.
   Closes #290
 * fix debug info for byval parameters
 * sort command line help options
 * `std.debug.panic` supports format string printing
 * add `std.mem.IncrementingAllocator`
 * fix const ptr to a variable with data changing at runtime.
   closes #289
This commit is contained in:
Andrew Kelley
2017-03-31 05:48:15 -04:00
parent 536c35136a
commit 3ca027ca82
27 changed files with 477 additions and 190 deletions

View File

@@ -15,7 +15,7 @@ pub fn assert(ok: bool) {
var panicking = false;
/// This is the default panic implementation.
pub coldcc fn panic(message: []const u8) -> noreturn {
pub coldcc fn panic(comptime format: []const u8, args: ...) -> noreturn {
// TODO
// if (@atomicRmw(AtomicOp.XChg, &panicking, true, AtomicOrder.SeqCst)) { }
if (panicking) {
@@ -28,7 +28,7 @@ pub coldcc fn panic(message: []const u8) -> noreturn {
panicking = true;
}
%%io.stderr.printf("{}\n", message);
%%io.stderr.printf(format, args);
%%printStackTrace();
os.abort();
@@ -74,7 +74,7 @@ pub fn writeStackTrace(out_stream: &io.OutStream) -> %void {
const name = %return compile_unit.die.getAttrString(st, DW.AT_name);
%return out_stream.printf("{} -> {}\n", return_address, name);
maybe_fp = *(&const ?&const u8)(fp);
maybe_fp = *@bitcast(&const ?&const u8, fp);
}
},
ObjectFormat.coff => {
@@ -511,7 +511,6 @@ pub var global_allocator = mem.Allocator {
.allocFn = globalAlloc,
.reallocFn = globalRealloc,
.freeFn = globalFree,
.context = null,
};
var some_mem: [100 * 1024]u8 = undefined;