5

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'

2 Answers 2

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.)

Sign up to request clarification or add additional context in comments.

3 Comments

I dont know what MINGW version I have. Stack automatically installed it.
I just tried every combination of those flags, and none of them worked. The same error message was show.
GCC did not recognize the -mbig-obj flag when i tried adding it to vulkan's compilation settings.
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.

4 Comments

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
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.
@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.
Certainly, I mentioned the original package because I'm the author of vulkan :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.