Skip to content

Xcode 26.2: Metal compile warning 'constexpr if is a C++17 extension' in generated steel_attention.h #342

@atlascodesai

Description

@atlascodesai

Environment

  • Xcode 26.2 (Build 17C52)
  • macOS 26.2 (Build 25C56)
  • Building from an Xcode project that pulls mlx-swift via SwiftPM

mlx-swift revision

  • main @ b2796b8 (from Package.resolved)

What happens
During a clean build, the Metal compilation for the generated Steel attention kernels emits warnings like this (seen on both macOS and iOS Simulator builds):

In file included from /tmp/LocalAIChat-DD-macOS/SourcePackages/checkouts/mlx-swift/Source/Cmlx/mlx-generated/metal/steel/attn/kernels/steel_attention.metal:7:
/tmp/LocalAIChat-DD-macOS/SourcePackages/checkouts/mlx-swift/Source/Cmlx/mlx-generated/metal/steel/attn/kernels/../../../steel/attn/kernels/steel_attention.h:349:16: warning: constexpr if is a C++17 extension [-Wc++17-extensions]
            if constexpr (is_bool) {
               ^
/tmp/LocalAIChat-DD-macOS/SourcePackages/checkouts/mlx-swift/Source/Cmlx/mlx-generated/metal/steel/attn/kernels/../../../steel/attn/kernels/steel_attention.h:419:14: warning: constexpr if is a C++17 extension [-Wc++17-extensions]
          if constexpr (BD == 128) {
             ^
/tmp/LocalAIChat-DD-macOS/SourcePackages/checkouts/mlx-swift/Source/Cmlx/mlx-generated/metal/steel/attn/kernels/../../../steel/attn/kernels/steel_attention.h:429:14: warning: constexpr if is a C++17 extension [-Wc++17-extensions]
          if constexpr (BD == 128) {
             ^
3 warnings generated.

Repro

  • Build any Xcode project that depends on mlx-swift at the revision above.
  • For example (from my app project):
    • xcodebuild -project "Local AI Chat.xcodeproj" -scheme "Seek Deep Local AI" -destination "generic/platform=macOS" -derivedDataPath /tmp/LocalAIChat-DD-macOS -quiet clean build
    • xcodebuild -project "Local AI Chat.xcodeproj" -scheme "Seek Deep Local AI" -destination "generic/platform=iOS Simulator" -derivedDataPath /tmp/LocalAIChat-DD-iOS -quiet clean build

Question
Is there an intended way to silence/avoid these warnings under Xcode 26.2 (e.g. Metal language standard flags), or should the generated MSL headers avoid using if constexpr?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions