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

需要改进对 zig 编译器的支持 #5915

Open
Redbeanw44602 opened this issue Dec 1, 2024 · 2 comments
Open

需要改进对 zig 编译器的支持 #5915

Redbeanw44602 opened this issue Dec 1, 2024 · 2 comments
Labels

Comments

@Redbeanw44602
Copy link
Contributor

Redbeanw44602 commented Dec 1, 2024

Xmake 版本

v2.9.6+20241030

操作系统版本和架构

Manjaro Linux

描述问题

一般有需要使用 zig 编译 C/C++ 项目的需求,xmake 对此已经有了初步支持,但测试发现仍然有些方面需要改进。

  1. 对于系统包的处理
    zig 默认不导入系统包,而 xmake 的默认行为恰好与之相反,这将导致头文件查找问题。

  2. 依赖库编译的工具链
    zig 基于 llvm 工具链构建,与 linux 下常用的 gcc 工具链(以及对应包)兼容性往往存在问题。

  3. glibc 版本选择
    zig 支持在 target 中传入 glibc 版本(doc),xmake 尚不支持。

  4. Compiling a cmake project with zig c++ doesn't resolve to and absolute path #5610

期待的结果

  1. 考虑默认不搜索系统包,等价 xmake 配置:
local opt = {
    system = false
}

add_requireconfs('**|cmake|pkg-config', opt)
  1. 考虑在文档中写明兼容问题,或者添加警告?

  2. 添加一个 glibc_version 参数

工程配置

N/A

附加信息和错误日志

N/A

@Issues-translate-bot
Copy link

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


Title: Need to improve zig compiler support

Xmake version

v2.9.6+20241030

Operating system version and architecture

Manjaro Linux

Describe the problem

Generally, there is a need to use zig to compile C/C++ projects. xmake already has preliminary support for this, but testing found that there are still some aspects that need improvement.

  1. Processing of system packages
    zig does not import system packages by default, and xmake's default behavior is exactly the opposite, which will cause header file lookup problems.

  2. Tool chain that relies on library compilation
    zig is built based on the llvm tool chain, and there are often compatibility issues with the gcc tool chain (and corresponding packages) commonly used under Linux.

  3. glibc version selection
    zig supports passing the glibc version in the target (doc), but xmake does not yet support it.

Expected results

  1. Consider not searching for system packages by default, equivalent to xmake configuration:
local opt = {
    system = false
}

add_requireconfs('**|cmake|pkg-config', opt)
  1. Consider writing compatibility issues in the documentation, or adding warnings?

  2. Add a glibc_version parameter

Project configuration

N/A

Additional information and error logs

N/A

@waruqi
Copy link
Member

waruqi commented Dec 2, 2024

考虑默认不搜索系统包,等价 xmake 配置:

这个在语言层面是没法自动处理的,你只能自己配置 system = false 不走系统,

或者 set_policy("package.install_only", true) 全局配置下,不走系统。

考虑在文档中写明兼容问题,或者添加警告?

没时间,可以来个 pr 过来。

添加一个 glibc_version 参数

这个可以参考 gcc/clang/msvc ,在 toolchain 中增加支持的 runtimes ,比如 glibc 等

set_runtimes("stdc++_static", "stdc++_shared")

然后在 zig rules 中取 runtimes 处理下,可以来个 pr 过来

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants