GHC issueshttps://gitlab.haskell.org/ghc/ghc/-/issues2024-02-13T15:45:39Zhttps://gitlab.haskell.org/ghc/ghc/-/issues/24430Symbol type mismatch when building with llvm2024-02-13T15:45:39ZGreg SteuckSymbol type mismatch when building with llvm## Summary
I wanted to play with LLVM backend on OpenBSD amd64. A lot of tests produce prodigious extra output which doesn't occur with the default backend:
```
Symbol type mismatch.
Symbol __llvm_retpoline_r11 was defined by /home/greg...## Summary
I wanted to play with LLVM backend on OpenBSD amd64. A lot of tests produce prodigious extra output which doesn't occur with the default backend:
```
Symbol type mismatch.
Symbol __llvm_retpoline_r11 was defined by /home/greg/s/ghc/_build/stage1/lib/x86_64-openbsd-ghc-9.9.20240211/base-4.19.0.0-inplace/libHSbase-4.19.0.0-inplace.a to be a data symbol.
yet was defined by /home/greg/s/ghc/_build/stage1/lib/x86_64-openbsd-ghc-9.9.20240211/ghc-prim-0.10.0-inplace/libHSghc-prim-0.10.0-inplace.a to be a code symbol.
```
## Steps to reproduce
I built GHC with:
```
TEST=T5313 hadrian/build '*.*.ghc.link.opts+=-L/usr/local/lib' \
--docs=none \
--flavour=release+llvm+no_profiled_libs+split_sections \
-j test
```
After that when the tests run e.g. `GHC.load GHC.LoadAllTargets` they generate this `debugBelch` above.
## Expected behavior
Since the output doesn't seem to be otherwise harmful, it'd appear that suppressing the message entirely is a reasonable alternative?
## Environment
* GHC version used: 8bbe12f288
Optional:
* Operating System: OpenBSD 7.4-current
* System Architecture: amd64https://gitlab.haskell.org/ghc/ghc/-/issues/23909"ghc-toolchain" mismatch report on OpenBSD2023-09-05T14:24:16ZGreg Steuck"ghc-toolchain" mismatch report on OpenBSDWhen I run the ghc build the usual way I do on OpenBSD with the script at the end I recently started getting this report:
```
configure: WARNING:
There are some differences between the toolchain configured by "configure" (hadrian/cfg/def...When I run the ghc build the usual way I do on OpenBSD with the script at the end I recently started getting this report:
```
configure: WARNING:
There are some differences between the toolchain configured by "configure" (hadrian/cfg/default.target) and the toolchain configured by the "ghc-toolchain" program (hadrian/cfg/default.target.ghc-toolchain).
15,18c15,18
< , tgtCCompiler = Cc {ccProgram = Program { prgPath = "clang" , prgFlags = ["--target=x86_64-unknown-openbsd","-Wl,-z,nobtcfi","-Qunused-arguments"] }}
< , tgtCxxCompiler = Cxx {cxxProgram = Program { prgPath = "clang++" , prgFlags = ["--target=x86_64-unknown-openbsd"] }}
< , tgtCPreprocessor = Cpp {cppProgram = Program { prgPath = "clang" , prgFlags = ["-E"] }}
< , tgtHsCPreprocessor = HsCpp {hsCppProgram = Program { prgPath = "clang" , prgFlags = ["-E","-undef","-traditional","-Wno-invalid-pp-token","-Wno-unicode","-Wno-trigraphs"] }}
---
> , tgtCCompiler = Cc {ccProgram = Program { prgPath = "/usr/bin/clang" , prgFlags = ["--target=x86_64-unknown-openbsd","-Wl,-z,nobtcfi","-Qunused-arguments"] }}
> , tgtCxxCompiler = Cxx {cxxProgram = Program { prgPath = "/usr/bin/clang++" , prgFlags = ["--target=x86_64-unknown-openbsd"] }}
> , tgtCPreprocessor = Cpp {cppProgram = Program { prgPath = "/usr/bin/clang" , prgFlags = ["-E"] }}
> , tgtHsCPreprocessor = HsCpp {hsCppProgram = Program { prgPath = "/usr/bin/clang" , prgFlags = ["-E","-undef","-traditional","-Wno-invalid-pp-token","-Wno-unicode","-Wno-trigraphs"] }}
20c20
< { ccLinkProgram = Program { prgPath = "clang" , prgFlags = ["--target=x86_64-unknown-openbsd","-fuse-ld=lld"] }
---
> { ccLinkProgram = Program { prgPath = "/usr/bin/clang" , prgFlags = ["--target=x86_64-unknown-openbsd","-Wl,--no-as-needed"] }
Don't worry! This won't affect your ghc in any way.
However, in a near future, we will move to configuring toolchains with "ghc-toolchain" by default, so you might have discovered a future bug.
In light of it, if you've spotted this difference, please report a GHC bug at https://www.haskell.org/ghc/reportabug
```
The build then proceeds as expected and the majority of the tests pass.
```
#!/bin/ksh
set -eu
export MAKE=gmake
export AUTOCONF_VERSION=2.71 AUTOMAKE_VERSION=1.16
export GHC=/home/greg/ghc-9.6/bin/ghc
./boot
CONF_CC_OPTS_STAGE1='-Wl,-z,nobtcfi' \
CONF_CC_OPTS_STAGE2='-Wl,-z,nobtcfi' \
./configure --with-ffi-includes=/usr/local/include \
--with-ffi-libraries=/usr/local/lib \
--with-gmp-includes=/usr/local/include \
--with-gmp-libraries=/usr/local/lib \
--with-iconv-includes=/usr/local/include \
--with-iconv-libraries=/usr/local/lib \
--with-system-libffi \
--with-compiler=$GHC \
--disable-tables-next-to-code
ulimit -d $((10<<20))
# T4038 needs a bunch of stack
ulimit -s 8192
hadrian/build '*.*.ghc.link.opts+=-L/usr/local/lib' \
--docs=none \
--flavour=validate+no_profiled_libs \
-j test
```
@alt-romes FYI.9.10.1Matthew PickeringMatthew Pickeringhttps://gitlab.haskell.org/ghc/ghc/-/issues/23452CallConv causes SIGSEGV with --disable-tables-next-to-code2023-05-30T14:50:26ZGreg SteuckCallConv causes SIGSEGV with --disable-tables-next-to-codeWhen building with `--disable-tables-next-to-code` on OpenBSD-amd64
`testsuite/tests/codeGen/should_run/CallConv.hs` seems to not be using the right
calling convention. The continuation address pointed at by `%rbp` is not
sensible in thi...When building with `--disable-tables-next-to-code` on OpenBSD-amd64
`testsuite/tests/codeGen/should_run/CallConv.hs` seems to not be using the right
calling convention. The continuation address pointed at by `%rbp` is not
sensible in this case.
```
(gdb) bt
#0 0x0000000000354048 in someFuncF ()
#1 0x0000000000000000 in ?? ()
(gdb) disassemble
Dump of assembler code for function someFuncF:
=> 0x0000000000354048 <+0>: movss %xmm1,%xmm0
0x000000000035404c <+4>: subss %xmm2,%xmm0
0x0000000000354050 <+8>: addss %xmm2,%xmm1
0x0000000000354054 <+12>: movss %xmm0,%xmm2
0x0000000000354058 <+16>: movss %xmm3,%xmm0
0x000000000035405c <+20>: divss %xmm4,%xmm0
0x0000000000354060 <+24>: mulss %xmm4,%xmm3
0x0000000000354064 <+28>: movss %xmm0,%xmm4
0x0000000000354068 <+32>: jmpq *0x0(%rbp)
End of assembler dump.
(gdb) p/x $rbp
$1 = 0x2af505330
(gdb) p/x *((uint64_t*) $rbp)
$2 = 0x6882c0
(gdb) disassemble 0x00000000006882c0
No function contains specified address.
(gdb) c
Program received signal SIGSEGV, Segmentation fault.
0x00000000006882c0 in ?? ()
```
I guess this assembly code relies on TNTC and so the test should be made conditional on that setting.Ben GamariBen Gamarihttps://gitlab.haskell.org/ghc/ghc/-/issues/23011$ORIGIN is not what it appears2023-05-23T20:39:01ZGreg Steuck$ORIGIN is not what it appears## Summary
A ton of tests broke on OpenBSD on aa3a262d15.
## Steps to reproduce
Commit aa3a262d15 merged in !9767 is detrimental on OpenBSD. The first
symptom is a ton of tests are failing with the likes of:
```
Wrong exit code for C...## Summary
A ton of tests broke on OpenBSD on aa3a262d15.
## Steps to reproduce
Commit aa3a262d15 merged in !9767 is detrimental on OpenBSD. The first
symptom is a ton of tests are failing with the likes of:
```
Wrong exit code for CountDepsParser()(expected 0 , actual 2 )
Stderr ( CountDepsParser ):
ld.so: count-deps: can't load library 'libHSunix-2.8.0.0-ghc9.7.20230221.so'
```
The binaries are weirdly broken now, they work fine from stage1 but
they fail when invoked from a sym-linked location, i.e. test/bin.
E.g.
```
% ldd ./_validatebuild/test/bin/check-exact
./_validatebuild/test/bin/check-exact:
ld.so: check-exact: can't load library 'libHStime-1.12.2-ghc9.7.20230221.so'
./_validatebuild/test/bin/check-exact: signal 9
% ./_validatebuild/test/bin/check-exact
ld.so: check-exact: can't load library 'libHSexceptions-0.10.7-ghc9.7.20230221.so'
[1] 28192 killed ./_validatebuild/test/bin/check-exact
% ./_validatebuild/stage1/bin/check-exact
Missing file: /home/alanz/mysrc/git.haskell.org/worktree/master/_build/stage1/lib/settings
% readelf --dynamic ./_validatebuild/stage1/bin/check-exact | grep RUNPATH
0x000000000000001d (RUNPATH) Library runpath: [$ORIGIN/../lib/x86_64-openbsd-ghc-9.7.20230221:$ORIGIN/../../../lib/x86_64-openbsd-ghc-9.7.20230221]
% ls -l ./_validatebuild/test/bin/check-exact
lrwxr-xr-x 1 greg greg 61 Feb 20 20:01 ./_validatebuild/test/bin/check-exact -> /home/greg/s/ghc-broken/_validatebuild/stage1/bin/check-exact
% ls -l ./_validatebuild/test/lib
ls: ./_validatebuild/test/lib: No such file or directory
```
When I build at the commit before this change I get a much more
verbose RUNPATH which works fine when the binary is symlinked into
test/bin.
```
% readelf --dynamic ghc/_validatebuild/test/bin/check-exact | grep RUNP
0x000000000000001d (RUNPATH) Library runpath: [/home/greg/s/ghc/_validatebuild/stage1/inplace/../compiler/build:...
```
The semantics of $ORIGIN is not covered by any standard I know of. If
I read the [Linux manual
page](https://man7.org/linux/man-pages/man8/ld.so.8.html) literally,
the behavior of OpenBSD ld.so is not errant:
> $ORIGIN (or equivalently ${ORIGIN})
> This expands to the directory containing the program or
> shared object. Thus, an application located in
> somedir/app could be compiled with
>
> gcc -Wl,-rpath,'$ORIGIN/../lib'
>
> so that it finds an associated shared object in
> somedir/lib no matter where somedir is located in the
> directory hierarchy. This facilitates the creation of
> "turn-key" applications that do not need to be installed
> into special directories, but can instead be unpacked into
> any directory and still find their own shared objects.
The symlinked `test/bin` location does *NOT* have a corresponding
`test/lib` where `$ORIGIN` points at. Apparently other implementations
resolve `$ORIGIN` relative to the symlink pointee.
## Environment
* GHC version used: aa3a262d15
Optional:
* Operating System: OpenBSD
* System Architecture: amd64
FYI @PHOGreg SteuckGreg Steuckhttps://gitlab.haskell.org/ghc/ghc/-/issues/22210libHSdirectory-1.3.7.1-ghc9.5.20220824.so: undefined reference to unixzm2zi7z...2024-03-26T22:12:40ZGreg SteucklibHSdirectory-1.3.7.1-ghc9.5.20220824.so: undefined reference to unixzm2zi7zi2zi2_*## Summary
Build fails on OpenBSD with:
```
===> Command failed with error code: 1
ld.lld: error: .../x86_64-openbsd-ghc-9.5.20220824/libHSdirectory-1.3.7.1-ghc9.5.20220824.so: undefined reference to unixzm2zi7zi2zi2_SystemziPosixziFile...## Summary
Build fails on OpenBSD with:
```
===> Command failed with error code: 1
ld.lld: error: .../x86_64-openbsd-ghc-9.5.20220824/libHSdirectory-1.3.7.1-ghc9.5.20220824.so: undefined reference to unixzm2zi7zi2zi2_SystemziPosixziFiles_setFileMode1_info [--no-allow-shlib-undefined]
ld.lld: error: .../x86_64-openbsd-ghc-9.5.20220824/libHSdirectory-1.3.7.1-ghc9.5.20220824.so: undefined reference to unixzm2zi7zi2zi2_SystemziPosixziFiles_setFileMode1_closure [--no-allow-shlib-undefined]
...
ld.lld: error: too many errors emitted, stopping now (use -error-limit=0 to see all errors)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
`clang' failed in phase `Linker'. (Exit code: 1)
Error when running Shake build system:
at action, called at src/Rules.hs:38:19 in main:Rules
at need, called at src/Rules.hs:60:5 in main:Rules
* Depends on: _validatebuild/stage1/bin/hpc
at cmd', called at src/Builder.hs:386:23 in main:Builder
at cmdArgs, called at src/Builder.hs:539:8 in main:Builder
at cmdArgs, called at src/Builder.hs:563:18 in main:Builder
at cmdArgs, called at src/Builder.hs:563:18 in main:Builder
at error, called at src/Builder.hs:608:13 in main:Builder
* Raised the exception:
Command failed
Build failed.
```
The problem is bisected to 112e4f9c9c299b460e37a60d8f8d8693aa6ab06a, the same build works at b929063ec5.
FYI @TerrorJack
## Steps to reproduce
On OpenBSD:
```
AUTOCONF_VERSION=2.71 AUTOMAKE_VERSION=1.16 \
config_args='--with-ffi-includes=/usr/local/include
--with-ffi-libraries=/usr/local/lib
--with-gmp-includes=/usr/local/include
--with-gmp-libraries=/usr/local/lib
--with-iconv-includes=/usr/local/include
--with-iconv-libraries=/usr/local/lib
--with-system-libffi ' \
./validate --fast "$@"
```
## Expected behavior
Build working GHC.
## Environment
* GHC version used: 9.2.4
Optional:
* Operating System: OpenBSD
* System Architecture: amd649.6.1https://gitlab.haskell.org/ghc/ghc/-/issues/22174system-cxx-std-lib: Add support for FreeBSD libcxxrt doesn't work on OpenBSD2022-09-25T19:03:49ZMatthew Pickeringsystem-cxx-std-lib: Add support for FreeBSD libcxxrt doesn't work on OpenBSD@blackgnezdo reports:
Sadly, this is not working on OpenBSD (whereas the previous version did). A fix which makes `configure` succeed would be to add:
```
diff --git a/m4/fp_find_cxx_std_lib.m4 b/m4/fp_find_cxx_std_lib.m4
index 24f78d0a...@blackgnezdo reports:
Sadly, this is not working on OpenBSD (whereas the previous version did). A fix which makes `configure` succeed would be to add:
```
diff --git a/m4/fp_find_cxx_std_lib.m4 b/m4/fp_find_cxx_std_lib.m4
index 24f78d0a6f..09f4524d89 100644
--- a/m4/fp_find_cxx_std_lib.m4
+++ b/m4/fp_find_cxx_std_lib.m4
@@ -75,6 +75,7 @@ EOF
case $CXX_STD_LIB_FLAVOUR in
c++)
try_libs "-lc++ -lc++abi" "libc++.so" "c++ c++abi" || \
+ try_libs "-lc++ -lc++abi -lpthread" "libc++.so" "c++ c++abi pthread" || \
try_libs "-lc++ -lcxxrt" "libc++.so" "c++ cxxrt" ||
AC_MSG_ERROR([Failed to find C++ standard library]) ;;
stdc++)
```
but I'm uncertain if it's a great idea to effectively replicate some behaviors [baked into platform-dependent clang code](https://github.com/openbsd/src/blob/a0747c9f67a4ae71ccb71e62a28d1ea19e06a63c/gnu/llvm/clang/lib/Driver/ToolChains/OpenBSD.cpp#L305-L307).9.4.3Ben GamariBen Gamarihttps://gitlab.haskell.org/ghc/ghc/-/issues/21908T20494 fails on OpenBSD2022-07-26T15:06:47ZGreg SteuckT20494 fails on OpenBSD## Summary
T20494 destr order on OpenBSD doesn't match the recorded one.
## Steps to reproduce
```
$ TEST="T20494" validate --testsuite-only
...
diff -uw "/tmp/ghctest-zsnew51z/test spaces/testsuite/tests/rts/linker/T20494.run/T2049...## Summary
T20494 destr order on OpenBSD doesn't match the recorded one.
## Steps to reproduce
```
$ TEST="T20494" validate --testsuite-only
...
diff -uw "/tmp/ghctest-zsnew51z/test spaces/testsuite/tests/rts/linker/T20494.run/T20494.stdout.normalised" "/tmp/ghctest-zsnew51z/test spaces/testsuite/tests/rts/linker/T20494.run/T20494.run.stdout.normalised"<
--- /tmp/ghctest-zsnew51z/test spaces/testsuite/tests/rts/linker/T20494.run/T20494.stdout.normalised Wed Jul 20 23:14:38 2022
+++ /tmp/ghctest-zsnew51z/test spaces/testsuite/tests/rts/linker/T20494.run/T20494.run.stdout.normalised Wed Jul 20 23:14:38 2022
@@ -1,5 +1,5 @@
constr a
constr b
hello
-destr b
destr a
+destr b
*** unexpected failure for T20494(normal)
```
## Expected behavior
Test passes.
## Environment
* GHC version used: e2f0094c315746ff15b8d9650cf318f81d8416d7
Optional:
* Operating System: OpenBSD
* System Architecture: amd64Ben GamariBen Gamarihttps://gitlab.haskell.org/ghc/ghc/-/issues/21836CXX_STD_LIB_LIBS should surface in testsuite2022-07-15T12:11:52ZGreg SteuckCXX_STD_LIB_LIBS should surface in testsuite## Summary
Some tests (e.g. T13366Cxx) rely on `config.stdcxx_impl` which is currently not set to the values determined by cofigure tests responsible for setting `CXX_STD_LIB_LIBS`. Instead the value of `stdcxx_impl` defaults to `stdc++...## Summary
Some tests (e.g. T13366Cxx) rely on `config.stdcxx_impl` which is currently not set to the values determined by cofigure tests responsible for setting `CXX_STD_LIB_LIBS`. Instead the value of `stdcxx_impl` defaults to `stdc++` with a tweak in `testsuite/config/ghc` which replaces the value with:
```
if windows:
config.supports_dynamic_hs = False
config.stdcxx_impl = 'c++'
```
## Steps to reproduce
`T13366Cxx` test fails on OpenBSD:
```
<command line>: user specified .o/.so/.DLL could not be loaded (File not found)
Whilst trying to load: (dynamic) stdc++
Additional directories searched: (none)
```
## Expected behavior
Once `CXX_STD_LIB_LIBS` get propagated into the testsuite the correct libraries will be easy to use. There's a minor twist, the libraries should be a list whereas `config.stdcxx_impl` is a singleton string.
A couple of tests (e.g. `ghcilink006`, `ghcilink003`) use `LIBCXX` make variable which is copied from `config.stdcxx_impl`, so they should also be updated.
## Environment
* GHC version used: 460505345e
Optional:
* Operating System: OpenBSD
* System Architecture: amd64Ben GamariBen Gamarihttps://gitlab.haskell.org/ghc/ghc/-/issues/21214make binary-dist fails on OpenBSD when building from "tag: ghc-9.2.2-release"2022-03-22T22:35:01ZAdam steenmake binary-dist fails on OpenBSD when building from "tag: ghc-9.2.2-release"## Summary
I followed the instructions to build master on OpenBSD [here](https://gitlab.haskell.org/ghc/ghc/-/wikis/building/preparation/openbsd)
then ran `gmake binary-dist` and it failed.
```
gmake --no-print-directory -f ghc.mk uni...## Summary
I followed the instructions to build master on OpenBSD [here](https://gitlab.haskell.org/ghc/ghc/-/wikis/building/preparation/openbsd)
then ran `gmake binary-dist` and it failed.
```
gmake --no-print-directory -f ghc.mk unix-binary-dist-prep
"rm" -rf bindistprep/
"inplace/bin/mkdirhier" bindistprep/ghc-9.2.2
set -e; for i in packages LICENSE compiler ghc rts libraries utils docs libffi includes driver mk rules Makefile m4 aclocal.m4 config.sub config.guess install-sh llvm-targets llvm-passes ghc.m
k inplace distrib/configure.ac distrib/README distrib/INSTALL; do ln -s ../../$i bindistprep/ghc-9.2.2/; done
echo "HADDOCK_DOCS = YES" >> bindistprep/ghc-9.2.2/bindist.mk
echo "BUILD_SPHINX_HTML = NO" >> bindistprep/ghc-9.2.2/bindist.mk
echo "BUILD_SPHINX_PDF = NO" >> bindistprep/ghc-9.2.2/bindist.mk
echo "BUILD_MAN = NO" >> bindistprep/ghc-9.2.2/bindist.mk
echo "override ghc-cabal_INPLACE = utils/ghc-cabal/dist-install/build/tmp/ghc-cabal-bindist" >> bindistprep/ghc-9.2.2/bindist.mk
echo "UseSystemLibFFI = YES" >> bindistprep/ghc-9.2.2/bindist.mk
echo "CrossCompiling = NO" >> bindistprep/ghc-9.2.2/bindist.mk
cd bindistprep/ghc-9.2.2 && autoreconf
aclocal-1.15: warning: couldn't open directory '../m4': No such file or directory
"rm" -f bindistprep/ghc-9.2.2-x86_64-unknown-openbsd.tar
sort bindist-list | uniq > bindist-list.uniq
cd bindistprep && "/usr/local/bin/gtar" hcf - -T ../bindist-list.uniq | /usr/local/bin/xz -c > ../bindistprep/ghc-9.2.2-x86_64-unknown-openbsd.tar.xz
/usr/local/bin/gtar: ghc-9.2.2/rts/dist/build/ffi.h: Cannot stat: No such file or directory
/usr/local/bin/gtar: ghc-9.2.2/rts/dist/build/ffitarget.h: Cannot stat: No such file or directory
/usr/local/bin/gtar: Exiting with failure status due to previous errors
mv bindistprep/*.tar.xz "."
```
## Steps to reproduce
follow [Preparing and Building OpenBSD](https://gitlab.haskell.org/ghc/ghc/-/wikis/building/preparation/openbsd)
`cabal install` any required dependencies
rerun, `./boot`, `./configure` and `gmake` sequence
finally run `gmake binary-dist`
I did this but I have an OpenBSD environment working for older versions of GHC
```
export TMP=$HOME/tmp
export TEMP=$HOME/tmp
./boot
./configure \
--with-iconv-libraries=/usr/local/lib \
--with-iconv-includes=/usr/local/include \
--with-gmp-libraries=/usr/local/lib \
--with-gmp-includes=/usr/local/include \
--with-ffi-libraries=/usr/local/lib \
--with-ffi-includes=/usr/local/include \
--with-system-libffi \
--prefix=$HOME/.local/ \
CC=clang
gmake
gmake binary-dist
```
## Expected behavior
`gmake binary-dist` to succeed.
## Environment
* GHC version used:
```
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.10.6
```
Optional:
* Operating System: `OpenBSD`
* System Architecture: x86_64
```
$ uname -a
OpenBSD nuci5.adamsteen.com.au 7.1 GENERIC.MP#403 amd64
```https://gitlab.haskell.org/ghc/ghc/-/issues/21155NativeAmd64Asm: ld.lld: error: can't create dynamic relocation R_X86_64_64 ag...2022-03-26T17:38:23ZGreg SteuckNativeAmd64Asm: ld.lld: error: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segmentI suspect something in the recent adjustors work by @bgamari went sideways. At least my usual HEAD-building OpenBSD recipe started failing with:
```
"rm" -f rts/dist-install/build/libHSrts-ghc9.3.20220301.so
"inplace/bin/ghc-stage1" -th...I suspect something in the recent adjustors work by @bgamari went sideways. At least my usual HEAD-building OpenBSD recipe started failing with:
```
"rm" -f rts/dist-install/build/libHSrts-ghc9.3.20220301.so
"inplace/bin/ghc-stage1" -this-unit-id rts -shared -dynamic -dynload deploy -no-auto-link-packages `cat rts/dist-install/libs.depend` rts/dist-install/build/Adjustor.dyn_o rts/dist-install/build/Arena.dyn_o rts/dist-install/build/Capability.dyn_o rts/dist-install/build/CheckUnload.dyn_o rts/dist-install/build/CloneStack.dyn_o rts/dist-install/build/ClosureFlags.dyn_o rts/dist-install/build/ClosureSize.dyn_o rts/dist-install/build/Disassembler.dyn_o rts/dist-install/build/ExecPage.dyn_o rts/dist-install/build/FileLock.dyn_o rts/dist-install/build/ForeignExports.dyn_o rts/dist-install/build/Globals.dyn_o rts/dist-install/build/Hash.dyn_o rts/dist-install/build/Heap.dyn_o rts/dist-install/build/Hpc.dyn_o rts/dist-install/build/HsFFI.dyn_o rts/dist-install/build/IOManager.dyn_o rts/dist-install/build/IPE.dyn_o rts/dist-install/build/Inlines.dyn_o rts/dist-install/build/Interpreter.dyn_o rts/dist-install/build/LdvProfile.dyn_o rts/dist-install/build/Libdw.dyn_o rts/dist-install/build/LibdwPool.dyn_o rts/dist-install/build/Linker.dyn_o rts/dist-install/build/Messages.dyn_o rts/dist-install/build/OldARMAtomic.dyn_o rts/dist-install/build/PathUtils.dyn_o rts/dist-install/build/Pool.dyn_o rts/dist-install/build/Printer.dyn_o rts/dist-install/build/ProfHeap.dyn_o rts/dist-install/build/ProfilerReport.dyn_o rts/dist-install/build/ProfilerReportJson.dyn_o rts/dist-install/build/Profiling.dyn_o rts/dist-install/build/Proftimer.dyn_o rts/dist-install/build/RaiseAsync.dyn_o rts/dist-install/build/ReportMemoryMap.dyn_o rts/dist-install/build/RetainerProfile.dyn_o rts/dist-install/build/RetainerSet.dyn_o rts/dist-install/build/RtsAPI.dyn_o rts/dist-install/build/RtsDllMain.dyn_o rts/dist-install/build/RtsFlags.dyn_o rts/dist-install/build/RtsMain.dyn_o rts/dist-install/build/RtsMessages.dyn_o rts/dist-install/build/RtsStartup.dyn_o rts/dist-install/build/RtsSymbolInfo.dyn_o rts/dist-install/build/RtsSymbols.dyn_o rts/dist-install/build/RtsUtils.dyn_o rts/dist-install/build/STM.dyn_o rts/dist-install/build/Schedule.dyn_o rts/dist-install/build/Sparks.dyn_o rts/dist-install/build/SpinLock.dyn_o rts/dist-install/build/StableName.dyn_o rts/dist-install/build/StablePtr.dyn_o rts/dist-install/build/StaticPtrTable.dyn_o rts/dist-install/build/Stats.dyn_o rts/dist-install/build/StgCRun.dyn_o rts/dist-install/build/StgPrimFloat.dyn_o rts/dist-install/build/Task.dyn_o rts/dist-install/build/ThreadLabels.dyn_o rts/dist-install/build/ThreadPaused.dyn_o rts/dist-install/build/Threads.dyn_o rts/dist-install/build/Ticky.dyn_o rts/dist-install/build/Timer.dyn_o rts/dist-install/build/TopHandler.dyn_o rts/dist-install/build/Trace.dyn_o rts/dist-install/build/TraverseHeap.dyn_o rts/dist-install/build/TraverseHeapTest.dyn_o rts/dist-install/build/WSDeque.dyn_o rts/dist-install/build/Weak.dyn_o rts/dist-install/build/fs.dyn_o rts/dist-install/build/hooks/FlagDefaults.dyn_o rts/dist-install/build/hooks/LongGCSync.dyn_o rts/dist-install/build/hooks/MallocFail.dyn_o rts/dist-install/build/hooks/OnExit.dyn_o rts/dist-install/build/hooks/OutOfHeap.dyn_o rts/dist-install/build/hooks/StackOverflow.dyn_o rts/dist-install/build/sm/BlockAlloc.dyn_o rts/dist-install/build/sm/CNF.dyn_o rts/dist-install/build/sm/Compact.dyn_o rts/dist-install/build/sm/Evac.dyn_o rts/dist-install/build/sm/Evac_thr.dyn_o rts/dist-install/build/sm/GC.dyn_o rts/dist-install/build/sm/GCAux.dyn_o rts/dist-install/build/sm/GCUtils.dyn_o rts/dist-install/build/sm/MBlock.dyn_o rts/dist-install/build/sm/MarkWeak.dyn_o rts/dist-install/build/sm/NonMoving.dyn_o rts/dist-install/build/sm/NonMovingCensus.dyn_o rts/dist-install/build/sm/NonMovingMark.dyn_o rts/dist-install/build/sm/NonMovingScav.dyn_o rts/dist-install/build/sm/NonMovingShortcut.dyn_o rts/dist-install/build/sm/NonMovingSweep.dyn_o rts/dist-install/build/sm/Sanity.dyn_o rts/dist-install/build/sm/Scav.dyn_o rts/dist-install/build/sm/Scav_thr.dyn_o rts/dist-install/build/sm/Storage.dyn_o rts/dist-install/build/sm/Sweep.dyn_o rts/dist-install/build/eventlog/EventLog.dyn_o rts/dist-install/build/eventlog/EventLogWriter.dyn_o rts/dist-install/build/linker/CacheFlush.dyn_o rts/dist-install/build/linker/Elf.dyn_o rts/dist-install/build/linker/LoadArchive.dyn_o rts/dist-install/build/linker/M32Alloc.dyn_o rts/dist-install/build/linker/MMap.dyn_o rts/dist-install/build/linker/MachO.dyn_o rts/dist-install/build/linker/PEi386.dyn_o rts/dist-install/build/linker/SymbolExtras.dyn_o rts/dist-install/build/linker/elf_got.dyn_o rts/dist-install/build/linker/elf_plt.dyn_o rts/dist-install/build/linker/elf_plt_aarch64.dyn_o rts/dist-install/build/linker/elf_plt_arm.dyn_o rts/dist-install/build/linker/elf_reloc.dyn_o rts/dist-install/build/linker/elf_reloc_aarch64.dyn_o rts/dist-install/build/linker/elf_tlsgd.dyn_o rts/dist-install/build/linker/elf_util.dyn_o rts/dist-install/build/linker/macho/plt.dyn_o rts/dist-install/build/linker/macho/plt_aarch64.dyn_o rts/dist-install/build/posix/GetEnv.dyn_o rts/dist-install/build/posix/GetTime.dyn_o rts/dist-install/build/posix/OSMem.dyn_o rts/dist-install/build/posix/OSThreads.dyn_o rts/dist-install/build/posix/Select.dyn_o rts/dist-install/build/posix/Signals.dyn_o rts/dist-install/build/posix/TTY.dyn_o rts/dist-install/build/posix/Ticker.dyn_o rts/dist-install/build/adjustor/AdjustorPool.dyn_o rts/dist-install/build/adjustor/NativeAmd64.dyn_o rts/dist-install/build/StgCRunAsm.dyn_o rts/dist-install/build/adjustor/NativeAmd64Asm.dyn_o rts/dist-install/build/Apply.dyn_o rts/dist-install/build/Compact.dyn_o rts/dist-install/build/Exception.dyn_o rts/dist-install/build/HeapStackCheck.dyn_o rts/dist-install/build/PrimOps.dyn_o rts/dist-install/build/StgMiscClosures.dyn_o rts/dist-install/build/StgStartup.dyn_o rts/dist-install/build/StgStdThunks.dyn_o rts/dist-install/build/Updates.dyn_o rts/dist-install/build/AutoApply.dyn_o -optl-Wl,-z -optl-Wl,wxneeded -fPIC -dynamic -O0 -H64m -Wall -fllvm-fill-undef-with-garbage -Werror -this-unit-id rts -dcmm-lint -package-env - -i -irts -irts/dist-install/build -Irts/dist-install/build -irts/dist-install/build/./autogen -Irts/dist-install/build/./autogen -Irts/include/../dist-install/build/include -Irts/include/. -Irts/. -optP-DCOMPILING_RTS -optP-DFS_NAMESPACE=rts -O2 -Wcpp-undef -Wnoncanonical-monad-instances -fno-use-rpaths -optl-Wl,-zorigin -o rts/dist-install/build/libHSrts-ghc9.3.20220301.so
ld.lld: error: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
>>> defined in rts/dist-install/build/adjustor/NativeAmd64Asm.dyn_o
>>> referenced by NativeAmd64Asm.S
>>> rts/dist-install/build/adjustor/NativeAmd64Asm.dyn_o:(.text+0x50)
cc: error: linker command failed with exit code 1 (use -v to see invocation)
`cc' failed in phase `Linker'. (Exit code: 1)
gmake[1]: *** [rts/ghc.mk:353: rts/dist-install/build/libHSrts-ghc9.3.20220301.so] Error 1
gmake: *** [Makefile:128: all] Error 2
```
The file indeed has an R_X86_64_64 relocation:
```
% "inplace/bin/ghc-stage1" -optc--target=x86_64-unknown-openbsd -optc-Wall -optc-Werror -optc-Wall -optc-Wextra -optc-Wstrict-prototypes -optc-Wmissing-prototypes -optc-Wmissing-declarations -optc-Winline -optc-Wpointer-arith -optc-Wmissing-noreturn -optc-Wnested-externs -optc-Wredundant-decls -optc-Wno-aggregate-return -optc-Wno-unused-label -optc-fno-strict-aliasing -optc-fno-common -optc-Irts/dist-install/build/./autogen -optc-Irts/include/../dist-install/build/include -optc-Irts/include/. -optc-Irts/. -optc-DCOMPILING_RTS -optc-DFS_NAMESPACE=rts -optc-Wno-unknown-pragmas -optc-O2 -optc-fomit-frame-pointer -optc-g -optc-DDYNAMIC -optc-DRtsWay=\"rts_dyn\" -fPIC -dynamic -O0 -H64m -Wall -fllvm-fill-undef-with-garbage -Werror -this-unit-id rts -dcmm-lint -package-env - -i -irts -irts/dist-install/build -Irts/dist-install/build -irts/dist-install/build/./autogen -Irts/dist-install/build/./autogen -Irts/include/../dist-install/build/include -Irts/include/. -Irts/. -optP-DCOMPILING_RTS -optP-DFS_NAMESPACE=rts -O2 -Wcpp-undef -Wnoncanonical-monad-instances -c rts/adjustor/NativeAmd64Asm.S -o rts/dist-install/build/adjustor/NativeAmd64Asm.dyn_o
% file rts/dist-install/build/adjustor/NativeAmd64Asm.dyn_o
rts/dist-install/build/adjustor/NativeAmd64Asm.dyn_o: ELF 64-bit LSB relocatable, x86-64, version 1
% objdump -r rts/dist-install/build/adjustor/NativeAmd64Asm.dyn_o
rts/dist-install/build/adjustor/NativeAmd64Asm.dyn_o: file format elf64-x86-64
RELOCATION RECORDS FOR [.text]:
OFFSET TYPE VALUE
0000000000000050 R_X86_64_64 .text+0x0000000000000060
```
Doing a naive monkey-see-monkey-do doesn't help:
```
% git diff rts/adjustor/NativeAmd64Asm.S
diff --git a/rts/adjustor/NativeAmd64Asm.S b/rts/adjustor/NativeAmd64Asm.S
index 32e8da50fd..7c4444d46e 100644
--- a/rts/adjustor/NativeAmd64Asm.S
+++ b/rts/adjustor/NativeAmd64Asm.S
@@ -14,7 +14,7 @@
CSYM(x):
-#if defined(darwin_HOST_OS)
+#if defined(darwin_HOST_OS) || defined(openbsd_HOST_OS)
/*
* Note [Adjustor templates live in data section on Darwin]
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -84,7 +84,7 @@ lcl_complex_ccall_adjustor_context: // See Note [Adjustors: Local symbol referen
DECLARE_CSYM(complex_ccall_adjustor_end)
-#if defined(darwin_HOST_OS)
+#if defined(darwin_HOST_OS) || defined(openbsd_HOST_OS)
/* See Note [Adjustor templates live in data section on Darwin]. */
.section __TEXT,__text
#endif
% "inplace/bin/ghc-stage1" -optc--target=x86_64-unknown-openbsd -optc-Wall -optc-Werror -optc-Wall -optc-Wextra -optc-Wstrict-prototypes -optc-Wmissing-prototypes -optc-Wmissing-declarations -optc-Winline -optc-Wpointer-arith -optc-Wmissing-noreturn -optc-Wnested-externs -optc-Wredundant-decls -optc-Wno-aggregate-return -optc-Wno-unused-label -optc-fno-strict-aliasing -optc-fno-common -optc-Irts/dist-install/build/./autogen -optc-Irts/include/../dist-install/build/include -optc-Irts/include/. -optc-Irts/. -optc-DCOMPILING_RTS -optc-DFS_NAMESPACE=rts -optc-Wno-unknown-pragmas -optc-O2 -optc-fomit-frame-pointer -optc-g -optc-DDYNAMIC -optc-DRtsWay=\"rts_dyn\" -fPIC -dynamic -O0 -H64m -Wall -fllvm-fill-undef-with-garbage -Werror -this-unit-id rts -dcmm-lint -package-env - -i -irts -irts/dist-install/build -Irts/dist-install/build -irts/dist-install/build/./autogen -Irts/dist-install/build/./autogen -Irts/include/../dist-install/build/include -Irts/include/. -Irts/. -optP-DCOMPILING_RTS -optP-DFS_NAMESPACE=rts -O2 -Wcpp-undef -Wnoncanonical-monad-instances -c rts/adjustor/NativeAmd64Asm.S -o rts/dist-install/build/adjustor/NativeAmd64Asm.dyn_o
rts/adjustor/NativeAmd64Asm.S:29:17: error:
error: expected string in directive
|
29 | .section __DATA,__data
| ^
.section __DATA,__data
^
rts/adjustor/NativeAmd64Asm.S:89:17: error:
error: expected string in directive
|
89 | .section __TEXT,__text
| ^
.section __TEXT,__text
^
`cc' failed in phase `Assembler'. (Exit code: 1)
%
```9.4.1https://gitlab.haskell.org/ghc/ghc/-/issues/20870-Wmissed-extra-shared-lib complains about text using libstdc++ unclearly2022-07-11T23:13:35ZGreg Steuck-Wmissed-extra-shared-lib complains about text using libstdc++ unclearly## Summary
The error is under-informative:
```
Loading unit text-2.0 ...
<no location info>: warning: [-Wmissed-extra-shared-lib]
File not found
It's OK if you don't want to use symbols from it directly.
(the package DLL is...## Summary
The error is under-informative:
```
Loading unit text-2.0 ...
<no location info>: warning: [-Wmissed-extra-shared-lib]
File not found
It's OK if you don't want to use symbols from it directly.
(the package DLL is loaded by the system linker
which manages dependencies by itself).
linking ... done.
```
## Steps to reproduce
```
$ printf ":set -package ghc\n" | ./inplace/bin/ghc-stage2 --interactive -v
```
## Expected behavior
Should load without complaining or at least provide a more actionable complaint.
## Environment
* GHC version used: 9.3
Optional:
* Operating System: OpenBSD 7.0
* System Architecture: amd64
## More details
```
Loading unit hpc-0.6.1.0 ... linking ... done.
*** systool:linker:
*** gcc:
cc '--target=x86_64-unknown-openbsd' '--target=x86_64-unknown-openbsd' '-fuse-ld=lld' -Wl,-z,wxneeded -B/home/greg/s/ghc/libraries/text/dist-install/build --print-file-name 'libstdc++.so'
!!! systool:linker: finished in 0.00 milliseconds, allocated 0.232 megabytes
*** systool:linker:
*** gcc:
cc '--target=x86_64-unknown-openbsd' '--target=x86_64-unknown-openbsd' '-fuse-ld=lld' -Wl,-z,wxneeded -B/home/greg/s/ghc/libraries/text/dist-install/build --print-file-name 'liblibstdc++.so'
!!! systool:linker: finished in 10.00 milliseconds, allocated 0.235 megabytes
*** systool:linker:
*** gcc:
cc '--target=x86_64-unknown-openbsd' '--target=x86_64-unknown-openbsd' '-fuse-ld=lld' -Wl,-z,wxneeded -B/home/greg/s/ghc/libraries/text/dist-install/build --print-file-name 'stdc++.lib'
!!! systool:linker: finished in 10.00 milliseconds, allocated 0.230 megabytes
*** systool:linker:
*** gcc:
cc '--target=x86_64-unknown-openbsd' '--target=x86_64-unknown-openbsd' '-fuse-ld=lld' -Wl,-z,wxneeded -B/home/greg/s/ghc/libraries/text/dist-install/build --print-file-name 'libstdc++.lib'
!!! systool:linker: finished in 10.00 milliseconds, allocated 0.234 megabytes
*** systool:linker:
*** gcc:
cc '--target=x86_64-unknown-openbsd' '--target=x86_64-unknown-openbsd' '-fuse-ld=lld' -Wl,-z,wxneeded -B/home/greg/s/ghc/libraries/text/dist-install/build --print-file-name 'libstdc++.dll.a'
!!! systool:linker: finished in 0.00 milliseconds, allocated 0.234 megabytes
*** systool:linker:
*** gcc:
cc '--target=x86_64-unknown-openbsd' '--target=x86_64-unknown-openbsd' '-fuse-ld=lld' -Wl,-z,wxneeded -B/home/greg/s/ghc/libraries/text/dist-install/build --print-file-name 'stdc++.dll.a'
!!! systool:linker: finished in 10.00 milliseconds, allocated 0.232 megabytes
*** systool:linker:
*** gcc:
cc '--target=x86_64-unknown-openbsd' '--target=x86_64-unknown-openbsd' '-fuse-ld=lld' -Wl,-z,wxneeded -B/home/greg/s/ghc/libraries/text/dist-install/build --print-file-name 'libstdc++.a'
!!! systool:linker: finished in 10.00 milliseconds, allocated 0.231 megabytes
*** systool:linker:
*** gcc:
cc '--target=x86_64-unknown-openbsd' '--target=x86_64-unknown-openbsd' '-fuse-ld=lld' -Wl,-z,wxneeded -B/home/greg/s/ghc/libraries/text/dist-install/build --print-file-name 'stdc++.a'
!!! systool:linker: finished in 0.00 milliseconds, allocated 0.228 megabytes
*** systool:linker:
*** gcc:
cc '--target=x86_64-unknown-openbsd' '--target=x86_64-unknown-openbsd' '-fuse-ld=lld' -Wl,-z,wxneeded -B/home/greg/s/ghc/libraries/text/dist-install/build --print-file-name 'libstdc++'
!!! systool:linker: finished in 0.00 milliseconds, allocated 0.229 megabytes
*** systool:linker:
*** gcc:
cc '--target=x86_64-unknown-openbsd' '--target=x86_64-unknown-openbsd' '-fuse-ld=lld' -Wl,-z,wxneeded -B/home/greg/s/ghc/libraries/text/dist-install/build --print-file-name 'stdc++'
!!! systool:linker: finished in 10.00 milliseconds, allocated 0.225 megabytes
Loading unit text-2.0 ...
<no location info>: warning: [-Wmissed-extra-shared-lib]
File not found
It's OK if you don't want to use symbols from it directly.
(the package DLL is loaded by the system linker
which manages dependencies by itself).
linking ... done.
```https://gitlab.haskell.org/ghc/ghc/-/issues/20869Ignore linker script loading on OpenBSD2022-01-07T11:08:40ZGreg SteuckIgnore linker script loading on OpenBSDStarting with e020e387b3da272ef9750bad5f585119cbaf387 which addressed #2615 ghci had support for loading linker scripts as `.so`. This capability is verified with `T2615.hs` test. The test fails on OpenBSD because the regexp looking for ...Starting with e020e387b3da272ef9750bad5f585119cbaf387 which addressed #2615 ghci had support for loading linker scripts as `.so`. This capability is verified with `T2615.hs` test. The test fails on OpenBSD because the regexp looking for this condition is not sufficient to match the error message returned by OpenBSD `ld.so`. The small attached program (extracted out of Linker.c)[l.c](/uploads/277842b74cfba58ec25653bef97b3fd7/l.c) demonstrates the condition and its output is:
```
errmsg = 'File not an ELF object'
result = 1
result File not an ELF object
```
The `re_invalid` could conceivably be expanded to match this error as well, but the underlying assumption that the file name is included into `dlerror` result does NOT hold on OpenBSD.
Luckily, OpenBSD doesn't ship any system libraries fronted by linker scripts. Hence the only impact at the moment is the broken test which I'll mark to be ignored.https://gitlab.haskell.org/ghc/ghc/-/issues/20866Divizion by zero in T169162022-01-19T05:08:25ZGreg SteuckDivizion by zero in T16916## Summary
The test has a history of instability, but I observed another interesting way it's failing.
## Steps to reproduce
Running the full test suite resulted in this (partial) output:
```
Wrong exit code for T16916(normal)(expecte...## Summary
The test has a history of instability, but I observed another interesting way it's failing.
## Steps to reproduce
Running the full test suite resulted in this (partial) output:
```
Wrong exit code for T16916(normal)(expected 0 , actual 1 )
Stdout ( T16916 ):
Idle CPU consumption too different after event registration: +179769313486231590772930519078902473361797697894230657273430081157732675805500963132708477322407536021120113879871393357658789768814416622492847430639474124377767893424865485276302219601246094119453082952085005768838150682342462881473913110540827237163350510684586298239947245938479716304835356329624224137216% (> +/- 100%)
Before: 0ms
After: 1000ms
*** unexpected failure for T16916(normal)
```
## Expected behavior
The test should pass.
## Environment
* GHC version used: 9.3-current
Optional:
* Operating System: OpenBSD 7.0
* System Architecture: amd64ZubinZubinhttps://gitlab.haskell.org/ghc/ghc/-/issues/20841linkwhole test case fails on OpenBSD2022-01-18T23:36:33ZGreg Steucklinkwhole test case fails on OpenBSD## Summary
`TEST="linkwhole" gmake test` currently fails on OpenBSD
## Steps to reproduce
```
=====> 1 of 1 [0, 0, 0]
$ TEST="linkwhole" gmake test
...
linkwhole(normal) 1 of 1 [0, 0, 0]�Wrong exit code for linkwhole()(expected 0 , ac...## Summary
`TEST="linkwhole" gmake test` currently fails on OpenBSD
## Steps to reproduce
```
=====> 1 of 1 [0, 0, 0]
$ TEST="linkwhole" gmake test
...
linkwhole(normal) 1 of 1 [0, 0, 0]�Wrong exit code for linkwhole()(expected 0 , actual 2 )
Stderr ( linkwhole ):
host: lib.so: unknown symbol `base_GHCziNum_zdfNumInt_closure'
host: Could not load Object Code lib.so.
host: Unable to resolve objects for lib.so
gmake[1]: *** [Makefile:20: linkwhole] Error 1
*** unexpected failure for linkwhole(normal)
```
## Expected behavior
The test should pass.
## Environment
* GHC version used: 9.3 (commit 6cea73113e)
Optional:
* Operating System: OpenBSD 7.0-current with clang 13
* System Architecture: amd64
## More details
This test checks `-fwhole-archive-hs-libs` related behavior which is documented as
> This is for specialist applications that may require symbols defined in these Haskell libraries at
> runtime even though they aren’t referenced by any other code linked into the executable. If you’re
> using -fwhole-archive-hs-libs, you probably also want -rdynamic.
and -rdynamic in turn is documented as:
> This instructs the linker to add all symbols, not only used ones, to the dynamic symbol table.
> Currently Linux and Windows/MinGW32 only. This is equivalent to using -optl -rdynamic on Linux,
> and -optl -export-all-symbols on Windows.
Based on these I wouldn't expect the test to actually work on OpenBSD, but the failure mode is somewhat strange. Note that the test goes all the way until `./host lib.so` runs. At this point, with LD_DEBUG I get more information:
```
-rwxr-xr-x 1 greg wsrc 29671392 Dec 19 17:27 host
-rw-r--r-- 1 greg wsrc 8240 Dec 19 17:27 lib.so
Stderr ( linkwhole ):
ld.so loading: 'host'
exe load offset: 0x0
flags ./host = 0x0
head ./host
obj ./host has ./host as head
examining: './host'
loading: libiconv.so.7.0 required by ./host
flags /usr/local/lib/libiconv.so.7.0 = 0x0
obj /usr/local/lib/libiconv.so.7.0 has ./host as head
loading: libc.so.96.1 required by ./host
flags /usr/lib/libc.so.96.1 = 0x21
obj /usr/lib/libc.so.96.1 has ./host as head
loading: libffi.so.1.2 required by ./host
flags /usr/local/lib/libffi.so.1.2 = 0x0
obj /usr/local/lib/libffi.so.1.2 has ./host as head
loading: libgmp.so.11.0 required by ./host
flags /usr/local/lib/libgmp.so.11.0 = 0x0
obj /usr/local/lib/libgmp.so.11.0 has ./host as head
loading: libutil.so.16.0 required by ./host
flags /usr/lib/libutil.so.16.0 = 0x0
obj /usr/lib/libutil.so.16.0 has ./host as head
loading: libcharset.so.1.1 required by ./host
flags /usr/local/lib/libcharset.so.1.1 = 0x0
obj /usr/local/lib/libcharset.so.1.1 has ./host as head
loading: libpthread.so.26.1 required by ./host
flags /usr/lib/libpthread.so.26.1 = 0x8
obj /usr/lib/libpthread.so.26.1 has ./host as head
loading: libm.so.10.1 required by ./host
flags /usr/lib/libm.so.10.1 = 0x0
obj /usr/lib/libm.so.10.1 has ./host as head
linking dep /usr/lib/libm.so.10.1 as child of ./host
linking dep /usr/lib/libutil.so.16.0 as child of ./host
objname /usr/lib/libpthread.so.26.1 is nodelete
linking dep /usr/lib/libpthread.so.26.1 as child of ./host
linking dep /usr/local/lib/libiconv.so.7.0 as child of ./host
linking dep /usr/local/lib/libcharset.so.1.1 as child of ./host
linking dep /usr/local/lib/libgmp.so.11.0 as child of ./host
linking dep /usr/local/lib/libffi.so.1.2 as child of ./host
linking dep /usr/lib/libc.so.96.1 as child of ./host
examining: '/usr/lib/libm.so.10.1'
examining: '/usr/lib/libutil.so.16.0'
examining: '/usr/lib/libpthread.so.26.1'
examining: '/usr/local/lib/libiconv.so.7.0'
examining: '/usr/local/lib/libcharset.so.1.1'
examining: '/usr/local/lib/libgmp.so.11.0'
examining: '/usr/local/lib/libffi.so.1.2'
examining: '/usr/lib/libc.so.96.1'
flags /usr/libexec/ld.so = 0x0
obj /usr/libexec/ld.so has ./host as head
static tls size=0 align=8 offset=0
Start End Type Open Ref GrpRef Name
0000000000200000 00000000013f4000 exe 2 0 0 ./host
000000020652f000 0000000206560000 rlib 0 1 0 /usr/lib/libm.so.10.1
00000002854f4000 0000000285509000 rlib 0 1 0 /usr/lib/libutil.so.16.0
00000002e330d000 00000002e3319000 rlib 0 1 0 /usr/lib/libpthread.so.26.1
000000024a62f000 000000024a731000 rlib 0 1 0 /usr/local/lib/libiconv.so.7.0
00000002f01c4000 00000002f01c8000 rlib 0 1 0 /usr/local/lib/libcharset.so.1.1
0000000225373000 0000000225401000 rlib 0 1 0 /usr/local/lib/libgmp.so.11.0
00000002d3b44000 00000002d3b50000 rlib 0 1 0 /usr/local/lib/libffi.so.1.2
000000023074e000 0000000230842000 rlib 0 1 0 /usr/lib/libc.so.96.1
00000002d667a000 00000002d667a000 ld.so 0 1 0 /usr/libexec/ld.so
dynamic loading done, success.
tib new=0x2cc0bdb00
doing initarray obj 0x29d137000 @0x23082f9b0: [/usr/lib/libc.so.96.1]
version 0 callbacks requested
protect RELRO [0x23082ad90,0x230830000) in /usr/lib/libc.so.96.1
protect RELRO [0x20655ccd0,0x20655e000) in /usr/lib/libm.so.10.1
doing ctors obj 0x29d137400 @0x20655b9e0: [/usr/lib/libm.so.10.1]
protect RELRO [0x285506e70,0x285508000) in /usr/lib/libutil.so.16.0
doing ctors obj 0x29d137c00 @0x285504b00: [/usr/lib/libutil.so.16.0]
protect RELRO [0x2e33175c0,0x2e3318000) in /usr/lib/libpthread.so.26.1
doing ctors obj 0x2c5bac800 @0x2e3315db0: [/usr/lib/libpthread.so.26.1]
protect RELRO [0x24a72d940,0x24a730000) in /usr/local/lib/libiconv.so.7.0
doing ctors obj 0x226894c00 @0x24a72c690: [/usr/local/lib/libiconv.so.7.0]
protect RELRO [0x2f01c6bd0,0x2f01c7000) in /usr/local/lib/libcharset.so.1.1
doing ctors obj 0x2c5bac000 @0x2f01c5ac0: [/usr/local/lib/libcharset.so.1.1]
protect RELRO [0x2253fd380,0x2253fead8) in /usr/local/lib/libgmp.so.11.0
doing ctors obj 0x2c5bac400 @0x2253f96f0: [/usr/local/lib/libgmp.so.11.0]
protect RELRO [0x2d3b4d7e0,0x2d3b4dc60) in /usr/local/lib/libffi.so.1.2
doing ctors obj 0x226894000 @0x2d3b4c470: [/usr/local/lib/libffi.so.1.2]
protect RELRO [0x116edc0,0x1188000) in ./host
doing initarray obj 0x226894800 @0x11711d8: [./host]
entry point: 0x25e440
dlsym: failed to find symbol base_GHCziNum_zdfNumInt_closure
host: lib.so: unknown symbol `base_GHCziNum_zdfNumInt_closure'
host: Could not load Object Code lib.so.
host: Unable to resolve objects for lib.so
doing dtors
```
We can see that `lib.so` is this kind of file:
```
$ ls -l lib.so
-rw-r--r-- 1 greg wsrc 8232 Dec 19 17:29 lib.so
$ file lib.so
lib.so: ELF 64-bit LSB relocatable, x86-64, version 1
$ nm lib.so
00000000 d .L.str
00000110 D Handles_hsNewSOHandle_closure
00000298 T Handles_hsNewSOHandle_info
00000110 D Handles_zdfstableZZC0ZZCmainZZCHandlesZZChsNewSOHandle_closure
00000150 D Handles_zdtrModule_closure
00000088 D MyCode_myFunction_closure
000001c8 T MyCode_myFunction_info
00000020 D MyCode_zdtrModule_closure
U Types_SOHandles_con_info
00000000 W __llvm_retpoline_r11
00000000 W __retguard_2041
00000000 W __retguard_834
U base_GHCziBase_zd_closure
U base_GHCziBase_zpzp_closure
U base_GHCziNum_zdfNumInt_closure
U base_GHCziNum_zp_info
U base_GHCziShow_show_info
U base_GHCziShow_zdfShowInt_closure
U base_GHCziStable_newStablePtr_closure
U base_GHCziTopHandler_runIO_closure
U base_SystemziIO_putStrLn_closure
00000023 c cC5_str
0000000f c cSK_str
00000000 F ghc_1.s
00000000 F ghc_1.s
00000000 F ghc_2.c
00000000 F ghc_3.s
U ghczmprim_GHCziCString_unpackCStringzh_closure
U ghczmprim_GHCziTypes_Module_con_info
U ghczmprim_GHCziTypes_TrNameS_con_info
000002f0 T hs_soHandles
U newCAF
U registerForeignExports
U rts_apply
U rts_checkSchedStatus
U rts_getStablePtr
U rts_inCall
U rts_lock
U rts_unlock
U stg_INTLIKE_closure
U stg_SRT_2_info
U stg_SRT_3_info
U stg_ap_n_fast
U stg_ap_p_fast
U stg_ap_p_info
U stg_ap_pp_fast
U stg_ap_pp_info
U stg_bh_upd_frame_info
00000170 d stg_exports_Handles
U stg_upd_frame_info
00000380 t stginit_export_Handles
```https://gitlab.haskell.org/ghc/ghc/-/issues/20734internal error: m32_alloc_page: failed to get allocation in lower 32-bits2022-02-10T02:40:59ZGreg Steuckinternal error: m32_alloc_page: failed to get allocation in lower 32-bits## Summary
ghc --interactive aborts with message in the title.
## Steps to reproduce
```
% ./inplace/bin/ghc-stage2 --interactive
GHCi, version 9.3.20211124: https://www.haskell.org/ghc/ :? for help
ghc-stage2: internal error: m32_all...## Summary
ghc --interactive aborts with message in the title.
## Steps to reproduce
```
% ./inplace/bin/ghc-stage2 --interactive
GHCi, version 9.3.20211124: https://www.haskell.org/ghc/ :? for help
ghc-stage2: internal error: m32_alloc_page: failed to get allocation in lower 32-bits
(GHC version 9.3.20211124 for x86_64_unknown_openbsd)
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
```
gdb stack trace (not that it's particularly mysterious):
```
(gdb) bt
#0 thrkill () at /tmp/-:3
#1 0x00000002ed8fc80e in _libc_abort () at /usr/src/lib/libc/stdlib/abort.c:51
#2 0x000000023eb2fdd8 in rtsFatalInternalErrorFn (s=0x23eb08e06 "m32_alloc_page: failed to get allocation in lower 32-bits",
ap=0x7f7ffffc4ad0) at /home/greg/s/ghc/rts/RtsMessages.c:186
#3 0x000000023eb2ffe2 in barf (s=0x0) at /home/greg/s/ghc/rts/RtsMessages.c:48
#4 0x000000023eb6b55c in m32_alloc_page () at rts/linker/M32Alloc.c:250
#5 m32_alloc (alloc=0x2e9987e00, size=<optimized out>, alignment=<optimized out>) at rts/linker/M32Alloc.c:441
#6 0x000000023eb6b683 in ocAllocateExtras (oc=0x2e9998700, count=<optimized out>, first=0, bssSize=0)
at rts/linker/SymbolExtras.c:104
#7 0x000000023eb27a84 in loadOc (oc=0x2e9998700) at /home/greg/s/ghc/rts/Linker.c:1740
#8 0x000000023eb6ab48 in loadArchive_ (path=0x26db1a510 "/usr/local/lib/libgmp.a") at rts/linker/LoadArchive.c:535
#9 loadArchive (path=0x26db1a510 "/usr/local/lib/libgmp.a") at rts/linker/LoadArchive.c:629
#10 0x00000002bcab6059 in ?? () from /home/greg/s/ghc/libraries/ghci/dist-install/build/libHSghci-9.3-ghc9.3.20211124.so
```
ktrace (syscall trace) reveals this:
```
52253 ghc-stage2 CALL mmap(0x40000000,0x1000,0x3<PROT_READ|PROT_WRITE>,0x1002<MAP_PRIVATE|MAP_ANON>,-1,0)
52253 ghc-stage2 RET mmap 1073741824/0x40000000
52253 ghc-stage2 CALL mmap(0,0x2000,0x3<PROT_READ|PROT_WRITE>,0x1002<MAP_PRIVATE|MAP_ANON>,-1,0)
52253 ghc-stage2 RET mmap 9112080384/0x21f1f5000
52253 ghc-stage2 CALL kbind(0x7f7fffff48f8,24,0x2f81bae1abf0c0d7)
52253 ghc-stage2 RET kbind 0
52253 ghc-stage2 CALL mmap(0,0x3000,0x3<PROT_READ|PROT_WRITE>,0x1002<MAP_PRIVATE|MAP_ANON>,-1,0)
52253 ghc-stage2 RET mmap 9471471616/0x2348b3000
52253 ghc-stage2 CALL mmap(0,0x2000,0x3<PROT_READ|PROT_WRITE>,0x1002<MAP_PRIVATE|MAP_ANON>,-1,0)
52253 ghc-stage2 RET mmap 11532533760/0x2af648000
52253 ghc-stage2 CALL mmap(0x40000000,0x20000,0x3<PROT_READ|PROT_WRITE>,0x1002<MAP_PRIVATE|MAP_ANON>,-1,0)
52253 ghc-stage2 RET mmap 8593272832/0x20032f000
52253 ghc-stage2 CALL kbind(0x7f7fffff4728,24,0x2f81bae1abf0c0d7)
52253 ghc-stage2 RET kbind 0
52253 ghc-stage2 CALL write(2,0x7f7fffff3f40,0x1c)
52253 ghc-stage2 GIO fd 2 wrote 28 bytes
"ghc-stage2: internal error: "
```
## Expected behavior
Working ghci.
## Environment
* GHC version used: 9.3 snapshot
Optional:
* Operating System: OpenBSD 7.0-current
* System Architecture: amd64Ben GamariBen Gamarihttps://gitlab.haskell.org/ghc/ghc/-/issues/20635Failure of hadrian stage1 libffi: Needed "_validatebuild/stage1/rts/build/lib...2022-09-25T19:14:58ZGreg SteuckFailure of hadrian stage1 libffi: Needed "_validatebuild/stage1/rts/build/libffi.so.9.0" which is not any of libffi's built shared libraries: ["_validatebuild/stage1/libffi/build/inst/lib/libffi.so.9.0"]## Summary
Hadrian build fails on OpenBSD:
```
| ContextData oracle: resolving data for 'ghc' (Stage1, v)...
# _validatebuild/stage1/compiler/setup-config
# _validatebuild/stage0/utils/haddock/build/Documentation/Haddock.o
# _validatebu...## Summary
Hadrian build fails on OpenBSD:
```
| ContextData oracle: resolving data for 'ghc' (Stage1, v)...
# _validatebuild/stage1/compiler/setup-config
# _validatebuild/stage0/utils/haddock/build/Documentation/Haddock.o
# _validatebuild/stage0/utils/haddock/build/Main.o
# _validatebuild/stage0/utils/haddock/build/Documentation/Haddock.o _validatebuild/stage0/utils/haddock/build/Documentation/Haddock.hi
# _validatebuild/stage0/utils/haddock/build/Main.o _validatebuild/stage0/utils/haddock/build/Main.hi
# _validatebuild/stage0/utils/haddock/build/Documentation/Haddock.hi
# _validatebuild/stage1/rts/build/libCffi_thr_l.a
# _validatebuild/stage1/rts/build/libCffi_thr_debug.a
# _validatebuild/stage1/rts/build/libCffi_l.a
# _validatebuild/stage1/rts/build/libCffi_debug.a
# _validatebuild/stage1/rts/build/libCffi_thr.a
# _validatebuild/stage1/rts/build/libCffi.a
# _validatebuild/stage1/rts/build/libffi.so.9.0
Error when running Shake build system:
at action, called at src/Rules.hs:39:19 in main:Rules
at need, called at src/Rules.hs:61:5 in main:Rules
* Depends on: _validatebuild/stage1/lib/package.conf.d/ghc-prim-0.8.0.conf
at apply1, called at src/Development/Shake/Internal/Rules/Oracle.hs:159:32 in shake-0.19.4-956df6a960f412f043f5c30515a600878ff928d4342dfe8839afc8448494863c:Development.Shake.Internal.Rules.Oracle
* Depends on: OracleQ (ContextDataKey (Context {stage = Stage1, package = Package {pkgType = Library, pkgName = "ghc-prim", pkgPath = "libraries/ghc-prim"}, way = v}))
at need, called at src/Hadrian/Oracles/Cabal/Rules.hs:54:9 in main:Hadrian.Oracles.Cabal.Rules
* Depends on: _validatebuild/stage1/libraries/ghc-prim/setup-config
at need, called at src/Rules/Library.hs:164:18 in main:Rules.Library
* Depends on: _validatebuild/stage1/rts/build/libffi.so.9.0
at error, called at src/Rules/Rts.hs:77:18 in main:Rules.Rts
* Raised the exception:
Needed "_validatebuild/stage1/rts/build/libffi.so.9.0" which is not any of libffi's built shared libraries: ["_validatebuild/stage1/libffi/build/inst/lib/libffi.so.9.0"]
Build failed.
```
## Steps to reproduce
I'm using this patched tree (https://gitlab.haskell.org/blackgnezdo/ghc/-/commit/93b01c3d691ec614fe09b373d43809fa91e37b47) to avoid #18173. I start the build and it fails with diagnostics above.
```
ulimit -d $((10<<20)); AUTOCONF_VERSION=2.71 AUTOMAKE_VERSION=1.16 ./validate --build-only
```
These are the only files to choose from, note the absence of `*.so` (which is normal on OpenBSD):
```
% ls -l _validatebuild/stage1/libffi/build/inst/lib/
total 368
-rw-r--r-- 1 greg wsrc 92662 Nov 7 11:55 libffi.a
-rwxr-xr-x 1 greg wsrc 947 Nov 7 11:55 libffi.la
-rwxr-xr-x 1 greg wsrc 65856 Nov 7 11:55 libffi.so.9.0
drwxr-xr-x 2 greg wsrc 512 Nov 7 11:55 pkgconfig
```
I suspect hadrian/src/Rules/Rts.hs needs to adapt as this is unlikely to work given the files above:
```
buildPath -/- "libffi*.so*" %> copyLibffiDynamicUnix stage ".so"
```
## Expected behavior
Build goes all the way.
## Environment
* GHC version used: 8.10.6
Optional:
* Operating System: OpenBSD 7.0-current
* System Architecture: amd64https://gitlab.haskell.org/ghc/ghc/-/issues/202799.2.1-rc1 fails to compile on OpenBSD2021-09-10T22:27:29Zkgardas9.2.1-rc1 fails to compile on OpenBSDThe compilation failure in in libraries/base where configure.ac is not able to detect provided libiconv iconv.h file. The patch with explanation is already on a master:
commit 31dc013fdec0cf2ddac1ba093c8a6933a0b62df2
Author: Greg Steuck...The compilation failure in in libraries/base where configure.ac is not able to detect provided libiconv iconv.h file. The patch with explanation is already on a master:
commit 31dc013fdec0cf2ddac1ba093c8a6933a0b62df2
Author: Greg Steuck <greg@nest.cx>
Date: Sun Jun 6 22:30:52 2021 -0700
Fix iconv detection in configure on OpenBSD
This regressed in 544414ba604b13e0992ad87e90b8bdf45c43011c causing
configure: error: iconv is required on non-Windows platforms
More details:
https://gitlab.haskell.org/ghc/ghc/-/commit/544414ba604b13e0992ad87e90b8bdf45c43011c#3bae3b74ae866493bd6b79df16cb638a5f2e0f87_106_106
Would be great if this may be cherry picked to 9.2 branch too.9.2.1Ben GamariBen Gamari