4

I am trying to build a haskell project from Ludum Dare, but whenever I attempt the build I get an error message saying the object file has too many sections. Here is the error:

C:\Users\REDACTED\AppData\Local\Programs\stack\x86_64-windows\ghc-8.10.2\lib\../mingw/bin\ld.exe: .stack-work\dist\a3a5fe88\build\HSsingletons-2.7-J1xRPYS9ah3kGEIOoeLuX.o: too many sections (90295)
singletons           > C:\Users\REDACTED\AppData\Local\Programs\stack\x86_64-windows\ghc-8.10.2\lib\../mingw/bin\ld.exe: final link failed: file too big

--  While building package singletons-2.7 using:
      C:\Users\REDACTED\AppData\Local\Temp\stack-5ba10ebdb151d9fa\singletons-2.7\.stack-work\dist\a3a5fe88\setup\setup --builddir=.stack-work\dist\a3a5fe88 build --ghc-options " -fdiagnostics-color=always"
    Process exited with code: ExitFailure 1

I am using stack 2.3.3 and Windows 10. The project uses the vulkan library.

I tried adding -opta-mbig-obj, but gcc then failed with error: unrecognized command line option '-mbig-obj'

Nailuj29
  • 750
  • 1
  • 10
  • 28

2 Answers2

2

It looks like you may need to try explicitly using the “large object” file format, which I believe you can do by adding -opta-mbig-obj or -Wa,-mbig-obj to the GHC flags in the project’s build config (package.yaml or .cabal file) to add -mbig-obj to the assembler options. You may also need to add --oformat pe-bigobj-x86-64 to the linker flags, using (I think) -optl--oformat -optlpe-bigobj-x86-64 or -Wl,--oformat,pe-bigobj-x86-64. Are you using a 32-bit MinGW? I would expect MinGW64 to handle this by default. (And I’m not actually sure whether 32-bit supports these flags, so you may need to upgrade anyway.)

Jon Purdy
  • 53,300
  • 8
  • 96
  • 166
1

Since about a year ago (https://gitlab.haskell.org/ghc/ghc/-/commit/1ef90f990da90036d481c830d8832e21b8f1571b) GHC already uses the -mbig-obj and --oformat,pe-bigobj-x86-64 when assembling and linking on 64 bit MinGW. Adding these flags manually will not help on recent GHC versions.

I was able to replicate this problem for both the sdl2 and vulkan Haskell packages using Stack, however neither of them exhibit this issue when compiled with Cabal (and --enable-split-sections) on Windows; this looks to be a bug in stack.

  • I tried building with cabal, and now it is telling me that `vulkan-1` is a missing or bad library. I have already added `--extra-lib-dirs` and `--extra-include-dirs` – Nailuj29 Oct 22 '20 at 19:11
  • Sorry you're having this trouble, I think it might be best for you to open an issue against the project you're using with precise instructions for reproduction. – Joe Hermaszewski Oct 24 '20 at 00:59
  • @JoeHermaszewski probably it's worth to file it as a Stack issue? For some that could be a more discoverable and maybe somebody could check out how Stack could cause this kind of a bug. – Qrilka Dec 05 '20 at 11:52
  • Certainly, I mentioned the original package because I'm the author of `vulkan` :) – Joe Hermaszewski Apr 30 '21 at 14:48