I am new to LLVM compiler and infrastructure. I have the following thought. Clang is the LLVM front end for C/C++, similarly Rustc for Rust programming language. Both can emit the LLVM IR code and the emitted code can be compiled to executable application.
My question is is it possible to link different programming languages? Example shown below -
/* Code in C */
int add(int, int);
int main()
{
printf("%d", add(5 ,6));
}
The function defined in Rust for example
// Code in Rust
fn main()
{
println!("{}", add(5, 6));
}
fn add (x: i32, y: i32) -> i32
{
x + y
}
Once the IR is generated from both the source files, is it possible to link them and create a single application?
I am just curious to know if this works, please let me know.