[LLVMdev] Byte code portability (was Re: libstdc++ as bytecode, and compiling C++ to C)

Chris Lattner sabre at nondot.org
Thu Nov 23 00:46:43 PST 2006


On Wed, 22 Nov 2006, [ISO-8859-1] Pertti Kellomäki wrote:
> Aside from stuff that depends on system headers, are there any other
> dependencies on the host system? In other words, will llvm-gcc produce
> exactly the same byte code for a given set of source files regardless of
> where compilation takes place? This has obvious implications on

Yes.  Many aspects of the target compiler can leak through.  One trivial 
example is:

int X = sizeof(long);

gcc evaluates 'sizeof' before LLVM gets control, therefore the var will 
get initialized with 8 or 4 depending on the target.

Another example is code like:

#ifdef __POWERPC__
int X = 1;
#else
int X = 0;
#endif

There are many other examples.

-Chris

-- 
http://nondot.org/sabre/
http://llvm.org/


More information about the llvm-dev mailing list