Chris Lattner
2006-Nov-23 08:46 UTC
[LLVMdev] Byte code portability (was Re: libstdc++ as bytecode, and compiling C++ to C)
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 onYes. 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/
Pertti Kellomäki
2006-Nov-23 14:51 UTC
[LLVMdev] Byte code portability (was Re: libstdc++ as bytecode, and compiling C++ to C)
Chris Lattner wrote:> Many aspects of the target compiler can leak through.So if one wants to use the LLVM system as a cross compiler, one has to configure llvm-gcc as a cross compiler? Fair enough, I guess.> One trivial example is: > > int X = sizeof(long);So I assume this also means that while getelementptr insulates llvm byte code from the details of target specific address calculations, the target back end has to agree with gcc on how much space values of each data type consume. -- Pertti
Reid Spencer
2006-Nov-23 15:18 UTC
[LLVMdev] Byte code portability (was Re: libstdc++ as bytecode, and compiling C++ to C)
On Thu, 2006-11-23 at 16:51 +0200, Pertti Kellomäki wrote:> Chris Lattner wrote: > > Many aspects of the target compiler can leak through. > > So if one wants to use the LLVM system as a cross compiler, one > has to configure llvm-gcc as a cross compiler? Fair enough, I guess.Yes.> > > One trivial example is: > > > > int X = sizeof(long); > > So I assume this also means that while getelementptr insulates > llvm byte code from the details of target specific address calculations, > the target back end has to agree with gcc on how much space values > of each data type consume.They agree through the llvm IR. LLVM integer and floating point types are fixed in size. The front end compiler must use the appropriate type to get the size that it wants. The only difference might be in structure layout as LLVM doesn't support alignment attributes in structures. Reid.
Philipp Klaus Krause
2006-Nov-23 18:10 UTC
[LLVMdev] Byte code portability (was Re: libstdc++ as bytecode, and compiling C++ to C)
Pertti Kellomäki schrieb:> Chris Lattner wrote: >> Many aspects of the target compiler can leak through. > > So if one wants to use the LLVM system as a cross compiler, one > has to configure llvm-gcc as a cross compiler? Fair enough, I guess.I hope the C backend is still meant to generate portable code though. Philipp
Possibly Parallel Threads
- [LLVMdev] Byte code portability (was Re: libstdc++ as bytecode, and compiling C++ to C)
- [LLVMdev] Byte code portability (was Re: libstdc++ as bytecode, and compiling C++ to C)
- [LLVMdev] Byte code portability (was Re: libstdc++ as bytecode, and compiling C++ to C)
- [LLVMdev] Byte code portability (was Re: libstdc++ as bytecode, and compiling C++ to C)
- [LLVMdev] Byte code portability (was Re: libstdc++ as bytecode, and compiling C++ to C)