-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add OpenBSD and NetBSD? #707
Comments
I've been messing around with GHCup on OpenBSD (7.5), and these are the roadblocks to getting GHCup to compile and run:
|
This is great work. A few comments:
I don't really trust OpenBSD/NetBSD to care about binary compatibility. So I want to have as few C libraries linked as possible. We can't really fix ghcup linkage and distribute it, because But it could be a stop-gap.
That would be odd, since the build would then fail on windows. It's per platform:
I'm ok switching to tar for some platforms. It has most bugs fixed that caused me to migrate to libarchive. As for lzma-static: I'd be fine to switch to autoconf based build. I've done that for libarchive too, but it's some maintenance overhead to e.g. clean up the |
To clarify: macOS doesn't support static linking, too, so I was confused, but I just assumed, “if it's not a build flag that configures whether to compile a vendored but I couldn't find any Cabal documentation that said that, and I knew macOS, which we enable the flag on, doesn't support static linking, so that's how I discounted that possibility.
What kind of bugs are we talking about? If they're relevant for GHCup (cause specific issues/breakages under some conditions for GHCup itself), we should link to them from our own issues, so people can tackle them.
Adjustments are already being made for Darwin's but keep that portion of the script which Obviously, the ideal solution is to fix the issue upstream in Either way, if we're switching to an Autoconf-based build, that suggests you're trying to remove the arbitrary restriction Otherwise, if you want to keep the whitelisted-platforms approach, we can just add the OpenBSD-specific |
Yes, I think the next step is to have |
I think GHCup codebase should also be modified to support shims to make GHC build on certain platforms; I'm sure it supports patches to allow older GHC versions to build on officially unsupported platforms, so this would be a similar thing, it would even be setup before the patch phase of the build. All it would take is prepending some shim directory to the I'm happy to do the tedious work (over a long span of time, bit by bit) to figure out all the problems with getting (mostly older) versions of GHC to build on (mostly older) versions of OpenBSD and write the build scripts to generate bindists and incorporate those patches, shims, etc. into the GHCup manifests, too (my focus will probably be equally split between amd64 and arm64, but hey, I might play around with other architectures that OpenBSD supports). That said, GHC versions will probably be released at a faster rate than I could keep up, unless the newer versions don't require too much work to get to build on newer versions of OpenBSD and/or I let support for older GHC and/or OpenBSD versions languish. I think there's some work upstream to get OpenBSD better supported, so hopefully, it shouldn't be an issue at some point. |
@habibalamin I see that you have mostly figured out the steps for getting |
Oh I missed the "proper autoconf" part, so get rid of all config.h and use |
Appreciate you taking on the job of switching I'll make the changes to GHCup when I get a chance hopefully before this weekend. |
I was able to build GHCup on OpenBSD 6.8 amd64 only a few days ago, but then I upgraded my installation to 7.5 right afterwards, as it was woefully out of date (latest is 7.6, never got around to finishing). That was right before I left the message about getting this working on OpenBSD. Now, it would involve getting this building on GHC 9.6 (and OpenBSD 7.6 may be on GHC 9.8 on its ports). I am now getting a lot of missing imports (“variable not in scope”) build errors on my OpenBSD 7.5 amd64 machine when making my changes on It seems to mostly be I don't have the time to finish this right now and I don't even know how many errors I'll have to fix given how GHC hides some until I fix previous (dependency?) modules, but I'll get back to it at some point in the coming week if I can. I also got a missing My OpenBSD machine is running GHC 9.6.4, and my macOS is running GHC 9.6.2, however, I think the real issue is that, for whatever reason, I have to add The proper solution to this is to figure out what's holding the This means my I haven't tracked down why the sudden need to import |
Anyway, this is the diff needed for OpenBSD separate from the concern of getting it to build with recent OpenBSD versions which come with packages of recent GHC versions. If I don't get round to dealing with that stuff, which is not really particular to OpenBSD, then someone can create a PR by starting with these changes. diff --git a/lib-opt/GHCup/OptParse/ChangeLog.hs b/lib-opt/GHCup/OptParse/ChangeLog.hs
index 97bf9d2..797cfef 100644
--- a/lib-opt/GHCup/OptParse/ChangeLog.hs
+++ b/lib-opt/GHCup/OptParse/ChangeLog.hs
@@ -136,6 +136,7 @@ changelog ChangeLogOptions{..} runAppState runLogger = do
Darwin -> exec "open" [T.unpack $ decUTF8Safe $ serializeURIRef' uri] Nothing Nothing
Linux _ -> exec "xdg-open" [T.unpack $ decUTF8Safe $ serializeURIRef' uri] Nothing Nothing
FreeBSD -> exec "xdg-open" [T.unpack $ decUTF8Safe $ serializeURIRef' uri] Nothing Nothing
+ OpenBSD -> exec "xdg-open" [T.unpack $ decUTF8Safe $ serializeURIRef' uri] Nothing Nothing
Windows -> do
let args = "start \"\" " ++ (T.unpack $ decUTF8Safe $ serializeURIRef' uri)
c <- liftIO $ system $ args
diff --git a/lib-tui/GHCup/Brick/Actions.hs b/lib-tui/GHCup/Brick/Actions.hs
index 020ce0b..7e528e4 100644
--- a/lib-tui/GHCup/Brick/Actions.hs
+++ b/lib-tui/GHCup/Brick/Actions.hs
@@ -458,6 +458,7 @@ changelog' (_, ListResult {..}) = do
Darwin -> exec "open" [T.unpack $ decUTF8Safe $ serializeURIRef' uri] Nothing Nothing
Linux _ -> exec "xdg-open" [T.unpack $ decUTF8Safe $ serializeURIRef' uri] Nothing Nothing
FreeBSD -> exec "xdg-open" [T.unpack $ decUTF8Safe $ serializeURIRef' uri] Nothing Nothing
+ OpenBSD -> exec "xdg-open" [T.unpack $ decUTF8Safe $ serializeURIRef' uri] Nothing Nothing
Windows -> do
let args = "start \"\" " ++ (T.unpack $ decUTF8Safe $ serializeURIRef' uri)
c <- liftIO $ system $ args
diff --git a/lib/GHCup/Platform.hs b/lib/GHCup/Platform.hs
index 93dcd05..15669e6 100644
--- a/lib/GHCup/Platform.hs
+++ b/lib/GHCup/Platform.hs
@@ -119,11 +119,17 @@ getPlatform = do
either (const Nothing) Just . versioning . decUTF8Safe'
<$> getFreeBSDVersion
pure $ PlatformResult { _platform = FreeBSD, _distroVersion = ver }
+ "openbsd" -> do
+ ver <-
+ either (const Nothing) Just . versioning . decUTF8Safe'
+ <$> getOpenBSDVersion
+ pure $ PlatformResult { _platform = OpenBSD, _distroVersion = ver }
"mingw32" -> pure PlatformResult { _platform = Windows, _distroVersion = Nothing }
what -> throwE $ NoCompatiblePlatform what
lift $ logDebug $ "Identified Platform as: " <> T.pack (prettyShow pfr)
pure pfr
where
+ getOpenBSDVersion = lift $ fmap _stdOut $ executeOut "uname" ["-r"] Nothing
getFreeBSDVersion = lift $ fmap _stdOut $ executeOut "freebsd-version" [] Nothing
getDarwinVersion = lift $ fmap _stdOut $ executeOut "sw_vers"
["-productVersion"]
@@ -306,6 +312,7 @@ getStackGhcBuilds PlatformResult{..} = do
[] -> []
_ -> L.intercalate "-" c)
libComponents
+ OpenBSD -> pure []
FreeBSD ->
case _distroVersion of
Just fVer
@@ -343,6 +350,8 @@ getStackOSKey PlatformRequest { .. } =
(A_64 , Darwin ) -> pure "macosx"
(A_32 , FreeBSD) -> pure "freebsd32"
(A_64 , FreeBSD) -> pure "freebsd64"
+ (A_32 , OpenBSD) -> pure "openbsd32"
+ (A_64 , OpenBSD) -> pure "openbsd64"
(A_32 , Windows) -> pure "windows32"
(A_64 , Windows) -> pure "windows64"
(A_ARM , Linux _) -> pure "linux-armv7"
@@ -350,6 +359,7 @@ getStackOSKey PlatformRequest { .. } =
(A_Sparc, Linux _) -> pure "linux-sparc"
(A_ARM64, Darwin ) -> pure "macosx-aarch64"
(A_ARM64, FreeBSD) -> pure "freebsd-aarch64"
+ (A_ARM64, OpenBSD) -> pure "openbsd-aarch64"
(arch', os') -> throwE $ UnsupportedSetupCombo arch' os'
getStackPlatformKey :: (MonadReader env m, MonadFail m, HasLog env, MonadCatch m, MonadIO m)
diff --git a/lib/GHCup/Types.hs b/lib/GHCup/Types.hs
index 33e496e..5406e48 100644
--- a/lib/GHCup/Types.hs
+++ b/lib/GHCup/Types.hs
@@ -229,6 +229,7 @@ data Platform = Linux LinuxDistro
| Darwin
-- ^ must exit
| FreeBSD
+ | OpenBSD
| Windows
-- ^ must exit
deriving (Eq, GHC.Generic, Ord, Show)
@@ -239,6 +240,7 @@ platformToString :: Platform -> String
platformToString (Linux distro) = "linux-" ++ distroToString distro
platformToString Darwin = "darwin"
platformToString FreeBSD = "freebsd"
+platformToString OpenBSD = "openbsd"
platformToString Windows = "windows"
instance Pretty Platform where
diff --git a/lib/GHCup/Types/JSON.hs b/lib/GHCup/Types/JSON.hs
index d30f433..13b96d6 100644
--- a/lib/GHCup/Types/JSON.hs
+++ b/lib/GHCup/Types/JSON.hs
@@ -143,6 +143,7 @@ instance ToJSONKey Platform where
FreeBSD -> T.pack "FreeBSD"
Linux (OtherLinux s) -> T.pack ("Linux_" <> s)
Linux d -> T.pack ("Linux_" <> show d)
+ OpenBSD -> T.pack "OpenBSD"
Windows -> T.pack "Windows"
instance FromJSONKey Platform where |
That's because of an upgrade from |
Ah, makes sense. I'd initially started by trying to upgrade packages one by one, though I could have sworn I removed them after adding I just after writing my above message made an accidental change on macOS and figured out the changes to package version bounds in I've just got it building on OpenBSD 7.5 now very simply:
|
Okay, I copied @hasufell are you happy to take a PR that adds The PR will also add:
to all the GHC 9.6-specific and release-specific Cabal project files that don't already enable that flag, and upgrade I'll wait for @Bodigrim to make the changes to |
See #1132 |
haskell/unix#262
But we have no bindists so far.
The text was updated successfully, but these errors were encountered: