HNHacker News
TopNewBestAskShowJobs

jcranmer

36,256 karma · joined November 17, 2014

submissionscomments
jcranmer··on Mold Linker Version 3.0.0 Release – Rewritten in Rust
The list of supported GCC architectures is here: https://gcc.gnu.org/backends.html

LLVM doesn't have an equivalent annotated list, but it is missing alpha, bfin, c6x, fr30, frv, gcn, h8300, ia64 (aka Itanium), lm32, m32c, m32r, mcore, mep, microblaze, mmix, mn10300, moxie, nds32, nios2, pa (aka PA-RISC), pdp11, pru, rl78, rs6000, rx, sh (aka SuperH), storm16, v850, vax, and visium. For its part, LLVM does have some targets that GCC doesn't have (mostly related to GPU compilation).

The "big" targets that GCC has that LLVM lacks are Alpha, Itanium, PA-RISC, and SuperH, with Itanium being sufficiently weird that it's pretty firmly in the "fuck this" category from a maintainer's perspective, and people are actively ripping out support for it.

jcranmer··on Beating the compiler (2024)
An optimizer is trying to balance between compile time, runtime speed, and code size, and most optimizations will win you one axis at the cost of one or both of the other axes. (The rare optimizations that win on all 3 are already all implemented in the compiler.) Compiler developer time is also a scarce resource; I know of so many more optimizations I could implement, but without demonstrable code that would actually benefit, it's not a good use of my time to implement them. Compilers tune this balance by making lots of heuristic decisions, and these heuristics are tuned by large benchmarks, which often times involve a lot of flat code profiles (i.e., no code is worth spending a lot of time really nailing down the best code layout).

One of the advantages of hand-written assembly is that you get to opt out of the compiler heuristics and commit to being able to spend the time to optimize the one bit of code that you know is really important for runtime as perfectly as you want, instead of relying on the compiler to get it close enough to perfect before it exhausts its budget of caring about optimizing it.

jcranmer··on Beating the Compiler
Modifying the ABI of a function requires being able to track down all of the call-sites of the function, which is less trivial than you might assume. ABI concerns also tend to baked in relatively early in the optimization pipeline because you just simply can't get the ABI wrong, and I can think of several instances where the ABI decision causes missed optimizations.

There is also the other issue that a good algorithm for optimizing a problem like register allocation tends to be super-linear (e.g., quadratic), and if you shift the model from "allocate on a per-function basis" to "allocate all functions", the N in the O(N²) goes from "size of function" to "size of program," which is now suddenly a lot more compiler time spent for very modest gains. If register spilling across a function call is a noticeable component of runtime, then you're probably better off inlining that function in the first place!

jcranmer··on What is going on with ceiling fans
The United Arab Emirates is a federal state, like the US or Canada (and notably not like the UK--Scotland is a devolved component of a unitary state, not a member of a federal state). The Emirate of Dubai is thus most closely analogized to a US state or a Canadian province, though I'm not entirely sure off-hand how the power of a UAE Emirate compares to federal subjects in the countries whose politics I'm more familiar with.

Also, Dubai is effectively a city-state, as the vast majority of the population of the Emirate lives in the city itself.

jcranmer··on How Singapore's government-run dating service works
> Before, women would suffer the hardship and danger of childbirth, and in return men would take on the physical perils of war.

The problem with this view is that the VAST majority of deaths in war are civilian deaths, which do not bound themselves by gender. It's only in recent decades that it's possible to contemplate conflicts with as few as 1 civilian death per combatant death, and even then, that's the extreme exception, not the rule.

In non-state warfare, the civilian casualty ratio is even worse--imagine living in "Eastern Europe in World War 2"-style casualty rates as the baseline of your existence. The typical battle in such circumstances isn't "two opposing armies meet on a battlefield, one army emerges victorious;" it's "we're going to sneak into your village, set fire to all your food stores, rape some of your women (maybe steal them for brides), and maybe whack off several of your children."

> In modern society, of course, conflict mostly means playing video games in an armchair.

I rather think most Ukrainian soldiers would disagree with you here.

jcranmer··on How Singapore's government-run dating service works
What time do you think that was?

Exact times do vary by country, but female 'emancipation' is largely starting around WWI, whereas the middle class lifestyle you're suggesting doesn't arise until after WWII.

jcranmer··on Git 3.0's upcoming SHA-256 default will be a costly mistake
The problem is existing repositories have SHA-1 commit hashes, and if you also end up changing those...

There's lots of tools that refer to git commit IDs. Some of those tools may even hardcode a commit ID to be 40 hex digits long. The fact that these tools are external also means that "oh, just rewrite the commit messages or code to refer to the new IDs" isn't feasible. The only way to not break the world is to let people refer to existing commits with their SHA-1 hashes in perpetuity, and it doesn't sound like git is set up to allow this in any way, which means that existing repositories have to stay SHA-1 in perpetuity and that will cause fun down the line if you start having to make SHA-1 and SHA-256 repositories.

Changing from master to main is a one-off change. It might require changing your scripts once to refer to 'origin/main' instead of 'origin/master', but other than that, there is essentially nothing more that needs to be done, there is no risk to historical artifacts that needs to be mitigated.

jcranmer··on EDG C++ front-end goes public
The Intel compiler used to use the EDG frontend; they swiched to Clang a few years ago.
jcranmer··on EDG C++ front-end goes public
I'm not sure Watcom is C++98 compliant, let alone C++11 or newer

(and I'm implicitly using C++11 here when I say "C++", given that it effectively defines 'modern' C++).

jcranmer··on EDG C++ front-end goes public
The Apache's patent clauses conflict with the requirements of the GPL license. GPLv3 contains explicit wording to handle this conflict; GPLv2 does not. The exception here is adding wording to let this Apache-licensed code be used with GPLv2 code in the same way that it would normally be usable with GPLv3.
jcranmer··on EDG C++ front-end goes public
There are essentially four C++ frontends: gcc, clang, MSVC, and EDG. Pretty much every C++ compiler is a reskinned version of one of those compilers. Most of the proprietary compilers have been slinking away from using EDG to using clang (e.g., Intel did this transition a few years ago).

The reason why the EDG frontend is being open-sourced is because EDG itself is closing up shop, and the open sourcing is an interim solution as EDG's customers work on migrating to using Clang instead. So... it's really not good news, because it means that one of the frontends is basically reaching end-of-life.

jcranmer··on Solving Factorio Quality
Technocratic abilities do not necessarily make for good presidents. See, for example, Herbert Hoover.
jcranmer··on U.S. Strategic Petroleum Reserve Falls to Lowest Level Since 1982
In 2014, there was no political will in the US political system to do anything--witness Obama drawing the red line in Syria over the use of chemical weapons, and after Assad used them, Congress said "fuck off, we don't want to do anything." Given that Crimea was by far the most Russophile portion of Ukraine (it only veeeery barely voted to support Ukrainian independence in the Ukrainian independence referendum), it was much more difficult to build a case for any sort of intervention there than it would be after Syrian war crimes, and the latter wasn't enough to gain sufficient political will.

On top of that, 2014 is the 100th anniversary of the start of World War I, which means that all of the foreign policy people had been brushing up on their histories of World War I and the causes of said war, which is of course the ur-example of "random event escalates to every great power at war with each other." I definitely felt like a lone voice pointing out that I was getting more World War II vibes, with Putin acting like Hitler: "I just want a little bit of X, it's the last thing I'll ask for, I promise!"

Also, probably more important than the US reaction here is the German reaction, and Germany was in full Russian appeasement mode really right up until Russian tanks were literally rolling across the border in 2022.

jcranmer··on OpenAI still doesn't seem to have a handle on all of its rogue AI activity
I don't think it's so much "too big to fail" as it is the fact that all of the AI companies have been similarly reckless in their drive for frontier AI. So if you establish the precedent that an AI company can be held legally liable for its recklessness, well, all of them can be held liable, and those costs start to add up fast.
jcranmer··on What makes Lisp difficult to read?
Most languages use either subject-object-verb or subject-verb-object word orders, which together account for ~90% of world languages; verb-first word order languages only account for ~10% of world languages.
jcranmer··on 37,500 border drawings: a map of the world as people remember it
At least on the easy mode, you're given the names of major cities, coastlines, rivers, and major roads. The city names are also given a gloss in both English and the local script, if the local script is not in Latin.

For a country like China, whose neighboring countries do not use the same language, you can get a reasonably good guess as to its borders simply by drawing in the space between city names written in hanzi and nearby cities without those names.

jcranmer··on 37,500 border drawings: a map of the world as people remember it
The red lines are the only segments filled in via small border segments; the green and the blue lines require you to do much more of the country's outline.
jcranmer··on Owed a billion dollars in Nvidia stock
A few reasons:

- If you wait too long to pursue a case, then the reliability of evidence goes down, as people lose older records, memories fail, physical infrastructure is replaced, etc.

- Statutes of limitations diminish the ability of malicious accusers to pursue cases against their targets.

- Statutes of limitations also create a sense of finality to a situation; it prevents people from coming out of the woodwork to unsettle something settled 20 years ago.

- In general, the clock runs from when you first find out about an injury to when you can first take action do something about it. That action isn't necessarily to actually file a lawsuit; there are often many things you can do to pause or reset the clock before filing the lawsuit.

- They also incentivize people to pursue redress sooner rather than later, with the concomitant benefits of doing so.

- If it takes you, say, five years to figure out that you are really mad about being injured by somebody... why were you fine with it for five years? It really undercuts your argument about the seriousness of the injury to delay for so long.

jcranmer··on Musk, the Movie
There are, I think, two things that the documentary is trying to do with this statement. The first is to remind people that even visionaries selling their actions on a noble cause must still be evaluated for the negative consequences of their actions. In this case, Musk is known to be the cause of quite a few deaths in the world thanks to things like eliminating USAID [1]. People like him need to be fairly evaluated not just on the good they might potentially unlock in the future, but the evil they are unlocking today.

The second thing is to point out that Musk may not be entirely honest about trying to colonize Mars, just as some politicians may campaign on a promise to make a country great again while robbing blind the rubes who vote for them.

[1] Although I think Mark Zuckerberg still beats him in the deadliest tech CEO race, given the role that Facebook plays in the Rohingya genocide.

jcranmer··on LA Metro has some of the slowest escalators
The current plan aims to have the subway system 95% accessible by 2055.

<https://www.mta.info/project/station-accessibility-upgrades>

(Of the old US subway systems, MTA seems to be the most lackadaisical in actually making their system accessible.)

jcranmer··on CEO of Mistral: AI is software. It can be controlled
For starters, the entire framing of AI in public discourse is based on the way that Amodei and Altman want them to be framed, with little consideration given to alternative ways of framing the current and prospective future capabilities of AI.
jcranmer··on Dutch governments builds alternative for Microsoft based on NixOS
Patents are essentially by design almost unreadable: the attorneys who put them together are trying to make the patent seem as broad as possible, while the actual operative claims (a tiny fraction of the text) need to be single gargantuan sentences that need to be narrow enough to not be invalidated by prior art.

My guess--and this is only a guess, I can't make enough sense to do anything more--is that the novel part may have something to do with the "credit duration" stuff.

jcranmer··on When the Debugger Lies
Having been involved in the WG14 discussions on this topic:

The issue is that there is a contingent of users who complains about cases where the return dynamically can't be hit but that isn't obvious statically. Consider something like this:

  int do_something(enum meow koala) {
    switch (koala) {
    case enum_val_1: return 5;
    case enum_val_2: return 3;
    /* etc., covering all the enum values */
    }
  }
Should this be required to diagnose? That's the sticking point.
jcranmer··on Transit rewards
NYC's subway system is an amalgamation of three systems, two of them built privately (but both of whom subsequently went bankrupt) and the third built by the city.
jcranmer··on Transit rewards
The Highway Trust Fund pays primarily for highway capital expenditure projects. It's not just highway construction; things like replacing a bridge or widening a highway are also covered, but these are also capital expenses, not operational expenses. A portion of it goes to funding mass transit capital expenditures.
jcranmer··on AMD's random number generator can't generate a 0?
> The thing about standards is this: A given piece of C code, if standards compliant, should, when compiled, act a given way with any compiler conformant with that standard. C developers writing C99 code shouldn’t have to look at any development or document which exists after 1999 to determine whether their code will act a given way. C compiler writers shouldn’t be telling C99 developers “well, you should know about this 2021 change to the C compiler”. They should instead say, “well, if you look at this page of the C99 spec, that behavior is undefined so we have no obligation to implement it the same way GCC does”.

The thing about standards is this: we have the same ability to write large, bug-free specifications as we do to write large, bug-free applications--effectively none. Bugs in the specification can take years or even decades to be discovered, and then the interpretation adjudicated and fixed in a newer version of the standard, with the fossil C99 specification never being updated or given any indication that the original text was buggy. On top of that, compilers don't implement C99, they implement C99-with-compiler-extensions, and those compiler extensions' documentation range from poor to atrocious.

> Standards correct C99 code written in 2005 should behave the same way when compiled in 2026 as it did in 2005.

Standards-correct code means not hitting UB. The number of programs that exhibit UB is approximately 100%, especially in 2005 (which is about when GCC started optimizing based on C's effective type rules). The best way to figure out whether or not your code is standards-correct generally isn't to read the standard [1]. Instead, go run a suite of undefined behavior sanitizers on your code to see if your code is known to violate some of the rules. We unfortunately don't have checkers for all the known UBs (for example, effective type rules).

[1] The standard is hard to read, especially because you have to know where to track down more authoritative sources to be able to resolve interpretation issues. I'll note that you've both incorrectly identified the source of undefined behavior and incorrectly identified where to find the undefined behavior--you're citing Annex J, which is an informative section, meaning it doesn't actually mean anything as far as interpretation goes (and I'm aware of at least one entry in there which is outright incorrect).

jcranmer··on Transit rewards
> The reason there's not more public transit is because the economics are terrible.

The reason we don't have roads is because the economics are terrible. The government gets $0 per trip [1], but it costs billions of dollars a year in operating expenses.

Wait, that's not how it works.

[1] Federal gas taxes don't count, because those go to the Highway Trust Fund which funds road construction, which is not an operating expense. State gas taxes may vary. Although toll roads also properly charge people user fees, although for some reason, lots of drivers complain about how expensive tolls are...

jcranmer··on AMD's random number generator can't generate a 0?
> My question is: If code being around for years doesn’t build confidence in it being secure, what would it take to build confidence in the code.

One of my experiences with programmers is that we (and I do not exclude myself from this category) are extraordinarily bad at sufficiently imagining the failure paths that our code might take and making code work handle failure cases correctly. It's these erroneous failure paths that are the real issue with code, and age doesn't really indicate how much testing of those failure paths actually exist.

To build confidence in code, what we need is proactive testing of potential failure paths that don't rely on humans to think of them in the first place--that means investment in various exhaustive testing techniques. (And I'd also like to see formal verification be more of a thing, but the tech just isn't there.) A stepping stone in that regard is also heavy use of static and dynamic analyzers to catch things that at known to be Obviously Bad™. The gold standard here really is whitebox concolic execution that's specifically trying to get something akin to 100% path coverage by trying to synthesize inputs to test the unhit paths.

Saying that it's okay to seed an entropy pool with uninitialized memory in 2005 is maybe defensible. There is a shift in compiler design around that time from thinking of it as compiling to a set of instructions and then optimizing them (so that the basic 'structure' of the code is something that's inherent to the program) towards looking at program semantics as abstract things where the only thing you need to preserve are the observable semantics [1]. One of the side effects of that shift is that undefined behavior stops being something that is fairly reliable so you assume you get the 'equivalent' assembly effects for that machine and starts being something that really screws over code.

But it's not 2005; it's 2026, and this change in compilers has been heavily advertised, discussed, complained about for well over a decade. And if you're using the kind of tools that give me confidence in code, those tools would have been bitching about that behavior for decades. If this is a surprise to you in this time and age, then it suggests to me that you've not really been proactive in trying to test your code in the manner I suggest, or worse, you have been proactive and decided to ignore everything telling you your practices are wrong because you know better than the tools and your code isn't obviously wrong.

(I say obviously wrong because your code example does demonstrate, when I tried it in the latest version of clang on godbolt, that it is eliminating the seeding of the entropy pool, in a way that is actually pretty clear if you read the assembly.)

[1] One of the most concrete examples to really observe the difference is the concept of control flow. Compilers nowadays are really happy to turn control flow (if statements) into dataflow (conditional moves or funky bit manipulations) and vice versa, because the only thing that needs to be preserved is the final value. Of course, cryptographers keep complaining that we broke their code by turning their obfuscated dataflow-based if statement into an actual if statement and so it's no longer constant-time, no matter how many times we keep telling them that we do not make any pretense of guaranteeing constant-time execution of code.

jcranmer··on AMD's random number generator can't generate a 0?
Uninitialized memory should never be used as source of entropy. Most release software these days compiles using hardening flags, which will (at some levels) replace uninitialized memory with sentinel values, making the entropy of uninitialized memory frequently around 0.

But it gets worse. If the optimizer sees that you're loading uninitialized memory, it can reason that since the result of uninitialized memory is garbage, doing any computation on that result is also garbage, and happily delete said computation as a result. The cascading effect of this is to delete all of the entropy-mixing code, leaving your entropy pool with only the very low entropy source--giving uninitialized memory effectively negative entropy.

The net effect is that, at least for me, seeing someone trying to seed an entropy pool with uninitialized memory is a giant neon flashing sign saying "do not trust this code." It provides at best very little entropy and at worst actively destroys entropy and has other calamitous effects like valgrind or sanitizer errors, so you need to have other entropy sources anyways, so why bother?

jcranmer··on Looking forward to Git 2.56 – and 3.0
> AIUI cryptographic hashes are safe from quantum attacks (for there's an infinity of secrets that, once hashed, give a specific hash and hence somehow it's not possible to use a quantum computer to forge what you'd want).

Quantum algorithms require some sort of quantum 'trick' to actually have any speedup over classical computers. The most general quantum trick is Grover's algorithm, which lets you find f⁻¹(x) (given f and x) in sqrt(N) queries rather than N queries, where N is the size of the set from which x is drawn. This cuts the bit security of every algorithm in half, although for things like cryptographic hashes, it really means that a second preimage is now only as 'easy' as finding a collision (due to the birthday attack).

The other really well-known quantum trick is QFT, which allows you to find the period of an unknown periodic function really quickly. This is what allows quantum computers to break asymmetric algorithms based on integer factoring or elliptic curves, since they can both be expressed in terms of the QFT.

← PreviousPage 4 of 34Next →