[HN Gopher] Using TinyCC to compile Linux (2.4) kernels
       ___________________________________________________________________
        
       Using TinyCC to compile Linux (2.4) kernels
        
       Author : jesprenj
       Score  : 97 points
       Date   : 2022-06-13 09:32 UTC (13 hours ago)
        
 (HTM) web link (github.com)
 (TXT) w3m dump (github.com)
        
       | mobilio wrote:
       | Original:
       | 
       | https://bellard.org/tcc/tccboot.html
        
       | john-tells-all wrote:
       | should be flagged [2016]
        
         | jesprenj wrote:
         | You're right, sorry, I'm not yet used to the HN netiquette. I
         | did specify the kernel version in the title, because the
         | program really can't compile newer kernels. It seems I can't
         | fix the title now. Please flag the OP, after all it would be
         | better to link to the original bellard's site instead of this
         | github repository.
        
       | bumblebritches5 wrote:
        
       | lionkor wrote:
       | Why is it so fast? 8 seconds seems awfully low for the linux
       | kernel.
        
         | matthews2 wrote:
         | The version being built (2.4) is over twenty years old and had
         | much less code.
         | 
         | If you take a modern kernel (like 5.x) and build configure it
         | with 'make tinyconfig', it should build similarly quickly.
        
           | MuffinFlavored wrote:
           | Can TinyCC still compile the 5.x kernel without issues?
        
             | rurban wrote:
             | No, this is being worked in. The goal should be a -Oboring
             | optimizer without any broken optimizations and aggressive
             | UB assumptions. Something neither gcc nor clang can
             | provide.
        
             | wrycoder wrote:
             | See bootstrapping.org
        
               | chexum wrote:
               | http://bootstrappable.org perhaps?
        
           | pacetherace wrote:
           | Thanks for making me feel old
        
         | hawski wrote:
         | It is a single pass compiler, that doesn't do many
         | optimizations. Fun factoid: TCC is sort of predecessor to QEMU.
        
           | phyrex wrote:
           | They're both from the same guy
        
             | masklinn wrote:
             | Yes, but beyond that qemu was pretty much fabrice
             | nerdsniping himself: he initially wanted to make the tcc
             | backend more flexible (to support other targets than x86),
             | then started playing with making the _frontend_ more
             | flexible, at one point he started to make the frontend take
             | in compiled machine code, and that 's the starting point of
             | qemu: a dynamic recompiler / machine code translator,
             | rather than a traditional emulator.
        
       | londons_explore wrote:
       | You could take this one step further and have some magic
       | filesystem filter such that all binaries are compiled before use.
       | Ie. your hard disk would contain no executable code, only source
       | code.
       | 
       | It sounds slow, but it needn't be if you have the right caching
       | in place. Binaries could even be recompiled with better/slower
       | compilers as needed to give better performance too.
       | 
       | Now I think about it it isn't so different from the android/java
       | model of shipping applications as bytecode...
        
         | jesprenj wrote:
         | tcc has a -run option argument which executes the binary after
         | creating it as a temporary file. This way tcc -run can be
         | specified in the shebang and you can execute c code like a
         | script, which is outright amazing.
        
         | wongarsu wrote:
         | I guess that's the logical extreme of what Gentoo is doing,
         | just without the speed benefits (since the compiler is under
         | time pressure and thus won't do a great job). Maybe if you
         | combine it with profile guided optimization? (Yes, this is
         | basically reinventing Java/.NET)
        
       ___________________________________________________________________
       (page generated 2022-06-13 23:01 UTC)