stage2: disable default panic handler when linking -lc

It's failing to compile std.os.dl_iterate_phdr correctly.
This commit is contained in:
Andrew Kelley
2022-03-20 00:33:56 -07:00
parent b6203b89d6
commit 6d73f89bf1
3 changed files with 19 additions and 2 deletions

View File

@@ -751,9 +751,18 @@ else
/// therefore must be kept in sync with the compiler implementation.
pub fn default_panic(msg: []const u8, error_return_trace: ?*StackTrace) noreturn {
@setCold(true);
// Until self-hosted catches up with stage1 language features, we have a simpler
// default panic function:
if (builtin.zig_backend != .stage1 and builtin.zig_backend != .stage2_llvm) {
if ((builtin.zig_backend == .stage2_llvm and builtin.link_libc) or
builtin.zig_backend == .stage2_c or
builtin.zig_backend == .stage2_wasm or
builtin.zig_backend == .stage2_arm or
builtin.zig_backend == .stage2_aarch64 or
builtin.zig_backend == .stage2_x86_64 or
builtin.zig_backend == .stage2_x86 or
builtin.zig_backend == .stage2_riscv64)
{
while (true) {
@breakpoint();
}

View File

@@ -263,7 +263,11 @@ pub extern "c" fn inotify_rm_watch(fd: fd_t, wd: c_int) c_int;
/// See std.elf for constants for this
pub extern "c" fn getauxval(__type: c_ulong) c_ulong;
pub const dl_iterate_phdr_callback = fn (info: *dl_phdr_info, size: usize, data: ?*anyopaque) callconv(.C) c_int;
pub const dl_iterate_phdr_callback = switch (builtin.zig_backend) {
.stage1 => fn (info: *dl_phdr_info, size: usize, data: ?*anyopaque) callconv(.C) c_int,
else => *const fn (info: *dl_phdr_info, size: usize, data: ?*anyopaque) callconv(.C) c_int,
};
pub extern "c" fn dl_iterate_phdr(callback: dl_iterate_phdr_callback, data: ?*anyopaque) c_int;
pub extern "c" fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) c_int;

View File

@@ -6231,6 +6231,10 @@ fn funcCommon(
comptime_params[i] = param.is_comptime or
try sema.typeRequiresComptime(block, param_src, param.ty);
is_generic = is_generic or comptime_params[i] or param.ty.tag() == .generic_poison;
if (is_extern and is_generic) {
// TODO add note: function is generic because of this parameter
return sema.fail(block, param_src, "extern function cannot be generic", .{});
}
}
is_generic = is_generic or