Skip to content

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

Merged
p-x9 merged 5 commits intop-x9:mainfrom
asevko:fix-linux-compilation
Apr 2, 2026
Merged

fix: compilation on x86_64-swift-linux-musl#271
p-x9 merged 5 commits intop-x9:mainfrom
asevko:fix-linux-compilation

Conversation

@asevko
Copy link
Copy Markdown
Contributor

@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
Contributor Author

asevko commented Apr 1, 2026

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

@asevko
Copy link
Copy Markdown
Contributor Author

asevko commented Apr 2, 2026

@p-x9 I also bumped ObjectArchiveKit to 0.5.0 to have consistent PR, that adds support for cross-compilation.

Can you make, please, a release of MachOKit, after currnt PR will be merged?

@asevko asevko force-pushed the fix-linux-compilation branch from e95d846 to 21d0ae1 Compare April 2, 2026 07:48
@p-x9
Copy link
Copy Markdown
Owner

p-x9 commented Apr 2, 2026

Sorry for the delayed response—I’ve been quite busy.

Thank you for updating the version and fixing the CI as well.
I’ll merge it and proceed with the release.

@p-x9 p-x9 merged commit 053c053 into p-x9:main Apr 2, 2026
2 checks passed
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