JayXon / Leanify

lightweight lossless file minifier/optimizer
MIT License
832 stars 75 forks source link

Out of memory error when compiling #87

Closed K0-RR closed 1 year ago

K0-RR commented 1 year ago

Hello, building on Linux and Mac works fine but when I try it on Windows I get the following error.

 lib/zopfli/cache.c: In function 'ZopfliInitCache':
lib/zopfli/cache.c:36:51: error: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'size_t' {aka 'long long unsigned int'} [-Werror=format=]
   36 |         "Error: Out of memory. Tried allocating %lu bytes of memory.\n",
      |                                                 ~~^
      |                                                   |
      |                                                   long unsigned int
      |                                                 %llu
cc1.exe: all warnings being treated as errors
mingw32-make: *** [<builtin>: lib/zopfli/cache.o] Error 1
Error: Process completed with exit code 1.

Full log here

And here is a run with clang https://github.com/RDKRACZ/Leanify/actions/runs/3911784049/jobs/6685571593

JayXon commented 1 year ago

If you cherry pick this commit it should fix the issue, I just haven't updated my fork yet https://github.com/google/zopfli/commit/60503d108244382d8ab1d3b2a45ea8a5f915636c

K0-RR commented 1 year ago

Now I'm getting

lib/zopfli/cache.c: In function 'ZopfliInitCache':
lib/zopfli/cache.c:36:51: error: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'size_t' {aka 'long long unsigned int'} [-Werror=format=]
   36 |         "Error: Out of memory. Tried allocating %lu bytes of memory.\n",
      |                                                 ~~^
      |                                                   |
      |                                                   long unsigned int
      |                                                 %llu
   37 |         (unsigned long)ZOPFLI_CACHE_LENGTH * 3 * blocksize);
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                                |
      |                                                size_t {aka long long unsigned int}
cc1.exe: all warnings being treated as errors
mingw32-make: *** [<builtin>: lib/zopfli/cache.o] Error 1
JayXon commented 1 year ago

hmm, maybe change it to (unsigned long)(ZOPFLI_CACHE_LENGTH * 3 * blocksize) instead?

K0-RR commented 1 year ago

Now all builds are failing gcc:

lib/zopfli/cache.c:37:61: error: expected ')' before 'exit'
   37 |         (unsigned long)(ZOPFLI_CACHE_LENGTH * 3 * blocksize)
      |                                                             ^
      |                                                             )
   38 |     exit (EXIT_FAILURE);
      |     ~~~~                                                     
lib/zopfli/cache.c:35:12: note: to match this '('
   35 |     fprintf(stderr,
      |            ^
lib/zopfli/cache.c:38:25: error: expected ';' before '}' token
   38 |     exit (EXIT_FAILURE);
      |                         ^
      |                         ;
   39 |   }
      |   ~                      

clang:

lib/zopfli/cache.c:38:5: error: expected ')'
    exit (EXIT_FAILURE);
    ^
lib/zopfli/cache.c:35:12: note: to match this '('
    fprintf(stderr,
           ^
1 error generated.
JayXon commented 1 year ago

Did you replaced the whole line? 😅 you need to add ); after that

K0-RR commented 1 year ago

That's what I tried at first but the error is nearly the same with ";".

lib/zopfli/cache.c:37:61: error: expected ')' before ';' token
   37 |         (unsigned long)(ZOPFLI_CACHE_LENGTH * 3 * blocksize);
      |                                                             ^
      |                                                             )
lib/zopfli/cache.c:35:12: note: to match this '('
   35 |     fprintf(stderr,
      |            ^
lib/zopfli/cache.c:38:25: error: expected ';' before '}' token
   38 |     exit (EXIT_FAILURE);
      |                         ^
      |                         ;
   39 |   }
      |   ~                      
JayXon commented 1 year ago

you are missing a ) should be (unsigned long)(ZOPFLI_CACHE_LENGTH * 3 * blocksize));

K0-RR commented 1 year ago

It seems to be working on Windows now but only for gcc. clang returns this

C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.34.31933\include\any:22:2: error: class any requires static RTTI.
#error class any requires static RTTI.
 ^
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.34.31933\include\any:239:16: error: use of typeid requires -frtti
        return typeid(void);
               ^
main.cpp:165:15: error: 'getenv' is deprecated: This function or variable may be unsafe. Consider using _dupenv_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [-Werror,-Wdeprecated-declarations]
  is_pause = !getenv("PROMPT");
              ^
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\stdlib.h:1183:20: note: 'getenv' has been explicitly marked deprecated here
    _Check_return_ _CRT_INSECURE_DEPRECATE(_dupenv_s)
                   ^
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.34.31933\include\vcruntime.h:355:55: note: expanded from macro '_CRT_INSECURE_DEPRECATE'
        #define _CRT_INSECURE_DEPRECATE(_Replacement) _CRT_DEPRECATE_TEXT(    \
                                                      ^
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.34.31933\include\vcruntime.h:345:47: note: expanded from macro '_CRT_DEPRECATE_TEXT'
#define _CRT_DEPRECATE_TEXT(_Text) __declspec(deprecated(_Text))
                                              ^
3 errors generated.
mingw32-make: *** [<builtin>: main.o] Error 1
JayXon commented 1 year ago

That error is from your Visual Studio, not related to leanify

K0-RR commented 1 year ago

Ok