mirror of
https://github.com/ziglang/zig.git
synced 2026-02-21 16:54:52 +00:00
std lib general purpose allocator: disable stack tracing on mips
Sadly, trying to collect stack frames goes into an infinite loop on mips. This sets the default number of stack frames to collect to 0 on mips.
This commit is contained in:
parent
72b5ceed66
commit
051aadd781
@ -9363,7 +9363,7 @@ pub fn main() !void {
|
|||||||
Finally, if none of the above apply, you need a general purpose allocator.
|
Finally, if none of the above apply, you need a general purpose allocator.
|
||||||
Zig's general purpose allocator is available as a function that takes a {#link|comptime#}
|
Zig's general purpose allocator is available as a function that takes a {#link|comptime#}
|
||||||
{#link|struct#} of configuration options and returns a type.
|
{#link|struct#} of configuration options and returns a type.
|
||||||
Generally, you will set up one {#syntax#}std.heap.GeneralPurposeAllocator#{endsyntax#} in
|
Generally, you will set up one {#syntax#}std.heap.GeneralPurposeAllocator{#endsyntax#} in
|
||||||
your main function, and then pass it or sub-allocators around to various parts of your
|
your main function, and then pass it or sub-allocators around to various parts of your
|
||||||
application.
|
application.
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@ -102,8 +102,22 @@ const StackTrace = std.builtin.StackTrace;
|
|||||||
/// Integer type for pointing to slots in a small allocation
|
/// Integer type for pointing to slots in a small allocation
|
||||||
const SlotIndex = std.meta.Int(false, math.log2(page_size) + 1);
|
const SlotIndex = std.meta.Int(false, math.log2(page_size) + 1);
|
||||||
|
|
||||||
// WebAssembly doesn't support stack tracing yet.
|
const sys_can_stack_trace = switch (std.Target.current.cpu.arch) {
|
||||||
const default_stack_trace_frames: usize = if (std.Target.current.cpu.arch.isWasm()) 0 else 4;
|
// Observed to go into an infinite loop.
|
||||||
|
// TODO: Make this work.
|
||||||
|
.mips,
|
||||||
|
.mipsel,
|
||||||
|
=> false,
|
||||||
|
|
||||||
|
// `@returnAddress()` in LLVM 10 gives
|
||||||
|
// "Non-Emscripten WebAssembly hasn't implemented __builtin_return_address".
|
||||||
|
.wasm32,
|
||||||
|
.wasm64,
|
||||||
|
=> std.Target.current.os.tag == .emscripten,
|
||||||
|
|
||||||
|
else => true,
|
||||||
|
};
|
||||||
|
const default_stack_trace_frames: usize = if (sys_can_stack_trace) 4 else 0;
|
||||||
|
|
||||||
pub const Config = struct {
|
pub const Config = struct {
|
||||||
/// Number of stack frames to capture.
|
/// Number of stack frames to capture.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user