WEBVTT

NOTE
This file was generated by Descript <www.descript.com>

00:00:13.212 --> 00:00:15.952
<v Amanda Majorowicz>This is Self
-Directed Research, where our hosts,

00:00:16.012 --> 00:00:19.192
James and Amos, give each other 20
minute presentations that usually

00:00:19.192 --> 00:00:22.362
last longer than that about whatever
they've been obsessing over lately.

00:00:22.782 --> 00:00:27.722
For more episodes, show notes, and
transcripts, visit sdr-podcast.com.

00:00:28.122 --> 00:00:30.022
New episodes drop every Wednesday.

00:00:30.622 --> 00:00:32.862
Today's episode is
sponsored by fasterthanlime.

00:00:33.032 --> 00:00:35.082
More info at the end of the episode.

00:00:35.612 --> 00:00:39.502
This week, Amos presents, "How
Usable is Crane Lift Today?"

00:00:44.585 --> 00:00:45.235
<v Amos Wenger>Okay, let's go.

00:00:45.335 --> 00:00:49.795
So, this week I want to talk about:
I want everyone to congratulate

00:00:49.795 --> 00:00:51.175
me on being so generous.

00:00:51.515 --> 00:00:52.135
Not really.

00:00:52.425 --> 00:00:52.725
Okay.

00:00:52.725 --> 00:00:53.615
So here's what happened.

00:00:53.675 --> 00:00:59.036
The Rust compiler: it's a machine
that turns your code into a metric ton

00:00:59.526 --> 00:01:01.906
of LLVM intermediate representation.

00:01:02.026 --> 00:01:06.646
And then LLVM turns that into native code,
and then your linker just sleeps in a

00:01:06.646 --> 00:01:08.676
loop, probably, because it's that slow.

00:01:08.775 --> 00:01:09.945
<v James Munns>Puts a big bow around it.

00:01:09.945 --> 00:01:13.795
<v Amos Wenger>Magically, yeah, you have
an executable file appear on your disk

00:01:13.875 --> 00:01:18.185
and it's between, let's say two and 700
megabytes, depending on where you work and

00:01:18.185 --> 00:01:19.845
how many debug information you pull in.

00:01:20.185 --> 00:01:21.715
That's basically what
the Rust compiler does.

00:01:21.745 --> 00:01:22.045
Actually.

00:01:22.055 --> 00:01:25.015
Well, no, no- that's
the compiler side gig.

00:01:25.445 --> 00:01:27.265
I think was the talk Esteban gave.

00:01:27.485 --> 00:01:30.111
So the main thing the Rust compiler
does is parse and emit diagnostics.

00:01:30.111 --> 00:01:32.601
And then as a side gig,
it generates network.

00:01:33.024 --> 00:01:39.673
But, problems with LLVM: it's a big
pile of C++, it's a research project

00:01:39.683 --> 00:01:42.733
that has been productionized and
then remained a research project.

00:01:42.743 --> 00:01:45.085
So there's a lot of things happening.

00:01:45.415 --> 00:01:48.645
Like, I think they turned their
people optimization register

00:01:48.825 --> 00:01:52.575
allocator from code to like a model.

00:01:52.615 --> 00:01:53.815
Like let's just train a model.

00:01:53.825 --> 00:01:56.155
Cause it's going to be better than
whatever heuristics we can come up with.

00:01:56.165 --> 00:01:57.285
So there's things like that.

00:01:57.285 --> 00:02:00.700
There's like really strange
vectorization things happening.

00:02:01.240 --> 00:02:02.810
LLVM is still research ground and-

00:02:02.853 --> 00:02:04.163
<v James Munns>So these
are all optimizations.

00:02:04.173 --> 00:02:07.963
Like we have some code that comes in
and LLVM goes, "I see what you're doing.

00:02:07.963 --> 00:02:09.163
There's a better way to do that."

00:02:09.183 --> 00:02:12.263
And without actually knowing the
source code form or with limited

00:02:12.263 --> 00:02:14.763
access to it just goes, "No, no, no.

00:02:14.763 --> 00:02:15.623
It's better like this."

00:02:15.653 --> 00:02:16.188
<v Amos Wenger>Yeah, yeah, yeah.

00:02:16.188 --> 00:02:19.248
And the way it actually works is
like it transforms the input into

00:02:19.248 --> 00:02:21.188
different intermediate representations.

00:02:21.368 --> 00:02:25.118
And then using those forms, it's easier
to analyze like what you can optimize

00:02:25.348 --> 00:02:28.644
because you, you realize: Oh, those two
things come from the same computation.

00:02:28.831 --> 00:02:29.991
So we can just merge them or whatever.

00:02:30.001 --> 00:02:31.166
There's a lot of that going around.

00:02:31.186 --> 00:02:35.196
So LLVM is a blessing and a curse
because the point that they made the

00:02:35.196 --> 00:02:37.926
choice to use it- let's say I'm not
familiar with the entire history-

00:02:38.161 --> 00:02:39.861
it was the good obvious choice.

00:02:40.181 --> 00:02:43.949
And since then, another project has
happened, for WebAssembly reasons

00:02:44.279 --> 00:02:49.179
called Cranelift, but it does happen
to generate AMD64 code or x86-64 or

00:02:49.179 --> 00:02:52.109
whatever you want to call it, and a
bunch of other architectures now as well.

00:02:52.449 --> 00:02:54.509
I don't exactly know who had the
idea at first, but they were like,

00:02:54.509 --> 00:02:59.127
"Well, Cranelift, the WebAssembly
based projects, the backend is Rust.

00:02:59.337 --> 00:03:00.427
The Rust compiler is Rust.

00:03:00.727 --> 00:03:01.827
Let's arrange something."

00:03:01.910 --> 00:03:05.900
I don't have any of the dates or the
timeline off the top of my head, but

00:03:06.274 --> 00:03:12.094
it went as far as like a few months ago
on the official Rust blog, they talked

00:03:12.094 --> 00:03:17.564
about using that backend, the Cranelift
CodeGen backend for debug builds.

00:03:17.944 --> 00:03:22.324
And it is now distributed on a
rustup for at least 64 bit Linux.

00:03:22.808 --> 00:03:26.878
And I was very interested in it, but
as it happens, I switched entirely

00:03:26.878 --> 00:03:29.238
over to Macs for a very simple reason.

00:03:29.308 --> 00:03:33.636
It's that macOS is the only operating
system that works on desktop in 2024.

00:03:33.636 --> 00:03:36.568
Because you have Linux, which
is, you know, the year Linux

00:03:36.568 --> 00:03:38.377
on the desktop is any year now.

00:03:38.667 --> 00:03:40.507
And then you have Windows,
which is being actively made

00:03:40.517 --> 00:03:42.267
worse with every passing month.

00:03:42.597 --> 00:03:44.327
I defended it, until I couldn't.

00:03:44.627 --> 00:03:44.957
I don't know.

00:03:44.957 --> 00:03:46.047
I just have so many workflows.

00:03:46.047 --> 00:03:48.067
I was like, "Well, this is
great, but it only works on Mac."

00:03:48.077 --> 00:03:50.067
And I was like, "What if I only had Macs?

00:03:50.427 --> 00:03:51.287
Then everything is great."

00:03:51.337 --> 00:03:53.247
Essentially, except when
AirDrop doesn't work.

00:03:53.774 --> 00:03:57.904
<v James Munns>For me, it was just having
a reasonable ARM architecture processor,

00:03:57.904 --> 00:04:01.954
because like the M-series Macs versus
any other laptop- like on a desktop,

00:04:01.954 --> 00:04:06.264
it's more debatable, I feel like, but
at least in terms of like efficiency

00:04:06.264 --> 00:04:10.259
and performance for a mobile device,
like a laptop, which I use very often.

00:04:10.549 --> 00:04:14.889
I was looking at like Framework or
M-series Macs and it was like: okay,

00:04:14.909 --> 00:04:17.009
it pretty much has to be M-series Mac.

00:04:17.146 --> 00:04:19.436
<v Amos Wenger>That is definitely what
pulled me in on the laptop level.

00:04:19.476 --> 00:04:22.996
But then I had like the nice laptop
and then I had to go back to my Windows

00:04:23.036 --> 00:04:25.836
desktop and just interacting with
Windows- just even transferring files.

00:04:25.836 --> 00:04:27.669
I'm like- I'm not going
to email files for myself.

00:04:27.669 --> 00:04:29.339
I'm not going to use USB sticks.

00:04:29.339 --> 00:04:30.569
Like I don't even have USB ports.

00:04:30.569 --> 00:04:31.289
I have USB C.

00:04:31.289 --> 00:04:31.869
What do I do?

00:04:32.369 --> 00:04:32.779
I don't know.

00:04:33.319 --> 00:04:36.156
And, I was always interested in
the Cranelift codegen backend.

00:04:36.391 --> 00:04:41.099
But it didn't work on MacOS-
aarch64, whatever the actual

00:04:41.099 --> 00:04:42.369
name of the architecture is.

00:04:43.819 --> 00:04:47.098
And recently it started working and I
was like - it's time to check it out.

00:04:47.278 --> 00:04:49.258
And I don't know if you
know, but I write articles.

00:04:49.298 --> 00:04:54.578
I'm a bit of an author myself, you may
say, and my website is powered by a

00:04:54.578 --> 00:04:57.148
gigantic bunch of Rust code as well.

00:04:57.498 --> 00:05:00.838
<v James Munns>I've sat down and built a
static site generator where you go, "Aha,

00:05:00.848 --> 00:05:02.578
I have written code that generates HTML."

00:05:02.588 --> 00:05:06.696
You went like the one step further of
like, "I have a fully dynamic running

00:05:06.696 --> 00:05:10.696
web server backend that powers my
entire site that I've written while

00:05:10.696 --> 00:05:16.116
writing articles about writing a
website dynamic backend in Rust."

00:05:16.131 --> 00:05:18.891
<v Amos Wenger>Yes, and I want
you to know that every single

00:05:18.891 --> 00:05:20.901
decision and isolation made sense.

00:05:21.191 --> 00:05:24.571
I still don't know how I ended up
here with like 20,000 lines of code

00:05:24.601 --> 00:05:27.210
to maintain and operate on Kubernetes.

00:05:27.240 --> 00:05:28.540
But somehow we're here.

00:05:28.940 --> 00:05:31.440
And the reason I was talking about
built performance and whatnot in the

00:05:31.440 --> 00:05:35.450
previous episode was because I'm trying
to get it back into a shape where I

00:05:35.450 --> 00:05:38.890
can actually iterate and add features
rather than just make sure it builds

00:05:38.910 --> 00:05:40.221
with the latest version of crates.

00:05:40.593 --> 00:05:45.336
So: that mountain of code ends
up having about 700 transitive

00:05:45.346 --> 00:05:48.136
dependencies, which is not all my fault.

00:05:48.196 --> 00:05:48.626
I don't know.

00:05:48.626 --> 00:05:49.886
I pulled the S3 crates.

00:05:49.886 --> 00:05:51.366
That's a hundred dependencies right there.

00:05:51.366 --> 00:05:54.416
Probably the aws-sdk-s3 crate.

00:05:54.799 --> 00:05:55.709
I'm doing what I can, okay?

00:05:55.709 --> 00:05:59.719
I'm doing video encoding, I'm doing image
encoding, I'm doing a bunch of templating.

00:05:59.729 --> 00:06:00.759
It's complicated!

00:06:00.759 --> 00:06:01.639
It's not all my fault.

00:06:01.639 --> 00:06:05.499
I'm doing compression, broadly, gzip,
whatever, Patreon API, all the APIs.

00:06:05.549 --> 00:06:06.989
There's so much functionality in there.

00:06:07.021 --> 00:06:08.021
And

00:06:08.140 --> 00:06:10.860
<v Amos Wenger>I tried the Cranelift
codegen backend, fully expecting

00:06:10.860 --> 00:06:15.066
it to vomit an error and then just
immediately stop after a couple of crates.

00:06:15.596 --> 00:06:20.066
But to my surprise, only like a couple
crates didn't build out of the 700.

00:06:20.346 --> 00:06:26.170
So there's ring because it has asserts
that are supposed to run at compile time.

00:06:26.180 --> 00:06:28.520
And I'm not even exactly
sure how that works.

00:06:28.860 --> 00:06:30.515
But it was very, very unhappy about that.

00:06:30.515 --> 00:06:34.095
But the nice thing about asserts is that
like, let's just make sure this actually

00:06:34.095 --> 00:06:39.185
looks like 64-bit ARM on MacOS and you can
just comment them out because yes, it is.

00:06:39.195 --> 00:06:41.225
It's regular MacOS, trust
me, it's going to be fine.

00:06:41.705 --> 00:06:42.765
So that took care of ring.

00:06:43.705 --> 00:06:49.515
And then the other thing was in
the half crate, which you may know,

00:06:49.515 --> 00:06:52.415
actually from your embedded work,
but it's like it defines float16.

00:06:52.753 --> 00:06:57.042
And so it has assembly, and so we
actually moved away from LLVM assembly

00:06:57.042 --> 00:06:59.002
to like Rust assembly syntax...

00:06:59.092 --> 00:07:00.302
I want to say one edition ago?

00:07:00.302 --> 00:07:02.642
I don't know exactly how that change
happened, but I know I had to update

00:07:02.642 --> 00:07:04.272
my series that had inline assembly.

00:07:04.822 --> 00:07:07.662
Yeah, so we had ring, we had
half, and half wouldn't compile.

00:07:07.662 --> 00:07:11.699
So I just- it turns out that it was pulled
in by a crate I didn't actually use.

00:07:12.069 --> 00:07:14.889
So I just dropped that dependency
and uh, everything built!

00:07:15.459 --> 00:07:16.149
But didn't link!

00:07:16.469 --> 00:07:20.489
It didn't link because- and we talked
about that recently, so it all tied

00:07:20.489 --> 00:07:23.919
in, this is why I was excited to
talk about this- it doesn't link

00:07:24.309 --> 00:07:29.081
on Xcode 15, which is the release
where they optimized the linker.

00:07:29.081 --> 00:07:31.351
I'm assuming they rewrote
a large part of it.

00:07:31.661 --> 00:07:34.369
So you can downgrade to
Xcode 14 and then it works.

00:07:34.649 --> 00:07:39.819
Or you can use a patch that someone
wrote and it's the most hilarious patch

00:07:39.819 --> 00:07:43.748
because it's like really domain specific
linker knowledge, like it's the wrong

00:07:43.748 --> 00:07:45.403
kind of relocation being generated.

00:07:45.543 --> 00:07:46.393
<v James Munns>Wait, a patch to what?

00:07:46.403 --> 00:07:47.102
The compiler?

00:07:47.163 --> 00:07:48.998
<v Amos Wenger>To the
Cranelift codegen backend.

00:07:49.098 --> 00:07:49.268
Yeah.

00:07:49.498 --> 00:07:51.508
It's not a patch, it's not a pull request.

00:07:51.718 --> 00:07:55.348
It's like someone did 'git diff'
and then posted the result in a git

00:07:55.368 --> 00:07:56.778
command saying, "Don't use this.

00:07:56.808 --> 00:07:57.568
I don't know what I'm doing.

00:07:57.568 --> 00:07:59.788
Someone who actually knows what they're
doing should take care of this."

00:08:00.128 --> 00:08:02.608
But if they don't know what
they're doing, who does?

00:08:02.638 --> 00:08:04.478
Cuz I don't know what's in the
patch I don't understand it...

00:08:04.782 --> 00:08:06.952
<v James Munns>There's this whole
fight on Twitter, and I know you

00:08:06.952 --> 00:08:10.952
found this thread too, of like:
Linkers are the like intersection

00:08:10.952 --> 00:08:13.082
point of so many integration schemes.

00:08:13.402 --> 00:08:20.042
It's like the integration point- it is the
cursed knowledge, stare-into-the-void item

00:08:20.332 --> 00:08:25.592
that is at the intersection of like five
other cursed stare-into-the-void items.

00:08:25.702 --> 00:08:28.462
I was not happy with all the
responses on that thread because

00:08:28.462 --> 00:08:30.582
some of it are just like, "Oh,
it's cursed, you'll never fix it."

00:08:30.782 --> 00:08:34.444
So I think the issue is generally
that people like to avoid-

00:08:34.450 --> 00:08:35.960
like, linkers are unpleasant.

00:08:35.980 --> 00:08:39.106
Like, I feel like this is the old
way of handling abstraction is you

00:08:39.106 --> 00:08:40.806
pretend that things don't exist.

00:08:41.026 --> 00:08:43.756
Then they're allowed to grow
as big and uncomfortable and

00:08:43.756 --> 00:08:45.466
terrible to deal with as they want.

00:08:45.686 --> 00:08:47.806
Because you just go, "Just
don't, don't look at it.

00:08:47.806 --> 00:08:49.446
Don't make eye contact, and you'll fine."

00:08:49.446 --> 00:08:53.163
Linkers are like the ideal of
that: you just hope that you never

00:08:53.173 --> 00:08:54.737
have to hear the word 'linker.'

00:08:54.767 --> 00:08:57.202
<v Amos Wenger>And this ties into two
other things I already talked about

00:08:57.222 --> 00:09:00.692
on this podcast, which are: I was
wrong about splitting your code base

00:09:00.692 --> 00:09:03.572
into many different crates because
it creates interfaces and interfaces

00:09:03.572 --> 00:09:04.892
by definition are boundaries.

00:09:05.122 --> 00:09:06.512
The exact same thing happens.

00:09:06.522 --> 00:09:10.542
You start to ignore what's on the
other side of the boundary and you're

00:09:10.552 --> 00:09:13.662
missing out on optimizations or
simplifications that could have been done.

00:09:13.932 --> 00:09:16.731
And, let me tell you: ever since I
merged everything back into one big

00:09:16.731 --> 00:09:19.577
crate, I'm going, "Oh, this thing
is duplicated all over the place.

00:09:19.597 --> 00:09:20.827
I can simplify the whole thing.

00:09:20.837 --> 00:09:23.768
I can build this thing once
instead of doing it on demand and

00:09:23.788 --> 00:09:25.348
like reallocating over and over."

00:09:25.548 --> 00:09:28.068
Like, the whole structure of the
thing becomes so much clearer

00:09:28.068 --> 00:09:29.318
now that it's one big blob.

00:09:29.648 --> 00:09:32.638
And I'm looking forward to finding
the interfaces that do make sense

00:09:32.658 --> 00:09:33.648
and actually split it up again.

00:09:33.948 --> 00:09:35.608
But specifically for linkers,
I think you're right.

00:09:35.648 --> 00:09:36.086
I think

00:09:36.086 --> 00:09:36.886
we

00:09:36.894 --> 00:09:40.084
<v Amos Wenger>collectively, like
people around compilers tend to think

00:09:40.099 --> 00:09:41.239
that it's not our problem, right?

00:09:41.239 --> 00:09:42.559
We just emit the object files.

00:09:42.559 --> 00:09:44.879
Whatever happens after that
is none of our concern.

00:09:45.229 --> 00:09:50.009
So back to the Cranelift code generation
backend: you can either downgrade to Xcode

00:09:50.009 --> 00:09:52.639
14, which is not a future proof solution.

00:09:52.649 --> 00:09:56.739
It's not what's favored by the maintainers
of cg_clif is the short name for the

00:09:57.409 --> 00:09:58.809
Cranelift code generation backend.

00:09:58.859 --> 00:10:01.952
And the patch that is in the
comments as an inline diff

00:10:01.975 --> 00:10:04.345
file that I did apply works...

00:10:04.385 --> 00:10:05.405
until it doesn't?

00:10:05.405 --> 00:10:07.769
So it did compile all the
crates individually which

00:10:07.989 --> 00:10:09.329
already involves some linking.

00:10:09.622 --> 00:10:09.922
<v James Munns>Yeah.

00:10:09.922 --> 00:10:13.922
Cause typically when things get
linked, you create one archive or

00:10:13.922 --> 00:10:17.792
library that you link together as
an archive or like a unified thing.

00:10:17.802 --> 00:10:21.221
And then, essentially at the
end the linker goes,  "Merge all

00:10:21.221 --> 00:10:25.231
of those intermediate archives
into one big final executable."

00:10:25.961 --> 00:10:28.801
<v Amos Wenger>And so there's many different
opportunities for linker errors to happen.

00:10:28.876 --> 00:10:32.127
You don't actually have to downgrade
to Xcode 14, you can just use a

00:10:32.127 --> 00:10:34.887
linker flag called ld_classic.

00:10:35.457 --> 00:10:39.657
And of course there's like 26
different ways to spell it wrong?

00:10:40.027 --> 00:10:42.307
If you just get it
wrong, it's just ignored.

00:10:42.727 --> 00:10:44.997
I love that, I love when programs do that.

00:10:44.997 --> 00:10:47.237
<v James Munns>Linker UX is real good.

00:10:47.427 --> 00:10:49.527
<v Amos Wenger>Just pass a flag it
doesn't know about it's like, "Okay"

00:10:50.204 --> 00:10:51.334
<v James Munns>That's compatibility!

00:10:51.384 --> 00:10:55.351
<v Amos Wenger>Yeah, it is for sure,
which is why when I derive deserialize,

00:10:55.368 --> 00:10:59.111
I always have like  'error on unknown
fields.' I forget the exact attribute.

00:10:59.135 --> 00:11:00.844
<v James Munns>Oh yeah, serde ignore?

00:11:00.891 --> 00:11:01.561
<v Amos Wenger>Not ignore.

00:11:01.723 --> 00:11:02.103
<v James Munns>You're right.

00:11:02.103 --> 00:11:03.900
Yeah, yeah, I, know exactly
what you're talking about.

00:11:04.010 --> 00:11:06.190
<v Amos Wenger>I want to look at the schema
change and I want to know about it.

00:11:06.680 --> 00:11:10.090
Well, I could version my configs,
but I'm- I'm a, I'm a one man shop.

00:11:10.140 --> 00:11:10.880
I don't need to do that.

00:11:11.520 --> 00:11:12.650
I'd rather have production trash.

00:11:12.815 --> 00:11:16.095
<v James Munns>Schema evolution is a
conversation for another day and we should

00:11:16.095 --> 00:11:18.055
talk about schema evolution at some point.

00:11:18.080 --> 00:11:19.320
<v Amos Wenger>It doesn't fit in 20 minutes.

00:11:19.320 --> 00:11:20.560
We can never talk about it here.

00:11:20.705 --> 00:11:21.135
<v James Munns>No

00:11:21.375 --> 00:11:24.310
<v Amos Wenger>So, there is a
linker flag called ld_classic.

00:11:24.445 --> 00:11:28.815
I was trying to use it, but as you can
imagine, building an alternative codegen

00:11:28.835 --> 00:11:32.435
backend for rustc is a bit involved.

00:11:32.445 --> 00:11:33.835
So there's an actual build system.

00:11:33.835 --> 00:11:36.415
So if you're building the Rust compiler,
rustc, if you check it out, which I

00:11:36.415 --> 00:11:38.975
encourage everyone to do, because they
have a really good contributors guide.

00:11:39.325 --> 00:11:40.425
Everyone can just clone it.

00:11:40.425 --> 00:11:41.575
It's not that big.

00:11:41.576 --> 00:11:44.641
It can download pre
built versions of LLVM.

00:11:44.851 --> 00:11:46.161
It doesn't actually take that long.

00:11:46.161 --> 00:11:48.451
I thought it was going to take like a
whole day to build for the first time.

00:11:48.451 --> 00:11:49.631
I thought it was like
Chromium or whatever.

00:11:49.631 --> 00:11:49.861
No.

00:11:50.171 --> 00:11:52.281
Contributing to rustc is
actually not that scary.

00:11:52.661 --> 00:11:57.791
It has this thing called x.py, which
is a Python script that ends up

00:11:57.801 --> 00:12:02.021
building a bunch of Rust, which is
then the actual build system for rustc.

00:12:02.331 --> 00:12:04.813
So the rustc build system is mostly
written in Rust, but it has this

00:12:04.833 --> 00:12:06.653
Python wrapper, so it's cross platform.

00:12:06.883 --> 00:12:09.643
And the Cranelift codegen
backend has a similar thing.

00:12:10.053 --> 00:12:14.483
It has y.sh and y.ps1 and
whatever for other platforms.

00:12:14.733 --> 00:12:18.373
And it also builds some Rust to also
end up invoking the Rust compiler and

00:12:18.373 --> 00:12:21.673
it applies patches to the standard
library so that it gets to compile

00:12:21.692 --> 00:12:22.932
with that backend and whatever.

00:12:23.049 --> 00:12:26.884
For some reason throughout this whole
process, the linker flag got lost.

00:12:27.014 --> 00:12:31.914
So not only will the linker not complain
if you give it a nonsense flag, or Rust

00:12:31.934 --> 00:12:35.384
flags will be ignored if you forget -Wl.

00:12:35.384 --> 00:12:37.954
So it's not a linker
flag, it's a normal flag.

00:12:38.344 --> 00:12:42.154
Just a bunch of drivers and frontends
and programs just ignore flags if they

00:12:42.154 --> 00:12:43.714
don't know about them, which is lovely.

00:12:44.144 --> 00:12:46.954
<v James Munns>Does the phrase
linker driver mean anything to you?

00:12:47.114 --> 00:12:48.784
<v Amos Wenger>To me, yes, but
you should still explain.

00:12:49.509 --> 00:12:51.229
<v James Munns>Okay- I was going to say,
I'm probably gonna get this wrong, cause

00:12:51.229 --> 00:12:54.249
this is again, cursed knowledge, but like-
a lot of the times you don't necessarily

00:12:54.249 --> 00:12:59.602
even invoke the linker as its own binary
program, you call the compiler with

00:12:59.602 --> 00:13:04.450
certain arguments because hopefully the
compiler knows what it's supposed to be

00:13:04.450 --> 00:13:09.069
doing and then can pass on more of that
information when it invokes the linker.

00:13:09.120 --> 00:13:13.630
A lot of those flags that you set
are rustc flags, which means you

00:13:13.630 --> 00:13:18.670
basically are giving them to rustc with
forwarding instructions to the linker.

00:13:18.860 --> 00:13:21.190
So you're not even talking
to the linker itself.

00:13:21.260 --> 00:13:21.620
I don't know.

00:13:22.175 --> 00:13:26.625
I've built some build system type stuff
where you  do independently do it, but

00:13:26.625 --> 00:13:29.975
it means that you then need to remember
everything that you gave to the compiler,

00:13:30.185 --> 00:13:34.995
and when Rust has, like, cargo followed by
rustc, the frontend, followed by whatever

00:13:35.235 --> 00:13:38.765
codegen backend it has, followed by
whatever linker you're using, there's just

00:13:38.765 --> 00:13:43.975
a lot of parts that really, really need to
agree on what configuration means to them.

00:13:44.230 --> 00:13:44.900
<v Amos Wenger>That is correct.

00:13:44.930 --> 00:13:49.570
The actual flag is ld_classic, but that's
the flag for LLD, which is invoked by

00:13:49.580 --> 00:13:57.738
CC, and the flag for CC is so what we
were saying: " -Wl, -ld_classic," but

00:13:57.748 --> 00:13:59.478
then we're actually passing a Rust flag.

00:13:59.508 --> 00:14:09.188
So the full chain is '-Clink-arg=-Wl,
ld_classic' which: don't ask

00:14:09.188 --> 00:14:10.678
me why I know that by heart!

00:14:10.678 --> 00:14:12.018
This is just the trauma-

00:14:12.062 --> 00:14:13.953
<v James Munns>Gonna say trauma is the
reason that you have to know that.

00:14:15.828 --> 00:14:16.538
<v Amos Wenger>Yes it is.

00:14:18.108 --> 00:14:19.358
Wow, this was a short story.

00:14:19.358 --> 00:14:20.573
I didn't think it was
going to last that long.

00:14:20.932 --> 00:14:23.682
The problem was: I think it's safe
to say I haven't checked the GitHub,

00:14:23.712 --> 00:14:27.740
but the person that has been behind
most of the effort of like, hooking

00:14:27.740 --> 00:14:30.800
up rustc to Cranelift- he hasn't
developed all of Cranelift by himself.

00:14:30.820 --> 00:14:31.510
It's a different team.

00:14:31.540 --> 00:14:33.990
It's like Wasmtime, the Wasmtime team?

00:14:33.990 --> 00:14:37.690
I don't know exactly who works on what,
but like the Bytecode Alliance, Wasmtime,

00:14:37.710 --> 00:14:40.380
Cranelift, whatever-related-word-cloud.

00:14:41.050 --> 00:14:42.560
And then rustc is a
different set of people.

00:14:42.680 --> 00:14:45.440
And then between rustc
and Cranelift: Bjorn!

00:14:46.130 --> 00:14:49.920
Bjorn the third, no bjorn3, on
GitHub, whom I met at EuroRust.

00:14:50.035 --> 00:14:51.569
I asked, " Are you getting paid for this?

00:14:51.569 --> 00:14:52.689
Do you get any kind of support?"

00:14:52.959 --> 00:14:55.639
And he was like, "Well, the Rust
Foundation is giving some things

00:14:55.639 --> 00:14:57.309
including like a VM and whatnot."

00:14:57.639 --> 00:15:00.849
And as I was messing around with
the Cranelift codegen backend,

00:15:00.869 --> 00:15:02.369
I realized: it's so close.

00:15:02.399 --> 00:15:03.339
It seems so close.

00:15:03.339 --> 00:15:05.944
I don't know if it actually runs
because the last linker command failed.

00:15:06.254 --> 00:15:08.631
I asked him, "Hey, do do you
have access to a Mac machine?

00:15:08.631 --> 00:15:10.316
Like an M1 or an M2 or anything?

00:15:10.356 --> 00:15:10.946
Have they given you a VM?"

00:15:11.726 --> 00:15:14.176
And the answer is of course,
no, because it's so easy to give

00:15:14.176 --> 00:15:16.606
someone a 64-bit Linux VM, right?

00:15:16.864 --> 00:15:19.909
It costs like pennies or whatever
on whatever cloud platform,

00:15:20.209 --> 00:15:22.049
but the M2s and whatnot...

00:15:22.834 --> 00:15:25.674
kind of hard to get by, kind
of more awkward to start a

00:15:25.674 --> 00:15:26.714
VM yourself and everything.

00:15:26.714 --> 00:15:27.724
I had never done it before.

00:15:27.724 --> 00:15:31.964
I just heard that like recently
it became possible to log into

00:15:31.964 --> 00:15:39.294
your iCloud account from a MacOS
ARM VM ran from an ARM machine?

00:15:39.314 --> 00:15:41.556
I didn't even know that
was "not a thing" before.

00:15:41.606 --> 00:15:43.376
I didn't even know that was
a limitation that existed.

00:15:43.376 --> 00:15:46.936
<v James Munns>Yeah, Mac has weird licensing
rules on virtualization, which means

00:15:47.106 --> 00:15:51.796
essentially every virtualized, like,
hosting provider of Mac is sort of in

00:15:51.796 --> 00:15:56.223
a gray area, and also they're required
to have physical machines on hand.

00:15:56.463 --> 00:16:02.818
Like, you can only rent out the VM-
not on demand, it has to be, like, in

00:16:02.828 --> 00:16:05.538
increments of 24 hours or something
like that, which means they have

00:16:05.538 --> 00:16:08.878
to have physical units on the shelf
that they only rent out once a day.

00:16:08.918 --> 00:16:09.348
I don't know.

00:16:09.558 --> 00:16:11.108
Maybe it's changed in recent years.

00:16:11.288 --> 00:16:18.048
Apple made the licensing of essentially
OSX ridiculous, which makes virtualization

00:16:18.058 --> 00:16:21.018
of it very hard, which means in
turns it becomes very expensive.

00:16:21.077 --> 00:16:25.287
<v Amos Wenger>So long story short, I
created a VM on my Mac Studio, which

00:16:25.287 --> 00:16:28.827
I bought for video editing reasons,
and it is way overpowered for what

00:16:28.827 --> 00:16:29.997
I need to do on a daily basis.

00:16:30.027 --> 00:16:31.347
Like I'm not always compiling Rust.

00:16:31.357 --> 00:16:33.641
Sometimes I think in between
compiles, believe it or not.

00:16:33.871 --> 00:16:37.367
And so I made a VM, gave it to Bjorn
and now he, he is actually able to

00:16:37.377 --> 00:16:41.297
build stuff and like test it in real
time, not wait for CI, which it's as

00:16:41.297 --> 00:16:43.187
you know, it's a long iteration loop.

00:16:43.327 --> 00:16:43.707
Whatever.

00:16:44.097 --> 00:16:44.697
Can't find the words.

00:16:45.117 --> 00:16:49.527
It just makes you think, I don't know if
he ever was asked that question before.

00:16:49.527 --> 00:16:53.117
Cause there's so many issues
about 64-bit MacOS ARM.

00:16:53.507 --> 00:16:56.137
But he never had the machine,
so he was never able to test.

00:16:56.167 --> 00:16:59.167
And it cost me next to nothing because
I already had the machine here.

00:16:59.177 --> 00:17:01.547
I just created the VM, created
a VPN, and then there you go.

00:17:01.587 --> 00:17:03.127
Remote desktop SSH.

00:17:03.127 --> 00:17:03.811
Go wild, do what you want.

00:17:04.276 --> 00:17:07.956
<v James Munns>We're so surprisingly close
to so many things that people think are

00:17:07.956 --> 00:17:14.166
very far away, just of getting the triple
point of: the person who knows about

00:17:14.166 --> 00:17:18.641
this, to have the time and money to do
it, and to have the resources to do it,

00:17:18.641 --> 00:17:20.184
like the access to the things they need.

00:17:20.231 --> 00:17:23.031
And you see this a bunch in Rust, I
feel like: Someone makes some very

00:17:23.031 --> 00:17:27.045
tiny token donation, and they go,
"Okay, well, yeah, then this person can

00:17:27.055 --> 00:17:28.515
buy the VM or the laptop they need."

00:17:28.675 --> 00:17:31.545
And then, two weeks later, something
you thought was years away is done.

00:17:31.705 --> 00:17:32.415
And ready.

00:17:32.515 --> 00:17:37.075
There's so much of that inefficiency
of resource distribution in reality.

00:17:37.360 --> 00:17:40.250
<v Amos Wenger>And this is why I'm happy
to announce my new charity, which

00:17:40.270 --> 00:17:42.050
is called Mac minis for Everyone.

00:17:42.200 --> 00:17:44.200
You can donate now, go
to macminisforeveryone.

00:17:44.230 --> 00:17:46.730
com, and I will send everyone a Mac mini.

00:17:46.950 --> 00:17:50.020
And then finally, we won't have
to wait for things to compile on

00:17:50.020 --> 00:17:51.610
your fucking Acer laptop again.

00:17:52.250 --> 00:17:52.640
There you go.

00:17:58.867 --> 00:18:00.917
<v James Munns>This episode is
sponsored by fasterthanlime.

00:18:01.263 --> 00:18:04.553
fasterthanlime is a 34 year old person
named Amos who makes articles and

00:18:04.553 --> 00:18:06.093
videos about computers for a living.

00:18:06.281 --> 00:18:08.621
They tend to go on long explorations
to find out the answers to

00:18:08.621 --> 00:18:10.781
questions that have been bothering
them since they were a kid.

00:18:11.422 --> 00:18:15.222
Rust and Linux are often involved,
but also asynchronous IO, dynamic

00:18:15.222 --> 00:18:17.982
linking, thread locals, and other
topics that only a few people get the

00:18:17.982 --> 00:18:19.472
chance to mess with on their own terms.

00:18:20.097 --> 00:18:23.637
You can support Amos's work by reading
articles on their website, watching their

00:18:23.637 --> 00:18:27.247
videos on YouTube, and by sponsoring
them on GitHub sponsors or Patreon.

00:18:27.693 --> 00:18:30.013
Thank you to Faster Than Lime
for sponsoring this episode.
