On Nov 11, 2008, at 10:34 AM, Peter Shugalev wrote:> Hi, > > Anton Korobeynikov wrote: >>> I thought llvm-gcc isn't meant to compile for specific target (at >>> least >>> with -emit-llvm flag I'm using). >> No, it is not. C language is highly target-specific, thus LLVM IR >> obtained from such sources also has the same nice 'property' > > I can see only one reason for such dependence: inclusion of system > headers in /usr/include. If I compile llvm-gcc with predefined set of > Linux headers (the way cross-compilers are usually made) will the IR > output be the same no matter which platform is used for compilation? >No. Consider use of sizeof(), ABI issues, etc. --Owen -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2624 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20081111/e39dab81/attachment.bin>
Hi, Owen Anderson wrote:>> I can see only one reason for such dependence: inclusion of system >> headers in /usr/include. If I compile llvm-gcc with predefined set of >> Linux headers (the way cross-compilers are usually made) will the IR >> output be the same no matter which platform is used for compilation? >> > > No. Consider use of sizeof(), ABI issues, etc.Ooh, now I see llvm-gcc is not cross-compiler in the terms of GCC. Okay, but what if I actually compile LLVM-gcc as cross-compiler for 64-bit x86-64 Linux. Then it is guaranteed to produce identical output on all the systems. Question is: how the resulting LLVM IR will run on 32-bit machine? Should I create stubs for all called functions to convert between 32 and 64-bit pointers? Or it won't run at all? -- Best Regards Peter Shugalev
On Nov 11, 2008, at 2:19 PM, Peter Shugalev wrote:> Hi, > > Owen Anderson wrote: >>> I can see only one reason for such dependence: inclusion of system >>> headers in /usr/include. If I compile llvm-gcc with predefined set >>> of >>> Linux headers (the way cross-compilers are usually made) will the IR >>> output be the same no matter which platform is used for compilation? >>> >> >> No. Consider use of sizeof(), ABI issues, etc. > > Ooh, now I see llvm-gcc is not cross-compiler in the terms of GCC. > Okay, > but what if I actually compile LLVM-gcc as cross-compiler for 64-bit > x86-64 Linux. Then it is guaranteed to produce identical output on all > the systems. > > Question is: how the resulting LLVM IR will run on 32-bit machine? > Should I create stubs for all called functions to convert between 32 > and > 64-bit pointers? Or it won't run at all?If you configure it as a cross-compiler for 64-bit x86 Linux and feed it the appropriate header files, it will produce the same output on any platform. However, that output will not be executable on most platforms, just on 64-bit x86 Linux. The problems go beyond pointer size. The size of int is implementation dependent, etc. The layout and padding of structs is implementation dependent. While all implementations on a given target-triple will generally agree to ensure binary compatibility, there is no guarantee of things being the same once you go to another target-triple. --Owen -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2624 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20081111/8771b027/attachment.bin>