TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Stage0 – A set of minimal C compiler bootstrap binaries

200 pointsby z29LiTp5qUC30nalmost 6 years ago
https://github.com/oriansj/stage0/blob/master/Linux%20Bootstrap/x86/cc_x86.M1 It also appears to be bootstrapped from hex

16 comments

rgoulteralmost 6 years ago
<i>This is a set of manually created hex programs in a Cthulhu Path to madness fashion. Which only have the goal of creating a bootstrapping path to a C compiler capable of compiling GCC, with only the explicit requirement of a single 1 KByte binary or less.</i><p>What a wonderfully mad, cool goal.
评论 #20270765 未加载
Dylan16807almost 6 years ago
Does it support all of C?<p>Is this actually smaller than TCC? It&#x27;s kind of hard to tell since TCC is split into files and I don&#x27;t know what&#x27;s actually necessary. And that question includes earlier, less featureful versions of TCC. Note that the more-or-less-C compiler it&#x27;s based off of is absolutely miniscule: <a href="https:&#x2F;&#x2F;bellard.org&#x2F;otcc&#x2F;" rel="nofollow">https:&#x2F;&#x2F;bellard.org&#x2F;otcc&#x2F;</a>
评论 #20269692 未加载
评论 #20270217 未加载
评论 #20265630 未加载
0xffff2almost 6 years ago
&gt;Additionally, all code must be able to be understood by 70% of the population of programmers. If the code can not be understood by that volume, it needs to be altered until it satifies the above requirement.<p>How is this measured&#x2F;qualified? These days, I would doubt that 70% of people whose primary job is to write code have any knowledge of assembly whatsoever, so a naive reading of the above paragraph seems unlikely to succeed.
评论 #20267290 未加载
sly010almost 6 years ago
Do the instructions in the README count as part of the program?<p>If not, then the smallest binary to bootstrap a C compiler is actually a single jump to a C compiler in memory with a README containing the memory dump in to be typed in :)<p>Seriously though, it reminds me of the Toaster Project [0] where an RCA student attempted to build a modern toaster without using the modern supply chain.<p>[0] <a href="http:&#x2F;&#x2F;www.thetoasterproject.org&#x2F;" rel="nofollow">http:&#x2F;&#x2F;www.thetoasterproject.org&#x2F;</a>
kragenalmost 6 years ago
What oriansj (as well as rain1 and others) are doing is both very impressive and important. The objective is to get us to bootstrappability and, for example, escape Trusting-Trust attacks; one reason it&#x27;s profoundly important is the long-term archival problem. <i>Media longevity</i> is one crucial part of archival, but as we were discussing today in <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=20272557" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=20272557</a>, there are plausible solutions to that problem.<p><i>Interpretability</i> is another part of the problem: even if we recovered an executable copy of Ivan Sutherland&#x27;s historically groundbreaking program SKETCHPAD, for example, we wouldn&#x27;t be able to run it because we don&#x27;t know the instruction set for the computer it was built for. Remember that the entire body of knowledge about Ancient Egyptian culture was lost in the 5th Century, when the Christian Dark Age closed the temples, and not regained for almost 1400 years — and then only due to the great good fortune of the Rosetta Stone.<p>A bootstrappable computing stack is a crucial part of the &quot;Rosetta Stone&quot; that will be needed to preserve 21st-century knowledge. One of the few papers tackling the interpretability problem in this form is <a href="http:&#x2F;&#x2F;www.vpri.org&#x2F;pdf&#x2F;tr2015004_cuneiform.pdf" rel="nofollow">http:&#x2F;&#x2F;www.vpri.org&#x2F;pdf&#x2F;tr2015004_cuneiform.pdf</a>, &quot;The Cuneiform Tablets of 2015&quot;, by Long Tien Nguyen and Alan Kay.<p>There&#x27;s a more immediate necessity, though. As recent events make clear — Chrome&#x27;s extension API kneecapping ad-blockers, the increasing effectiveness of Chinese censorship, and the shocking US$12 million award to Nintendo last November against ROM site operators for preserving classic video games, for example — the current political and economic system cannot be trusted to preserve our access to our cultural heritage, even during our lifetimes. That means that we need an autonomously-bootstrappable trustworthy free-software infrastructure that is viable without the massive economies of scale that fund mainstream platforms like Linux, Android, MacOS, Chrome, and even Firefox. If your personal archive of the Tank Man photo, the Arab Spring tweets, or the video of the murder of Philando Castile runs afoul of future malicious-content filters integrated into your operating system, there is no guarantee that it, or you, will survive.<p>So we&#x27;re doing our best to get some green shoots established before the situation has any opportunity to get worse.
评论 #20276366 未加载
评论 #20329278 未加载
bloakalmost 6 years ago
The trouble with bootstrapping GCC is that it requires flex&#x2F;lex. Have you tried bootstrapping flex&#x2F;lex?<p>It sounds stupid, I know, but when I investigated possible paths for getting from zero to GCC, flex looked like the biggest potential obstacle.<p>There are also C files in GCC&#x2F;binutils that are generated by complex shell scripts. That was perhaps the second biggest obstacle.<p>(If I recall correctly, bison&#x27;s not a problem: old versions of bison don&#x27;t use bison.)
评论 #20272170 未加载
logicalleealmost 6 years ago
What special limits can this limbo under? 15 kb is so small.<p>It&#x27;s even smaller than l1 cache. (In case you wanted to bruteforce every possible text file you could feed this binary, and wanted to do it all on cache in the CPU).<p>Maybe it&#x27;s the size of payload you can put into a usb C cable or something.<p>I mean it&#x27;s just so freaking small. Any ideas what limits this is &quot;small enough&quot; to fit under?
评论 #20267284 未加载
评论 #20268240 未加载
评论 #20269470 未加载
cylinder714almost 6 years ago
See also Edmund Grimley Evans&#x27; bcompiler, mirrored at <a href="https:&#x2F;&#x2F;github.com&#x2F;certik&#x2F;bcompiler" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;certik&#x2F;bcompiler</a><p>On a related note, one can write arbitrary bytes to a file (on a Unix-like system) using GNU &#x27;echo&#x27; or the &#x27;printf&#x27; utilities. Chris Wellons&#x27; post &quot;A Magnetized Needle and a Steady Hand&quot; describes how to write a basic utility in this way.
tomcamalmost 6 years ago
Read this code if you think you don’t understand assembly. A wonderful project, very clearly written.
agumonkeyalmost 6 years ago
Oh so this is similar to kragen &#x27;basement experiment&#x27; .. kudos
评论 #20270890 未加载
kaushalmodialmost 6 years ago
So cool to see Org mode READMEs in projects unrelated to Emacs!<p>I hope Github improves Org mode support at some point.
评论 #20268924 未加载
edwintorokalmost 6 years ago
Does this have similar goes as <a href="https:&#x2F;&#x2F;www.gnu.org&#x2F;software&#x2F;mes&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.gnu.org&#x2F;software&#x2F;mes&#x2F;</a>?
评论 #20268227 未加载
zachrosealmost 6 years ago
Does this have any implications for trusting trust?
评论 #20270853 未加载
评论 #20277714 未加载
rain1almost 6 years ago
of course this isn&#x27;t the smallest C compiler, it&#x27;s 5000 lines of code. There is a 500 line C compiler written in C.<p>But perhaps it&#x27;s the smallest if we count transitive dependencies! (by this I mean count the lines of code of the program, and every program you need to build the program and everything you need to build them and so on)
评论 #20266276 未加载
评论 #20266515 未加载
评论 #20272018 未加载
sittingnutalmost 6 years ago
why link to github when main repository is in savannah.gnu.org?
评论 #20268250 未加载
评论 #20268901 未加载
kjhughesalmost 6 years ago
Clickable link: <a href="https:&#x2F;&#x2F;github.com&#x2F;oriansj&#x2F;stage0&#x2F;blob&#x2F;master&#x2F;Linux%20Bootstrap&#x2F;x86&#x2F;cc_x86.M1" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;oriansj&#x2F;stage0&#x2F;blob&#x2F;master&#x2F;Linux%20Bootst...</a>