-
-
Notifications
You must be signed in to change notification settings - Fork 776
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平台下C++项目使用lld-link时传递参数字符串编码为utf-8导致链接参数无法被linker识别 #5547
Comments
Title: When using lld-link in a C++ project on the Windows platform, the parameter string passed is encoded as utf-8, resulting in the link parameters not being recognized by the linker. Xmake versionv2.9.4+HEAD.e85b001f1 Operating system version and architectureWindows 11 23H2 Describe the problemAs the title states, when using lld-link in a C++ project on the Windows platform, the parameter string passed is encoded as utf-8, and the link parameters cannot be recognized by the linker. After testing, it can be linked normally when using ansi, but it is difficult to reproduce the demo alone. This can only be reproduced when there are long paths + multiple Chinese file names. It is somewhat difficult to provide demos. When the regional settings of Windows 11 are turned on and the system's default encoding is set to utf-8, the link is normal. However, turning on utf-8 in the system will affect individual applications, which is not a good solution. Expected resultsUse local encoding when passing link parameters so that the link can work normally even if the regional settings are not turned on and the system's default encoding is set to utf-8. Project configurationnone Additional information and error logsNone |
如果是长路径,其实现在已经是 ansi 了。。长路径会走 file list 作为 args,不走终端命令行。 xmake/xmake/modules/core/tools/link.lua Line 133 in 2f3f1a0
xmake/xmake/core/base/winos.lua Line 171 in 2f3f1a0
|
那就有点迷了,这个报错,编码这个问题,因为用命令行手动输入链接命令的话确实是能过的 |
我把ansi改成utf-8,它竟然好了,可能要探测一下看看原本输入的编码是什么,否则出现非英文字符可能会出问题 |
If it is a long path, it is actually ansi now. . For long paths, file list will be used as args instead of the terminal command line. xmake/xmake/modules/core/tools/link.lua Line 133 in 2f3f1a0
xmake/xmake/core/base/winos.lua Line 171 in 2f3f1a0
|
Then I’m a little confused. How should I test this error? As for the encoding problem, it is indeed possible to pass the link command manually by using the command line. |
I changed ansi to utf-8 and it worked. I may need to adjust it to see what the original input encoding was. |
xmake 内部所有字符串都是 utf8,除非是写文件 显式指定了 ansi 。。 |
那这个问题应该怎么解决比较好呢?理论上windows命令行程序输入的参数的编码是是ansi的,但是这里又不是。 |
All strings inside xmake are utf8, unless ansi is explicitly specified when writing a file. . |
So what is the best way to solve this problem? Theoretically, the encoding of parameters input into the Windows command line program is ANSI, but it is not the case here. |
不知道,我这边也没换环境复现。。先确认是否只有 lld-link.exe 支持 utf8 不支持 ansi,如果只是这一个特例,那就只能针对它单独处理。 |
I don’t know, I haven’t changed the environment to reproduce it. . First confirm whether only lld-link.exe supports utf8 and not ansi. If it is just a special case, it can only be dealt with separately. |
测试下来,在控制台本地编码是936的情况下手动输入链接命令能正常链接,在xmake中指定ansi不行,反而使用utf-8却可以,这就是说不通的地方。 |
After testing, when the local encoding of the console is 936, manually entering the link command can link normally. Specifying ansi in xmake does not work, but using utf-8 does. This is where it doesn't make sense. |
Xmake 版本
v2.9.4+HEAD.e85b001f1
操作系统版本和架构
windows 11 23H2
描述问题
如题,Windows平台下C++项目使用lld-link时传递参数字符串编码为utf-8,链接参数无法被linker识别。经过测试,手动复制编译命令使用ansi的情况下可以正常链接,但是单独的demo很难复现,这个要在长路径+多中文文件名的情况下才能复现,提供demo有些困难。在开启windows 11 的区域设置将系统的默认编码设置为utf-8时链接正常,但是系统开启utf-8会对个别应用造成影响,不是很好的解决方案。
期待的结果
传递链接参数时使用本地编码,使得不开启区域设置将系统的默认编码设置为utf-8时链接也能正常工作
工程配置
无
附加信息和错误日志
lld-link: error: could not open 'build\.objs\server\windows\x86\release\src\2.server\xxx\xxx\中文.cpp.obj': 在多字节的目标代码页中,没有此 Unicode 字符可以映射到的字符。
The text was updated successfully, but these errors were encountered: