I am using an obscure programming language which doesn't have the privilege of having as much options in terms of third party libraries as popular languages do. The language I use is flexible though, and its pretty easy to modify the language. Let's say the language is Common Lisp. Lets also assume that CL has a compiler that compiles to LLVM and the language+library (let's say C++ and OpenCV) I want to use from CL also has a LLVM compiler. So could I use LLVM IR form of OpenCV as a pseudo-transpilation?
Asked
Active
Viewed 1,479 times
1
-
Related: https://stackoverflow.com/a/45235544/637669 – arrowd Jan 08 '19 at 07:39
-
2What exactly are you asking? Whether you can translate C++ to to Common Lisp via LLVM? No. Just because you can compile a language to LLVM does not automatically mean you can easily "decompile" arbitrary LLVM code to that language. If you want to call a C++ library from another language, you'll either want a C interface to the lib that you invoke via the language's native FFI or you want to add a specific C++ FFI to your language (the latter being the much less common approach). Either way you'd usually go through the native code, not the LLVM IR. – sepp2k Jan 08 '19 at 08:14
1 Answers
3
That kind of thing requires that struct/object layout matches, that name mangling matches (for languages that have naming scopes other than global), that various exception handling details agree if either/both languages have exceptions, that inheritance/vtables is handled in the same way, and the calling conventions have to be compatible. There may be more, that was just a quick answer from the top of my head.
If you have to ask about this, I fear that the short answer is "no".

arnt
- 8,949
- 5
- 24
- 32
-
I don't understand what you mean by "If you have to ask about this, I fear that the short answer is "no"" – maou Jan 08 '19 at 15:41
-
2I meant that if you you have to ask, you probably aren't familiar with these matters, and then the number of difficulties may be too large. Solving some of these is work, solving some others is hard work, but you have to solve all to get it to work, and solving all is very, very hard work for someone who isn't familiar with the subject area. – arnt Jan 08 '19 at 16:56