GHC 9.2.7 on FreeBSD - HSC2HS_EXTRA issue

Hello, I am a FreeBSD user, running FreeBSD 13.1 with Clang 13 and GCC 12.2, and still fairly new to the Haskell Platform. When I tried to upgrade a hobby project to Stackage's latest LTS 20.15, I realized that neither the GHC 9.2.6 nor the GHC 9.2.7 binary packages from GHCUP work anymore. There are two issues - and I wrote a detailed article about my investigation on Medium: https://medium.com/@martin.baulig/ghc-9-2-7-on-freebsd-22afab71c715 The first one is a trivial one-line change - in hadrian/src/Rules/BinaryDist.hs, we need to change
( "HSC2HS_EXTRA=\"" <> unwords ccArgs <> unwords ldFlags <> "\""
into
( "HSC2HS_EXTRA=\"" <> unwords (ccArgs <> ldFlags) <> "\""
Otherwise, this will break when both ccArgs and ldFlags are non-empty:
HSC2HS_EXTRA="--cflag=--target=x86_64-portbld-freebsd--lflag=--target=x86_64-portbld-freebsd --lflag=-fuse-ld=lld"
Unfortunately, this is not quite it just yet. The problem is that Clang supports the --target= argument, but GCC does not - and it looks like Cabal insists on always invoking hsc2hs with an explicit --cc= argument. Overriding that in ~/.cabal/config doesn't work either - because then Cabal passes "-pgmc /usr/bin/cc" to GHC, but no "-pgma" and GHC tries to invoke GCC for assembling with a Clang-only argument. I am a bit lost here now about what the correct path forward is, but would very much like to help fixing this problem, so I created an account on gitlab.haskell.org to report this issue, but got a message saying that it is awaiting admin approval. Looking a bit further in the documentation for new contributors, I saw a comment suggesting I should post on this mailing list and ask for approval. Could an admin please have a look at that? My user name is my last name in lowercase, baulig. Looking forward to hear back from you, Martin

Hi Martin,
Thanks for your reports.
I have approved your account on gitlab now.
* The FreeBSD bindists are not officially created during the release
process. The ones you are using from ghcup are created (and
maintained) by the ghcup maintainers.
* Most linux bindists are created using the old make build system on
the 9.2.* series but it seems these bindists were not.
* We will gladly fix the bugs you report with the hsc2hs wrapper.
* Please open an issue for the problem with --target flag
Cheers,
Matt
On Mon, Mar 20, 2023 at 2:05 AM Martin Baulig via ghc-devs
Hello,
I am a FreeBSD user, running FreeBSD 13.1 with Clang 13 and GCC 12.2, and still fairly new to the Haskell Platform.
When I tried to upgrade a hobby project to Stackage's latest LTS 20.15, I realized that neither the GHC 9.2.6 nor the GHC 9.2.7 binary packages from GHCUP work anymore.
There are two issues - and I wrote a detailed article about my investigation on Medium: https://medium.com/@martin.baulig/ghc-9-2-7-on-freebsd-22afab71c715
The first one is a trivial one-line change - in hadrian/src/Rules/BinaryDist.hs, we need to change
( "HSC2HS_EXTRA=\"" <> unwords ccArgs <> unwords ldFlags <> "\""
into
( "HSC2HS_EXTRA=\"" <> unwords (ccArgs <> ldFlags) <> "\""
Otherwise, this will break when both ccArgs and ldFlags are non-empty:
HSC2HS_EXTRA="--cflag=--target=x86_64-portbld-freebsd--lflag=--target=x86_64-portbld-freebsd --lflag=-fuse-ld=lld"
Unfortunately, this is not quite it just yet.
The problem is that Clang supports the --target= argument, but GCC does not - and it looks like Cabal insists on always invoking hsc2hs with an explicit --cc= argument.
Overriding that in ~/.cabal/config doesn't work either - because then Cabal passes "-pgmc /usr/bin/cc" to GHC, but no "-pgma" and GHC tries to invoke GCC for assembling with a Clang-only argument.
I am a bit lost here now about what the correct path forward is, but would very much like to help fixing this problem, so I created an account on gitlab.haskell.org to report this issue, but got a message saying that it is awaiting admin approval. Looking a bit further in the documentation for new contributors, I saw a comment suggesting I should post on this mailing list and ask for approval. Could an admin please have a look at that? My user name is my last name in lowercase, baulig.
Looking forward to hear back from you,
Martin
_______________________________________________ ghc-devs mailing list ghc-devs@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs

The HSC2HS_EXTRA option was fixed in
```
commit 99623358754d812b8b4bdfcdc57190d38617b9cc
Author: Matthew Pickering
Hi Martin,
Thanks for your reports.
I have approved your account on gitlab now.
* The FreeBSD bindists are not officially created during the release process. The ones you are using from ghcup are created (and maintained) by the ghcup maintainers. * Most linux bindists are created using the old make build system on the 9.2.* series but it seems these bindists were not. * We will gladly fix the bugs you report with the hsc2hs wrapper. * Please open an issue for the problem with --target flag
Cheers,
Matt
On Mon, Mar 20, 2023 at 2:05 AM Martin Baulig via ghc-devs
wrote: Hello,
I am a FreeBSD user, running FreeBSD 13.1 with Clang 13 and GCC 12.2, and still fairly new to the Haskell Platform.
When I tried to upgrade a hobby project to Stackage's latest LTS 20.15, I realized that neither the GHC 9.2.6 nor the GHC 9.2.7 binary packages from GHCUP work anymore.
There are two issues - and I wrote a detailed article about my investigation on Medium: https://medium.com/@martin.baulig/ghc-9-2-7-on-freebsd-22afab71c715
The first one is a trivial one-line change - in hadrian/src/Rules/BinaryDist.hs, we need to change
( "HSC2HS_EXTRA=\"" <> unwords ccArgs <> unwords ldFlags <> "\""
into
( "HSC2HS_EXTRA=\"" <> unwords (ccArgs <> ldFlags) <> "\""
Otherwise, this will break when both ccArgs and ldFlags are non-empty:
HSC2HS_EXTRA="--cflag=--target=x86_64-portbld-freebsd--lflag=--target=x86_64-portbld-freebsd --lflag=-fuse-ld=lld"
Unfortunately, this is not quite it just yet.
The problem is that Clang supports the --target= argument, but GCC does not - and it looks like Cabal insists on always invoking hsc2hs with an explicit --cc= argument.
Overriding that in ~/.cabal/config doesn't work either - because then Cabal passes "-pgmc /usr/bin/cc" to GHC, but no "-pgma" and GHC tries to invoke GCC for assembling with a Clang-only argument.
I am a bit lost here now about what the correct path forward is, but would very much like to help fixing this problem, so I created an account on gitlab.haskell.org to report this issue, but got a message saying that it is awaiting admin approval. Looking a bit further in the documentation for new contributors, I saw a comment suggesting I should post on this mailing list and ask for approval. Could an admin please have a look at that? My user name is my last name in lowercase, baulig.
Looking forward to hear back from you,
Martin
_______________________________________________ ghc-devs mailing list ghc-devs@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs

Hey Matthew,
Thank you so very much for fixing this and my apologies for not following up on the issue.
I was planning to file an issue with a PR, but got distracted with other things. My new
AMD Radeon RX 6700 XT had arrived in the mail and while it's working fine with OpenBSD,
I had to upgade the FreeBSD to 14-CURRENT to get it working there as well.
Since I didn't feel good about filing any issue while using an unsupported developer
preview version of the operating system, I had planned to install FreeBSD 13.1 in some
AWS instance for testing, but then got too busy with OpenBSD.
GHC 9.2.7 works great on OpenBSD - I just had two minor issues to get it to compile,
I'll file an issue and a PR for that shortly.
Best wishes,
Martin
------- Original Message -------
On Thursday, March 30th, 2023 at 8:26 AM, Matthew Pickering
The HSC2HS_EXTRA option was fixed in
``` commit 99623358754d812b8b4bdfcdc57190d38617b9cc Author: Matthew Pickering matthewtpickering@gmail.com
Date: Thu Mar 10 20:48:44 2022 +0000
hadrian: Correct generation of hsc2hs wrapper
If you inspect the inside of a wrapper script for hsc2hs you will see that the cflag and lflag values are concatenated incorrectly.
`HSC2HS_EXTRA="--cflag=-U__i686--lflag=-fuse-ld=gold"`
It should instead be
`HSC2HS_EXTRA="--cflag=-U__i686 --lflag=-fuse-ld=gold"`
Fixes #21221 ```
On Tue, Mar 21, 2023 at 1:28 PM Matthew Pickering matthewtpickering@gmail.com wrote:
Hi Martin,
Thanks for your reports.
I have approved your account on gitlab now.
* The FreeBSD bindists are not officially created during the release process. The ones you are using from ghcup are created (and maintained) by the ghcup maintainers. * Most linux bindists are created using the old make build system on the 9.2.* series but it seems these bindists were not. * We will gladly fix the bugs you report with the hsc2hs wrapper. * Please open an issue for the problem with --target flag
Cheers,
Matt
On Mon, Mar 20, 2023 at 2:05 AM Martin Baulig via ghc-devs ghc-devs@haskell.org wrote:
Hello,
I am a FreeBSD user, running FreeBSD 13.1 with Clang 13 and GCC 12.2, and still fairly new to the Haskell Platform.
When I tried to upgrade a hobby project to Stackage's latest LTS 20.15, I realized that neither the GHC 9.2.6 nor the GHC 9.2.7 binary packages from GHCUP work anymore.
There are two issues - and I wrote a detailed article about my investigation on Medium: https://medium.com/@martin.baulig/ghc-9-2-7-on-freebsd-22afab71c715
The first one is a trivial one-line change - in hadrian/src/Rules/BinaryDist.hs, we need to change
( "HSC2HS_EXTRA=\"" <> unwords ccArgs <> unwords ldFlags <> "\""
into
( "HSC2HS_EXTRA=\"" <> unwords (ccArgs <> ldFlags) <> "\""
Otherwise, this will break when both ccArgs and ldFlags are non-empty:
HSC2HS_EXTRA="--cflag=--target=x86_64-portbld-freebsd--lflag=--target=x86_64-portbld-freebsd --lflag=-fuse-ld=lld"
Unfortunately, this is not quite it just yet.
The problem is that Clang supports the --target= argument, but GCC does not - and it looks like Cabal insists on always invoking hsc2hs with an explicit --cc= argument.
Overriding that in ~/.cabal/config doesn't work either - because then Cabal passes "-pgmc /usr/bin/cc" to GHC, but no "-pgma" and GHC tries to invoke GCC for assembling with a Clang-only argument.
I am a bit lost here now about what the correct path forward is, but would very much like to help fixing this problem, so I created an account on gitlab.haskell.org to report this issue, but got a message saying that it is awaiting admin approval. Looking a bit further in the documentation for new contributors, I saw a comment suggesting I should post on this mailing list and ask for approval. Could an admin please have a look at that? My user name is my last name in lowercase, baulig.
Looking forward to hear back from you,
Martin
_______________________________________________ ghc-devs mailing list ghc-devs@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
participants (2)
-
Martin Baulig
-
Matthew Pickering