xmonad/xmonad

Compiling XMonad fails with relocation error unless --disable-shared is added

Closed this issue · 1 comments

Problem Description

When compiling XMonad using runhaskell Setup, I notice that the build fails with a relocation error unless I add the flag --disable-shared to runhaskell Setup configure.

Steps to Reproduce

  1. Build the dependencies from source (data-default-class, X11, setlocale) using runhaskell Setup configure && runhaskell Setup build && runhaskell register --inplace. Verify that all packages are working using ghc-pkg check.
  2. Enter the xmonad directory. Execute the same build command, runhaskell Setup configure && runhaskell Setup build. Now the build fails:
Configuring xmonad-0.17.2...
Preprocessing library for xmonad-0.17.2..
Building library for xmonad-0.17.2..
[1 of 9] Compiling Paths_xmonad     ( dist/build/autogen/Paths_xmonad.hs, dist/build/Paths_xmonad.o, dist/build/Paths_xmonad.dyn_o )
[2 of 9] Compiling XMonad.StackSet  ( src/XMonad/StackSet.hs, dist/build/XMonad/StackSet.o, dist/build/XMonad/StackSet.dyn_o )
[3 of 9] Compiling XMonad.Core      ( src/XMonad/Core.hs, dist/build/XMonad/Core.o, dist/build/XMonad/Core.dyn_o )
[4 of 9] Compiling XMonad.Layout    ( src/XMonad/Layout.hs, dist/build/XMonad/Layout.o, dist/build/XMonad/Layout.dyn_o )
[5 of 9] Compiling XMonad.Operations ( src/XMonad/Operations.hs, dist/build/XMonad/Operations.o, dist/build/XMonad/Operations.dyn_o )
[6 of 9] Compiling XMonad.ManageHook ( src/XMonad/ManageHook.hs, dist/build/XMonad/ManageHook.o, dist/build/XMonad/ManageHook.dyn_o )
[7 of 9] Compiling XMonad.Config    ( src/XMonad/Config.hs, dist/build/XMonad/Config.o, dist/build/XMonad/Config.dyn_o )
[8 of 9] Compiling XMonad.Main      ( src/XMonad/Main.hs, dist/build/XMonad/Main.o, dist/build/XMonad/Main.dyn_o )
[9 of 9] Compiling XMonad           ( src/XMonad.hs, dist/build/XMonad.o, dist/build/XMonad.dyn_o )
/usr/bin/ld.bfd: dist/build/XMonad/Layout.dyn_o: warning: relocation against `xmonadzm0zi17zi2zmC7STTfB6ggAKcdk3yLfZZbh_XMonadziLayout_zdfLayoutClassFulla6_closure' in read-only section `.text'
/usr/bin/ld.bfd: dist/build/XMonad/Config.dyn_o: relocation R_X86_64_PC32 against symbol `xmonadzm0zi17zi2zmC7STTfB6ggAKcdk3yLfZZbh_XMonadziConfig_zdfDefaultXConfig26_bytes' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld.bfd: final link failed: bad value
collect2: error: ld returned 1 exit status
`x86_64-solus-linux-gcc' failed in phase `Linker'. (Exit code: 1)

I tried adding --ghc-option="-fPIC" or --ghc-option="-pie", but they all don't work. The only way I could successfully build xmonad is to run configure with --disable-shared.

Configuration File

n/a

GHC version: 9.2.8, built from source

Checklist

Apologies, it's a problem with Solus's build flag. -Bsymbolic-functions and -Bno-symbolic both break the build. Compiling data-default-class and (any package that depends on it) with -Bsymbolic solves the issue.