Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
csasarak opened this issue Apr 13, 2023 · 0 comments
Open

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

csasarak opened this issue Apr 13, 2023 · 0 comments

Comments

@csasarak
Copy link

csasarak commented Apr 13, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant