Bug 699317 - Compiler error Visual Studion 2017 CE
Summary: Compiler error Visual Studion 2017 CE
Status: RESOLVED FIXED
Alias: None
Product: MuPDF
Classification: Unclassified
Component: mupdf (show other bugs)
Version: master
Hardware: PC Windows 10
: P4 normal
Assignee: MuPDF bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-05-07 15:32 UTC by Hafedh TRIMECHE
Modified: 2018-06-11 23:35 UTC (History)
3 users (show)

See Also:
Customer:
Word Size: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hafedh TRIMECHE 2018-05-07 15:32:43 UTC
Error	C1060	compiler is out of heap space	libresources	d:\mupdf\generated\resources\fonts\han\sourcehanserif-regular.ttc.c	1159976
Comment 1 Tor Andersson 2018-05-08 09:18:38 UTC
It is a large and sometimes problematic file. However, Visual Studio 2005 compiles the file just fine on my test system which only has 2GB of memory.

Could you check a few things for me?

1) Is optimization turned off for the libresources project?

2) Try removing the "generated/resources/fonts/han/SourceHanSerif.ttc.c" file,
and in "scripts/fontdump.nmake" change the build line for that file to add a "-s" command line flag. The -s flag generates a source file that uses a syntax which is faster to compile and uses less memory, but does not work on VS 2005.

    hexdump.exe -s generated\resources\fonts\han\SourceHanSerif.ttc.c resources\fonts\han\SourceHanSerif.ttc
Comment 2 Razi Alavizadeh 2018-05-12 00:52:36 UTC
I has the same issue using MSVC2015x86.

(In reply to Tor Andersson from comment #1)
> It is a large and sometimes problematic file. However, Visual Studio 2005
> compiles the file just fine on my test system which only has 2GB of memory.
> 
> Could you check a few things for me?
> 
> 1) Is optimization turned off for the libresources project?

How to check this? 

> 2) Try removing the "generated/resources/fonts/han/SourceHanSerif.ttc.c"
> file,
> and in "scripts/fontdump.nmake" change the build line for that file to add a
> "-s" command line flag. The -s flag generates a source file that uses a
> syntax which is faster to compile and uses less memory, but does not work on
> VS 2005.
> 
>     hexdump.exe -s generated\resources\fonts\han\SourceHanSerif.ttc.c
> resources\fonts\han\SourceHanSerif.ttc

After applying this patch it is stopped with another error:
..\..\generated\resources\fonts\han\SourceHanSerif-Regular.ttc.c(3451): fatal error C1091: compiler limit: string exceeds 65535 bytes in length [C:\projects\mupdf-win32-release\mupdf\platform\win32\libresources.vcxproj]
Comment 3 Tor Andersson 2018-06-11 11:00:33 UTC
We have rejigged the build for Visual Studio to use bin2coff to directly
generate object files for our binary data blobs. This should fix the issues
with compiler limitations.

Fixed in commit a71f6edd591038828e9552d758e2a5378e399f41
Author: Tor Andersson <tor.andersson@artifex.com>
Date:   Thu Jun 7 14:01:37 2018 +0200

    Use bin2coff to generate font data blobs object files.
    
    This is the windows equivalent of objcopy or ld -r binary.
    
    We need different bin2coff font object files for 32 and 64 bit builds,
    so put the font object files in AdditionalDependencies.
    
    Revamp Windows builds to use bin2coff.
    
    Fix bin2coff to not use '-' in symbol names.
    
    Add a new project file to make bin2coff.
    
    Add a .rules file to tell MSVC how to call the built version of bin2coff.
    
    Update libresources build to use this rules file.
    
    Update noto.c to correctly find the symbols we make.
Comment 4 Razi Alavizadeh 2018-06-11 23:35:29 UTC
(In reply to Tor Andersson from comment #3)
> We have rejigged the build for Visual Studio to use bin2coff to directly
> generate object files for our binary data blobs. This should fix the issues
> with compiler limitations.
> 
> Fixed in commit a71f6edd591038828e9552d758e2a5378e399f41
> Author: Tor Andersson <tor.andersson@artifex.com>
> Date:   Thu Jun 7 14:01:37 2018 +0200
> 
>     Use bin2coff to generate font data blobs object files.
>     
>     This is the windows equivalent of objcopy or ld -r binary.
>     
>     We need different bin2coff font object files for 32 and 64 bit builds,
>     so put the font object files in AdditionalDependencies.
>     
>     Revamp Windows builds to use bin2coff.
>     
>     Fix bin2coff to not use '-' in symbol names.
>     
>     Add a new project file to make bin2coff.
>     
>     Add a .rules file to tell MSVC how to call the built version of bin2coff.
>     
>     Update libresources build to use this rules file.
>     
>     Update noto.c to correctly find the symbols we make.

It seems the issue has been fixed. But there are some compile issues. As above I am using MSVC2015: (msbuild /m mupdf.sln /property:Configuration=Release /p:PlatformTarget=x86  /p:Platform=Win32)

1- Build tries to create 64Bit *.obj files for fonts in "x64\release\libresources" and since that directory dose not exist build fails.
  (as workaround I make that directory manually.)

2- Build also try to bin2coff the following fonts:
  - resources\fonts\urw\NimbusSansNarrow-Bold.cff
  - resources\fonts\urw\NimbusSansNarrow-Oblique.cff
  - resources\fonts\urw\NimbusSansNarrow-Regular.cff
  - resources\fonts\urw\NimbusSansNarrow-BdOblique.cff
But they are not there. (as workaround I copied and renamed NimbusSans fonts.)

3- Finally, there is some link issues, see:
  - https://beepaste.io/paste/view/4VHWUE