Cannot configure on Windows in Chinese Environment

吴 国璋 zcxsythenew at outlook.com
Thu Nov 16 10:06:30 UTC 2023


Hi Magnus,

Yes, I think this is a good summary. And I also tried installing the language pack on the command line and it worked. 

-----邮件原件-----
发件人: Magnus Ihse Bursie <magnus.ihse.bursie at oracle.com> 
发送时间: 2023年11月15日 23:07
收件人: 吴 国璋 <zcxsythenew at outlook.com>; build-dev at openjdk.org
主题: Re: Cannot configure on Windows in Chinese Environment

Hi Wu,

Thank you very much for your assistance in testing this! I have followed up with some testing on my own as well. These are my conclusions:

* On Windows, you will need to have the English language pack installed for Visual Studio. For languages closely related to English, you might get away with a non-English locale, but this is not recommended nor supported.

* To install the English language pack, you can either use the Visual Studio GUI using this method:

- Click on "Visual Studio Installer" in Start menu.
- Click "Modify".
- Select the tab "Language packs".
- Choose "English".
- Click "Modify".

Or you can run it on the command line. For this to work, you need to start cmd.exe using "Run as Administrator". Then execute the following
line: (note that the " characters are essential)

"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installer.exe" modify --channelId VisualStudio.16.Release --productId Microsoft.VisualStudio.Product.BuildTools --addProductLang en-us -p

VisualStudio.16 represent VS 2019 -- replace the version number accordingly. If you have not installed the BuildTools, but e.g. 
Professional, adjust the product ID accordingly.

* The above information needs to be added to the build readme.

* When this is all done, apparently cl.exe notices something about the environment when run from configure, and selects the English locale. 
But, to be on the safe side, we should also add VSLANG=1033 to the environment when running cl.exe in the build system.

* When failing to parse the version number output from cl.exe, we can check if English locale seem to be installed. If it is, there should be a directory named "1033" in the same directory as cl.exe resides in. If this is missing, we should print a hint about installing the English language pack.

Do you think this sound like a good summary of the findings and what needs to be done?

/Magnus


On 2023-11-15 11:29, 吴 国璋 wrote:
> I did some test on my machine, and the results are shown below:
>
> - If I run `bash configure` with Chinese and English language pack installed, the command will succeed and cl.exe presents itself in English.
> - If I run cl.exe directly, it presents itself in Chinese, based on my Windows language settings.
>
> Given the above 2 facts, now we have several questions to answer, if we want to investigate the issue further:
>
> 1. Why `bash configure` works?
>
> I inserted a command `env` before Line 985 of `make/autoconf/toolchain.m4`, to find out what difference does `bash configure` make. And it shows that `bash configure` adds the following environment variables:
>
>> LANGUAGE=C
>> as_nl=
>> SHLVL=3
>> DUALCASE=1
>> LC_ALL=C
> However, none of these environment variables work when I run cl.exe directly. I don't know why `bash configure` can work, and it seems like some magic to me.
>
> 2. Does `VSLANG=1033` work?
>
> Yes, it works. If I run `VSLANG=1033 cl` in Cygwin terminal, cl.exe will present itself in English (language pack required). And there is a document about VSLANG, though this document is for vcpkg, not directly for cl.exe:
>
> https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flearn
> .microsoft.com%2F&data=05%7C01%7C%7C4a1eb654a53448a4f8f908dbe5ec9600%7
> C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638356576523321302%7CUnkno
> wn%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiL
> CJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=ZEMerHNPckAYOKTG5HIPjeOeFPF7NsUmxb
> F47ncfj1Q%3D&reserved=0 /vcpkg/users/config-environment
>
> 3. How to install Visual Studio language packs?
>
> As we know, Visual Studio is called "Visual" Studio, so most of its configurations are performed through GUI. To install the language pack:
>
> - Click on "Visual Studio Installer" in Start menu.
> - Click "Modify".
> - Select the tab "Language packs".
> - Choose "English".
> - Click "Modify".
>
> The command "vs_installer.exe --locale en-US" you mentioned just changes the installer itself to English.
>
> -----邮件原件-----
> 发件人: Magnus Ihse Bursie <magnus.ihse.bursie at oracle.com>
> 发送时间: 2023年11月14日 23:00
> 收件人: 吴国璋 <zcxsythenew at outlook.com>; build-dev at openjdk.org
> 主题: Re: Cannot configure on Windows in Chinese Environment
>
> On 2023-11-14 15:41, Magnus Ihse Bursie wrote:
>
>> However, I'd like to have some more investigation into how cl.exe 
>> picks the language.
>>
>> Is it a hard-coded behavior that it always picks English if it is 
>> installed? If so, it does not really make sense to have more than one 
>> language pack installed. Or is there some way to tell cl.exe which 
>> language to pick? Perhaps we send those signals without realizing it, 
>> like if it happens to look at LC_ALL. If that is the case, we need to 
>> know about this, so we don't inadvertently break it.
>>
> It seems that setting the environment variable VSLANG=1033 should do the trick. Some reports on the Internet indicates that this perhaps needs to be coupled with a "chcp 437".
>
> Can you please test if that works? If you try setting VSLANG=2052, does that force cl.exe to use the Chinese locale? If it does, happens if you combine VSLANG=2052 with chcp 437?
>
> If we are lucky, then this will boil down to
>
> a) instructions in the documentation to install the English language 
> pack of Visual Studio, and
>
> b) adding VSLANG=1033 to the makefiles.
>
> but I'd like to get some confirmation that VS really works like that.
>
> I have a vague memory of a discussion about VSLANG=1033 before, that it did not help, but maybe the core issue at that time was that the language pack was not installed, which made VS ignore the VSLANG variable.
>
> /Magnus
>
>


More information about the build-dev mailing list