Skip to content

fix: compilation on x86_64-swift-linux-musl#271

Open
asevko wants to merge 2 commits intop-x9:mainfrom
asevko:fix-linux-compilation
Open

fix: compilation on x86_64-swift-linux-musl#271
asevko wants to merge 2 commits intop-x9:mainfrom
asevko:fix-linux-compilation

Conversation

@asevko
Copy link
Copy Markdown

@asevko asevko commented Mar 31, 2026

When building for x86_64-swift-linux-musl:

swift build --configuration release --swift-sdk x86_64-swift-linux-musl

the build failed with no such module 'Crypto' error:

warning: 'machokit': /Users/asevko/work/forks/MachOKit/Package.swift:137:1: warning: extension declares a conformance of imported type 'SwiftSetting' to imported protocol 'CaseIterable'; this will not behave correctly if the owners of 'PackageDescription' introduce this conformance in the future
135 | }
136 | 
137 | extension SwiftSetting: CaseIterable {
    | |- warning: extension declares a conformance of imported type 'SwiftSetting' to imported protocol 'CaseIterable'; this will not behave correctly if the owners of 'PackageDescription' introduce this conformance in the future
    | `- note: add '@retroactive' to silence this warning
138 |     public static var allCases: [Self] {
139 |         [
[1/1] Planning build
Building for production...
warning: '--product' cannot be used with the automatic product 'MachOKit'; building the default target instead
/Users/asevko/work/forks/MachOKit/Sources/MachOKit/Model/Codesign/CodeDirectory/CodeSignCodeDirectory.swift:16:16: error: no such module 'Crypto'
 14 | #else
 15 | #if compiler(>=6.0)
 16 | private import Crypto
    |                `- error: no such module 'Crypto'
 17 | #elseif compiler(>=5.10) && hasFeature(AccessLevelOnImport)
 18 | private import Crypto

That happens when cross-compiling on macOS to linux due to the reason, that

#if (os(macOS) || os(iOS) || os(watchOS) || os(tvOS)) &&  canImport(CommonCrypto)

evaluates on macOs, so the swift-crypto won't be added as a dependency. So we have to declare the package swift-crypto unconditionally, conditionally link the product for linux platforms.

Note: the x86_64-swift-linux-musl toolchain is installed via swiftly; the active toolchain should also be managed by swiftly >= 6.3.0 as on lower versions there was a compiler crash. For validating build on x86_64-swift-linux-musl the patch from p-x9/ObjectArchiveKit#5 is also required.

@p-x9
Copy link
Copy Markdown
Owner

p-x9 commented Apr 1, 2026

Thank you for the PR.
I hadn’t considered cross-compilation.

The PR you submitted to ObjectArchiveKit has already been merged, and a new version has been released.
https://github.com/p-x9/ObjectArchiveKit/releases/tag/0.5.0

@asevko
Copy link
Copy Markdown
Author

asevko commented Apr 1, 2026

Should I bump ObjectArchiveKit and then update my PR to MachOKit?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants