Description
Right now the compiler has a rustc_platform_intrinsics
crate which is basically a database of all platform intrinsics with their inputs/outputs and LLVM names, etc. This is the information the compiler uses to typecheck all intrinsics and also generate code for them with LLVM. An example generated file looks like aarch64.rs
.
These files are all generated by a generator.py
script in the src/etc
dir. This generator slurps up a ton of JSON definitions, for example all the files in src/etc/platform-intrinsics/x86
and then generates these Rust files.
Now that we're using Cargo as a build system we can avoid checking in these generated source files. Instead we can translate generator.py
into Rust as a build script and use build-time code generation to generate all of these files.
This isn't necessarily an easy task because generator.py
is not exactly a trivial script, but I'm more than willing to help out if anyone's got any questions!
Activity
tommyip commentedon May 10, 2017
I would like to work on this issue!
alexcrichton commentedon May 10, 2017
@tommyip oh I believe @F001 in also expressed interest earlier in #41568 for this issue. Just in that y'all may want to coordinate to make sure no toes are stepped on!
alexcrichton commentedon May 10, 2017
(not sure why that issue link didn't show up...), also sorry, should have mentioned that in the issue earlier!
tommyip commentedon May 10, 2017
ok no problem, I guess I should leave this to @F001 . @alexcrichton Are there any other scripts that need to be rewritten?
F001 commentedon May 10, 2017
Thanks. I will work on this.
theduke commentedon Sep 1, 2017
@F001 are you still working on this?
F001 commentedon Sep 1, 2017
@theduke I'm sorry, I have not wok on this for more than two months. And I guess I won't have enough time for the comming 2 months. I have updated my code on https://github.com/F001/librustc_platform_intrinsics, in a very early stage.
If anyone want to take this, that's OK. You can start from scratch or base on my project, it's your choice. I will probably come back to this issue at least 2 months later, if no one finish this task at that time.
laumann commentedon Sep 26, 2017
I see this was taken out of "impl period", but it is a desirable thing to have implemented at the moment? It looks interesting, and I think I have time to look into it, so I'd be happy to give it a go (unless @tommyip wants a go first 😄).
I also have some questions: the
generator.py
script takes some command-line parameters, and as this is not possible in build scripts, how should the generated code be built correctly? I'm guessing the parameters should be passed through env variables. Also, how should the code then be included? Is that any different than how it is now? (Now that I'm writing it, I guess I'm wondering where the code generation is triggered from and where the generated code is included.)12 remaining items