Skip to content

Add Flang support#7096

Merged
waruqi merged 6 commits intodevfrom
flang
Dec 3, 2025
Merged

Add Flang support#7096
waruqi merged 6 commits intodevfrom
flang

Conversation

@waruqi
Copy link
Member

@waruqi waruqi commented Dec 3, 2025

@waruqi waruqi added this to the v3.0.6 milestone Dec 3, 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 significantly enhances xmake's compiler support by integrating the LLVM Fortran Compiler (Flang). It provides a complete framework for detecting, configuring, and utilizing Flang, ensuring that Fortran projects can be built seamlessly with xmake. The changes include a new toolchain definition, specific flag handling, and robust detection mechanisms to accommodate Flang's unique characteristics and platform-specific requirements.

Highlights

  • Flang Toolchain Integration: Introduced a new toolchain definition for Flang, the LLVM Fortran Compiler, enabling xmake to support Fortran projects built with Flang.
  • Custom Flang Tool Configuration: Added a dedicated Flang tool configuration module that inherits from Clang, customizing shared library flags, handling unsupported C/C++ flags, and adapting strip, symbol, and linking argument generation for Flang's specific requirements.
  • Flang Flag Detection Utility: Implemented a utility to robustly detect whether Flang supports specific compiler or linker flags, improving compatibility and configuration accuracy.
  • Flang Executable Discovery: Provided a new module to locate the Flang compiler executable and its version, including a fallback search for 'flang-new' on Linux systems.
  • Documentation Update: Updated both the English and Chinese README files to reflect the newly added support for the LLVM Fortran Compiler (Flang).
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 introduces support for the Flang Fortran compiler. The changes are comprehensive, including a new toolchain definition, tool-specific logic for flags and linking, and detection scripts. The implementation is well-structured, considering platform-specific details for architecture flags and symbol stripping, and follows the existing conventions within the xmake project. I have one minor suggestion to improve code clarity in the new toolchain definition file.


-- only add --target on platforms that need it (Linux, Windows)
-- macOS flang may work without explicit target
if target and (toolchain:is_plat("linux") or toolchain:is_plat("windows", "mingw")) then
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The target variable is checked for being non-nil here, but it has already been checked in the outer if statement on line 56. Since target is not modified to a falsy value within this block, this check is redundant and can be removed for better code clarity and maintainability.

            if toolchain:is_plat("linux") or toolchain:is_plat("windows", "mingw") then

@waruqi waruqi merged commit 6d803e2 into dev Dec 3, 2025
65 checks passed
@waruqi waruqi deleted the flang branch December 3, 2025 05:31
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