Skip to content

Improve clang runtime#7145

Merged
waruqi merged 20 commits intodevfrom
clangrt
Dec 18, 2025
Merged

Improve clang runtime#7145
waruqi merged 20 commits intodevfrom
clangrt

Conversation

@waruqi
Copy link
Member

@waruqi waruqi commented Dec 18, 2025

@waruqi waruqi added this to the v3.0.6 milestone Dec 18, 2025
@waruqi waruqi requested review from Arthapz and star-hengxing and removed request for Arthapz December 18, 2025 01:41
@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 significantly refines Xmake's integration with Clang and LLVM toolchains. The primary goal is to ensure robust and correct linking of C++ standard libraries (libc++) and compiler-rt builtins across various platforms, with a particular focus on resolving known issues on Windows. This is achieved by introducing a comprehensive set of utility functions to precisely locate LLVM's internal directories and by applying these paths to compiler and linker flags. The changes also include a new test case to verify the improved runtime behavior and make toolchain detection more forgiving by converting fatal errors into warnings.

Highlights

  • Enhanced Clang/LLVM Runtime Support: Improved handling of libc++ and compiler-rt builtins, especially for Windows platforms, by correctly identifying and applying necessary include and library paths.
  • New LLVM Toolchain Utilities: Introduced a set of helper functions in private.utils.toolchain.lua to accurately detect and cache LLVM-related directories (resource, root, compiler-rt) and configure runtime environment variables (PATH, LD_LIBRARY_PATH, DYLD_FALLBACK_LIBRARY_PATH).
  • Improved Toolchain Configuration: Refactored clang.lua to leverage the new utilities for setting include paths and linker flags for libc++ and compiler-rt, addressing specific issues like manual -cxx-isystem for headers and -Xclang --dependent-lib for builtins on Windows.
  • New Test Case for Compiler-RT: Added a dedicated test project (tests/projects/c/llvm_compiler_rt) to validate llvm_compiler_rt functionality, specifically using __int128 types.
  • Non-Fatal Toolchain Checks: Modified LLVM toolchain checks in llvm/check.lua to issue warnings (wprint) instead of fatal errors (raise) when a toolchain or cross-target is not found, allowing for more flexible build configurations.
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 significantly improves the clang runtime support by refactoring the LLVM/Clang path detection logic into a new shared utility module. This is a great step towards better maintainability and robustness, especially for handling runtimes and library paths on different platforms like Windows. The changes also include new tests to validate the improved functionality. I've found a couple of issues in the new code that should be addressed.

@waruqi waruqi requested a review from Arthapz December 18, 2025 01:42
@waruqi
Copy link
Member Author

waruqi commented Dec 18, 2025

/gemini review

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 significantly refactors and improves the Clang/LLVM toolchain support, especially for Windows platforms using libc++ and compiler-rt. The introduction of the private.utils.toolchain module centralizes LLVM directory and environment detection, which is a great improvement for maintainability. The addition of tests for compiler-rt is also very valuable.

My main feedback is regarding a potential regression where rpath is no longer being added for shared libraries, which could affect the portability of binaries built with a custom LLVM toolchain.

@waruqi waruqi merged commit 67019f3 into dev Dec 18, 2025
64 of 65 checks passed
@waruqi waruqi deleted the clangrt branch December 18, 2025 07:07
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