Skip to content
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

builder: fix non-ASCII pathname under Windows #22405

Closed
wants to merge 2 commits into from

Conversation

kbkpbot
Copy link
Contributor

@kbkpbot kbkpbot commented Oct 4, 2024

This PR may help solve #20743, #21502, #21718

Because Windows use CP_ACP encoding, not UTF-8. So the generated rsp file should be encoded in CP_ACP/ANSI encoding under Windows.

This PR will help users build non-ASCII filename/pathname:

D:\测试目录\你好.v

你好.exe

@spytheman
Copy link
Member

spytheman commented Oct 4, 2024

Importing encoding.iconv in the compiler is not a good idea.
It will make a module, that depends on the presence of a thirdparty library, that we do not ship with V, a dependency for bootstrapping the compiler.

Besides, the V compiler already has no problem with non ASCII pathnames under windows or anything else.

What does have problem with those, on windows, is the prebuilt tcc executable that we ship in vlang/tccbin .

You can verify that by just using -cc gcc or -cc msvc when building a V program, placed in a path, that has non ASCII characters in it.

@spytheman spytheman closed this Oct 4, 2024
@spytheman
Copy link
Member

As for:

Because Windows use CP_ACP encoding, not UTF-8. So the generated rsp file should be encoded in CP_ACP/ANSI encoding under Windows.

That is worth doing in a private function in v.builder, that has a $if windows { branch, containing just a stripped down version of the code needed for converting utf8 to CP_ACP, not the entire encoding.iconv module (that also has a lot of unrelated stuff in it, that can break bootstrapping on not just windows).

@spytheman
Copy link
Member

It is interesting though if only the encoding of the .rsp file has to change 🤔 .
Does passing -no-rsp fix building with tcc on windows?

@spytheman
Copy link
Member

On windows-11 this works, both with and without -no-rsp 🤔 :
изображение

@spytheman
Copy link
Member

The 你好.v file also works:
изображение

@kbkpbot
Copy link
Contributor Author

kbkpbot commented Oct 4, 2024

image

This is not good for me. As tcc not work with non-ASCII filename.
Windows 10

V full version: V 0.4.8 0390c07
OS: windows, Microsoft Windows 10 ҵ LTSC v19044 64 λ
Processor: 16 cpus, 64bit, little endian,

getwd: D:\v\v\v
vexe: D:\v\v\v\v.exe
vexe mtime: 2024-10-04 11:45:39

vroot: OK, value: D:\v\v\v
VMODULES: OK, value: C:\Users\DDT.vmodules
VTMP: OK, value: C:\Users\DDT\AppData\Local\Temp\v_0

Git version: git version 2.43.0.windows.1
Git vroot status: 0.4.8-37-g0390c070-dirty
.git/config present: true

CC version: Error: 'cc' is not recognized as an internal or external command,
operable program or batch file.

thirdparty/tcc status: thirdparty-windows-amd64 b425ac82

@kbkpbot kbkpbot deleted the fix-windows-ansi-path branch October 6, 2024 04:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants