GHC issueshttps://gitlab.haskell.org/ghc/ghc/-/issues2020-12-04T21:16:18Zhttps://gitlab.haskell.org/ghc/ghc/-/issues/18984Pandoc-2.11.2 build failed on FreeBSD-11.4 i386 system2020-12-04T21:16:18ZwenhepingPandoc-2.11.2 build failed on FreeBSD-11.4 i386 system
Pandoc-2.11.2 build failed on FreeBSD-11.4 i386 system, while success on amd64 system. The last lines of buildlog is:
```
\[118 of 184\] Compiling Text.Pandoc.Writers.ConTeXt
\[119 of 184\] Compiling Text.Pandoc.PDF
\[120 of 184\] Comp...
Pandoc-2.11.2 build failed on FreeBSD-11.4 i386 system, while success on amd64 system. The last lines of buildlog is:
```
\[118 of 184\] Compiling Text.Pandoc.Writers.ConTeXt
\[119 of 184\] Compiling Text.Pandoc.PDF
\[120 of 184\] Compiling Text.Pandoc.Lua.Module.Utils
\[121 of 184\] Compiling Text.Pandoc.Writers.OpenDocument
\[122 of 184\] Compiling Text.Pandoc.Writers.ODT
\[123 of 184\] Compiling Text.Pandoc.Writers.MediaWiki
\[124 of 184\] Compiling Text.Pandoc.Writers.XWiki
\[125 of 184\] Compiling Text.Pandoc.Writers.JATS.Table
\[126 of 184\] Compiling Text.Pandoc.Writers.JATS
\[127 of 184\] Compiling Text.Pandoc.Writers.ICML
\[128 of 184\] Compiling Text.Pandoc.Writers.HTML
ghc: panic! (the 'impossible' happened) (GHC version 8.10.2: ghc: panic! (the 'impossible' happened) (GHC version 8.10.2: ghc: panic! (the 'impossible' happened) (GHC version 8.10.2: exprToType
Call stack: CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1179:37 in ghc:Outputable
pprPanic, called at compiler/coreSyn/CoreSyn.hs:2087:28 in ghc:CoreSyn
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
```https://gitlab.haskell.org/ghc/ghc/-/issues/23125Add Cirrus CI configuration for FreeBSD tests2023-03-21T15:19:37ZHécate MoonlightAdd Cirrus CI configuration for FreeBSD testsHere are two pre-existing configuration and explanation from which we can draw.
https://github.com/qemu/qemu/tree/master/.gitlab-ci.d/cirrus
https://github.com/haskell/text/blob/master/.cirrus.ymlHere are two pre-existing configuration and explanation from which we can draw.
https://github.com/qemu/qemu/tree/master/.gitlab-ci.d/cirrus
https://github.com/haskell/text/blob/master/.cirrus.ymlHécate MoonlightHécate Moonlighthttps://gitlab.haskell.org/ghc/ghc/-/issues/22003encoding004 fails on FreeBSD 132022-11-22T12:31:20ZBen Gamariencoding004 fails on FreeBSD 13It appears that `encoding004` fails on FreeBSD 13 on account of CP936 not roundtripping:
```
Actual stdout output differs from expected:
--- /tmp/ghctest-1klnjj65/test spaces/libraries/base/tests/IO/encoding004.run/encoding004.stdout.n...It appears that `encoding004` fails on FreeBSD 13 on account of CP936 not roundtripping:
```
Actual stdout output differs from expected:
--- /tmp/ghctest-1klnjj65/test spaces/libraries/base/tests/IO/encoding004.run/encoding004.stdout.normalised 2022-08-10 21:18:39.767262000 +0000
+++ /tmp/ghctest-1klnjj65/test spaces/libraries/base/tests/IO/encoding004.run/encoding004.run.stdout.normalised 2022-08-10 21:18:39.767363000 +0000
@@ -1,3 +1,14 @@
== CP936
+Failed to roundtrip given mutant byte at index 891 (251 /= 123 at index 891)
+Failed to roundtrip given mutant byte at index 1605 (197 /= 69 at index 1605)
+Failed to roundtrip given mutant byte at index 2411 (235 /= 107 at index 2411)
+Failed to roundtrip given mutant byte at index 6480 (208 /= 80 at index 6480)
+Failed to roundtrip given mutant byte at index 6482 (210 /= 82 at index 6482)
+Failed to roundtrip given mutant byte at index 6484 (212 /= 84 at index 6484)
+Failed to roundtrip given mutant byte at index 6496 (224 /= 96 at index 6496)
+Failed to roundtrip given mutant byte at index 7243 (203 /= 75 at index 7243)
+Failed to roundtrip given mutant byte at index 7277 (237 /= 109 at index 7277)
+Failed to roundtrip given mutant byte at index 8027 (219 /= 91 at index 8027)
+Failed to roundtrip given mutant byte at index 8801 (225 /= 97 at index 8801)
== CP1251
== UTF-8
*** unexpected failure for encoding004(normal)
```https://gitlab.haskell.org/ghc/ghc/-/issues/21986Clang --target argument breaks C++ compilation on FreeBSD2023-01-23T10:09:04ZBen GamariClang --target argument breaks C++ compilation on FreeBSDIt turns out that the fact that we pass `--target=...` to `clang` breaks C++ compilation on FreeBSD:
```
$ cat hi.cpp
#include <iostream>
int main() {
std::cout << "hello\n";
return 0;
}
$ ghc -c hi.cpp
hi.cpp:1:10: fata...It turns out that the fact that we pass `--target=...` to `clang` breaks C++ compilation on FreeBSD:
```
$ cat hi.cpp
#include <iostream>
int main() {
std::cout << "hello\n";
return 0;
}
$ ghc -c hi.cpp
hi.cpp:1:10: fatal error: 'iostream' file not found
#include <iostream>
^~~~~~~~~~
1 error generated.
$ clang++ -c hi.cpp
$
```
Passing `-v3` to `ghc` reveals the `clang++` command-line which replicates the issue:
```
'clang++' -x 'c++' -c hi.cpp -o hi.o.tmp -fno-PIC -include /usr/home/vagrant/ghc/_build/stage1/lib/../lib/x86_64-freebsd-ghc-9.5.20220808/rts-1.0.2/include/ghcversion.h -I/usr/local/include -I/usr/home/vagrant/ghc/_build/stage1/lib/../lib/x86_64-freebsd-ghc-9.5.20220808/base-4.17.0.0/include -I/usr/home/vagrant/ghc/_build/stage1/lib/../lib/x86_64-freebsd-ghc-9.5.20220808/ghc-bignum-1.3/include -I/usr/home/vagrant/ghc/_build/stage1/lib/../lib/x86_64-freebsd-ghc-9.5.20220808/rts-1.0.2/include '--target=x86_64-unknown-freebsd'
```
Dropping the `'--target=x86_64-unknown-freebsd'` flag allows the command to run.
This causes `T13366Cxx` to fail on FreeBSD, among othres.Ben GamariBen Gamarihttps://gitlab.haskell.org/ghc/ghc/-/issues/20287Non-hermetic build "Couldn't find #define HS_CONSTANTS"2022-04-17T06:59:20ZGreg SteuckNon-hermetic build "Couldn't find #define HS_CONSTANTS"## Summary
Building ghc-9.2.1-rc1 on OpenBSD fails with:
```
===--- building phase 0
gmake --no-print-directory -f ghc.mk phase=0 phase_0_builds
gmake[1]: Nothing to be done for 'phase_0_builds'.
===--- building phase 1
gmake --no-print...## Summary
Building ghc-9.2.1-rc1 on OpenBSD fails with:
```
===--- building phase 0
gmake --no-print-directory -f ghc.mk phase=0 phase_0_builds
gmake[1]: Nothing to be done for 'phase_0_builds'.
===--- building phase 1
gmake --no-print-directory -f ghc.mk phase=1 phase_1_builds
gmake[1]: Nothing to be done for 'phase_1_builds'.
===--- building final phase
gmake --no-print-directory -f ghc.mk phase=final install
... below reflowed for clarity
"inplace/bin/ghc-cabal" register libraries/ghc-prim dist-install \
"/usr/ports/pobj/ghc-9.2.0.20210821/fake-amd64/usr/local/lib/ghc/bin/ghc" \
"/usr/ports/pobj/ghc-9.2.0.20210821/fake-amd64/usr/local/lib/ghc/bin/ghc-pkg" \
"/usr/ports/pobj/ghc-9.2.0.20210821/fake-amd64/usr/local/lib/ghc" \
'/usr/ports/pobj/ghc-9.2.0.20210821/fake-amd64' \
'/usr/local' '/usr/local/lib/ghc' '/usr/local/share/doc/ghc/html/libraries' \
NO
ghc-cabal:
'/usr/ports/pobj/ghc-9.2.0.20210821/fake-amd64/usr/local/lib/ghc/bin/ghc'
exited with an error:
ghc: panic! (the 'impossible' happened)
(GHC version 9.2.0.20210821:
Couldn't find #define HS_CONSTANTS " in
/usr/local/lib/ghc/include/DerivedConstants.h
CallStack (from HasCallStack):
error, called at compiler/stage2/build/GHC/Platform/Constants.hs:143:20 in
ghc:GHC.Platform.Constants
```
Notice the reported file path: `/usr/local/lib/ghc` is the previous version of ghc installed on the system and isn't even supposed to be used by the build (because the bootstrap is provided separately). I would expect the intermediate (fake) installation directory to be used everywhere in the install process, but something isn't hermetic.
This used to work with 9.2.1-alpha1 package which I previously built from https://github.com/blackgnezdo/ports/commits/ghc-9.2 (almost, the `libHSrts_l` hack isn't automated on that branch). The timeline is aligned with the submission of 9c762f27 which makes it a likely culprit (FYI @hsyl20).
## Steps to reproduce
The ports tree snapshot is at https://github.com/blackgnezdo/ports/commits/ghc-9.2.1-rc1. Running `make package` in `lang/ghc` should be enough to reproduce.
## Expected behavior
A working build independent of the previously installed local system packages.
## Environment
* GHC version used: 8.10.3 is used as a bootstrap
Optional:
* Operating System: OpenBSD 7.0-beta
* System Architecture: amd64Sylvain HenrySylvain Henryhttps://gitlab.haskell.org/ghc/ghc/-/issues/19723T14028 fails on FreeBSD2021-04-22T01:00:38ZvdukhovniT14028 fails on FreeBSD## Summary
Details to follow, but basically T14028 fails to build on FreeBSD with some linker-related issues as reported in https://gitlab.haskell.org/ghc/ghc/-/merge_requests/5561#note_347396
Opening issue so I can mark the test `frag...## Summary
Details to follow, but basically T14028 fails to build on FreeBSD with some linker-related issues as reported in https://gitlab.haskell.org/ghc/ghc/-/merge_requests/5561#note_347396
Opening issue so I can mark the test `fragile` with the right issue number.
* Operating System: FreeBSD 12.2
* System Architecture: X86_64https://gitlab.haskell.org/ghc/ghc/-/issues/19086Unhandled relocation type on FreeBSD2021-04-18T21:49:33ZBen GamariUnhandled relocation type on FreeBSDWhile testing the FreeBSD binary distribution for 8.10.3 I noticed the following failure:
```
=====> ghci062(ghci-ext) 1748 of 7348 [0, 11, 2]
cd "ghci/scripts/ghci062.run" && HC="/home/ben/ghc/inplace/bin/ghc-stage2" HC_OPTS="-dcore-lin...While testing the FreeBSD binary distribution for 8.10.3 I noticed the following failure:
```
=====> ghci062(ghci-ext) 1748 of 7348 [0, 11, 2]
cd "ghci/scripts/ghci062.run" && HC="/home/ben/ghc/inplace/bin/ghc-stage2" HC_OPTS="-dcore-lint -dstg-lint -dcmm-lint -no-user-package-db -rtsopts -fno-warn-missed-specialisations -fshow-warning-groups -fdiagnostics-color=never -fno-diagnostics-show-caret -Werror=compat -dno-debug-output " "/home/ben/ghc/inplace/bin/ghc-stage2" --interactive -v0 -ignore-dot-ghci -fno-ghci-history -fexternal-interpreter +RTS -I0.1 -RTS -dcore-lint -dstg-lint -dcmm-lint -no-user-package-db -rtsopts -fno-warn-missed-specialisations -fshow-warning-groups -fdiagnostics-color=never -fno-diagnostics-show-caret -Werror=compat -dno-debug-output < ghci062.script
Wrong exit code for ghci062(ghci-ext)(expected 0 , actual 1 )
Stderr ( ghci062 ):
ghc-iserv.bin: internal error: /home/ben/ghc/libraries/integer-gmp/dist-install/build/HSinteger-gmp-1.0.3.0.o: unhandled ELF relocation(RelA) type 19
(GHC version 8.10.3 for x86_64_portbld_freebsd)
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
{handle: <file descriptor: 12>}: GHCi.Message.remoteCall: end of file
*** unexpected failure for ghci062(ghci-ext)
```https://gitlab.haskell.org/ghc/ghc/-/issues/17776C pre processor doing the wrong thing FreeBSD 12.12020-02-20T16:49:48ZBrandon MartinC pre processor doing the wrong thing FreeBSD 12.1## Summary
As suggested from the mailing list [thread](https://mail.haskell.org/pipermail/haskell-cafe/2020-February/131833.html) there seems to be a bug in the c pre processor on FreeBSD. I was trying to build a a Haskell library whi...## Summary
As suggested from the mailing list [thread](https://mail.haskell.org/pipermail/haskell-cafe/2020-February/131833.html) there seems to be a bug in the c pre processor on FreeBSD. I was trying to build a a Haskell library which depended on the dbus package (haskell-dbus). It failed with `Not in scope: type constructor or class ‘HsType’`. More on the error [here](https://gist.github.com/codedmart/2b04438566ed8e985d909db7d426649c). Nevermind that I set allow-newer. The error this is pasted from was a quick trail of building the haskell-dbus from cloning the git repo and there where some dep issues. I reproduced this error trying a few different stack lts's and nightly's as well as using a system ghc/cabal as well.
The `lib/DBus/Internal/Types.hspp` ran with `stack exec ghc -- -E -cpp`:\
[FreeBSD](https://gist.github.com/codedmart/58d1681731c8721b50b630f4188a31f2#file-freebsd-types-hspp)\
[VoidLinux](https://gist.github.com/codedmart/58d1681731c8721b50b630f4188a31f2#file-voidlinux-types-hspp)
## Steps to reproduce
From a fresh new install of 12.1 FreeBSD `mkdir test && cd test && stack init && stack install dbus`
## Expected behavior
Would expect the dbus (haskell-dbus) package to be installed with no errors.
## Environment
* GHC version used: 8.6.5 with stack and system installed, also tried stack with GHC 8.8.1
Optional:
* Operating System: FreeBSD 12.1
* System Architecture: x86_64https://gitlab.haskell.org/ghc/ghc/-/issues/17735FreeBSD dynamic linker crashes on ghc-iserv-prof2020-01-23T18:51:22ZBen GamariFreeBSD dynamic linker crashes on ghc-iserv-profSomehow we break FreeBSD 12's dynamic linker:
```
# gdb --args ./bindisttest/a/b/c/ghc-8.11.0.20200123/utils/iserv/stage2_p/build/tmp/ghc-iserv-prof +RTS --info
(gdb) run
Starting program: /home/ben/ghc/bindisttest/a/b/c/ghc-8.11.0.20200...Somehow we break FreeBSD 12's dynamic linker:
```
# gdb --args ./bindisttest/a/b/c/ghc-8.11.0.20200123/utils/iserv/stage2_p/build/tmp/ghc-iserv-prof +RTS --info
(gdb) run
Starting program: /home/ben/ghc/bindisttest/a/b/c/ghc-8.11.0.20200123/utils/iserv/stage2_p/build/tmp/ghc-iserv-prof +RTS --info
Program received signal SIGSEGV, Segmentation fault.
digest_dynamic1 (obj=0x80204e000, early=0, dyn_rpath=0x7fffffffd1a0, dyn_soname=0x7fffffffd6a8, dyn_runpath=0x7fffffffd820) at /usr/src/libexec/rtld-elf/rtld.c:1121
1121 /usr/src/libexec/rtld-elf/rtld.c: No such file or directory.
(gdb) bt
#0 digest_dynamic1 (obj=0x80204e000, early=0, dyn_rpath=0x7fffffffd1a0, dyn_soname=0x7fffffffd6a8, dyn_runpath=0x7fffffffd820) at /usr/src/libexec/rtld-elf/rtld.c:1121
#1 0x000000080202f6bf in digest_dynamic (obj=0x80204e000, early=0) at /usr/src/libexec/rtld-elf/rtld.c:1378
#2 _rtld (sp=<optimized out>, exit_proc=0x7fffffffd890, objp=0x7fffffffd898) at /usr/src/libexec/rtld-elf/rtld.c:628
#3 0x000000080202e019 in rtld_start () at /usr/src/libexec/rtld-elf/amd64/rtld_start.S:39
#4 0x0000000000000000 in ?? ()
(gdb)
```https://gitlab.haskell.org/ghc/ghc/-/issues/22782Avoid reading text section in generate code2023-03-28T17:48:39ZGreg SteuckAvoid reading text section in generate code## Summary
Some OSs ([Android](https://source.android.com/docs/security/test/execute-only-memory), OpenBSD) are moving to execute-only (xonly) unreadable code as a
mitigation technique.
GHC should put any data that it reads at runtime ...## Summary
Some OSs ([Android](https://source.android.com/docs/security/test/execute-only-memory), OpenBSD) are moving to execute-only (xonly) unreadable code as a
mitigation technique.
GHC should put any data that it reads at runtime outside `.text` section and into `.rodata`.
## Steps to reproduce
OpenBSD 7.3 is likely to ship with xonly enabled by default. Right now this is a development set of patches. With these patches GHC build process fails as soon as it creates and runs the first program. The program happens to be `ghc-cabal` which gets a SIGSEGV promptly at startup. The problem is easy to reproduce with other binaries, but I didn't minimize the repro.
The details indicate reading from `text`.
```
% /usr/ports/pobj/ghc-9.2.5/ghc-9.2.5/inplace/bin/ghc-cabal
[1] 99461 segmentation fault (core dumped) /usr/ports/pobj/ghc-9.2.5/ghc-9.2.5/inplace/bin/ghc-cabal
% egdb /usr/ports/pobj/ghc-9.2.5/ghc-9.2.5/inplace/bin/ghc-cabal ghc-cabal.core
Core was generated by `ghc-cabal'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x0000077e6f693de3 in stg_enter_info ()
(gdb) disassemble
Dump of assembler code for function stg_enter_info:
0x0000077e6f693dd8 <+0>: mov 0x8(%rbp),%rax
0x0000077e6f693ddc <+4>: test $0x7,%al
0x0000077e6f693dde <+6>: jne 0x77e6f693e2f <stg_enter_info+87>
0x0000077e6f693de0 <+8>: mov (%rax),%rbx
=> 0x0000077e6f693de3 <+11>: movslq -0x8(%rbx),%rcx
0x0000077e6f693de7 <+15>: cmp $0x1a,%rcx
0x0000077e6f693deb <+19>: jb 0x77e6f693e15 <stg_enter_info+61>
0x0000077e6f693ded <+21>: cmp $0x1c,%rcx
0x0000077e6f693df1 <+25>: jb 0x77e6f693e03 <stg_enter_info+43>
0x0000077e6f693df3 <+27>: cmp $0x1d,%rcx
0x0000077e6f693df7 <+31>: jae 0x77e6f693e09 <stg_enter_info+49>
0x0000077e6f693df9 <+33>: mov 0x8(%rax),%rax
0x0000077e6f693dfd <+37>: mov %rax,0x8(%rbp)
0x0000077e6f693e01 <+41>: jmp 0x77e6f693ddc <stg_enter_info+4>
0x0000077e6f693e03 <+43>: cmp $0x1b,%rcx
0x0000077e6f693e07 <+47>: jae 0x77e6f693df9 <stg_enter_info+33>
0x0000077e6f693e09 <+49>: mov %rbx,%rcx
0x0000077e6f693e0c <+52>: mov %rax,%rbx
0x0000077e6f693e0f <+55>: add $0x10,%rbp
0x0000077e6f693e13 <+59>: jmpq *%rcx
0x0000077e6f693e15 <+61>: cmp $0xf,%rcx
0x0000077e6f693e19 <+65>: jb 0x77e6f693e29 <stg_enter_info+81>
0x0000077e6f693e1b <+67>: cmp $0x19,%rcx
0x0000077e6f693e1f <+71>: jae 0x77e6f693e2f <stg_enter_info+87>
0x0000077e6f693e21 <+73>: cmp $0x17,%rcx
0x0000077e6f693e25 <+77>: jne 0x77e6f693e09 <stg_enter_info+49>
0x0000077e6f693e27 <+79>: jmp 0x77e6f693e2f <stg_enter_info+87>
0x0000077e6f693e29 <+81>: cmp $0x8,%rcx
0x0000077e6f693e2d <+85>: jb 0x77e6f693e09 <stg_enter_info+49>
0x0000077e6f693e2f <+87>: mov %rax,%rbx
0x0000077e6f693e32 <+90>: add $0x10,%rbp
0x0000077e6f693e36 <+94>: jmpq *0x0(%rbp)
End of assembler dump.
(gdb) p/x $rbx
$1 = 0x77e6f48b7c8
(gdb) x/100bx $rbx
0x77e6f48b7c8 <ZCMain_main_info>: 0x48 0x8d 0x45 0xf0 0x4c 0x39 0xf8 0x72
0x77e6f48b7d0 <ZCMain_main_info+8>: 0x45 0x48 0x83 0xec 0x08 0x4c 0x89 0xe8
0x77e6f48b7d8 <ZCMain_main_info+16>: 0x48 0x89 0xde 0x48 0x89 0xc7 0x31 0xc0
0x77e6f48b7e0 <ZCMain_main_info+24>: 0xe8 0xeb 0x3b 0x20 0x00 0x48 0x83 0xc4
0x77e6f48b7e8 <ZCMain_main_info+32>: 0x08 0x48 0x85 0xc0 0x74 0x26 0x48 0x8d
0x77e6f48b7f0 <ZCMain_main_info+40>: 0x1d 0x13 0xf0 0x20 0x00 0x48 0x89 0x5d
0x77e6f48b7f8 <ZCMain_main_info+48>: 0xf0 0x48 0x89 0x45 0xf8 0x4c 0x8d 0x35
0x77e6f48b800 <ZCMain_main_info+56>: 0x6c 0x9e 0x45 0x00 0x48 0x8d 0x1d 0x25
0x77e6f48b808 <ZCMain_main_info+64>: 0xc9 0x47 0x00 0x48 0x83 0xc5 0xf0 0xe9
0x77e6f48b810 <ZCMain_main_info+72>: 0x8c 0x32 0x21 0x00 0xff 0x23 0x41 0xff
0x77e6f48b818 <ZCMain_main_info+80>: 0x65 0xf0 0xcc 0xcc 0xcc 0xcc 0xcc 0xcc
0x77e6f48b820 <_hs_text_memcpy>: 0x4c 0x8b 0x1d 0x01 0x67 0x21 0x00 0x4c
0x77e6f48b828 <_hs_text_memcpy+8>: 0x33 0x1c 0x24 0x55
```
## Expected behavior
Data gets placed into `.rodata` and programs run fine when built with `--execute-only` linker flag. As it stands I will be disabling this feature for all GHC-compiled programs on OpenBSD.
## Environment
* GHC version used: 8.10.7 from bootstrap, but newer versions like 9.2.5 are similarly affected.
Optional:
* Operating System: OpenBSD
* System Architecture: amd64Ben GamariBen Gamari