[LLVMdev] Binary output to cout on Windows

Chris Lattner sabre at nondot.org
Mon May 22 16:35:41 PDT 2006


On Mon, 22 May 2006, Michael Smith wrote:
> llvm-as interprets "-" as using standard output (cout), so llvm-as <
> input.ll -o - | opt has the same behavior. You'll actually find a
> comment on it in llvm-as.cpp, so I guess I shouldn't hold out hope that
> there's a good way to do it.

Please see:
http://www.parashift.com/c++-faq-lite/input-output.html#faq-15.13

We'd welcome patches to do this, and we can localize this in our system 
support library, but you'd have to figure out the magic to make this 
happen on win32.

-Chris

> -----Original Message-----
> From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu]
> On Behalf Of Reid Spencer
> Sent: Monday, May 22, 2006 3:34 PM
> To: LLVM Developers Mailing List
> Subject: Re: [LLVMdev] Binary output to cout on Windows
>
> Hi Michael,
>
> LLVM uses the standard C++ library for this output. If LLVM opens the
> file, it is opened in binary mode. However, LLVM is inheriting this file
> descriptor from the shell in your example (std::cout) so we don't/can't
> change the  open mode. You might want to try this instead:
>
> llvm-as < input.ll -o output.bc OR llvm-as < input.ll -o - | opt
>
> Reid.
>
> On Mon, 2006-05-22 at 14:43 -0700, Michael Smith wrote:
>> I'm trying to resolve an issue that occurs in the native Windows
>> implementation of LLVM (it probably doesn't occur in Cygwin, but I
>> haven't checked). Namely, when calling
>>
>>             llvm-as < input.ll > output.bc     OR     llvm-as <
>> input.ll | opt
>>
>> outputting to cout is adding \r (the CR character) to newlines. This
>> specifically causes problems in WriterContext::write(...) in
>> lib/Support/Compressor.cpp. Is anyone aware of a way to use a binary
>> mode on cout in Windows (compiled with Visual Studio .NET 2003), or at
>> least disable the inclusion of \r? It would be nice to allow the pipe
>> functionality if it can be done cleanly.
>>
>>
>>
>> ~Michael
>>
>>
>> _______________________________________________
>> LLVM Developers mailing list
>> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>

-Chris

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




More information about the llvm-dev mailing list