Skip to content

Fix rc compiler with cmake in cross-compilation#6857

Merged
waruqi merged 1 commit intoxmake-io:devfrom
star-hengxing:patch-1
Sep 25, 2025
Merged

Fix rc compiler with cmake in cross-compilation#6857
waruqi merged 1 commit intoxmake-io:devfrom
star-hengxing:patch-1

Conversation

@star-hengxing
Copy link
Contributor

clang-xx toolchain

/bin/sh: 1: llvm-rc: not found

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @star-hengxing, 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 addresses a critical build issue encountered during CMake cross-compilation, specifically when using clang-xx toolchains on Windows, which previously resulted in the llvm-rc: not found error. The changes ensure that the resource compiler (rc) is properly identified and configured by CMake for Windows targets, thereby enabling successful compilation of projects that incorporate resource files.

Highlights

  • Resource Compiler Configuration: Explicitly sets the CMAKE_RC_COMPILER environment variable for Windows platforms during CMake cross-compilation, ensuring that resource files are correctly processed.
  • Conditional Logic Refinement: Refactors the assignment of CMAKE_AR to be nested within the Windows platform check, improving the specificity of toolchain configuration.
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 fixes an issue with cross-compilation for Windows targets using CMake, where the resource compiler (llvm-rc) was not being found. The change correctly sets CMAKE_RC_COMPILER in the cross-compilation configuration. My review includes a suggestion to make this change more robust by checking for an empty path before setting the environment variable, which will prevent potential issues with CMake.

Comment on lines +628 to 633
if package:is_plat("windows") then
envs.CMAKE_RC_COMPILER = _translate_bin_path(package:build_getenv("mrc"))
if package:has_tool("cxx", "cl") then
envs.CMAKE_AR = path.join(path.directory(envs.CMAKE_CXX_COMPILER), "lib.exe")
end
end
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This change correctly identifies the need to set CMAKE_RC_COMPILER. However, it could be made more robust. If package:build_getenv("mrc") returns an empty string, CMAKE_RC_COMPILER will be set to "", which might cause issues with CMake. It's safer to only set the variable if a non-empty path is found. This prevents passing an empty -DCMAKE_RC_COMPILER= to CMake and allows it to use its default search logic.

    if package:is_plat("windows") then
        local mrc = package:build_getenv("mrc")
        if mrc and mrc ~= "" then
            envs.CMAKE_RC_COMPILER = _translate_bin_path(mrc)
        end
        if package:has_tool("cxx", "cl") then
            envs.CMAKE_AR = path.join(path.directory(envs.CMAKE_CXX_COMPILER), "lib.exe")
        end
    end

@waruqi waruqi merged commit 729a9e2 into xmake-io:dev Sep 25, 2025
22 checks passed
@star-hengxing star-hengxing deleted the patch-1 branch September 25, 2025 12:05
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