Skip to content

fix(linux): handle ATK C linkage with newer GLib headers - #193942

Draft
richyo-codes wants to merge 4 commits into
flutter:masterfrom
richyo-codes:pr/linux-atk-glib-compat
Draft

richyo-codes wants to merge 4 commits into
flutter:masterfrom
richyo-codes:pr/linux-atk-glib-compat

Conversation

@richyo-codes

@richyo-codes richyo-codes commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fix a Linux engine compilation issue involving ATK C linkage and newer GLib headers while preserving compatibility with the existing Debian Bullseye sysroot.

Older ATK headers do not consistently declare the atk_get_*version functions with C linkage. The existing workaround wraps <atk/atk.h> in extern "C", but newer GLib headers can include C++ support headers. Including those headers inside a C linkage block can cause C++ compilation errors.

Changes

  • Introduce a shared fl_atk_compat.h compatibility header that includes <glib.h> before wrapping <atk/atk.h> in extern "C".
  • Replace direct ATK includes and duplicated linkage workarounds in the affected Linux embedder sources and tests.
  • Register the compatibility header in BUILD.gn.
  • Avoid version-specific conditionals because distribution backports make header compatibility difficult to infer from GLib or ATK versions alone.

The underlying ATK header issue was fixed upstream in [at-spi2-core MR !219](https://gitlab.gnome.org/GNOME/at-spi2-core/-/merge_requests/219). See also [Debian bug #1145539](https://bugs.debian.org/1145539).

Compatibility and scope

This addresses one compilation issue encountered when preparing Linux engine builds for newer Debian Trixie sysroots, while maintaining compatibility with Bullseye.

Contributes to #194923, which tracks broader Bullseye/Trixie sysroot compatibility.

This PR intentionally does not:

  • Change the default Linux sysroot.
  • Modify accessibility behavior or runtime requirements.

The compatibility wrapper can be removed once all supported build environments contain the corrected ATK declarations.

Testing

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

Centralize the ATK linkage workaround and include C++ type traits outside
the C linkage block. Keep GTK4 target selection and accessibility behavior
out of this compatibility fix.
@github-actions github-actions Bot added engine flutter/engine related. See also e: labels. a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) platform-linux Building on or for Linux specifically a: desktop Running on desktop team-linux Owned by the Linux platform team labels Oct 7, 2026
Let GLib include its own C++ support headers before entering the
external C linkage block required by older ATK version declarations.
Avoid depending explicitly on the standard headers GLib happens
to use internally.

Validated the ATK header and C linkage with Bullseye and Trixie
sysroots.
Document the upstream 2.59.0 fix and older-version distribution
backports, the reason GLib must load outside C linkage, and the
condition for removing the wrapper.

A header linkage probe fails without the wrapper for the local
Bullseye ATK 2.38 and Trixie ATK 2.55 headers. Fixed host ATK
2.60.7 headers work directly; the GLib-first wrapper works in all
three environments.
@richyo-codes
richyo-codes marked this pull request as ready for review October 21, 2026 16:11
@richyo-codes
richyo-codes requested a review from a team as a code owner October 21, 2026 16:11

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

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 a new compatibility header, fl_atk_compat.h, to centralize and handle ATK header C-linkage compatibility issues, replacing inline workarounds and direct <atk/atk.h> includes across several Linux platform files. The review feedback identifies multiple violations of the Google C++ Style Guide regarding include ordering, specifically recommending that primary headers be placed first and project headers be grouped and sorted alphabetically.

extern "C" {
#include <atk/atk.h>
}
#include "flutter/shell/platform/linux/fl_atk_compat.h"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

According to the Google C++ Style Guide, the primary header (fl_accessibility_handler.h) should be the very first include in a test file, and project headers should be grouped and sorted alphabetically.\n\nPlease reorder the includes as follows:\ncpp\n#include "flutter/shell/platform/linux/fl_accessibility_handler.h"\n\n#include "flutter/shell/platform/linux/fl_atk_compat.h"\n#include "flutter/shell/platform/linux/fl_binary_messenger_private.h"\n

References
  1. The Google C++ Style Guide requires the primary header to be the first include, followed by other headers grouped and sorted alphabetically. (link)

extern "C" {
#include <atk/atk.h>
}
#include "flutter/shell/platform/linux/fl_atk_compat.h"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

According to the Google C++ Style Guide, the primary header (fl_view_accessible.h) should be the very first include in the source file, and other project headers should be grouped and sorted alphabetically.\n\nPlease reorder the includes as follows:\ncpp\n#include "flutter/shell/platform/linux/fl_view_accessible.h"\n\n#include "flutter/shell/platform/linux/fl_accessible_node.h"\n#include "flutter/shell/platform/linux/fl_accessible_text_field.h"\n#include "flutter/shell/platform/linux/fl_atk_compat.h"\n

References
  1. The Google C++ Style Guide requires the primary header to be the first include, followed by other headers grouped and sorted alphabetically. (link)


#include <atk/atk.h>
#include <gio/gio.h>
#include "flutter/shell/platform/linux/fl_atk_compat.h"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

According to the Google C++ Style Guide, project headers should be grouped together and sorted alphabetically.\n\nPlease reorder the project headers as follows:\ncpp\n#include "flutter/shell/platform/embedder/embedder.h"\n#include "flutter/shell/platform/linux/fl_atk_compat.h"\n#include "flutter/shell/platform/linux/public/flutter_linux/fl_engine.h"\n

References
  1. The Google C++ Style Guide requires project headers to be grouped together and sorted alphabetically. (link)

#endif

#include <atk/atk.h>
#include "flutter/shell/platform/linux/fl_atk_compat.h"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

According to the Google C++ Style Guide, project headers should be grouped together and sorted alphabetically.\n\nPlease reorder the project headers as follows:\ncpp\n#include "flutter/shell/platform/embedder/embedder.h"\n#include "flutter/shell/platform/linux/fl_atk_compat.h"\n#include "flutter/shell/platform/linux/public/flutter_linux/fl_engine.h"\n

References
  1. The Google C++ Style Guide requires project headers to be grouped together and sorted alphabetically. (link)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) a: desktop Running on desktop engine flutter/engine related. See also e: labels. platform-linux Building on or for Linux specifically team-linux Owned by the Linux platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant