[LLVMbugs] [Bug 787] NEW: Windows Native mangles bytecode output using cout
bugzilla-daemon at cs.uiuc.edu
bugzilla-daemon at cs.uiuc.edu
Tue May 23 12:22:51 PDT 2006
http://llvm.org/bugs/show_bug.cgi?id=787
Summary: Windows Native mangles bytecode output using cout
Product: tools
Version: 1.6
Platform: PC
OS/Version: Windows XP
Status: NEW
Severity: normal
Priority: P2
Component: llvm-as
AssignedTo: unassignedbugs at nondot.org
ReportedBy: mtsmith at synopsys.com
When using the Windows native build of version 1.6 (I've seen no sign this was
fixed in 1.7, although testing that is tricky since the win32 build in 1.7 is
pretty unstable) llvm-as output using cout uses text output, replacing newlines
with CR+LF characters, mangling the output.
Examples of this can be found in test case
Regression/Linker/2002-07-17-GlobalFail.ll where the following line has an error:
llvm-as < 2002-07-17-GlobalFail.ll > %s.bc
because the output is being written to stdout and redirected to %s.bc.
This also occurs when getting input from stdin (cin) in llc, lli, llvm-dis, and opt.
A solution to this has been discussed on the mailing list under the name "Binary
output to cout on Windows", and is reposted below, essentially changing the mode
on stdin and stdout to binary.
The code that needs to be run before input/output is done on stdin/stdout is:
int result = _setmode( _fileno(stdin), _O_BINARY );
if( result == -1 )
{ std::cerr<<"Cannot set input mode to binary."<<std::endl; return 1; }
result = _setmode( _fileno(stdout), _O_BINARY );
if( result == -1 )
{ std::cerr<<"Cannot set output mode to binary."<<std::endl; return 1; }
Error checking included. The files that need to be included for this code are
<cstdio>, <io.h>, and <fcntl.h>.
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
More information about the llvm-bugs
mailing list