Skip to content

Failure to embed large files with -O0 on GHC 9.4, Mac OS X #45

@csasarak

Description

@csasarak

Hi, I've found that when I try to build file-embed using GHC 9.4 with -O0 compilation fails when using a file > ~20MB in size. I get this error from the compiler:

$  cabal build test
Resolving dependencies...
Build profile: -w ghc-9.4.4 -O0
In order, the following will be built (use -v for more details):
 - file-embed-0.0.15.0 (lib) (first run)
 - file-embed-0.0.15.0 (test:test) (first run)
Configuring library for file-embed-0.0.15.0..
Preprocessing library for file-embed-0.0.15.0..
Building library for file-embed-0.0.15.0..
[1 of 1] Compiling Data.FileEmbed   ( Data/FileEmbed.hs, /Users/csasarak/file-embed/dist-newstyle/build/x86_64-osx/ghc-9.4.4/file-embed-0.0.15.0/noopt/build/Data/FileEmbed.o, /Users/csasarak/file-embed/dist-newstyle/build/x86_64-osx/ghc-9.4.4/file-embed-0.0.15.0/noopt/build/Data/FileEmbed.dyn_o )

Data/FileEmbed.hs:70:1: warning: [-Wunused-imports]
    The import of ‘Control.Applicative’ is redundant
      except perhaps to import instances from ‘Control.Applicative’
    To import instances alone, use: import Control.Applicative()
   |
70 | import Control.Applicative ((<$>))
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ld: warning: -undefined dynamic_lookup may not work with chained fixups
Configuring test suite 'test' for file-embed-0.0.15.0..
Preprocessing test suite 'test' for file-embed-0.0.15.0..
Building test suite 'test' for file-embed-0.0.15.0..
[1 of 1] Compiling Main             ( test/main.hs, /Users/csasarak/file-embed/dist-newstyle/build/x86_64-osx/ghc-9.4.4/file-embed-0.0.15.0/t/test/noopt/build/test/test-tmp/Main.o, /Users/csasarak/file-embed/dist-newstyle/build/x86_64-osx/ghc-9.4.4/file-embed-0.0.15.0/t/test/noopt/build/test/test-tmp/Main.dyn_o )
ghc-9.4.4: Stack space overflow: current size 33624 bytes.
ghc-9.4.4: Use `+RTS -Ksize -RTS' to increase it.
Error: cabal: Failed to build test:test from file-embed-0.0.15.0.

I've made a sample using file-embed's tests to demonstrate this behavior here that you can try yourself.

  1. Check out the branch here
  2. Find (or make: dd if=/dev/zero of=./zero_data bs=1024 count=20000) a file ~20MB or greater.
  3. Provide an absolute path to the file from step 2 here.
  4. Run cabal build test

Altering the cabal.project file to have optimization: 1 (or no optimization directive at all) and running cabal build test will resolve this problem.

Other things I've checked:

  1. I added traces in the code and found that it is indeed using bytesPrimL from Use TH 2.16 Bytes literal (#24) #36 in bsToExp.
  2. Compiling with -O0 and -ffull-laziness is also successful.

This may be a bug in the compiler, but I wanted to ask here. Thank you for maintaining this package. Please let me know if there's any additional info I can provide.

Best wishes,
-Chris

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions