You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Make mcs build and run on Linux. The codebase is already well-structured with Environment and ShellRunner as natural abstraction points, so most changes are conditional compilation guards and constant swaps.
Effort Estimate
Moderate — ~15-20 focused changes, no architectural rewrite needed.
Required Changes
Build Configuration
Remove or conditionalize .macOS(.v13) in Package.swift (line 7-8) — currently blocks compilation entirely
Conditional Compilation Guards
Darwin.read() → Glibc.read() in CLIOutput.swift:523 — use #if canImport(Darwin) / #if canImport(Glibc)
termios VMIN/VTIME indices in CLIOutput.swift:236-237 — macOS uses tuple indices 16/17, Linux uses 6/5. Replace magic numbers with platform-conditional named constants
Summary
Make
mcsbuild and run on Linux. The codebase is already well-structured withEnvironmentandShellRunneras natural abstraction points, so most changes are conditional compilation guards and constant swaps.Effort Estimate
Moderate — ~15-20 focused changes, no architectural rewrite needed.
Required Changes
Build Configuration
.macOS(.v13)inPackage.swift(line 7-8) — currently blocks compilation entirelyConditional Compilation Guards
Darwin.read()→Glibc.read()inCLIOutput.swift:523— use#if canImport(Darwin)/#if canImport(Glibc)termiosVMIN/VTIME indices inCLIOutput.swift:236-237— macOS uses tuple indices 16/17, Linux uses 6/5. Replace magic numbers with platform-conditional named constantsCryptoKit→ add#if canImport(CryptoKit)withimport Cryptofallback (fromapple/swift-crypto) in:FileHasher.swift:1SettingsHasher.swift:1SectionValidator.swift:1PackTrustManager.swift:1OSAllocatedUnfairLockinScriptRunner.swift:174— Apple-only (osframework). Replace with Swift 6Mutex(Synchronization module) orNSLockwrapperHomebrew on Linux
/home/linuxbrew/.linuxbrewtoHomebrew.allPrefixes(Homebrew.swift:6)Environment.swift:59-63brew prefix fallback to include Linux default pathVerification
Process,FileManager,NSString,ObjCBool— these work on Linux via swift-corelibs-foundation (verified in audit)/usr/bin/env,/usr/bin/which,/bin/bashinConstants.swift:36-42) — exist on all standard Linux distros, no change neededflock,ioctl+TIOCGWINSZ,isatty,open/close,.posixPermissions) — all available on Linux, no change neededFiles Affected
Package.swiftSources/mcs/Core/CLIOutput.swift#if canImport(Darwin/Glibc)forread(), fix termios indicesSources/mcs/Core/FileHasher.swiftSources/mcs/Core/SettingsHasher.swiftSources/mcs/Doctor/SectionValidator.swiftSources/mcs/ExternalPack/PackTrustManager.swiftSources/mcs/ExternalPack/ScriptRunner.swiftOSAllocatedUnfairLockSources/mcs/Core/Homebrew.swiftSources/mcs/Core/Environment.swiftNotes
NSString,ObjCBool,NSNumber,NSHomeDirectory) work via swift-corelibs-foundationflock,ioctl,termios,isatty) are all available on Linux