News for hackers. Stuff that matters.
Re:Using TinyCC to compile Linux (2.4) kernels by mobilio on Monday June 13, 2022 @06:41AM (#31723531)
Re:Using TinyCC to compile Linux (2.4) kernels by londons_explore on Monday June 13, 2022 @01:22PM (#31728570)
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...

Re:Using TinyCC to compile Linux (2.4) kernels by wongarsu on Monday June 13, 2022 @03:04PM (#31730100)
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)
Re:Using TinyCC to compile Linux (2.4) kernels by jesprenj on Monday June 13, 2022 @06:25PM (#31732541)
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.
Re:Using TinyCC to compile Linux (2.4) kernels by goldsteinq on Tuesday June 14, 2022 @03:45AM (#31735933)
TempleOS does this
Re:Using TinyCC to compile Linux (2.4) kernels by lionkor on Monday June 13, 2022 @09:24AM (#31725210)
Why is it so fast? 8 seconds seems awfully low for the linux kernel.
Re:Using TinyCC to compile Linux (2.4) kernels by hawski on Monday June 13, 2022 @09:50AM (#31725550)
It is a single pass compiler, that doesn't do many optimizations. Fun factoid: TCC is sort of predecessor to QEMU.
Re:Using TinyCC to compile Linux (2.4) kernels by phyrex on Monday June 13, 2022 @10:21AM (#31726012)
They’re both from the same guy
Re:Using TinyCC to compile Linux (2.4) kernels by masklinn on Monday June 13, 2022 @10:49AM (#31726374)
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.
Re:Using TinyCC to compile Linux (2.4) kernels by matthews2 on Monday June 13, 2022 @09:33AM (#31725326)
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.

Re:Using TinyCC to compile Linux (2.4) kernels by MuffinFlavored on Monday June 13, 2022 @09:35AM (#31725343)
Can TinyCC still compile the 5.x kernel without issues?
Re:Using TinyCC to compile Linux (2.4) kernels by rurban on Monday June 13, 2022 @11:27AM (#31726928)
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.
Re:Using TinyCC to compile Linux (2.4) kernels by sylware on Tuesday June 14, 2022 @06:29AM (#31736916)
you cannot, as linux code is using a lot of gcc/clang extensions stuff, namely this is some sort of C dialect, not really C. Almost at every new release of linux, "somebody" did manage to commit into its code the usage of new gcc/clang extensions.

The right(TM) way would be to port linux to simple and lean C (like some simple C89 with benign bits of c99/c11): the price is some loss of performance which could be partially mitigated with an assembly port of critical fast-paths (I guess that would show on really loaded servers only).

In the end, if RISC-V is a success, namely a world with a pertinent ISA without toxic IP tied to it (like x86/arm), then a full assembly port of linux would be more than interesting in order to rid it from compiler tantrums.

Re:Using TinyCC to compile Linux (2.4) kernels by MuffinFlavored on Thursday June 16, 2022 @01:32PM (#31768732)
> you cannot, as linux code is using a lot of gcc/clang extensions stuff

Linux 5.x kernel that is, but not Linux 4.x kernel because that was tcc-compilable?

Re:Using TinyCC to compile Linux (2.4) kernels by wrycoder on Monday June 13, 2022 @02:19PM (#31729302)
See bootstrapping.org
Re:Using TinyCC to compile Linux (2.4) kernels by chexum on Monday June 13, 2022 @02:42PM (#31729719)
Re:Using TinyCC to compile Linux (2.4) kernels by pacetherace on Monday June 13, 2022 @11:43AM (#31727142)
Thanks for making me feel old
Re:Using TinyCC to compile Linux (2.4) kernels by john-tells-all on Monday June 13, 2022 @11:31AM (#31726979)
should be flagged [2016]
Re:Using TinyCC to compile Linux (2.4) kernels by jesprenj on Monday June 13, 2022 @01:15PM (#31728477)
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.