Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

自动识别 clang 的 target #6077

Closed
KeqingMoe opened this issue Jan 13, 2025 · 6 comments
Closed

自动识别 clang 的 target #6077

KeqingMoe opened this issue Jan 13, 2025 · 6 comments

Comments

@KeqingMoe
Copy link

你在什么场景下需要该功能?

自从 830e65800 起,使用 llvm-mingw 必须手动 xmake f -p mingw 或 xmake.lua 中写上 set_plat("mingw") ,否则一律会将 --target=x86_64-windows-msvc 传递给 clang,然而期待的是 --target=x86_64-w64-windows-gnu

#6059 也提到了这个问题。

描述可能的解决方案

一个简单但未必足够好的实现方式是,编译前先运行 clang -v ,可能的输出:

clang version 19.1.3 (https://github.com/llvm/llvm-project.git ab51eccf88f5321e7c60591c5546b254b6afab99)
Target: x86_64-w64-windows-gnu
Thread model: posix
InstalledDir: C:/****/llvm-mingw-20241030-ucrt-x86_64/bin

从第二行的 Target: 之后开始提取出 x86_64-w64-windows-gnu ,然后再视情况做后续处理。

描述你认为的候选方案

No response

其他信息

No response

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Title: Automatically identify clang’s target

In what scenario do you need this function?

Since 830e65800, using llvm-mingw must manually xmake f -p mingw or write in xmake.lua set_plat("mingw"), otherwise --target=x86_64-windows-msvc will always be passed to clang, but what is expected is --target=x86_64-w64-windows-gnu.

#6059 also mentions this issue.

Describe possible solutions

A simple but not necessarily good enough implementation is to run clang -v before compiling. Possible output:

clang version 19.1.3 (https://github.com/llvm/llvm-project.git ab51eccf88f5321e7c60591c5546b254b6afab99)
Target: x86_64-w64-windows-gnu
Thread model: posix
InstalledDir: C:/****/llvm-mingw-20241030-ucrt-x86_64/bin

Start extracting x86_64-w64-windows-gnu after Target: in the second line, and then perform subsequent processing as appropriate.

Describe your alternatives

No response

Other information

No response

@waruqi
Copy link
Member

waruqi commented Jan 14, 2025

@star-hengxing 话说当初显式指定 target 是解决啥问题?不设置 直接走默认 target 不行么

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


@star-hengxing What problem was solved by explicitly specifying the target? Isn’t it okay to just use the default target without setting it?

@star-hengxing
Copy link
Contributor

target 名已经修了 #5973

@star-hengxing 话说当初显式指定 target 是解决啥问题?不设置 直接走默认 target 不行么

clang 本身是交叉编译工具链,如果默认 target 是 x86_64-windows-msvc 或者在非 msys2 之类的开发环境,想用 mingw + clang 就要显式给出 target & sysroot 。但 mingw 的 sysroot 头文件有 include 的问题(好像只是 msys2 的问题?)就删了,只留下 target,理论上应该没有大碍。
#5823 (comment)

@waruqi waruqi closed this as completed Jan 16, 2025
@waruqi
Copy link
Member

waruqi commented Jan 16, 2025

既然修了,直接用最新的 dev 版本就行了。 xmake update -s dev

@waruqi waruqi added this to the v2.9.8 milestone Jan 16, 2025
@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Now that it has been fixed, just use the latest dev version. xmake update -s dev

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

4 participants