HNHacker News
TopNewBestAskShowJobs

ndesaulniers

6,896 karma · joined July 30, 2012

https://nickdesaulniers.github.io
submissionscomments
ndesaulniers··on C extensions, portability, and alternative compilers
> it took significant effort to e.g. get clang to compile the Linux kernel (needing patches in both projects).

Tell me about it. :-)

ndesaulniers··on sp.h: Fixing C by giving it a high quality, ultra portable standard library
I spent a bit of time implementing parts of a C runtime for the brief tenure I had maintaining LLVM's libc. I quickly came the realization that a lot of the interfaces that made it all the way to standardization were trash. How the language is standardized is still comical to me. I agree with TFA that C style strings are trash.
ndesaulniers··on Microsoft starts canceling Claude Code licenses
Good then that Amazon sells it by the 55 gal drum then.

https://www.amazon.com/Passion-Lubes-Natural-Water-Based-Lub...

> This product is out of stock

Ah, shoot, there go my weekend plans. Bummer.

ndesaulniers··on Tennessee man jailed 37 days for Trump meme wins settlement after lawsuit
I find it ironic; George Orwell was English!
ndesaulniers··on No way to parse integers in C (2022)
It's a shame we never got a package manager for C (or C++).

EDIT: perhaps I should have been clearer; by not having one early on, we now have multiple competing package managers, with no clear winner. Responses prove that point.

ndesaulniers··on Saying Goodbye to Asm.js
A long time ago, I wrote a small chapter in a WebGL book on asm.js.

https://webglinsights.github.io/

It was fun to see the rise of asm.js, which was a precursor to Web Assembly. Some of the early demos were so cool to see; Unreal Engine running in the browser. :) Bitter sweet to see the sun set here, but it did lead to much better things.

ndesaulniers··on The Fil-C Optimized Calling Convention
Dig the posters in the background; I just saw Burning Ambition in theaters last week. Up the irons, Earth dog! Ghost opened for Iron Maiden a few years ago; I saw them all together in Oakland.
ndesaulniers··on Removing the modem and GPS from my 2024 RAV4 hybrid
There was a recent class action suit against GM for this.
ndesaulniers··on Chevrolet Performance eCrate package (400v/200hp)
Interesting. This past weekend, I got a chance to speak with Corvette's chief engineer Josh Holder at Chevrolet's Corvette Corral for the IMSA race at Laguna Seca.

I asked him if we'd see an all electric Corvette in the C8 timeframe, or would have to wait until the C9?

He confirmed (to the group) there would not be an all electric C8.

GM has long done "crate" engines, where people swap their cars OE engine for one of GM's small block v8s (an "LS or LT swap") frequently found in Corvettes, Escalades, and probably Silverado/large trucks/SUVs.

Seeing an electric crate engine from GM shows me that they plan to do the same with an electrified power train. Cool.

ndesaulniers··on WiiFin – Jellyfin Client for Nintendo Wii
I run it in a docker container behind traefik in another container. Getting that wired up and working in podman was quite the challenge. Docker container mounts my media as read only.
ndesaulniers··on System Card: Claude Mythos Preview [pdf]
Also, https://web.archive.org/web/20260407181432/https://www-cdn.a...
ndesaulniers··on Author of "Careless People" banned from saying anything negative about Meta
It was a page turner. I recommend it.
ndesaulniers··on Hollywood Enters Oscars Weekend in Existential Crisis
When you buy movie tickets, you go see the movie.

When I purchase a game, I generally don't have time to play it.

We are not the same.

This may be why gaming is a few multiples larger an industry than film.

ndesaulniers··on Emacs internals: Tagged pointers vs. C++ std:variant and LLVM (Part 3)
Consider amending those references to your post!
ndesaulniers··on Emacs internals: Tagged pointers vs. C++ std:variant and LLVM (Part 3)
Happy to see discussion of LLVM's interesting implementation of Static Polymorphism using CRTP. Some recommended reads:

1. https://en.wikipedia.org/wiki/Curiously_recurring_template_p...

2. https://david.alvarezrosa.com/posts/devirtualization-and-sta...

3. https://llvm.org/docs/ProgrammersManual.html#the-isa-cast-an...

ndesaulniers··on 10% of Firefox crashes are caused by bitflips
I still remember summoning flesh golems as a necromancer! Too much of my life sunk into GW1. Beat all 4(?) expansions. Logged in years later after I finally put it down to find someone had guessed my weak password, stole everything, then deleted all my characters. C'est la vie.
ndesaulniers··on Americans are destroying Flock surveillance cameras
I took a look at the schematics for the two fuse boxes in my 2023 Chevrolet and _could not tell which/if any_ fuse was dedicated to a cellular modem.

This was in regards to: https://www.ftc.gov/news-events/news/press-releases/2025/01/...

ndesaulniers··on Both GCC and Clang generate strange/inefficient code
Was looking at the llvm case with the dead store to the stack.

https://godbolt.org/z/Kb736onb4

  \*\* IR Dump After Expand memcmp() to load/stores (expand-memcmp) \*\*
  ; Function Attrs: mustprogress nofree norecurse nounwind willreturn memory(argmem: read) uwtable
  define dso_local noundef zeroext i1 @isAllZeros(ptr noundef nonnull readonly align 4 captures(none) dereferenceable(8) %0) local_unnamed_addr #0 {
    %2 = alloca %"struct.std::array", align 8
    call void @llvm.lifetime.start.p0(ptr %2)
    store i64 0, ptr %2, align 8
    %3 = load i64, ptr %0, align 4
    %4 = load i64, ptr %2, align 8
    %5 = icmp ne i64 %3, %4
    %6 = zext i1 %5 to i32
    %7 = icmp eq i32 %6, 0
    call void @llvm.lifetime.end.p0(ptr %2)
    ret i1 %7
  }
It looks like expand-memcmp in the backend converts a call to bcmp to multiple loads/stores. Perhaps expand-memcmp should then do a round of store-to-load forwarding.

Filed https://github.com/llvm/llvm-project/issues/180991 which I think is what the author should do in cases like this (rather than a blog post).

ndesaulniers··on Oxide raises $200M Series C
For those of us who are unaware of "the value proposition" of an "IBM AS/400," could someone spell it out for us?
ndesaulniers··on We tasked Opus 4.6 using agent teams to build a C Compiler
In practice, one of the difficulties in getting _clang_ to assemble the Linux kernel (as opposed to GNU `as` aka GAS), was having clang implement support for "fragments" in more places.

https://eli.thegreenplace.net/2013/01/03/assembler-relaxatio...

There were a few cases IIRC around usage of the `.` operator which means something to the effect of "the current point in the program." It can be used in complex expressions, and sometimes resolving those requires multiple passes. So supporting GAS compatible syntax in more than just the basic cases forces the architecture of your assembler to be multi-pass.

ndesaulniers··on We tasked Opus 4.6 using agent teams to build a C Compiler
Guess I better add https://github.com/bytecodealliance/rfcs/blob/main/accepted/... to my reading list!
ndesaulniers··on We tasked Opus 4.6 using agent teams to build a C Compiler
> I would love to meet these imaginary people that are fine with a compiler that is straight up broken.

That's not what I said; you're attacking a strawman.

My point was more so that some people prefer the madness that is -funsafe-math-optimizations, or happen to rely on UB (intentionally or otherwise). What even is "correct" in the presence of UB? What is correct in such case was left up to interpretation of the implementer by ISO WG14.

ndesaulniers··on We tasked Opus 4.6 using agent teams to build a C Compiler
This work originally wasn't my 100% project, it was my 20% project (or as I prefer to call it, 120% project).

I had to move teams twice before a third team was able to say: this work is valuable to us, please come work for us and focus just on that.

I had to organize multiple internal teams, then build an external community of contributors to collaborate on this shared common goal.

Having carte blanche to contribute to open source projects made this feasible at all; I can see that being a non-starter at many employers, sadly. Having low friction to change teams also helped a lot.

ndesaulniers··on We tasked Opus 4.6 using agent teams to build a C Compiler
> extensions

Some were necessary (asm goto), some were not (nested functions, flexible array members not at the end of structs).

> UDB, bugs and all

Luckily, the kernel didn't intentionally rely on GCC specifics this way. Where it did unintentionally, we fixed the kernel sources properly with detailed commit messages explaining why.

> or were there any issues that might be considered as specific to the linux kernel?

Yes, https://github.com/ClangBuiltLinux/linux/issues is our issue tracker. We use tags extensively to mark if we triage the issue to be kernel-side vs toolchain-side.

> Did you end up building a gcc compatability test suite as a part of this?

No, but some tricky cases LLVM got wrong were distilled from kernel sources using either:

- creduce - cvise (my favorite) - bugpoint - llvm-reduce

and then added to LLVM's existing test suite. Many such tests were also simply manually written.

> Did the gcc project themselves have a regression/test suite that you were able to use as a starting point?

GCC and binutils have their own test suites. Folks in the LLVM community have worked on being able to test clang against GCC's test suite. I personally have never run GCC's test suite or looked at its sources.

ndesaulniers··on We tasked Opus 4.6 using agent teams to build a C Compiler
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3685.pdf

Read section J.1.

ndesaulniers··on We tasked Opus 4.6 using agent teams to build a C Compiler
Yeah, my current boss spent time weeding out such hardware bugs: https://arxiv.org/abs/2110.11519 (EDIT: maybe https://x.com/Tesla_AI/status/1930686196201714027 is a more relevant citation)

They found a bimodal distribution in failures over the lifetime of chips. Infant mortality was well understood. Silicon aging over time was much less well understood, and I still find surprising.

ndesaulniers··on We tasked Opus 4.6 using agent teams to build a C Compiler
We're already starting to see people experimenting with applying AI towards register allocation and inlining heuristics. I think that many fields within a compiler are still ripe for experimentation.

https://llvm.org/docs/MLGO.html

ndesaulniers··on We tasked Opus 4.6 using agent teams to build a C Compiler
Some people care more about compile times than the performance of generated code. Perhaps even the correctness of generated code. Perhaps more so than determinism of the generated code. Different people in different contexts can have different priorities. Trying to make everyone happy can sometimes lead to making no one happy. Thus dichotomies like `-O2` vs `-Os`.

EDIT (since HN is preventing me from responding):

> Some people care more about compiler speed than the correctness?

Yeah, I think plenty of people writing code in languages that have concepts like Undefined Behavior technically don't really care as much about correctness as they may claim otherwise, as it's pretty hard to write large volumes of code without indirectly relying on UB somewhere. What is correct in such case was left up to interpretation of the implementer by ISO WG14.

ndesaulniers··on We tasked Opus 4.6 using agent teams to build a C Compiler
There's parts of LLVM architecture that are long in the tooth (IMO) (as is the language it's implemented in, IMO).

I had hoped one day to re-implement parts of LLVM itself in Rust; in particular, I've been curious if we can concurrently compile C (and parse C in parallel, or lazily) that haven't been explored in LLVM, and I think might be safer to do in Rust. I don't know enough about grammers to know if it's technically impossible, but a healthy dose of ignorance can sometimes lead to breakthroughs.

LLVM is pretty well designed for test. I was able to implement a lexer for C in Rust that could lex the Linux kernel, and use clang to cross check my implementation (I would compare my interpretation of the token stream against clang's). Just having a standard module system makes having reusable pieces seems like perhaps a better way to compose a toolchain, but maybe folks with more experience with rustc have scars to disagree?

ndesaulniers··on We tasked Opus 4.6 using agent teams to build a C Compiler
`asm goto` was the big one. The x86_64 maintainers broke the clang builds very intentionally just after we had gotten x86_64 building (with necessary patches upstreamed) by requiring compiler support for that GNU C extension. This was right around the time of meltdown+spectre, and the x86_64 maintainers didn't want to support fallbacks for older versions of GCC (and ToT Clang at the time) that lacked `asm goto` support for the initial fixes shipped under duress (embargo). `asm goto` requires plumbing throughout the compiler, and I've learned more about register allocation than I particularly care...

Fixing some UB in the kernel sources, lots of plumbing to the build system (particularly making it more hermetic).

Getting the rest of the LLVM binutils substitutes to work in place of GNU binutils was also challenging. Rewriting a fair amount of 32b ARM assembler to be "unified syntax" in the kernel. Linker bugs are hard to debug. Kernel boot failures are hard to debug (thank god for QEMU+gdb protocol). Lots of people worked on many different parts here, not just me.

Evangelism and convincing upstream kernel developers why clang support was worth anyones while.

https://github.com/ClangBuiltLinux/linux/issues for a good historical perspective. https://github.com/ClangBuiltLinux/linux/wiki/Talks,-Present... for talks on the subject. Keynoting LLVM conf was a personal highlight (https://www.youtube.com/watch?v=6l4DtR5exwo).

← PreviousPage 2 of 34Next →