Index | Thread | Search

From:
حبيب محمد الأمين محمد الهادي <ha.alamin@gmail.com>
Subject:
Re: GHC on OpenBSD/arm64 -> retguard fail?
To:
Greg Steuck <gnezdo@openbsd.org>
Cc:
ports@openbsd.org
Date:
Mon, 18 Nov 2024 17:48:32 +0000

Download raw body.

Thread
> To be honest, I'm focusing on putting together a monster of a hack
> environment on arm64 by cross-compiling just enough stuff. I suspect
> polishing the cross-build flow is too much trouble for one use that we
> need to happen. The next one is likely to be RISCV whenever this is.

Yeah, it probably is for OpenBSD's purposes, but I really get frustrated
and find it hard to walk away from utilising all the knowledge I've
gained in this process to improve the process itself for the next poor
sap.

I also don't know how we're gonna get the OpenBSD/arm64 port of
GHC included into the project exactly. Presumably, they want an
officially-built arm64 GHC binary where the stage 0 used to build it
is the stage 2 arm64 GHC binary from a cross-compiled build, and they
want that stage 2 cross-compilation process to be part of their build
process, even if it's just temporary.

I wanted to make that stage 2 behave as close as possible to a stage 0,
so they don't have to provide -pgm* and --sysroot flags.

Beyond that, a lot of this stuff isn't just stuff not suited for arm64
or OpenBSD or OpenBSD/arm64, rather it's dealing with the build itself
not being (fully) set up to work for cross-compilation. It should be a
hell of a lot smoother. And we're quite well-placed to do just a bit
more work to get that done.

Anyway, I do have an idea for a hacky way to get the sysroot stuff
sorted as part of the build; just add a command in the bindist Hadrian
rule to sed the sysroot prefix out of the $SYSROOT/usr/local/lib
library-dirs, $SYSROOT/usr/local/include include-dirs, and other
settings in the .conf files before ghc-pkg and creating the tarball.

That should remove the need to specify the -L for iconv when running
on arm64, and if you include the patches earlier in the thread, which
I hope you'll consider, that removes the need for all the -pgm* and
--sysroot flags.

With both modifications, all that'd be needed is the
-Wl,--no-execute-only, but that already is.

> It will take a bit before my slow-ish x13s churns through the whole
> build, but I've seen it go part way through Stage1, which means that the
> monster cross is good enough of a boot compiler to produce a Stage0.

That's great!

Honestly, getting this working for OpenBSD was my priority, so if we
land an arm64 GHC into ports, I'll be satisfied. I've poured a lot of
time into this and I wish I could pour more, but as much as I want to
improve the cross-compilation process in general, I should probably
defer that; our notes and all the work we did will still be here.

> In case anybody cares to pick up a prebuilt bindist, I put it up:
> 
> […]
> 
> I'll keep on pushing to get a 9.8.3 ports bootstrap bundle now.

…aaand, there it is. Nice work!

As you have an @openbsd.org email address, you're probably better placed
to get this past the finish line, so I'll leave it in your hands.

Would you be so kind as to notify me by email once this is out in a
release? :D

Cheers,
Habib