authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-03-20 00:33:56-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-03-20 00:36:44-07:00
log6d73f89bf17e96349255b351ad0603644441947a
tree5cad7ae4e28e2cb10c4615b01a6344928e81aa61
parentb6203b89d6b41f17e44f7806f2244309fa3bd86c

stage2: disable default panic handler when linking -lc

It's failing to compile std.os.dl_iterate_phdr correctly.

3 files changed, 19 insertions(+), 2 deletions(-)

lib/std/builtin.zig+10-1
......@@ -751,9 +751,18 @@ else
751751/// therefore must be kept in sync with the compiler implementation.
752752pub fn default_panic(msg: []const u8, error_return_trace: ?*StackTrace) noreturn {
753753 @setCold(true);
754
754755 // Until self-hosted catches up with stage1 language features, we have a simpler
755756 // default panic function:
756 if (builtin.zig_backend != .stage1 and builtin.zig_backend != .stage2_llvm) {
757 if ((builtin.zig_backend == .stage2_llvm and builtin.link_libc) or
758 builtin.zig_backend == .stage2_c or
759 builtin.zig_backend == .stage2_wasm or
760 builtin.zig_backend == .stage2_arm or
761 builtin.zig_backend == .stage2_aarch64 or
762 builtin.zig_backend == .stage2_x86_64 or
763 builtin.zig_backend == .stage2_x86 or
764 builtin.zig_backend == .stage2_riscv64)
765 {
757766 while (true) {
758767 @breakpoint();
759768 }
lib/std/c/linux.zig+5-1
......@@ -263,7 +263,11 @@ pub extern "c" fn inotify_rm_watch(fd: fd_t, wd: c_int) c_int;
263263/// See std.elf for constants for this
264264pub extern "c" fn getauxval(__type: c_ulong) c_ulong;
265265
266pub const dl_iterate_phdr_callback = fn (info: *dl_phdr_info, size: usize, data: ?*anyopaque) callconv(.C) c_int;
266pub const dl_iterate_phdr_callback = switch (builtin.zig_backend) {
267 .stage1 => fn (info: *dl_phdr_info, size: usize, data: ?*anyopaque) callconv(.C) c_int,
268 else => *const fn (info: *dl_phdr_info, size: usize, data: ?*anyopaque) callconv(.C) c_int,
269};
270
267271pub extern "c" fn dl_iterate_phdr(callback: dl_iterate_phdr_callback, data: ?*anyopaque) c_int;
268272
269273pub extern "c" fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) c_int;
src/Sema.zig+4
......@@ -6231,6 +6231,10 @@ fn funcCommon(
62316231 comptime_params[i] = param.is_comptime or
62326232 try sema.typeRequiresComptime(block, param_src, param.ty);
62336233 is_generic = is_generic or comptime_params[i] or param.ty.tag() == .generic_poison;
6234 if (is_extern and is_generic) {
6235 // TODO add note: function is generic because of this parameter
6236 return sema.fail(block, param_src, "extern function cannot be generic", .{});
6237 }
62346238 }
62356239
62366240 is_generic = is_generic or