Skip to content

Commit 51205fb

Browse files
authored
Enable ChangeStdin/outToBinary for llvm-dis on Windows. (#4509)
This will fix issue when read input from stdin. Without ChangeStdinToBinary, llvm-dis will get wrong size for stdin input in some case. That will cause 'Invalid bitcode size' error when parse bitcode. MSFT_SUPPORTS_TEXTMODE_STREAMS was added a long time ago during initial file system virtualization work, the API should hit these functions under virtualized paths (and testing so far confirms this). We should keep an eye out still for a regression where the global stdin or stdout mode is unexpectedly overridden when using the API.
1 parent 7cdeb95 commit 51205fb

1 file changed

Lines changed: 0 additions & 4 deletions

File tree

lib/Support/Windows/Program.inc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -470,20 +470,16 @@ ProcessInfo sys::Wait(const ProcessInfo &PI, unsigned SecondsToWait,
470470
#endif // HLSL Change - MSFT_SUPPORTS_CHILD_PROCESSES
471471

472472
std::error_code sys::ChangeStdinToBinary() {
473-
#ifdef MSFT_SUPPORTS_TEXTMODE_STREAMS // HLSL Change
474473
int result = _setmode(_fileno(stdin), _O_BINARY);
475474
if (result == -1)
476475
return std::error_code(errno, std::generic_category());
477-
#endif // HLSL Change
478476
return std::error_code();
479477
}
480478

481479
std::error_code sys::ChangeStdoutToBinary() {
482-
#ifdef MSFT_SUPPORTS_TEXTMODE_STREAMS // HLSL Change
483480
int result = _setmode(_fileno(stdout), _O_BINARY);
484481
if (result == -1)
485482
return std::error_code(errno, std::generic_category());
486-
#endif // HLSL Change
487483
return std::error_code();
488484
}
489485

0 commit comments

Comments
 (0)