I'm attempting to use file I/O across platforms from LLVM assembly using the standard GNU C library: fprintf(), stdin/stdout, etc. Ideally I'd like to simply provide a single bitcode file that could be compiled on each platform, but because the internals of the I/O on each platform is different, this is not currently workable. So my question is this: How do you suggest doing I/O in a portable way from LLVM assembly? My current thoughts run along two lines: 1. Writing a non-portable wrapper around the I/O routines to present a common interface to the calling module. 2. Conditional assembly for each platform, but I don't see any facilities for this in LLVM assembly. Are there any other ways to do this or any projects in the works that may provide a solution? Thanks, Mike -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100212/852c8745/attachment.html>
"Michael Ness" <mike at liquido2.com> writes:> I'm attempting to use file I/O across platforms from LLVM assembly > using the standard GNU C library: fprintf(), stdin/stdout, etc. > Ideally I'd like to simply provide a single bitcode file that could be > compiled on each platform, but because the internals of the I/O on > each platform is different, this is not currently workable.Why not library calls? [snip]
Hello Óscar, The problem with that idea is that they require a pointer to a FILE structure. This file structure is included from stdio.h which has macros and conditional compilation all over the place. There are no constructors in these libraries to call and, as such, they are platform dependent. Is there any way to link in an external type definition to an opaque type? We'd need to include some equivalent of stdio.h into the bitcode. Thanks for trying, --Sam ----- Original Message ----> From: Óscar Fuentes <ofv at wanadoo.es> > To: llvmdev at cs.uiuc.edu > Sent: Fri, February 12, 2010 9:45:32 AM > Subject: Re: [LLVMdev] Portable I/O > > "Michael Ness" writes: > > > I'm attempting to use file I/O across platforms from LLVM assembly > > using the standard GNU C library: fprintf(), stdin/stdout, etc. > > Ideally I'd like to simply provide a single bitcode file that could be > > compiled on each platform, but because the internals of the I/O on > > each platform is different, this is not currently workable. > > Why not library calls? > > [snip] > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev