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

Spot gpos fixes #380

Closed
wants to merge 10 commits into from
Closed

Spot gpos fixes #380

wants to merge 10 commits into from

Conversation

readroberts
Copy link
Contributor

@readroberts readroberts commented May 16, 2018

Fixes for issues #373 and #371 in dumping GPOS table with spot.

The AFM dumping logic requires creating a temporary file. With the 64-bit update, I also made a change to replace the deprecated tmpnam() function. The replacement code created a file name of length 0 for the temporary file, so the file open failed.

Note that I have now replaced the tmpnam() function with tmpfile(). This used to fail under Windows Vista through Windows 8, unless the user had admin privileges. Compiling with with VS 2017 allows this to run under Windows 7 and Windows 10. I now need to update all the Windows build files to use VS 2017 to avoid this problem with Windows users. 'spot' built with VC6 will have this problem under all platforms. We need to update to the new VS 2017 anyway, to support 64 bit tools under Windows, so I'd rather to do this than add complexity to the code to support older compilers
With the 64-bit update, the function global.c::getGlyphName() can return a glyph name of up to 128+7 characters long. The returned string was, in many places, copied into a string buffer that was much shorter.
Copy link
Member

@miguelsousa miguelsousa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please uncomment the test cases referenced by the bugs

@miguelsousa
Copy link
Member

Something is going on with Codacy.

@cjchapman
Copy link
Contributor

@readroberts Doesn't Python 2.7 use VS 2010 to compile C code on Windows (i.e. when you build everything through setup.py)?

@readroberts
Copy link
Contributor Author

@msousa @cjchapman. Yes, Travis is using VS 2010 to compile C code on Windows. I wouldn't accept this PR as is until I update the Windows builds to VS 2017. The alternative is to write some simple code for Windows only ( development time about 15 minutes - would just create a temp file in the current directory, without attempting to deal more than one version of 'spot' running) and then take it out when we get around to updating all the Windows projects. I favor the latter.

@miguelsousa
Copy link
Member

miguelsousa commented May 16, 2018

@readroberts how's updating the project files to VS 2017 going to make a difference given that (AFAIK) VisualStudio hardwires the version of Python it calls? Our Python scripts are not ready to go beyond Python 2.7 which (AFAIK) means we're stuck on VS 2010.

@readroberts
Copy link
Contributor Author

@msousa @cchapman Not on our system: we don't use Cython to build extensions. In the AFDKO setup.py, I override setuptools.command.build_py.build_py module with a custom class 'CustomBuild()'. The run() method in this class calls shell scripts that compile the code. The Windows 'BuildAll.cmd' command file references the build system for specific version of Visual Studio. I don't know how Travis works, but I think I recall Chis telling me that it can be configured to run on whatever Windows configuration you want.

@cjchapman
Copy link
Contributor

@readroberts When I did python setup.py build on my Windows 10 VM yesterday, it failed because I didn't have VisualStudio 2010 installed, and only built after I installed VisualStudio 2010.

@anthrotype
Copy link
Member

you need vs2010 simply because that's the version of the Visual Studio solution files (.sln) currently used to compile the afdko programs. There is no required link between the version of python and the version on visual studio in your case, because you are not building an extension module that has to dynamically link with the python interpreter (and thus would require you to use the same VS used to compile python interpreter itself, to avoid incompatibilities between different C runtimes). You are building standalone executables (.exe) which don't require python to run. You simply call them as external subprocesses.

@anthrotype
Copy link
Member

anthrotype commented May 16, 2018

strictly speaking, if you were to build an extension module for python 2.7 on windows, you would need visual studio 2008, which is ancient. MS provides a package called "Visual C++ for Python 2.7" that includes only the commandline tools from vs2008 and can be used to compile python extension module for 2.7. For compreffor, that was not too old, so I had to resort to using mingw-w64 toolchain (basically GCC on Windows).
Python 3.3-3.4 series uses vs2010, python 3.5-3.6 use vs2015 and the new 3.7 uses vs2017 (if I'm not mistaken).

@anthrotype
Copy link
Member

(typo -- of course I meant, "that was too old"...)

@anthrotype
Copy link
Member

Travis is using VS 2010 to compile C code on Windows

you meant Appveyor. All the available visual studio versions should already be installed there, see
https://www.appveyor.com/docs/build-environment

@cjchapman
Copy link
Contributor

@anthrotype Thanks for all of the information!

@miguelsousa
Copy link
Member

I believe the next step is for @readroberts to update spot's Visual Studio files.

…y of several types of VS 2017.

The Appveyor batch process failed with the more complex command file syntax using vswhere.exe to locate the msbuild.exe file. Try a very simple approach.
Try updating sln file to 23017 format, which we should do anywhere.
Try asking appveyor for VS 2017 image. I suspect that this will make all the 2010 builds fail
@readroberts
Copy link
Contributor Author

@miguelsousa @cjchapman After some experimentation, I see that we cannot build a mix of VS 2010 and VS 2017 Windows projects. The default image used by Appveyor is the VS 2015 image, which has the VS 2010 .Net build tools that is used by our Windows projects. However, the VS 2017 image does not have this. If I want to update any of our windows projects to VS 2017, I need to update all of them. This is pretty easy, and I expect that I could do it in one day. Going ahead with this is my preference, but I could also revert to plan B: for the moment, continue to use VS 2010, but use a simple and reasonably reliable method for generating a temp file. With plan B, we defer updating the Windows projects until later.

@miguelsousa
Copy link
Member

use a simple and reasonably reliable method for generating a temp file

What do you have in mind?

@miguelsousa
Copy link
Member

If I want to update any of our windows projects to VS 2017, I need to update all of them. This is pretty easy, and I expect that I could do it in one day. Going ahead with this is my preference

Updating to VS 2017 would be my preference too, but your time estimates are always over-optimistic, so it's difficult for me to weigh what the best option is.

@readroberts
Copy link
Contributor Author

The simple approach to generating a temp file is to create a temp file with hard-coded name like "spot.tmp' in the current directory, without attempting to deal more than one version of 'spot' running, and then reverting this when we have updated to VS 2017. The work involved in updating to to VS 2017 is to 1) open each of 12 Visual Studio solution files in VS 2017, and compile it, then 2) edit each of the 12 BuildAll.cmd files to reference the VS 2017 tools.

@miguelsousa
Copy link
Member

The temp file hack doesn't seem like a good option to me; I don't want us to end up with another issue like #244.

Here's my suggestion of what should be done:

  1. Create a new PR with the changes in 3c85e25; just start a new branch from develop and cherry-pick this commit. That PR will address [spot] Abort trap with spot -t GSUB=7 <ttf_font> #373.
  2. Close this current PR.
  3. Open a new issue about converting the Windows builds to VS2017.
  4. When you're ready, create a new PR containing the changes to address point 3 and issue [spot] Segmentation fault with spot -t GPOS=6 <font> #371.

@anthrotype
Copy link
Member

Requiring such a recent version of Microsoft's toolchain just to get a working tmpfile implementation seems a bit too much to me, especially for a code base that is basically all ANSI C.
I'm no C programmer, but I bet somebody else had the same issues and worked around it somehow. And you could probably find alternative ways to communicate between processes than temporary files, like using stdout/stdin.
I'm all for the new and shiny,I'm only concerned that you may be tempted to introduce dependencies on features only available on such recent compiler, and then it could become harder to compile AFDKO C modules in situations where the compiler version is constrained for some reasons (e.g. when making CPython extensions).
Anyway, just my 2c. You do what you think is best :)

@readroberts
Copy link
Contributor Author

I quite agree that this issue is too minor to solve by stepping up to a new development environment. I proposed this only because I had been planning to upgrade from VS 2010 in any case for some time, and this seemed as good a time as any. The FDK is all straight C, and we have been careful to avoid any constructs that are not very much plain vanilla. Quite a few Adobe groups have already stepped up to VS 2017, so overall this seems safe to me. However, you have pointed out an issue I overlooked, which is that most Python extensions are built with older versions of Visual Studio, and we are not doing AFDKO developers a service to require them to upgrade just for the afdko . Given that, I would agree that this year we should upgrade only to VS 2015, and I'll solve the tempname problem for windows separately.

@readroberts
Copy link
Contributor Author

Starting a new PR to address these issues separately.

@readroberts readroberts deleted the spot-GPOS-fixes branch May 24, 2018 20:04
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

Successfully merging this pull request may close these issues.

4 participants