Fix rc compiler with cmake in cross-compilation#6857
Conversation
Summary of ChangesHello @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 Highlights
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
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.
| 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 |
There was a problem hiding this comment.
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
clang-xx toolchain
/bin/sh: 1: llvm-rc: not found