-
Notifications
You must be signed in to change notification settings - Fork 315
Msvc build fix (for generating git.sln) #318
Conversation
A 'make -n' dry-run is used as part of the /compat/vcbuild and /contrib/buildsystems code. ee9be06 (perl: detect new files in MakeMaker builds, 2012-07-27) was not aware of that usage. Add a comment to the make file stating the issue and the available solutions of either NO_PERL or a '+recipe'. Signed-off-by: Philip Oakley <[email protected]>
ee9be06 (perl: detect new files in MakeMaker builds, 2012-07-27) did not include dry-run support for the generation of the PM.stamp file, though the dry-run output is used by the build engine. Disable the perl processing during the dry-run to avoid the issue. Signed-off-by: Philip Oakley <[email protected]>
Delete the duplicated GUID from the generation code for the Visual Studio .sln project file. The duplicate GUID tended to be allocated to test-svn-fe, which was then ignored by Visual Studio / MSVC, and it's omission from the build never noticed. Signed-off-by: Philip Oakley <[email protected]>
The engine.pl script barfs on the properly quoted spaces in filename options prevalent on Windows. Use shellwords() rather than split() to separate such options. Signed-off-by: Philip Oakley <[email protected]>
The i18n 5e9637c (i18n: add infrastructure for translating Git with gettext, 2011-11-18) introduced an extra '-o' option into the make file. If the msvc buildsystem is run without NO_GETTEXT being set then this broke the engine.pl code for extracting the git.sln for msvc gui-IDE. The setting of NO_GETTEXT was not fixed until later, relative to the Msysgit project where this issue was being investigated. The presence of these options in the Makefile output should not compromise the derived build structure. They should be ignored. Add tests to remove these non linker options, in same vein as 74cf9bd (engine.pl: Fix a recent breakage of the buildsystem generator, 2010-01-22). Signed-off-by: Philip Oakley <[email protected]>
Commit 4b623d8 (MSVC: link in invalidcontinue.obj for better POSIX compatibility, 2014-03-29) is not processed correctly by the buildsystem. Ignore it. Also split the .o and .obj processing; 'make' does not produce .obj files. Only substitute filenames ending with .o when generating the source .c filename. Signed-off-by: Philip Oakley <[email protected]>
Layout the 'either/or' with more white space to clarify which alternatives are matched up. Reference the Msysgit build script which automates one sequence of options. Signed-off-by: Philip Oakley <[email protected]>
Much better, thanks! |
MSysGit - the development behind Git for Windows » git #261 SUCCESS |
I suspect that 317efc0 may not properly remove (unlink) an empty errors file, plus I may not have fully described the scenario that creates an empty errors file. Also 912f0ff says that 'devenv git.sln /useenv' should be used but the msvc-build script doesn't use that. I'm not sure if this affects the final destination of the git.exe and whether/how it should be tested. |
Save the stderr from the dry MSVC make to a well named file for later review. Use 'msvc-build-makedryerrors.txt' which should be obvious as to its source, and is not ignored by 'git status'. Signed-off-by: Philip Oakley <[email protected]>
Keep the build clean of extraneous files if it is indeed clean. Otherwise leave the msvc-build-makedryerrors.txt file both as a flag for any CI system or for manual debugging. Note that the file will contain the new values of the GIT_VERSION and GITGUI_VERSION if they were generated by the make file. They are omitted if the release is tagged and indentically defined in their respective GIT_VERSION_GEN file DEF_VER variables. Signed-off-by: Philip Oakley <[email protected]> Conflicts: contrib/buildsystems/engine.pl
Highlight a debug suggestion for capturing the dry-run of the make file used in determining the msvc-build structure. Signed-off-by: Philip Oakley <[email protected]> Conflicts: contrib/buildsystems/engine.pl
Assist developers transitioning between the two cultures by including appropriate, but commented out, debug statements. The exception is when an unhandled compiler option is detected, where printing of the full line will supplement the line number and option part. Otherwise the OP has no immediate mechanism for inspecting the relevant part of the makedry output. These debug print statements act as a guide for a poor man's --verbose option. The test suite doesn't cover the contrib/buildsystems (or Msysgit's msvc-build) contributions so fails to notice breakages there-in. It is doubly hard to get developers to ride both horses so, contrary to normal convention, retain selected debug statements as a safety net for those willing to try. Signed-off-by: Philip Oakley <[email protected]>
Signed-off-by: Philip Oakley <[email protected]>
…stem Signed-off-by: Philip Oakley <[email protected]>
Add the Microsoft .manifest pattern, and correct the generic 'Debug' and 'Release' directory patterns which were mechanically adjusted way back in c591d5f (gitignore: root most patterns at the top-level directory, 2009-10-26).
69c34b9
to
9f94b36
Compare
The PR has been force updated, so the last few commits have been adjusted. In particular commit/912f0ff is unchanged. I have also updated the .gitignore to properly include some of the build products and ignore Debug and Release folders (which actually hadn't worked for a while). I hope to put a consolidated patch onto the list (and possibly the git-users list) to try and wet folks appetites, especially those who like being /in/ Visual Studio ;-) Comments and suggestions welcome. |
MSysGit - the development behind Git for Windows » git #262 SUCCESS |
The previous version, for those that care, is at https://github.com/PhilipOakley/git/tree/msvc-PR318-1 |
I just tested that the (VS2008) project will convert to VS2010 (express), which it did. It had been compiled in VS2008 previously which may have helped. I had 6 minor issues with failure to write manifests which completed on a second build - possibly a virus scanner issue. Next is to try a clean clone of msysgit (from ground zero net install) to a 'space in dir name' directory and see if it completes all the way through to a VS2010 build without problem..... |
I have now tested (SUCCESS) the patch series with 'spaces in filepaths' by simply renaming my msysgit base install directory to 'msy git' (with a space) and everything worked (once I'd remembered to 'make common-cmds.h' ;-) ). I had tried to net-install msysgit to a 'space in path' folder but was thwarted by the intolerance of windres from MinGW binutils, so I put that down to an education & experience [aka mistake]. I haven't checked that it rebases cleanly to master yet, but a diff showed no indication of conflicts, so I'm very hopeful. |
I have also tested (SUCCESS) the conversion of the project from VS2008 (.sln) to VS2010 express, and it converted fine and compiled. There was a minor glitch which was probably a virus scanner latency issue where some (6 of 42) of the resulting .manifest files weren't written, but simply building again filled those 6 back in (no actual recompiles IIRC. |
@PhilipOakley
I've compiled git using VS 2010 Pro and it finished without errors. Minor nits:
|
How about adding a rule for git.sln: common-cmds.h
msvc-build --vs |
@t-b Thanks for the confirmation. The readme needs to be double checked by a fresh pair of eyes as well (volunteers?) @dscho The msvc-build needs to be coped from msysgit to /contrib to make that work but a target of git.sln is a good idea. I've still to sort out how to get the install to work for an independent compile http://stackoverflow.com/questions/28969853/how-to-add-a-phony-target-halfway-through-a-make-file |
@dscho Perhaps a slightly easier fix is to include the common-cmd.h check in the msvc-build script, to avoid too many discussions with Junio about polluting His Makefile, though it does need some fixing. I think he prefers elegant fixes;-) |
While Junio requires convincing arguments for literally every change, he is hardly unreasonable. I do not expect opposition against the |
I tried to upgrade the created solution to VS 2013 Community. |
Thanks. I'll google some more... Philip I tried to upgrade the created solution to VS 2013 Community. — |
The bulk (hundreds?) of the 'error' messages (in the pastebin output) are the I'm guessing that the SAFESEH option became a default in VS2013 as I doubt we passed it as an option (extracted from the git Makefile's dry run) https://msdn.microsoft.com/en-us/library/9a89h429.aspx describes the MS view of the SAFESEH option. |
A quick grep through the pastebin output shows that ALL the LNK2026 errors are for zlib.lib. http://stackoverflow.com/a/28443212/717355 shows that it (zlib.lib) is a common problem for this SAFESEH gotcha (includes pictures of how to determine/fix). Now to see if there is a newer zlib.lib available that already meets the needs of the MS safety check, or if (our) zlib.lib was implicitly safe from that threat anyway. |
[These are my note summarising the day's googling] It looks like fixing the "Safe Execution Handler"(SAFESEH) issue automatically for VS2013+ builds will be problematic. My googling suggests this is a specific to VS2013+/32-bit compilation, and the inclusion of the (pre-compiled) zlib library that doesn't include the Microsoft(MS) SafeSEH processing. The MS https://msdn.microsoft.com/en-us/library/9a89h429.aspx page gives details of the flag, including that its only valid for x86 targets (i.e. invalid for x64). The MS blog http://blogs.technet.com/b/srd/archive/2009/02/02/preventing-the-exploitation-of-seh-overwrites-with-sehop.aspx gives details of why SEH can be / is a security issue. I'm not sure if git can be forced into the risk zone. As noted in my earlier comment to this PR, zlib is not compiled with SEH, http://stackoverflow.com/a/28443212/717355 (first picture shows the zlib properties page). The solution of adding /SAFESH:NO to the linker flags is given in http://stackoverflow.com/a/15983453/717355. For those who wish to try compiling zlib from source with the /SAFESEH option the blog http://www.francescofoti.com/2013/12/compiling-the-zlib-compression-library-with-visual-studio-2013/ gives some guidance, as does https://beeproc.wordpress.com/2012/12/29/building-static-zlib-v1-2-7-with-msvc-2012/ and http://www.tannerhelland.com/5076/compile-zlib-winapi-wapi-stdcall/. Aside: http://lwn.net/Articles/307732/ offers some comfort for those seeking cross compatibility. Also https://gcc.gnu.org/ml/gcc-help/2012-04/msg00306.html In summary (so far), |
Also failed on VS2012. |
From: Yue Lin Ho Also failed on VS2012. Thanks. Looks like its the same (Windows) Safe Exception Handler for zlib issue again (zlib.lib(inflate.obj) : error LNK2026: module unsafe for SAFESEH image.). So it looks like it either became a default in VS2012, or VS determines what the base OS vesrion is, and if SEH is a default for your base OS it sets it for compiling (or something like that. I also see the "gettext.h : warning C4819: The file contains a character that cannot be represented in the current code page (950). Save the file in Unicode format to prevent data loss" so I'll add that to my 'to look at' list ;-) |
My OS is Win7 Pro 64 Chinese Traditional (the current code page (950)) |
In VS2013, Now, build OK. see here |
From: Yue Lin Ho My OS is Win7 Pro 64 Chinese Traditional (the current code page (950)) I'd suspected that may be the case. Looking at gettext.h itself, I presume the warning is from the copyright notice:
|
@PhilipOakley |
From: Yue Lin Ho Now, build OK. see here That's excellent news. It proves it does work in VS2013 if we can get that option into the projects. I think it's possible to add that flag globally via the build script just after |
After re-build all, pdb is matched. I can debug, now. @PhilipOakley Thank you so much. ^_^ |
Beautiful! All we need now is the make install step ;-) |
@YueLinHo Would you be able to look at the saved vcproj (assuming VS2013 saves it) and report which field contains the "SAFESEH:NO" option (or however its coded) so that I can ensure that we have an option in the Makefile (or more likely 'config.mak.uname' which has the special msysgit options) for this case [I don't have a VS2013 I can access at the moment to test it myself] [my earlier guess]
|
I used
Use Still failed. (Debugger ran, but did not stop at break point.) |
@YueLinHo this is impressive, thanks for all your work! I am sure that this will help @PhilipOakley to adjust the PR accordingly. |
@YueLinHo, Thank you for that information. It's very useful. I tried injecting the option into the git.sln that the script generates (which targets VS2008). When I added It looks as if VS2008 expected the option to be passed as a command line linker option (i.e. no menu option) - It's just a question of searching for the right place to insert it into the existing VS2008 .vcproj files, using the style it used (I think). I also tried adding The "however" is that it doesn't detect that this "Image Has Safe Exception Handlers" has been set in the "advanced options" On the plus side it does compile without errors (I'd previously shown that 28 Feb) so the option isn't corrupting anything. The question is whether adding Just (re-?)checked what happens in VS2010 when I set the "Image Has Safe Exception Handlers" , and it does add the |
Sent: Friday, March 13, 2015 10:03 AM How about adding a rule for git.sln to the Makefile such as: git.sln: common-cmds.h It seems like the make file doesn't like this double invocation whereby I run: I've no idea how to handle this issue, so any suggestions would be welcome. my latest series is here https://github.com/PhilipOakley/git/tree/msvc-bld-rbase, based on a recent junio/master (so I could test the SubmitGit)Philip |
@PhilipOakley |
@PhilipOakley Yes, you are correct. It was to test SubmitGit, so isn't fully functioning (though it has improved!). The main problem now is the 'make git.sln' target, which is recursive, and gets the command line options 'wrong' (i.e. I don't understand why it does what it does - the internal call appears to miss the V=1 option). P. |
Microsoft flipped the Windows Safe Exception Handling default in VS2013 so that zlib became unacceptable to certain OS versions (Vista and subsequent 32-bit OS's) without the addition of the option -SAFESEH:NO. Provide a switch to disable the Safe Exeption Handler when required. The option ImageHasSafeExceptionHandlers for VS2013 is not available in earlier versions, so use the SAFESEH:NO linker flag. See https://msdn.microsoft.com/en-us/library/9a89h429.aspx for further details. This has only had limited testing due to the lack of a suitable system. Helped-by: Yue Lin Ho <[email protected]> Signed-off-by: Philip Oakley <[email protected]> --- Junio/my discussion on reviews: http://marc.info/?l=git&m=143526063906215&w=2 (2015-06-25) Patch series v1: msysgit#318 Yue Lin Ho: msysgit#318 (comment)
Microsoft flipped the Windows Safe Exception Handling default in VS2013 so that zlib became unacceptable to certain OS versions (Vista and subsequent 32-bit OS's) without the addition of the option -SAFESEH:NO. Provide a switch to disable the Safe Exeption Handler when required. The option ImageHasSafeExceptionHandlers for VS2013 is not available in earlier versions, so use the SAFESEH:NO linker flag. See https://msdn.microsoft.com/en-us/library/9a89h429.aspx for further details. This has only had limited testing due to the lack of a suitable system. Helped-by: Yue Lin Ho <[email protected]> Signed-off-by: Philip Oakley <[email protected]> --- Junio/my discussion on reviews: http://marc.info/?l=git&m=143526063906215&w=2 (2015-06-25) Patch series v1: msysgit#318 Yue Lin Ho: msysgit#318 (comment)
Since I want to focus on 2.x rather than retired Git for Windows 1.x, I close this ticket. Please, everybody, move along to git-for-windows#256. Thank you. |
Microsoft flipped the Windows Safe Exception Handling default in VS2013 so that zlib became unacceptable to certain OS versions (Vista and subsequent 32-bit OS's) without the addition of the option -SAFESEH:NO. Provide a switch to disable the Safe Exeption Handler when required. The option ImageHasSafeExceptionHandlers for VS2013 is not available in earlier versions, so use the SAFESEH:NO linker flag. See https://msdn.microsoft.com/en-us/library/9a89h429.aspx for further details. This has only had limited testing due to the lack of a suitable system. Helped-by: Yue Lin Ho <[email protected]> Signed-off-by: Philip Oakley <[email protected]> --- Junio/my discussion on reviews: http://marc.info/?l=git&m=143526063906215&w=2 (2015-06-25) Patch series v1: msysgit#318 Yue Lin Ho: msysgit#318 (comment)
The 'msvc-build --vs' for creating a git.sln file that is readable and compilable by Visual Studio 2008 (last working version;-) had bit rotted.
This series, on top of 1.9.5.msysgit.0 (commit/0d6f7c802) fixes most of the issues, including: the duplicate GUID, perl make dependencies, many debug improvements, and others.
It's still not perfect, but does now run properly to create a git.sln which will build without error in VS08 express ed.
Note that 'make common-cmd.h' is still required before the 'msvc-build --vs' will compile without error.
Ultimately this will be submitted to upstream Git once review feedback has been obtained, so I'm not expecting a merge (obviously), rather I'd like others to see if it works for them.
Philip