I Hate Compilers(xeiaso.net)
44 points by xena 1 hour ago | 9 comments
crvdgc 12 minutes ago
Nix also needs the build output to be deterministic to calculate the hash. It also has the problems of timestamps etc. The build environment tries to be hermetic by setting the time to be epoch among other things.
swiftcoder 8 minutes ago
The Birth and Death of Javascript really had the gift of prophecy, eh
ComputerGuru 53 minutes ago
These seem very reasonable, the workarounds used are natural, and overall the article is not at all congruous with the conclusion in the (clickbait?) title?

Compilers literally made your project possible!

jdw64 48 minutes ago
Reading this, I think low level engineering is actually more dependent on specific environments. Hardware also has its own points of change. Usually, when you think at a high level, environmental changes are less significant than you might expect. But low level thinking tends to be tied to specific environments, which is what makes it difficult. The reason low level is hard is that even if the code itself is short, the hidden assumptions inside it are difficult and place a heavy cognitive load on the programmer. For example, even a short snippet in C like `int value = (int)buffer` requires a lot of implicit knowledge about the 4 byte alignment of the buffer, or whether int is exactly 32 bits. LLMs do not seem to be very good at knowing these things. Rather, they are strong at high level wrapping, but at the low level, they seem surprisingly difficult and somewhat useless. Hardware has CPU generation changes, and in the case of PLCs, where I mainly work, the protocol differences between vendors are far too severe. There does not seem to be any technology with a very long lifecycle.
biglost 38 minutes ago
Time date env variables and random address... Is also input data, maybe not as a flag but still
RyanSquared 23 minutes ago
Time and date are... tolerable. There's SOURCE_DATE_EPOCH which should always be set to whack it into submission when used. ASLR of the _compiler being invoked_ resulting in a difference in the _program being compiled_ is nuts and would break any self-hosting compiler with consistency checks.
yjftsjthsd-h 5 minutes ago
Explicit is Better than Implicit.
pertymcpert 47 minutes ago
If Clang generated non-deterministic output due to pointer addresses then that's a bug (happens regularly) that should be fixed. The most common way this happens if it some code path is iterating over a DenseMap which is non-deterministic. Sometimes that's fine and sometimes that's not depending on how that map is used. The common way to fix that is to switch to a MapVector which pays some additional runtime/memory cost to guarantee deterministic iteration order.
xena 40 minutes ago
I'll try and make a minimal reproduction case and file a bug. Do you know if any tooling that can take a binary and fuzz it down to a minimal reproduction set?
glandium 5 minutes ago
Claude code is actually rather good at this. If your initial testcase is not too big, you can use creduce or cvise.
amatria 11 minutes ago
cvise. Here is a link to a mini tutorial I wrote for a user in an LLVM issue: https://github.com/llvm/llvm-project/issues/108827#issuecomm...
mathisfun123 1 hour ago
> lol you'd think, but no, it's not. In theory it is (and for small scale compilers it definitely is), but in practice compilers are strange and complicated beasts containing multitudes that no mere mortal can fully comprehend on their own.

Umm there are like 60,000 lit tests checked into LLVM that verify that the output is absolutely a deterministic function of the input of at least that compiler.

> Even though the source code had the same bytes, the output of the compiler was wildly different.

This is the goofiest I've seen written unironically in quite a long - the C preprocessor is not part of the compiler. The pre in preprocessor should probably give it away.

Just a tip: you should probably actually understand something before you decide you hate it.

xena 1 hour ago
heavensteeth 48 minutes ago
I'm surprised by the amount of heckling this post received almost immediately! And a lack of constructive input.

I for one enjoyed the article and understand what you're getting at.

yjftsjthsd-h 7 minutes ago
> This is the goofiest I've seen written unironically in quite a long - the C preprocessor is not part of the compiler. The pre in preprocessor should probably give it away.

This is true but doesn't seem relevant; does replacing the word "compiler" with "build chain" change anything? Because that seems like the clear meaning.

LPisGood 42 minutes ago
Re: source code producing different binaries: things like ASLR, stack canaries, optimization levels, linking, etc all lead to different binaries.
charcircuit 1 hour ago
As long as the program is equivalent there isn't an actual problem here. Requiring the output to always be the same is an arbitrary restriction.

If you want to have users trust that someone else hasn't modified it, then sign it with your identity.

yjftsjthsd-h 6 minutes ago
We'd like to verify, not trust.
dyauspitr 1 hour ago
LLMs should be trained on and directly output binary.
klodolph 1 hour ago
On the off chance that you’re serious, that would result in disastrously bad output. The difference between “jmp $+15” and “jmp $+16” is inscrutable and the LLM would not be able to pick the right one without tooling.

That tooling is a compiler. The higher level, the better chance the LLM can be steered to good output. Machine code is hopeless, don’t bother.

jenadine 57 minutes ago
> The difference between “jmp $+15” and “jmp $+16” is inscrutable

I don't see why that's the case. LLM trained on binary would totally see it, not?

Also the tool can also be running the test and a debugger.

klodolph 43 minutes ago
> I don't see why that's the case. LLM trained on binary would totally see it, not?

It would not. You find the correct version by counting the number of bytes to the destination. LLMs are famously bad at this kind of problem (counting).

> Also the tool can also be running the test and a debugger.

The test needs to provide a good amount of signal. That’s too hard if you are throwing machine code at the wall.

In order for debuggers to work, you need some kind of model that describes what the code should do and what state the computer should be in after each instruction. That model is high-level code.

I can understand the intuitive appeal of training LLMs with machine code, but all of my experience with LLMs suggest that they are incredibly ill-suited to the task, and we just don’t have the capacity to train them to make useful machine code.

zx8080 29 minutes ago
Can "LLMs are bad at counting" be generalized to "LLM are better in complex stuff but make more mistakes in simple"?
ozlikethewizard 18 minutes ago
Its more LLMs are better at vague problems with multiple non perfect solutions, and struggle at problems that require precision.
klodolph 20 minutes ago
No, I don’t think so. LLMs are good at a lot of simple tasks, but bad at certain simple tasks. Moravec’s paradox in a new iteration.

It applies to humans too. Calculus is “simple” but it takes something like sixteen years to train a human to do it, if all goes well. Meanwhile, most humans think that inverse kinematics is, like, the easiest thing in the world (it’s a super complicated task).

fluoridation 16 minutes ago
I would phrase it as "LLMs are good at big picture stuff and bad at fine detail", or to put it another way, they're accurate, but imprecise and with low reproducibility.
pjmlp 56 minutes ago
That compiler does wonders with languages that have UB on their specs, especially when having optimizations passes with heuristics.

Also there are dynamic compilers were the shape of machine code changes as the code executes, and each single execution will certainly generate different sequences, depending on the program execution and where it is running.

Deterministic JIT compiler code generation, at least on optimising ones, is not a solved problem.

faangguyindia 1 hour ago
What about AOT optimization? whuch brings aot closer to JITs performance? Isn't that something LLM + Harness can easily do?
klodolph 39 minutes ago
I think the idea that AOT is inherently faster than JIT, or vice versa, is a thoroughly debunked idea.

You can have LLMs help you optimize code but I don’t think you can do this unattended for non-trivial code.

xiaoyu2006 1 hour ago
It should not. Abstraction in software engineering brings intelligence. (compression correlates to intelligence)
shshshjaja 51 minutes ago
runApp()

Done! Excellent abstraction. High intelligence.

frwrfwrfeefwf 44 minutes ago
people don't get this
dyauspitr 54 minutes ago
Why? I mean this is all emergent, right? And it’s not like humans ever work at this level. It would be very interesting to see what sort of outputs and abstractions an LLM comes up with.
bandrami 41 minutes ago
Generative algorithms have been studied for decades now and while they have led to some interesting results they're a bad fit for LLMs because there's no such thing as a "plausible" binary: a small perturbation yields an unusable result.
fulafel 28 minutes ago
Technically they are, just a subset. But still a practical one, they're frequently used to produce executable files.
wahnfrieden 50 minutes ago
What other recent Musk talking points do you like to repeat?
rvz 58 minutes ago
I think you forgot the "/s"