7 ms·
I hate compilers
- charcircuit 4mo agoAs 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 4mo agoWe'd like to verify, not trust.
- charcircuit 4mo agoThe whole point of a signature is that you are able to verify what was signed was in fact a message that was signed by signer.
- robinsonb5 4mo agoSure, but a signature doesn't prove that a particular binary came from a particular codebase - merely that a particular human (or other trusted entity, for varying degrees of "trusted") has vouched for it. Being able to reproduce the binary from the source code and being able to verify that it's the same as the original is quite important in some contexts.
- charcircuit 4mo ago>Being able to reproduce the binary from the source code and being able to verify that it's the same as the original is quite important in some contexts. I disagree. The contexts that people come up with are purely theoretical, and are not practically important. Please do try and convince me otherwise by sharing such a context. From my view the juice of trying to accomplish this is no where worth the squeeze.
- harrouet 4mo agoYou disagree but you're wrong. Military context: a government would want to review the code and compile themselves. Provide a hash of the target binary to ensure they've compiled it correctly. SDLC: provide auditors with _proof_ that the tested binary is indeed coming from the audited code
- skydhash 4mo agoMilitary Context: Just build the code that you just reviewed. No need to get the binaries SDLC: Traceability is more important than reproducibility. Keeping logs is more important than deterministic build outputs
- charcircuit 4mo ago>a government would want to review the code and compile themselves. Provide a hash of the target binary to ensure they've compiled it correctly. The government doesn't want to do this. A lot of the time the government doesn't even get the source code in the first place. >provide auditors with _proof_ that the tested binary is indeed coming from the audited code This can be done by showing to the auditor how one's CI is setup to build checked in code and sign it.
- skydhash 4mo ago> Being able to reproduce the binary from the source code and being able to verify that it's the same as the original is quite important in some contexts Why not build your own binaries and be done with that. If you don’t trust the compiler or the machine doing the build, just build the code yourself.
- robinsonb5 4mo agoSure, I can do that, but there's some value in being able to check quickly and easily that, for example, the xz utils binaries shipped by a major distro actually match the published source. Also useful for checking that a binary containing GPLed code does actually correspond to its published source.
- skydhash 4mo agoThe capability may be nice to have, but what about its usefulness. Would that have been of use in any real world situation?
- dyauspitr 4mo agoLLMs should be trained on and directly output binary.
- klodolph 4mo agoOn 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.
- faangguyindia 4mo agoWhat about AOT optimization? whuch brings aot closer to JITs performance? Isn't that something LLM + Harness can easily do?
- klodolph 4mo agoI 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.
- jenadine 4mo 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 4mo 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.
- mathisfun123 4mo ago[flagged]
- xena 4mo agoTell me the flags I'm missing then: https://github.com/TecharoHQ/anubis/blob/Xe/wasm4/utils/wasm/wasm2js/build.sh https://github.com/TecharoHQ/anubis/blob/Xe/wasm4/utils/wasm...
- heavensteeth 4mo agoI'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.
- LPisGood 4mo agoRe: source code producing different binaries: things like ASLR, stack canaries, optimization levels, linking, etc all lead to different binaries.
- yjftsjthsd-h 4mo 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.
- ComputerGuru 4mo agoThese 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!
- zeratax 4mo ago> Clang relies on address layout for ordering things I would consider that a bug tbh
- StilesCrisis 4mo agoIf reproducible builds is a stated goal for Clang? I'm not sure that it is. If so, absolutely a bug.
- ammar2 4mo agoNot sure if it's a stated goal somewhere official but there's been plenty of fixes of the years moving stuff to be deterministic, e.g https://github.com/llvm/llvm-project/commit/cdbde3aacc1260a72d49b9aa7271b4bbec694e83 https://github.com/llvm/llvm-project/commit/cdbde3aacc1260a7... The internal programming guide also says which collections to use for deterministic iteration order: https://llvm.org/docs/ProgrammersManual.html#llvm-adt-setvector-h https://llvm.org/docs/ProgrammersManual.html#llvm-adt-setvec... So definitely a bug here.
- j2kun 4mo agoWhat is kind of annoying is that the author jumps to "I hate compilers" instead of "I will report/help fix this bug upstream."
- chiyc 4mo agoI don't get the sense they hate compilers at all. The writing describes work they seem to love doing. It's just clickbait. And it may not have crossed their mind that the clang behavior is a bug after finding a workaround. I'd also assume compilers do things "no mere mortal can fully comprehend on their own".
- jdw64 4mo agoReading 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.
- jstimpfle 4mo agoDepends on what you mean by low level I guess. Compared to web application framework churn rate, simple procedural programming without many dependencies is remarkably stable. You tend to program in a way that works for most platforms (all targetted platforms). How to best do that you learn over the years. To me personally it's very refreshing if the environment around you does not constantly change. That affords learning a bag of tricks and a list of gotchas to avoid.
- jdw64 4mo agoI think you're right too. So I also think that maybe I'm viewing the changes as bigger than they actually are, based on my own standards
- embedding-shape 4mo ago> You tend to program in a way that works for most platforms (all targetted platforms). Isn't that true for web frameworks too? Usually they'll only target unix, but if they target windows and macos, then they work on those platforms too? Or am I misunderstanding what you're trying to say here?
- pertymcpert 4mo agoIf 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 4mo agoI'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?
- amatria 4mo agocvise. 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#issuecomment-2597596068 https://github.com/llvm/llvm-project/issues/108827#issuecomm...
- xena 4mo agoThank you, this will be very useful.
- glandium 4mo agoClaude code is actually rather good at this. If your initial testcase is not too big, you can use creduce or cvise.
- xena 4mo agoSadly my initial test case is binaryen which has 290 compilation units. I will try though.
- deleted 4mo ago[deleted]
- frwrfwrfeefwf 4mo ago[dead]
- biglost 4mo agoTime date env variables and random address... Is also input data, maybe not as a flag but still
- RyanSquared 4mo agoTime 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.
- xiphias2 4mo agoASLR is important, but you should be able to provide the random seed (I don't know if it's possible or not)
- yjftsjthsd-h 4mo agoExplicit is Better than Implicit.
- crvdgc 4mo agoNix 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.
- stabbles 4mo agoNix hashes the build inputs, for which deterministic builds are not required, only desirable.
- lloeki 4mo agoSOURCE_DATE_EPOCH is not a Nix thing https://reproducible-builds.org/docs/source-date-epoch/ https://reproducible-builds.org/docs/source-date-epoch/ (although Nix sets it as a default)
- mplanchard 4mo agoYes, reading this I was thinking about how many of these problems go away with a nix environment. Certainly not all of them, but it’s a great way to get a reproducible build environment that includes direct specification of system dependencies.
- swiftcoder 4mo agoThe Birth and Death of Javascript really had the gift of prophecy, eh
- neocron 4mo agoWas that the thing where Gary predicted js in the kernel?
- swiftcoder 4mo agoyes, although more directly relevant here, chrome-compiled-to-wasm-nested-in-chrome
- yencabulator 4mo agoFirefox's font rendering is sandboxed by being C/C++-compiled-to-wasm-then-aot-compiled-to-native-code. Yavascript is dead, all hail WASM. https://hacks.mozilla.org/2020/02/securing-firefox-with-webassembly/ https://hacks.mozilla.org/2020/02/securing-firefox-with-weba...
- SSLy 4mo agobpf isn't a far stretch from that
- frollogaston 4mo agoHow about hardware accelerators to interpret JS? At least it wouldn't break, cause modern JS all transpiles to the old one.
- sylware 4mo agoTo avoid all those grotesque and absurd compilers and runtimes, more for those of computer languages with a ultra-complex syntax (c++ and similar), I now design "binary specifications" which I "design" and "validate" with RISC-V assembly coding. Here, since any whatwg cartel web engine is an issue, the author should not bother.
- Animats 4mo agoI hate proof of work code running on my machine for the benefit of someone else. It's like planting a crypto miner.
- account42 4mo agoYes, all these kind of bot checks are essentially malware.
- tengwar2 4mo agoYup, and I suspect that even if OP is honest in this respect, if proof-of-work gets established as a normal practice for web pages, it's going to be used this way. But just taking this as-is, what is the environmental impact likely to be when multiplied up by the number of users? Proof of work is a bad idea.
- ctrlmeta 4mo agoDo proof-of-work pages actually stop AI bots? Big AI companies have enough compute to solve these challenges at scale. And if their bots are already doing much heavier work to fetch, read and process each page, then solving a small challenge first seems unlikely to be a serious barrier. Who are these proof-of-work challenges actually helping?
- titularcomment 4mo agoI believe poisonous loops of non-sense text are the best choice in terms of LLM capabilities and human distinguishing potential; the next iteration could be non-sense with reasonably intact grammar and content. At the very least, show some content whilst doing the PoW (isn't the point rising computational costs? Give me something like YouTube video decryption instead of having me wait at least) OR use the PoW for some useful protein-folding, finding the next prime, or an alternative monetization scheme.
- xena 4mo agoAnubis does this: https://anubis.techaro.lol/docs/admin/honeypot/overview https://anubis.techaro.lol/docs/admin/honeypot/overview Getting in the maze influences your client's challenge difficulty.
- znpy 4mo ago> What do you do when the client has WebAssembly disabled? > I decided to take inspiration from the legendary talk The Birth and Death of JavaScript and just recompile the WebAssembly to JavaScript. So what do you do when the client has Javascript disabled ?
- zeratax 4mo agohttps://anubis.techaro.lol/docs/admin/configuration/challenges/metarefresh/ https://anubis.techaro.lol/docs/admin/configuration/challeng...
- ekjhgkejhgk 4mo ago[flagged]
- dang 4mo agoCould you please stop posting unsubstantive comments and flamebait? You've unfortunately been doing it repeatedly. It's not what this site is for, and destroys what it is for. If you wouldn't mind reviewing https://news.ycombinator.com/newsguidelines.html https://news.ycombinator.com/newsguidelines.html and taking the intended spirit of the site more to heart, we'd be grateful.
- evmar 4mo agoA better solution might be to use https://github.com/evanw/polywasm https://github.com/evanw/polywasm to run the original wasm in place.
- xena 4mo agoI tried doing that at first. I kept running into edge cases that made the whole thing fall to ribbons. I gave up and am just falling back to what I know works: compiling the WASM to JS.
- inigyou 4mo agoBetter title: Reproducible builds are hard
- arikrahman 4mo agoUnless you use a flake or the project has a flake.nix
- yencabulator 4mo agoThere is nothing in Nix that magically makes concurrent builds with completion-order-dependent outputs come out deterministic.
- menaerus 4mo agoI never tackled the reproducible builds topic but this is also something I had in mind while having a thought about it. Building object files for translation units, apart from macros introducing variance, should be reproducible no matter how high the number of compile jobs is running. So, isn't this largely a linking stage problem?
- yencabulator 4mo agoI would assume that compilers these days are likely to have internal parallelism too.
- menaerus 4mo agoThey do but the order of compiling the object files does not matter, at least not in C or C++ compilation model.
- arikrahman 4mo agoAs someone else stated the order of compiling the object files does not matter, at least not in C or C++ compilation model. I am responsible for packaging Jank with nixpkgs, where a Clojure dialect hits the raw machine. This is done with custom LLVM implementation, but I am also working on building Jank with Zig to take advantage of its pipeline. I am being downvoted and condescended to downplaying with claims of magic while working on the frontier of PL's.
- randusername 4mo agoI've seen posts by this author before and did not understand if the commentary characters were referential or a creation of the author. Turns out its the latter. I dismissed the underlined names as just styling, not hyperlinks. https://xeiaso.net/characters/ https://xeiaso.net/characters/
- antirez 4mo agoSo to avoid those energy-hungry LLM companies from scraping your website, you force each browser to compute a lot of hashes in a necessarily energy-hungry loop, creating, at the same time, all the kind of accessibility problems?
- hootz 4mo agoNot just LLM companies, but bots in general. They were a big problem even before LLMs.
- ericpauley 4mo agoI don’t get how people believe there’s a PoW function that both: 1. Allows access in reasonable time/battery use to me on my phone 2. Poses any meaningful challenge to the most compute-resourced organizations on the planet I wonder how many cumulative hours of human life have been wasted waiting on Anubis.
- deleted 4mo ago[deleted]
- lifthrasiir 4mo agoThe vast majority of that compute is locked in AI accelerators that do the inference. Those hardwares are bad at doing anything other than that---in fact crawlers would need more residential proxies than more computes in that regard.
- grayhatter 4mo ago> I wonder how many cumulative hours of human life have been wasted waiting on writing comments on creamsicle reddit. I disagree with a lot of the decisions around the design of Anubis... but resisting the current drive of the industry to ruin as much of the good faith resource donations from others is an admirable objective. The point isn't to increase the amount of work required to the point of exhaustion, it's to require that scripts be able to offer the exact same feature set that browsers offer. The point isn't to make it impossible, it's too make it more expensive than free. Anubis isn't trying to prevent all scraping, it's trying to reduce the abuse just enough that real requests get their fair share. You don't need to outcompute the botnet just slow them down a little. I hate seeing the Anubis interstitial too, I've complained about it publicly already too. But it doesn't come close to the frustration of waiting 10s for an SPA to load all of the routes it'll never use before the first redraw. Clearly our industry has also decided latency is a good thing.
- edude03 4mo agoCould have sworn the author was a nix(os) user already. I know it’s a meme but what all the problems they’re describing literally is solved by nix. The nix sandbox even catches calls for time for example to replace it with 0 for determinism.
- arikrahman 4mo agoThis was my first thought, use a declarative system like Nix.
- trexd 4mo agoThey stopped using Nix due to disagreements with how the project was run. https://xeiaso.net/blog/2024/much-ado-about-nothing/ https://xeiaso.net/blog/2024/much-ado-about-nothing/
- xena 4mo agoNix doesn't help when the issue is a compiler bug, sadly.
- drunner 4mo agoFrom what I gather you fear determinate systems will guide future Nixos dev like google steers chromium or am I way off base?
- arikrahman 4mo agoWhat about Guix? May be more their tempo.
- tetromino_ 4mo agoWeird article. The author is clearly heart-broken about some changes in how Nixos is managed - but what those changes were and why the author dislikes them is left completely unclear. The link to the Determinate blogpost doesn't clarify anything. I guess it might make sense to Nixos insiders...
- KolmogorovComp 4mo agoI’m still surprised by Anubis’ decision not to make the PoW have a useful output, for example a crypto, protein-folding like, or something else. And I speak as being generally very critical of cryptos, but here rewarding the website owner with some cents to have access seems fair, and resolves the traditional issues about micro-payments.
- xena 4mo agoPatches welcome. I'd love to do protein folding too.
- KolmogorovComp 4mo agowhat about something (crypto being the only idea I have) that could be leveraged to reward the website owner?
- xena 4mo agoAnubis is not a cryptocurrency miner: https://anubis.techaro.lol/docs/user/frequently-asked-questions#does-anubis-mine-bitcoin https://anubis.techaro.lol/docs/user/frequently-asked-questi...
- KolmogorovComp 4mo agoit does not answer if it's a conscious design choice or just a technical limitation of the PoW, or just a "patch welcome" issue.
- xena 4mo agoIt's a conscious design choice. Doing that gets you considered a botnet/malware. I don't want Anubis to be considered a botnet/malware.
- KolmogorovComp 4mo ago
- j16sdiz 4mo ago> What do you do when the client has WebAssembly disabled? Do people really do that? -- disable, not just using old browsers with no wasm. Disabling wasm while keeping js enabled is a configuration i can't understand
- pohl 4mo agoIt’s easy to imagine an organization with a paranoid security posture ending up with that configuration because they decided to only enable a minimum necessary feature set where they determined that JS was necessary while WASM was not.
- xena 4mo agoiOS Lockdown Mode also implements this configuration.
- lisper 4mo ago> There are a shocking number of ways to accidentally create nondeterministic output when doing C/C++ development. One of the easiest is to use the builtin __DATE__ and __TIME__ macros to stamp a build with the time the compiler was executed at: Am I missing something here? Yes, if you use a feature that intentionally inserts the build time and date into the code, the every build is going to be different. That's the whole point of these macros. It's a feature. If you don't want that behavior, don't use that feature.
- xena 4mo agoSurprisingly, cherry-picked examples to prove a point are cherry-picked examples to prove a point.
- fasterthanlime 4mo agoI think the intentional part is that you want to print the date and time something's been compiled, and the accidental part is that you suddenly made your build non-reproducible. But usually the realization follows the initial intent by several weeks, if not months! Your comment shines as the embodiment of hindsight is 20/20.
- lisper 4mo ago> the accidental part is that you suddenly made your build non-reproducible But that's exactly what I don't get. How can that be considered "accidental"? How can any thinking person not realize that putting the build time into the compiled image will make every build different because, you know, different builds happen at different times? Has software engineering really been dumbed down so much that this is not immediately obvious? It feels like a mechanic doing an oil change and being surprised by having all the oil drain out if they neglect to put the drain plug back in.
- Neywiny 4mo agoWith you on this especially because somebody I know asked me to help change their oil and they hadn't even considered there being waste oil to dispose of
- 3dedb728-3f77 4mo ago[flagged]
- childintime 4mo agoI hate compilers too, just because in theory they are the simplest type of program: transform one file into another. How is not be reproducible? You need to make an effort! Yet the author of this post has trouble getting a reproducible build. To me it sums up the utter insanity our industry is engaged in.
- MaskRay 4mo agoGetProgramPath consulting PATH is a pretty standard behavior inspired by GCC. Clang driver may find an external program from its program paths (e.g. -ccc-install-dir, the GCC installation's bin directory, -B, ) and then PATH. > Clang relies on address layout for ordering things Every such instance is a bug. I have fixed many issues in 2023. There is even an upstream build bot https://discourse.llvm.org/t/reverse-iteration-bots/72224 https://discourse.llvm.org/t/reverse-iteration-bots/72224
- juancn 4mo agoEverything is within spec, reproducible builds are not a goal of C/C++. The compiler builders may take pity on you, but really there's no bug here, just unwarranted expectations.