[llvm] r329468 - Windows needs the current codepage instead of utf8 sometimes

Friedman, Eli via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 9 14:36:00 PDT 2018


We have an API that C++ code can to use to correctly retrieve the 
Unicode command-line to a process: sys::Process::GetArgumentVector.  (On 
Unix systems, it just uses argv, but on Windows, it uses GetCommandLineW 
and converts the result to UTF-8.)  It looks like llvm-mc in particular 
doesn't use that API, but it should.

If llvm-mc is fixed to use GetArgumentVector, and lit is invoking 
llvm-mc with a Unicode command-line, everything should just work without 
the current codepage ever becoming involved.

-Eli

On 4/6/2018 6:12 PM, Aaron Smith wrote:
> Hi Eli,
>
> Yes that is unfortunate. The testing infrastructure is very delicate when it comes to encoding and python versions. See https://reviews.llvm.org/D43165 for more discussion. If you have other ideas, please let us know.
>
> Aaron
>
> On 4/6/18, 6:08 PM, "Friedman, Eli" <efriedma at codeaurora.org> wrote:
>
>      On 4/6/2018 5:32 PM, Aaron Smith via llvm-commits wrote:
>      > Author: asmith
>      > Date: Fri Apr  6 17:32:59 2018
>      > New Revision: 329468
>      >
>      > -  // Just use the caller's original path.
>      > -  return UTF8ToUTF16(Path8Str, Path16);
>      > +  // Path8Str now contains the full path or the original path
>      > +  // If the conversion from UTF8 to UTF16 fails because of ERROR_NO_UNICODE_TRANSLATION,
>      > +  // we also try using the current code page before giving up
>      > +  auto ec = UTF8ToUTF16(Path8Str, Path16);
>      > +  if (ec == mapWindowsError(ERROR_NO_UNICODE_TRANSLATION)) {
>      > +    ec = CurCPToUTF16(Path8Str, Path16);
>      > +  }
>      > +  return ec;
>      
>      This change is really dubious: we should not be charset sniffing in a
>      compiler.  This will cause bugs where code appears to work sometimes,
>      but randomly breaks when we guess the encoding incorrectly.
>      
>      -Eli
>      
>      --
>      Employee of Qualcomm Innovation Center, Inc.
>      Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
>      
>      
>

-- 
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project



More information about the llvm-commits mailing list