[llvm-dev] A "Cross-Platform Runtime Library API" in LLVM IR

Joerg Sonnenberger via llvm-dev llvm-dev at lists.llvm.org
Mon May 23 05:02:57 PDT 2016


On Mon, May 23, 2016 at 01:35:29PM +0200, Lorenzo Laneve via llvm-dev wrote:
> You guys are saying that the library which defines the runtime library is written in C for many languages.
> The problem is that such functions are in the libc and so the object files have to be linked against the **entire** libc.
> Sorry if I'm wrong but isn't it a little inefficient or hard to handle?
> With "hard to handle" I mean the entry point:
> if I use C's I/O operations, ain't I forced to use the C _start()
> implementation that calls its initializers (such as stdin and stdout
> initialization) before calling main() ?

And? The CRT startup often does a variety of things and if you want to
co-exist with C libraries at all, you won't be able to avoid it. Even if
you can avoid it, it adds a lot of OS and target specific knowledge to
your language runtime with little gain. Even for static linkage, a well
written stdio implementation is not that heavy. Just because glibc
requires 2MB for static linking hello-world, doesn't mean everyone else
does.

> I was thinking about maybe trying to make the languages runtimes
> independent from the C runtime. Wouldn't it make runtimes faster?

Unlikely. You might be able to reduce startup time a bit, but even that
is quite possible in the noise. On the other hand, you gain all the
advantage of dealing with different system call conventions, different
ways for managing kernel ABI compatibility etc. It's a pain when dealing
with Go already...

Joerg


More information about the llvm-dev mailing list