Index | Thread | Search

From:
Greg Steuck <gnezdo@openbsd.org>
Subject:
Re: GHC on OpenBSD/arm64 -> retguard fail?
To:
ha.alamin@gmail.com
Cc:
ports@openbsd.org
Date:
Fri, 15 Nov 2024 20:34:32 -0800

Download raw body.

Thread
Nice, with these hacks we're making more progress still :)

> I've been looking into this, and the weird line I mentioned before in
> hadrian/src/Rules/Program.hs was to blame.
>
> Make the following change and Hadrian will actually attempt to build a
> stage 2 aarch64 compiler instead of simply copying the amd64 one from
> the stage 1 directory (though I haven't tried running that stage 2
> compiler yet).

I stuck this arm64 ghc into that faux binary-dist full of x86 binaries.
`gmake install` still doesn't work due to:

configure: WARNING: m4/prep_target_file.m4: Expecting YES/NO but got  in ArSupportsAtFile_STAGE0. Defaulting to False.
configure: WARNING: m4/prep_target_file.m4: Expecting YES/NO but got  in ArSupportsDashL_STAGE0. Defaulting to False.
./configure[13195]: bin/ghc-toolchain-bin: not found

Yet the directory is laid out close enough to be somewhat functional. A
ton of hacks is required to wean this binary off its old sysroot habits:
% ./ghc-9.10.1-aarch64-unknown-openbsd/bin/aarch64-unknown-openbsd-ghc -pgmc=clang -pgml=clang -pgma=clang -optc=--sysroot=/ -optl=--sysroot=/ -optl=-L/usr/local/lib -optl=-Wl,--no-execute-only   ~/a.hs
[1 of 2] Compiling Main             ( /home/greg/a.hs, /home/greg/a.o )
clang: warning: argument unused during compilation: '-iquote /home/greg' [-Wunused-command-line-argument]
[2 of 2] Linking /home/greg/a
% ./a
"Hi!"

This brings us the first openbsd-arm64-built Haskell program!

Let's see now if this is enough of a compiler to work as a stage0 to
build ghc natively on arm64.

I pushed more hacky patches including yours below to my gitlab.

> By the way, I was able to build the aarch64 hello world and run it
> without issues without the last commit on your fork which adds $PATH and
> $LD_LIBRARY_PATH to the cc shim.

The cross compiler was using clang in PATH hence the PATH hack. Then I
started getting ldd errors that I didn't feel like debugging hence
LD_LIBRARY_PATH hack.

Thanks
Greg

P.S. Lidya's email bounces, so I took it off.