News for hackers. Stuff that matters.
Re:Backblaze restore for Personal Backup is awful by dataflow on Sunday December 12, 2021 @05:54PM (#29534547)
Eh, even Clang does this. Install it on Windows and you'll get clang-cl.exe, clang++.exe, clang-cpp.exe, and clang.exe, all 90 MB executables, and almost entirely the same executables, but not bit-for-bit identical, so you can't hardlink them. I actually hate this too, but my point is it doesn't necessarily say much about software quality.
Re:Backblaze restore for Personal Backup is awful by meinersbur on Sunday December 12, 2021 @08:34PM (#29535584)
They are identical copies of each other. Since symlink support is not universal on Windows (Possible since around the time WSL was introduced, but still requires either special privileges or developer mode enabled), many tools including GNU autotools fall back to copying. Since recently (https://reviews.llvm.org/D99170), LLVM et least tries to create a symlink on Windows, but still caused problems because this is kind of unexpected by Windows. The NSIS installer used by the official Windows installer (https://llvm.org/builds/) does not support symlinks at all such that the installer includes 4 identical copies of Clang.

A clean solution would be to have stub executables that link to a central libClang.dll/libLLVM.dll (-DCLANG_LINK_CLANG_DYLIB=ON), but this is not supported under Windows because a DLL can export at most 2^16 symbols. Some work would need to be invested to make process launching on Windows work differently than on other platforms, but then disk space is not that much of a problem.

Re:Backblaze restore for Personal Backup is awful by dataflow on Sunday December 12, 2021 @09:21PM (#29535852)
The Clangs are different from each other in some installations, and identical in others. In particular the Visual Studio installation doesn't have identical binaries, but the MSYS2 installation does. You'll have to check yours. For example, if you dir "%ProgramFiles%\Microsoft Visual Studio\2022\Community\VC\Tools\Llvm\bin\clang*.exe" you'll see they're slightly different sizes.

(Also note that in this case you don't need symlinks per se, just identical binaries with hardlinks. Each executable could inspect argv[0] and figure out what it's invoked as, and behave accordingly.)

What I don't understand is why can't they just bundle everything into a single DLL, then make whatever stub executables they want just call the exported main() in that DLL. I think that might be what MSYS2's copy already does, though I haven't checked. That DLL wouldn't need to export anything else, just the main() function that each .exe stub would forward to. And it can handle everything else internally if it so desires.

Re:Backblaze restore for Personal Backup is awful by cma on Sunday December 12, 2021 @11:49PM (#29536735)
Different sizes doesn't always mean different sizes (I'm not sure if that is completely true using 'dir'): https://superuser.com/questions/1353064/why-does-size-on-dis...
Re:Backblaze restore for Personal Backup is awful by dataflow on Sunday December 12, 2021 @11:52PM (#29536756)
I'm well aware of all the nuances but I assure you the files are different here.
Re:Backblaze restore for Personal Backup is awful by iggldiggl on Monday December 13, 2021 @05:51AM (#29538459)
> Since symlink support is not universal on Windows (Possible since around the time WSL was introduced, but still requires either special privileges or developer mode enabled)

Symlinks have been supported since Vista, though by default creating a symlink does indeed require Admin rights. Hardlinks can be created by anybody and are extensively used by Windows itself.

Re:Backblaze restore for Personal Backup is awful by brianwski on Tuesday December 14, 2021 @09:25PM (#29561300)
> Symlinks have been supported since Vista

I'm not aware of even Windows 10 or Windows 11 being able to create Symlinks on FAT32 and exFAT, but I could be wrong? But it doesn't matter, the code as written is cross platform, it works on Apple Journaled File Systems, APFS, exFAT, etc. We then compile it for Macintosh, compile it for Windows, and compile it for Linux.

We can then spend extra time and carefully detect each filesystem and each platform and then make the optimization if we can. And this is a valid criticism that we have not done this yet. But no matter what we need this general code that will always work FIRST, what the links are is a space optimization to save valuable SSD space when it is possible.

Re:Backblaze restore for Personal Backup is awful by jfrunyon on Sunday December 12, 2021 @06:46PM (#29534911)
But these are bit-for-bit identical.
Re:Backblaze restore for Personal Backup is awful by awinter-py on Sunday December 12, 2021 @07:15PM (#29535142)
maybe they're not identical but backblaze has discovered 20 hash collisions that are also valid executables? that would be impressive in a way
Re:Backblaze restore for Personal Backup is awful by selcuka on Sunday December 12, 2021 @08:35PM (#29535589)
Bit-for-bit identical means that they are actually identical though.
Re:Backblaze restore for Personal Backup is awful by dataflow on Sunday December 12, 2021 @06:50PM (#29534939)
Edit: You're talking about the Backblaze binaries? Yeah that's why I said Clang's is almost bit-for-bit identical, so it's clear to everyone it's not 100% the same as the Backblaze situation. Not sure what your complaint is about my comment though? It's still practically the same problem, and you can solve it just as well with the argv[0] tricks or whatever.

Or are you saying your heuristic for determining the underlying engineering quality changes its output based on 1 bit flip? Identical executables is awful engineering, but a few bytes different (out of 90MB) is great engineering?

Re:Backblaze restore for Personal Backup is awful by jfrunyon on Sunday December 12, 2021 @07:07PM (#29535076)
Not sure why you think clang having multiple not-identical executables is relevant to Backblaze having multiple identical executables.
Re:Backblaze restore for Personal Backup is awful by dataflow on Sunday December 12, 2021 @07:13PM (#29535118)
> Not sure why you think clang having multiple not-identical executables is relevant to Backblaze having multiple identical executables.

Really? You genuinely don't see why I would think a case with >99.99% identical executables might be relevant to a case with 100% identical executables?

Re:Backblaze restore for Personal Backup is awful by 300bps on Sunday December 12, 2021 @07:30PM (#29535237)
I genuinely don’t see why either.

With 100% identical executables, there does not appear to be a good reason to have multiple copies under any circumstance.

With anything < 100% identical, well, maybe there’s a good reason to have multiples. Who knows? Id probably give someone the benefit of the doubt and figure there was some engineering challenge that made it faster/easier to do it that way.

So yes, 100% identical is completely different than almost 100% identical.

Re:Backblaze restore for Personal Backup is awful by comex on Sunday December 12, 2021 @07:47PM (#29535337)
There is a reason: the majority of the file size comes from statically linked LLVM libraries.

You can instead configure LLVM’s build system to build a single dynamic library and have the tools link to it, and this eliminates all of the duplication. However, it apparently comes with a “substantial performance penalty” [1] due to the nature of dynamic linking. (This actually surprises me, and I wonder whether it’s only referring to the inability to do LTO, or whether even LTO-less static linking is faster. Aside from the startup time issue.)

A theoretical alternative would be to build all of the tools into a single executable, à la Busybox, where the combined executable would inspect argv[0] to figure out which tool’s code should be run. That way you could statically link the LLVM libraries without duplicating them in multiple executables. LLVM’s build system does not support this. I think it would be nice if it did, but it would be nontrivial to implement.

[1] https://llvm.org/docs/BuildingADistribution.html

Re:Backblaze restore for Personal Backup is awful by dataflow on Sunday December 12, 2021 @08:03PM (#29535419)
> (This actually surprises me, and I wonder whether it’s only referring to the inability to do LTO, or whether even LTO-less static linking is faster.)

I think the latter is also the case (though to a much lesser extent) on x64. One of the unfortunate features of x64 is it lacks direct 64-bit jumps, so every jump to an external library ends up being an indirect call. (In fact, with a potential memory load on top of that.) This was kind of surprising for me when I learned it too; it doesn't apply to x86.

Re:Backblaze restore for Personal Backup is awful by dataflow on Sunday December 12, 2021 @07:35PM (#29535257)
> So yes, 100% identical is completely different than almost 100% identical.

They're completely (!) different? And you're saying this despite the fact that the comment I replied to was discussing cases where one could "just execute one binary n times (with different argv[0] if they'd like)"... which is something you can do with different executables just as well as with identical ones? It's not just a little different but completely different? So different that not only you don't see any similarity, but you also cannot fathom why I might think there's some similarity?!

Re:Backblaze restore for Personal Backup is awful by dang on Sunday December 12, 2021 @08:12PM (#29535477)
Would you please stop posting in the flamewar style to HN? It's not what this site is for, and it destroys what it is for. We've had to ask you about this more than once in the past already. If you wouldn't mind reviewing https://news.ycombinator.com/newsguidelines.html and taking the intended spirit of the site more to heart, we'd be grateful.
Re:Backblaze restore for Personal Backup is awful by dataflow on Sunday December 12, 2021 @08:34PM (#29535586)
Apologies, but I still don't know how to respond in a situation like this. Can I ask how you would respond to this case yourself? I hope you can at least see why I found it difficult to swallow when people shut down my comment telling me there's zero similarity between a 99.99% case and a 100% case. It seems needlessly hyperbolic to me at best, and quite obviously frustrating. Looking back, I almost feel like it baited me into this. How do you see this from your standpoint? Does it feel like a good-faith comment to you that they can't tell why I would see 99.99% and 100% as similar?
Re:Backblaze restore for Personal Backup is awful by 300bps on Monday December 13, 2021 @07:58AM (#29539131)
I hope I can answer that for you. The core issue is that you are taking the original point out of context and kind of robotically parsing snippets.

Context is important. For example, chimpanzee DNA is 99% identical to human DNA. Without context you could make the argument, “They are almost identical!” and be correct. But in the context of discussing the ability to fly to the moon and return safely, the two genomes are completely different.

Re:Backblaze restore for Personal Backup is awful by dataflow on Monday December 13, 2021 @01:52PM (#29542924)
I appreciate the reply. I don't understand what context you believe I was missing? The analogy is incredibly confusing to me too, because humans are more than their DNA: you obviously can't hardlink humans, nor could you replace them with stubs that call some "common" humans, it's not like the obstacle to doing these goes away even with 100% equal DNA vs. 99%.

But with computer code, you very much can (for example) easily replace all the executables with a combined one that gets hardlinked with different names, such that they behave differently depending on argv[0]. They don't even need to be 100% identical for us to be able to do this; it works just as well with 1% identical code—you just end up with bigger combined binaries. This is the Busybox approach (notice it combines executables that have hardly anything in common), and it's in fact exactly what Clang already sometimes does (like on MSYS2); one would think they could take the same approach here. This is also precisely the context of the comment I replied to was saying, right? This is the context I was replying to. It's so confusing to me that you claim I'm missing context when I was in fact addressing the context I saw directly—and it was the other comments that were not.

Re:Backblaze restore for Personal Backup is awful by notthathardbro on Sunday December 12, 2021 @07:45PM (#29535325)
No, actually. And your incredulous doubling-down is, well, making it more obvious that you seem to be missing the point.

If they're 99% the same, it's generously easy to assume that there's a material difference. That assumption is completely nonsensical if they're 100% identical.

So no, for the sake of every bit of context in this conversation, it does not make sense that you'd bring up an unrelated scenario of "similar" binaries.

Re:Backblaze restore for Personal Backup is awful by somehnguy on Sunday December 12, 2021 @06:58PM (#29534995)
The 'these' being referenced here are the Backblaze executables, not your clang executables.
Re:Backblaze restore for Personal Backup is awful by monsieurbanana on Sunday December 12, 2021 @06:59PM (#29535008)
They're not saying the clang are bit by bit identical, but the blackblaze ones.
Re:Backblaze restore for Personal Backup is awful by mshockwave on Sunday December 12, 2021 @07:44PM (#29535315)
This only happens on Windows, on *nix systems these are all pointing to `clang-<version>`
Re:Backblaze restore for Personal Backup is awful by rgovostes on Sunday December 12, 2021 @06:02PM (#29534610)
This makes slightly more sense if it's the case that they are statically linking the Clang and LLVM libraries into each tool. Each one has a slightly different main() (e.g., one parses gcc-style args) but ends up using the same library functionality.
Re:Backblaze restore for Personal Backup is awful by vchuravy on Sunday December 12, 2021 @06:11PM (#29534668)
They are the same binary and on on Linux they are just soft-links.
Re:Backblaze restore for Personal Backup is awful by dataflow on Sunday December 12, 2021 @06:35PM (#29534843)
Interestingly they're also the same binary on Windows in MSYS2. But not if you install through whatever installer Visual Studio uses (probably the native one).