Skip to content

Fix finding clang-scan-deps#6851

Merged
waruqi merged 1 commit intoxmake-io:devfrom
tgsong:fix_finding_clang_scan_deps
Sep 24, 2025
Merged

Fix finding clang-scan-deps#6851
waruqi merged 1 commit intoxmake-io:devfrom
tgsong:fix_finding_clang_scan_deps

Conversation

@tgsong
Copy link
Contributor

@tgsong tgsong commented Sep 23, 2025

Finding clang-scan-deps is broken after 3.0.3, probably due to this commit e65101c, where target:tool("cxx") now returns clang++-<version> and clangxx when using versioned clang. Before it returned clang-<version> and clang. Since program may end with a version number, rtrim("+") will not work, changing it to gsub("%+%+", "") fixes this.

  • Before adding new features and new modules, please go to issues to submit the relevant feature description first.
  • Write good commit messages and use the same coding conventions as the rest of the project.
  • Please commit code to dev branch and we will merge into master branch in feature
  • Ensure your edited codes with four spaces instead of TAB.

  • 增加新特性和新模块之前,请先到issues提交相关特性说明,经过讨论评估确认后,再进行相应的代码提交,避免做无用工作。
  • 编写友好可读的提交信息,并使用与工程代码相同的代码规范,代码请用4个空格字符代替tab缩进。
  • 请提交代码到dev分支,如果通过,我们会在特定时间合并到master分支上。
  • 为了规范化提交日志的格式,commit消息,不要用中文,请用英文描述。

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @tgsong, 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 bug affecting the discovery of the clang_scan_deps tool, which became apparent after a recent update to version 3.0.3. The core issue was a change in how C++ compiler names were reported, specifically the inclusion of ++ in clang++-<version> executables. By refining the string manipulation logic to accurately strip the ++ suffix, this change restores the build system's ability to locate and utilize clang_scan_deps for all Clang versions, ensuring continued functionality for C++ module scanning.

Highlights

  • Fixing clang_scan_deps discovery: This pull request resolves an issue where the clang_scan_deps utility could not be correctly found after version 3.0.3 of the build system. The problem arose because target:tool("cxx") started returning clang++-<version> instead of clang-<version> for versioned Clang compilers.
  • Correcting string manipulation for compiler names: The previous logic used rtrim("+") to remove the + suffix, which failed when the program name included a version number (e.g., clang++-15). The fix replaces this with gsub("%+%+", "") to correctly remove the ++ sequence, ensuring proper identification of clang-scan-deps.
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

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 finding clang_scan_deps when using a versioned clang compiler like clang++-<version>. The change from rtrim("+") to gsub("%+%+", "") correctly handles the ++ in the compiler name. However, this change doesn't correctly handle the clangxx compiler name, which would be transformed into clang-scan-depsxx. I've suggested a more robust regular expression to handle all cases (clang, clang++, clangxx, with or without version suffixes) correctly and more concisely.

end
local extension = path.extension(program)
program = (basename:rtrim("+"):gsub("clang", "clang-scan-deps")) .. extension
program = (basename:gsub("%+%+", ""):gsub("clang", "clang-scan-deps")) .. extension
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

While this change correctly handles clang++ and clang++-<version>, it doesn't correctly handle clangxx, which would be transformed into clang-scan-depsxx. A more robust approach would be to handle all variants (clang, clang++, clangxx) in a single, more expressive regular expression. This simplifies the code and correctly handles all cases.

            program = (basename:gsub("clang(%+%+|xx)?", "clang-scan-deps")) .. extension

@tgsong tgsong changed the title Fix finding clang_scan_deps Fix finding clang-scan-deps Sep 23, 2025
@waruqi waruqi merged commit 844e171 into xmake-io:dev Sep 24, 2025
21 of 22 checks passed
@waruqi waruqi added this to the v3.0.4 milestone Sep 24, 2025
@tgsong tgsong deleted the fix_finding_clang_scan_deps branch September 24, 2025 02:39
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