Skip to content

SDK install copies PATH Clang 22 headers incompatible with Swift 6.4’s embedded Clang 21 #273

Closed

Description

@TheEdgeOfRage

Description

On Linux, xtool sdk install copies Clang resource headers from the clang executable found on PATH:

let clangURL = try await ToolRegistry.locate(\"clang\")
...
try await FileManager.default.copyItem(at: hostInclude, to: sdkInclude, preserveOwner: false)

On my system, this selects Clang 22.1.8, but Swift 6.4 embeds libclang.so.21.0.0. The resulting SDK contains Clang 22 resource headers that are compiled by Swift’s Clang 21 frontend.

Building an iOS package then fails in arm_neon.h:

.../usr/lib/clang/21/include/arm_neon.h:49996:11:
error: size of '__builtin_bit_cast' source type 'int' does not match
destination type 'int64_t' (aka 'long long') (4 vs 8 bytes)

Expected result

xtool sdk install should use Clang resource headers compatible with the selected Swift toolchain, or fail during SDK installation with an actionable version-mismatch error.

Actual result

The generated SDK copies Clang 22 headers from PATH, while swift-frontend uses Swift 6.4’s embedded Clang 21. xtool dev fails before app sources compile.

Validation

I replaced the installed SDK resource headers with the resource headers from Clang 21.1.8:

/usr/lib/llvm21/lib/clang/21/include

The __builtin_bit_cast and arm_neon.h failures disappeared completely. The build progressed through the prior _Builtin_intrinsics stage and into app compilation.

Environment

  • Arch Linux, latest
  • xtool: v1.20.1
  • Swift: swift-bin 6.4.0-1
  • Swift embedded Clang: libclang.so.21.0.0
  • PATH Clang: clang 22.1.8-1
  • Alternate compatible Clang: clang21 21.1.8-1
  • Darwin SDK: epoch=2,darwinTools=1.1.0,oam=1.3.0
  • iPhoneOS SDK: 27.0

Related: #215

Activity

  1. kabiroberai commented on Sep 21, 2026

    @kabiroberai
    Member

    I wonder if we're picking up the wrong clang resource dir (we should be using the one in the Swift toolchain).

    Could you please share the output of the following?

    clang -print-resource-dir
    swiftc -print-target-info
    readlink -f "$(swiftc -print-target-info | grep runtimeResourcePath | cut -d'"' -f4)/clang"
    
  2. kabiroberai commented on Sep 21, 2026

    @kabiroberai
    Member

    Also could you check if #274 fixes the issue for you?

  3. added a commit that references this issue on Sep 22, 2026
    df1b6fa
  4. TheEdgeOfRage commented on Sep 22, 2026

    @TheEdgeOfRage
    Author

    @kabiroberai got a bunch of warnings, but the build passed now with your fix, so I guess I'll just ignore these 🤷

    warning: Unable to locate libSwiftScan. Fallback to `swift-frontend` dependency scanner invocation.
    warning: /home/user/dev/ios/ytrssil/.build/out/Intermediates.noindex/ytrssil.build/Debug-iphoneos/ytrssilShared-t.build/Objects-normal/arm64/ytrssilShared-primary-emit-module.dia Could not read serialized diagnostics file: unable to find libclang in any registered toolchain
    warning: Unable to locate libSwiftScan. Fallback to `swift-frontend` dependency scanner invocation.
    warning: Unable to locate libSwiftScan. Fallback to `swift-frontend` dependency scanner invocation.
    warning: /home/user/dev/ios/ytrssil/.build/out/Intermediates.noindex/ytrssil.build/Debug-iphoneos/ytrssilShared-t.build/Objects-normal/arm64/ServerConfiguration.dia Could not read serialized diagnostics file: unable to find libclang in any registered toolchain
    warning: /home/user/dev/ios/ytrssil/.build/out/Intermediates.noindex/ytrssil.build/Debug-iphoneos/ytrssil-t.build/Objects-normal/arm64/ServerConfiguration.dia Could not read serialized diagnostics file: unable to find libclang in any registered toolchain
    warning: /home/user/dev/ios/ytrssil/.build/out/Intermediates.noindex/ytrssil.build/Debug-iphoneos/ytrssilShare-t.build/Objects-normal/arm64/ytrssilShare-primary-emit-module.dia Could not read serialized diagnostics file: unable to find libclang in any registered toolchain
    warning: /home/user/dev/ios/ytrssil/.build/out/Intermediates.noindex/ytrssil.build/Debug-iphoneos/ytrssil-t.build/Objects-normal/arm64/SettingsStore.dia Could not read serialized diagnostics file: unable to find libclang in any registered toolchain
    warning: /home/user/dev/ios/ytrssil/.build/out/Intermediates.noindex/ytrssil-Builder.build/Debug-iphoneos/ytrssilShare-Extension-p.build/Objects-normal/arm64/stub.dia Could not read serialized diagnostics file: unable to find libclang in any registered toolchain
    warning: /home/user/dev/ios/ytrssil/.build/out/Intermediates.noindex/ytrssil.build/Debug-iphoneos/ytrssil-t.build/Objects-normal/arm64/KeychainStore.dia Could not read serialized diagnostics file: unable to find libclang in any registered toolchain
    warning: /home/user/dev/ios/ytrssil/.build/out/Intermediates.noindex/ytrssil.build/Debug-iphoneos/ytrssil-t.build/Objects-normal/arm64/APIClient.dia Could not read serialized diagnostics file: unable to find libclang in any registered toolchain
    warning: /home/user/dev/ios/ytrssil/.build/out/Intermediates.noindex/ytrssil.build/Debug-iphoneos/ytrssil-t.build/Objects-normal/arm64/ytrssil-primary-emit-module.dia Could not read serialized diagnostics file: unable to find libclang in any registered toolchain
    warning: /home/user/dev/ios/ytrssil/.build/out/Intermediates.noindex/ytrssil-Builder.build/Debug-iphoneos/ytrssil-App-p.build/Objects-normal/arm64/stub.dia Could not read serialized diagnostics file: unable to find libclang in any registered toolchain
    warning: /home/user/dev/ios/ytrssil/.build/out/Intermediates.noindex/ytrssil.build/Debug-iphoneos/ytrssil-t.build/Objects-normal/arm64/ContentView.dia Could not read serialized diagnostics file: unable to find libclang in any registered toolchain
    warning: /home/user/dev/ios/ytrssil/.build/out/Intermediates.noindex/ytrssil.build/Debug-iphoneos/ytrssil-t.build/Objects-normal/arm64/ytrssilApp.dia Could not read serialized diagnostics file: unable to find libclang in any registered toolchain
    warning: /home/user/dev/ios/ytrssil/.build/out/Intermediates.noindex/ytrssil.build/Debug-iphoneos/ytrssilShare-t.build/Objects-normal/arm64/ShareViewController.dia Could not read serialized diagnostics file: unable to find libclang in any registered toolchain
    warning: /home/user/dev/ios/ytrssil/.build/out/Intermediates.noindex/ytrssil.build/Debug-iphoneos/ytrssil-t.build/Objects-normal/arm64/SettingsView.dia Could not read serialized diagnostics file: unable to find libclang in any registered toolchain
    warning: /home/user/dev/ios/ytrssil/.build/out/Intermediates.noindex/ytrssil.build/Debug-iphoneos/ytrssil-t.build/Objects-normal/arm64/HistoryView.dia Could not read serialized diagnostics file: unable to find libclang in any registered toolchain
    warning: /home/user/dev/ios/ytrssil/.build/out/Intermediates.noindex/ytrssil.build/Debug-iphoneos/ytrssil-t.build/Objects-normal/arm64/ChannelsView.dia Could not read serialized diagnostics file: unable to find libclang in any registered toolchain
    warning: /home/user/dev/ios/ytrssil/.build/out/Intermediates.noindex/ytrssil.build/Debug-iphoneos/ytrssil-t.build/Objects-normal/arm64/FeedView.dia Could not read serialized diagnostics file: unable to find libclang in any registered toolchain
    
  5. kabiroberai commented on Sep 22, 2026

    @kabiroberai
    Member

    @TheEdgeOfRage hmm I wonder if that's a toolchain issue (with AUR swift-bin) or an xtool one. Swift 6.4 has some growing pains with SwiftBuild. Do you see something similar when building an executable for Linux?

  6. TheEdgeOfRage commented on Sep 22, 2026

    @TheEdgeOfRage
    Author

    Yeah, seems that this is actually a swift build warning. Compiling a test swift package shows the same warnings, unless I switch to the legacy build system, so definitely not caused by xtool

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

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