I’m absolutely new to rust but want to write my first lines to be compiled for a target which is not yet supported by LLVM upstream.
So I built the LLVM fork which supports my target architecture, myself.
Now I figure, I have to tell rustc to use the manually compiled toolchain instead of what it dragged in as dependencies on my OS (Debian).
Whatever I tried so far, rustc --print target-list never showed the LLVM target from my manually built LLVM toolchain.
What do I have to do in order to make rust use a different LLVM toolchain? Does it work that way at all? If not, could anybody provide any pointer which might help me what uses/calls/interfaces what and expects what being where?
If you have LLVM with a custom target added you’ll have to build your own rustc and point to the custom LLVM toolchain during the build.
“Pointing” is done via specifying a path to llvm-config in the custom toolchain in llvm-config variable in config.toml (see config.toml.example for all the available configuration).
Thanks, that’s really helpful!
Could you elaborate on details why rustc needs to be recompiled?
I figured, if it uses LLVM it’s linked against respective libs dynamically and might just be able to pick up (new) targets provided by the LLVM backend?
Obvously/Apparently that’s not the case - but why’s that?
Because rustc statically links against its llvm by default. I think there was some work to dynamically link, especially to accommodate some Linux distros, but not sure the status of it (also it can be dangerous if you don’t dynamically link against a compatible version, and some other details)
Thanks! I now managed to (statically) link rustc against my custom LLVM toolchain.
However rustc didn’t list the new target until I manually patched it into it.
That raises the question, why rustc needs to maintain its own hard-compiled list of targets rather than querying and using supported targets provided by LLVM?