Skip to content

Fix build zig hello world project without specifying zig toolchain#7373

Closed
luadebug wants to merge 2 commits intoxmake-io:devfrom
luadebug:zigcc
Closed

Fix build zig hello world project without specifying zig toolchain#7373
luadebug wants to merge 2 commits intoxmake-io:devfrom
luadebug:zigcc

Conversation

@luadebug
Copy link
Member

@luadebug luadebug commented Mar 4, 2026

Resolves: #7372

Seems this prevent zig to work ;(

Code example https://ziglang.org/documentation/0.15.2/

const std = @import("std");

pub fn main() !void {
    try std.fs.File.stdout().writeAll("Hello, World!\n");
}
  1. Use --toolchain=zigcc when need C/C++ wrapper. (set_toolchains("zigcc") or xmake f --toolchain=zigcc)
  2. But use --toolchain=zig when need .zig language support. (set_toolchains("zig") or xmake f --toolchain=zig)

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a reported issue (#7372) that was preventing the Zig toolchain from working as intended within Xmake. The fix involves a precise modification to the Zig toolchain's configuration file, specifically by removing a set_kind directive that was identified as the root cause of the malfunction. This ensures better integration and stability for Zig projects using Xmake.

Highlights

  • Zig Toolchain Configuration: Removed the set_kind("standalone") configuration from the Zig toolchain definition in xmake.lua. This change addresses an issue where the previous setting prevented the Zig toolchain from functioning correctly.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • xmake/toolchains/zig/xmake.lua
    • Removed set_kind("standalone") from the Zig toolchain definition.
Activity
  • No specific activity has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request addresses a critical issue where the Zig toolchain was not functioning as expected, particularly in cross-compilation environments. By removing the explicit set_kind("standalone") declaration, the system can now correctly infer the toolchain's nature, resolving the reported problem and enabling proper functionality for Zig projects.


-- define toolchain
toolchain("zig")
set_kind("standalone")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Removing set_kind("standalone") is a crucial fix. The previous explicit setting was causing the Zig toolchain to be incorrectly classified, which prevented it from working correctly in cross-compilation scenarios as reported in issue #7372. This change allows the system to dynamically determine the toolchain's capabilities based on the environment, leading to correct behavior.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't simply remove it, as that would break support for zigcc. I haven't thought of a better solution yet. This is an old issue: #6628 (comment)

@luadebug luadebug closed this Mar 5, 2026
@waruqi
Copy link
Member

waruqi commented Mar 5, 2026

Or we can split it into two toolchains: zig and zigcc.

@luadebug luadebug reopened this Mar 5, 2026
@luadebug
Copy link
Member Author

luadebug commented Mar 5, 2026

Or we can split it into two toolchains: zig and zigcc.

Are current changes good enough?

@luadebug luadebug requested a review from waruqi March 6, 2026 10:07
@luadebug luadebug changed the title Resolve https://github.com/xmake-io/xmake/issues/7372 Fix build zig hello world project without specifying toolchain Mar 6, 2026
@luadebug luadebug changed the title Fix build zig hello world project without specifying toolchain Fix build zig hello world project without specifying zig toolchain Mar 6, 2026
@waruqi
Copy link
Member

waruqi commented Mar 7, 2026

Sorry, I've been quite busy lately. This seems a bit hacky; I still think splitting it into two toolchains, zig and zigcc, might be better.

@luadebug
Copy link
Member Author

luadebug commented Mar 7, 2026

Sorry, I've been quite busy lately. This seems a bit hacky; I still think splitting it into two toolchains, zig and zigcc, might be better.

It's ok. I am having hard time and being really busy recently so. That's indeed a good idea to split in a two but it looks like a big room of work to support that --toolchain=zigcc.

@waruqi
Copy link
Member

waruqi commented Mar 7, 2026

we also need to update tests. #7383

@waruqi
Copy link
Member

waruqi commented Mar 7, 2026

done

@waruqi waruqi closed this Mar 7, 2026
@luadebug luadebug deleted the zigcc branch March 7, 2026 15:26
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.

Xmake fails to build a hello world zig project without manually specifying the zig toolchain, despite zig being in PATH

2 participants