I’ve encountered and reported this issue, but without much knowledge of the compiler’s internals, (what little I have has been gained through trying to fix this bug!) I don’t know what else I can do to fix it. I have already a small example demonstrating the problem, determined the [pull request the problem started in], and I’ve further narrowed down the problem to this short diff. But I don’t know how to proceed from here, beyond trying to find someone else with better knowledge of the compiler to help.
Since there hasn’t been much attention paid to the issue, no one else must be affected by it, but I think more people should be doing what this bug is preventing me from doing.
What’s the problem exactly?
Prior to the bug I was able to load a dynamic library, written in Rust, compile a new version of it and reload the new dynamic library, changing the behaviour of the program, all while the program was running. On the latest versions (
1.20.0 and onwards) the behaviour of the program stopped changing.
Why would I want to do that?
Reloading the code like this allows extremely fast feedback. You can experiment with parts of the program it takes a long time to get to from program start-up without performing the same steps over and over or changing the program to jump to that point and having to change it back later.
If that paragraph didn’t convince you, this video demonstrates what you can do when you have good, fast feedback, (and I think it’s something everyone should watch either way!)
Here’s a shorter video demoing a similar system in Clojurescript:
If that’s still too long, here’s a gif of my minimal example code and an editor configured to compile the code on save.
That’s cool, but how does it work?
To understand how it works, you can look at my example code, (you currently need to compile on
Or, you can watch this video which walks through getting a live code reloading system working on windows, in C++, using a dynamic library. (I’ve linked to the part where the reloading actually works).