218 results for "":
A dynamic linker murder mystery
I write a ton of articles about rust. And in those articles, the main focus is about writing Rust code that compiles. Once it compiles, well, we’re basically in the clear! Especially if it compiles to a single executable, that’s made up entirely of Rust code.
That works great for short tutorials, or one-off explorations.
Unfortunately, “in the real world”, our code often has to share the stage with other code. And Rust is great at that. Compiling Go code to a static library, for example, is relatively finnicky. It insists on being built with GCC (and no other compiler), and linked with GNU ld (and no other linker).
Migrating from warp to axum
Falling out of love with warp
Back when I wrote this codebase, warp was the best / only alternative for something relatively high-level on top of hyper.
I was never super fond of warp’s model — it’s a fine crate, just not for me.
The way routing works is essentially building a type that gets larger and larger. One route might look like:
let bye = warp::path("bye")
.and(warp::path::param())
.map(|name: String| format!("Good bye, {}!", name));
Loading multiple ELF objects
Up until now, we’ve been loading a single ELF file, and there wasn’t much
structure to how we did it: everyhing just kinda happened in main, in no
particular order.
But now that shared libraries are in the picture, we have to load multiple ELF files, with search paths, and keep them around so we can resolve symbols, and apply relocations across different objects.
From Inkscape to poppler
What’s next? Well… poppler is the library Inkscape uses to import PDFs.
Yes, the name comes from Futurama.
Turns out, poppler comes with a bunch of CLI tools, including pdftocairo!
Halfway through this article, I realized the “regular weight” on my system was in fact Iosevka SS01 (Andale Mono Style) (see Releases), but the “bold weight” was the default Iosevka.
I am a Java, C#, C or C++ developer, time to do some Rust
As I’ve said before, I’m working on a book about lifetimes. Or maybe it’s just a long series - I haven’t decided the specifics yet. Like every one of my series/book things, it’s long, and it starts you off way in the periphery of the subject, and takes a lot of detours to get there.
In other words - it’s great if you want an adventure (which truly understanding Rust definitely is), but it’s not the best if you are currently on the puzzled end of a conversation with your neighborhood lifetime enforcer, the Rust compiler.
Day 6 (Advent of Code 2020)
The end of Advent of Code 2020 is fast approaching, and we’re nowhere near done. Time to do Day 6!
The problem statement here is a little contrived, as uh, as the days that came before it, but that won’t stop us.
Basically, the input looks like this:
abc
a
b
c
ab
ac
a
a
a
a
b
Each line represents one person, and “groups of persons” are separated by blank lines.
A half-hour to learn Rust
In order to increase fluency in a programming language, one has to read a lot of it.
But how can you read a lot of it if you don’t know what it means?
In this article, instead of focusing on one or two concepts, I’ll try to go through as many Rust snippets as I can, and explain what the keywords and symbols they contain mean.
Ready? Go!
Variable bindings
In the bowels of glibc
Good morning, and welcome back to “how many executables can we run with our custom dynamic loader before things get really out of control”.
In Part 13, we “implemented” thread-local storage. I’m using scare quotes because, well, we spent most of the article blabbering about Addressing Memory Through The Ages, And Other Fun Tidbits.
But that was then, and this is now, which is, uh, nine months later. Not only am I wiser and more productive, I’m also finally done updating all the previous thirteen parts of this series to fix some inconsistencies, upgrade crate versions, and redo all the diagrams as SVG.
Rust modules vs files
A while back, I asked on Twitter what people found confusing in Rust, and one of the top topics was “how the module system maps to files”.
I remember struggling with that a lot when I first started Rust, so I’ll try to explain it in a way that makes sense to me.
Important note
All that follows is written for Rust 2021 edition. I have no interest in learning (or teaching) the ins and outs of the previous version, especially because it was a lot more confusing to me.