-
Notifications
You must be signed in to change notification settings - Fork 12.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Windows Native mangles bytecode output using cout #1159
Comments
Thanks Michael, I won't be able to get to this for a few days (probably this weekend). If you'd
I'm not sure if step 3 will work because of the lateness of the time at which Thanks for filing this well written PR! |
Adding the call in Bytecode/Writer/Writer.cpp WriteBytecodeToFile() and |
Michael, Since you have it working, could you provide the patch so we can commit the Thanks, Reid. |
I meant to say BytecodeStdinReader::BytecodeStdinReader() rather than I downloaded the compressed source rather than getting it with CVS. I'm |
Sounds great. I look forward to closing this bug and solving this problem for Reid. |
Thanks for the patch. The output for the BytecodeWriter isn't quite correct. The Thanks! |
That shouldn't be an issue, since whenever you're not writing to std::cout, |
Nevermind, I misinterpreted what you were saying. |
Michael, Your patch has been applied, tested, and found to work on Unix. This bug is now Thanks, Reid. Patches Applied: |
I have the patch working as you've entered it using the base 1.7 release. |
Yeah, Jeff Cohen usually updates the win32 stuff but I haven't seen him around |
Extended Description
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
, <io.h>, and <fcntl.h>.
The text was updated successfully, but these errors were encountered: