Using Zig to Provide Stack Traces on Kernel Panic for a Bare Bones Operating System

2018年12月4日

AI 摘要 AI 生成,可能有误

作者描述了在 ClashOS 中为内核恐慌(kernel panic)添加堆栈跟踪的过程。ClashOS 是一个用 Zig 编写的、面向树莓派的极简街机游戏操作系统,其默认的自由环境(freestanding)panic 处理程序只会使 CPU 挂起。通过链接器脚本将 DWARF 调试信息段嵌入内核映像(这需要修补一个过于严格的 LLD 检查,该补丁后来被合并到上游的 LLVM 8 中),并编写使用 Zig 标准库 API 从内存中映射调试信息的胶水代码,内核便能在发生 panic 时打印带注释的堆栈跟踪。最后,内核自身的源文件也被包含在内存中,这样 panic 输出就可以显示对应的源代码行。

Using Zig to Provide Stack Traces on Kernel Panic for a Bare Bones Operating System

Last week, I reached an exciting milestone in my career as a programmer. For the first time in my life, I ran code directly on hardware, with no Operating System sitting between the bare metal and my code.

For some context, the goal of this side project is to create a 2-4 player arcade game running directly on a Raspberry Pi 3+.

继续阅读全文

为了尊重作者,这里只展示开头几段。你可以去原文阅读,或者在 HorizonReader 里读:划线做笔记、让 AI 帮忙。

更多来自 Andrew Kelley

Don't Take the Black Pill (Text Adaptation)

AI 摘要The author warns against the 'black pill'—the nihilistic despair that emerged from incel forums and was fictionalized in Cory Doctorow's 'Radicalized'—drawing a parallel to software engineers who feel hopeless about management blocking them from building quality software. He describes coping strategies like 'Benevolent Noncompliance,' secrecy, inception, misdirection, and the 'duck' trick, while arguing that software quality historically depended on engineers' strong negotiating power in the job market. Ultimately, he calls for preserving agency, insisting that computers—like a 'user-agent' browser—should always serve the person directly interacting with them rather than hostile third-party interests.

My Thoughts on the Bun Rust Rewrite

AI 摘要The author, Zig's project lead, recounts the deteriorating relationship between the Zig community and Bun's founder Jarred, citing his VC-driven management failures, sloppy code quality, and diverging values, which made the Zig Software Foundation relieved when Anthropic acquired Bun and it was rewritten in Rust. He rebuts the rewrite announcement's blog post, arguing that bugs are eliminated through dedicated engineering effort rather than language features alone, and disputing its claims about testing, performance, and binary size. He concludes the conflict was never about Zig versus Rust but about clashing value systems, and reveals that Jarred engaged in cruel, illegal employment practices, regretting not severing ties sooner.

Zig's New Async I/O (Text Version)

AI 摘要This article is the text version of a Zigtoberfest 2025 demo introducing Zig's new async I/O primitives, which will land in the upcoming Zig 0.16.0 via the std.Io interface. Through a series of progressive code examples, it demonstrates how to set up an Io implementation (similar to allocators), use async/await to express asynchrony for concurrent execution, and handle errors and resource management safely. It also introduces cancellation, showing how defer and cancel combine with try and await to prevent resource leaks and produce more optimal code.

An Open Letter to Everyone I've Butted Heads With

AI 摘要Reflecting on Zig's 10th anniversary, the author examines his negative interactions with community members and concludes that such conflicts stem from programmers' lack of agency over the technologies they depend on, which naturally breeds frustration and anger. He apologizes for his own grumpy moments, emphasizes that he respects and cares even for his critics, and vows to bring more empathy to his daily interactions while continuing to grow Zig into a mainstream, welcoming project.

Renting is for Suckers

AI 摘要The article argues that cloud computing and cloud-based AI coding services are modern forms of 'renting' that violate basic financial principles, as owning hardware is orders of magnitude cheaper—citing the author's $3,000 Mac mini for Zig's CI versus $42,000/year for a cloud runner. It claims cloud and AI companies use marketing, conference sponsorships, and propaganda to convince developers to abandon ownership, transferring massive wealth to a few large corporations while introducing opaque costs and trust risks, such as the potential for LLM providers to manipulate agent behavior for profit. The author concludes by urging programmers to reject cloud and agentic coding services, which can cost hundreds to tens of thousands of dollars monthly, and instead use their own powerful, already-owned computers for free, private programming.