Skip to content

Add dynamic debugging support for msvc#7091

Merged
waruqi merged 6 commits intodevfrom
debug
Dec 2, 2025
Merged

Add dynamic debugging support for msvc#7091
waruqi merged 6 commits intodevfrom
debug

Conversation

@waruqi
Copy link
Member

@waruqi waruqi commented Dec 2, 2025

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @waruqi, 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 enhances Xmake's C++ build capabilities by adding support for Microsoft Visual C++'s Dynamic Debugging feature. This allows developers to debug optimized builds more effectively by automatically configuring the necessary compiler and linker flags, while also managing potential conflicts with other build settings like Link-Time Optimization.

Highlights

  • MSVC Dynamic Debugging Policy: Introduced a new policy build.c++.dynamic_debugging to enable C++ Dynamic Debugging for MSVC, with clear descriptions of its requirements (MSVC toolset 14.44+, x64 only) and incompatibilities (LTCG/PGO/OPT-ICF).
  • Dynamic Debugging Rule Implementation: Added a new Lua rule file xmake/rules/c++/config/dynamic_debugging.lua that encapsulates the logic for applying MSVC dynamic debugging flags (/dynamicdeopt). This rule includes checks for Windows platform, x64 architecture, MSVC toolchain version (14.44+), and automatically disables incompatible optimization flags like LTO while ensuring debug symbols are enabled.
  • Integration into C++ Configuration: The new dynamic debugging rule is integrated into the main C++ configuration flow (xmake/rules/c++/config/main.lua), ensuring it is applied before other optimization configurations to correctly handle flag conflicts.
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.

@waruqi waruqi added this to the v3.0.6 milestone Dec 2, 2025
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 adds support for MSVC's new C++ Dynamic Debugging feature. The implementation is well-structured, adding a new policy and a corresponding configuration script. The script correctly checks for platform, architecture, and toolchain version requirements.

My review includes a critical fix for policy checking logic to ensure target-level settings correctly override project-level ones. I've also suggested renaming the new policy for better consistency with existing MSVC-specific policies, which involves changes in two files. Overall, these are great additions to xmake.

end

-- check incompatible optimizations
local has_lto = target:policy("build.optimization.lto") or project.policy("build.optimization.lto")
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The logic for checking if LTO is enabled is incorrect. target:policy(...) or project.policy(...) does not correctly handle the case where LTO is disabled on the target but enabled on the project. If target:policy("build.optimization.lto") returns false, has_lto will incorrectly be assigned the value of project.policy("build.optimization.lto"). You should use the same pattern as for checking the dynamic_debugging policy to correctly respect target-level overrides.

    local has_lto = target:policy("build.optimization.lto")
    if has_lto == nil then
        has_lto = project.policy("build.optimization.lto")
    end

-- Set the default vs runtime, e.g. MT, MD
["build.c++.msvc.runtime"] = {description = "Set the default vs runtime.", type = "string", values = {"MT", "MD"}},
-- Enable C++ Dynamic Debugging for MSVC (requires MSVC toolset 14.44+, x64 only, incompatible with LTCG/PGO/OPT-ICF).
["build.c++.dynamic_debugging"] = {description = "Enable C++ Dynamic Debugging for MSVC (requires MSVC toolset 14.44+, x64 only, incompatible with LTCG/PGO/OPT-ICF).", type = "boolean"},
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For consistency with other MSVC-specific policies like build.c++.msvc.runtime, it would be better to name this policy build.c++.msvc.dynamic_debugging. This makes it clearer that this is an MSVC-only feature. I've added another comment to update its usage in dynamic_debugging.lua.

            ["build.c++.msvc.dynamic_debugging"]  = {description = "Enable C++ Dynamic Debugging for MSVC (requires MSVC toolset 14.44+, x64 only, incompatible with LTCG/PGO/OPT-ICF).", type = "boolean"},

Comment on lines +31 to +33
local enabled = target:policy("build.c++.dynamic_debugging")
if enabled == nil then
enabled = project.policy("build.c++.dynamic_debugging")
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

To match the suggested policy name change to build.c++.msvc.dynamic_debugging for better consistency, please update the policy name here as well.

    local enabled = target:policy("build.c++.msvc.dynamic_debugging")
    if enabled == nil then
        enabled = project.policy("build.c++.msvc.dynamic_debugging")

@waruqi waruqi mentioned this pull request Dec 2, 2025
@waruqi waruqi merged commit 5b0d381 into dev Dec 2, 2025
62 of 64 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant