Skip to content

macOS: Fix macOS 27 os_log compile errors, improve TRACE_VSYNC - #191238

Merged
cbracken merged 1 commit into
flutter:masterfrom
cbracken:fix-vsync-oslog-macos-27
Aug 19, 2026
Merged

cbracken merged 1 commit into
flutter:masterfrom
cbracken:fix-vsync-oslog-macos-27

Conversation

@cbracken

Copy link
Copy Markdown
Member

Suppress -Wignored-attributes triggered when compiling macOS-specific logging and vsync tracing code.

In the macOS 27 SDK that's part of Xcode 27, Apple appears to have added an OS_LOG_UNINITIALIZED macro inside their logging and signposting headers (os/log.h, os/signpost.h, os/trace_base.h). This macro expands to include: __attribute__((stack_protector_ignore)).

Because of this, we skip stack protection checks on local formatting buffers generated by logging macros such as os_log_with_type and os_signpost_event_emit. However, in Flutter, we compile the engine with -fstack-protector-all, which causes the build to error out complaining the stack_protector_ignore attribute is being ignored:

error: 'stack_protector_ignore' attribute ignored due to '-fstack-protector-all' option [-Werror,-Wignored-attributes]

This wraps these usages in ignore pragmas to avoid disabling it across the board, which is the same as the approach that was taken in:

This also creates the vsync log once and caches it statically as Apple recommends. os_log is already multi-tenant safe.

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.

@cbracken
cbracken requested a review from a team as a code owner August 18, 2026 01:11
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Aug 18, 2026
@flutter-dashboard

Copy link
Copy Markdown

It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

@github-actions github-actions Bot added engine flutter/engine related. See also e: labels. platform-macos Building on or for macOS specifically a: desktop Running on desktop team-macos Owned by the macOS platform team labels Aug 18, 2026
Suppress `-Wignored-attributes` triggered when compiling macOS-specific
logging and vsync tracing code.

In the macOS 27 SDK that's part of Xcode 27, Apple appears to have added
an `OS_LOG_UNINITIALIZED` macro inside their logging and signposting
headers (`os/log.h`, `os/signpost.h`, `os/trace_base.h`). This macro
expands to include: `__attribute__((stack_protector_ignore))`.

Because of this, we skip stack protection checks on local formatting
buffers generated by logging macros such as `os_log_with_type` and
`os_signpost_event_emit`. However, in Flutter, we compile the engine
with `-fstack-protector-all`, which causes the build to error out
complaining the `stack_protector_ignore` attribute is being ignored:

  error: 'stack_protector_ignore' attribute ignored due to '-fstack-protector-all' option [-Werror,-Wignored-attributes]

This wraps these usages in ignore pragmas to avoid disabling it across
the board, which is the same as the approach that was taken in:
* dart-lang/sdk@6bea1b7
* google/angle@918b93f

This also creates the vsync log once and caches it statically as Apple
recommends. `os_log` is already multi-tenant safe.
@cbracken
cbracken force-pushed the fix-vsync-oslog-macos-27 branch from 8d40c15 to b3ea25a Compare August 18, 2026 01:12
@cbracken cbracken changed the title macOS: Fix macOS 27 SDK os_log compile errors, improveTRACE_VSYNC macOS: Fix macOS 27 os_log compile errors, improve TRACE_VSYNC Aug 18, 2026

@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 modifies the TRACE_VSYNC macro in FlutterVSyncWaiter.mm to declare the log variable as static, preventing repeated calls to os_log_create. Additionally, it wraps the os_signpost_event_emit call with compiler pragmas to suppress -Wignored-attributes diagnostics. There are no review comments, and I have no feedback to provide.

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

Labels

a: desktop Running on desktop CICD Run CI/CD engine flutter/engine related. See also e: labels. platform-macos Building on or for macOS specifically team-macos Owned by the macOS platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants