Skip to content

MSVC Build: Support VS2017 or VS2015 compiler tools #1273

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

Merged
merged 1 commit into from
Aug 21, 2017

Conversation

jeffhostetler
Copy link

Teach Makefile to use whatever VS compiler tool chain
is installed on the system.

Previously I had hard-coded paths to VS2015. This change
uses the new VsWhere.exe and VsDevCmd.bat in a background
Command Prompt process to compute the proper environment
variables for bash and make.

If VS2017u2 or higher is installed, it will use the
compiler, linker, libaries associated with it.

It will fall back to the previous configuration using
VS2015. It should be fairly easy to extend the fallback
section in the "find_vs_env.bat" script to support older
compilers.

I have tested this with VS2017.3 (Dev15.3) and the V140
command line tools (distributed with VS2015).

Signed-off-by: Jeff Hostetler jeffhost@microsoft.com

Thanks for taking the time to contribute to Git! Please be advised that the
Git community does not use github.com for their contributions. Instead, we use
a mailing list (git@vger.kernel.org) for code submissions, code reviews, and
bug reports. Nevertheless, you can use submitGit to conveniently send your Pull
Requests commits to our mailing list.

Please read the "guidelines for contributing" linked above!

config.mak.uname Outdated
@./compat/vcbuild/find_vs_env.bat | sed 's|\\|/|g' >GIT-MSVC-GEN
-include GIT-MSVC-GEN
endif

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

REM the bin/lib/include paths for GCC. It DOES NOT inherit values
REM for the corresponding MSVC tools.
REM
REM During normal (non-git) Windows development, you launche one

This comment was marked as off-topic.


REM Sanitize PATH to prevent git-sdk paths from confusing "wmic.exe"
REM (called internally in some of the system BAT files).
SET PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;

This comment was marked as off-topic.

@mfriedrich74
Copy link

mfriedrich74 commented Aug 21, 2017 via email

@danilaml
Copy link

@mfriedrich74 doesn't seem to be the case starting from VS2017 and going forward (if I understood this correctly).

Teach the top-level git Makefile to use whatever VS compiler
tool chain is installed on the system.

When building git from the command line in a git-sdk BASH
window with MAKE, the shell environment has environment
variables for GCC tools, but not MSVC tools.  MSVC bindings
are only avaliable from the various "VcVarsAll.bat" scripts
run by the "Developer Command Prompt" shortcuts.

Add compat/vcbuild/find_vs_env.bat to the Makefile.  It
uses the various "VcVarsAll.bat" scripts in a background
Developer Command Prompt process to compute the proper
environment variables and publish them for use by the Makefile.

[jes: fixed typos, used %SystemRoot% instead of C:\WINDOWS]

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
@dscho dscho force-pushed the jeffhostetler/vs2017 branch from e40d512 to 42d5dcf Compare August 21, 2017 15:55
@dscho dscho merged commit ec646c1 into git-for-windows:master Aug 21, 2017
@dscho
Copy link
Member

dscho commented Aug 21, 2017

Thanks all, in particular @jeffhostetler for the original work and @danilaml for the thorough and very helpful review!

@jeffhostetler
Copy link
Author

@mfriedrich74 Yes, it is a bit confusing. The layout of VS2017 (and beyond) is different from the layout of VS2015 which was different from earlier layouts. Yes, the stock install does/can set an environment variable pointing at the installation directory, or adds the directory containing the vcvars to the PATH, but we want to go a little deeper here and get the proper values for the "-I" and "-L" args to CL.exe. Those change between versions. For example, VS2015 introduced the UCRT and Windows Kits changes, so builds based on it or newer, have different values from previous generations.

So my script tries to find the most recent version of VS installed and build the version-specific compiler flags.

I left the TODO at the bottom because I cannot test the earlier versions (I don't have any of them installed). Also, I've not built it with the earlier tools and there might be compiler errors and etc.,
so I didn't just want to assume it would work. The existing TODO and overall layout of the script
should make it easy for someone to extend it if/when necessary.

Thanks!

dscho added a commit that referenced this pull request Aug 22, 2017
MSVC Build: Support VS2017 or VS2015 compiler tools
@dscho
Copy link
Member

dscho commented Aug 22, 2017

... because I cannot test the earlier versions (I don't have any of them installed).

@PhilipOakley maybe you are interested?

@PhilipOakley
Copy link

... because I cannot test the earlier versions (I don't have any of them installed).

@PhilipOakley maybe you are interested?

While I'm interested, unfortunately I'm rather time poor at the moment,

I will add it as part of my long todo list, but don't hold your breath just yet.

git-for-windows-ci pushed a commit that referenced this pull request Aug 23, 2017
MSVC Build: Support VS2017 or VS2015 compiler tools
git-for-windows-ci pushed a commit that referenced this pull request Aug 24, 2017
MSVC Build: Support VS2017 or VS2015 compiler tools
git-for-windows-ci pushed a commit that referenced this pull request Aug 24, 2017
MSVC Build: Support VS2017 or VS2015 compiler tools
git-for-windows-ci pushed a commit that referenced this pull request Aug 24, 2017
MSVC Build: Support VS2017 or VS2015 compiler tools
git-for-windows-ci pushed a commit that referenced this pull request Aug 24, 2017
MSVC Build: Support VS2017 or VS2015 compiler tools
git-for-windows-ci pushed a commit that referenced this pull request Aug 25, 2017
MSVC Build: Support VS2017 or VS2015 compiler tools
git-for-windows-ci pushed a commit that referenced this pull request Aug 25, 2017
MSVC Build: Support VS2017 or VS2015 compiler tools
dscho added a commit that referenced this pull request Aug 26, 2017
MSVC Build: Support VS2017 or VS2015 compiler tools
dscho added a commit that referenced this pull request Aug 28, 2017
MSVC Build: Support VS2017 or VS2015 compiler tools
dscho added a commit that referenced this pull request Jan 2, 2018
MSVC Build: Support VS2017 or VS2015 compiler tools
dscho added a commit that referenced this pull request Jan 18, 2018
MSVC Build: Support VS2017 or VS2015 compiler tools
git-for-windows-ci pushed a commit that referenced this pull request Jan 20, 2018
MSVC Build: Support VS2017 or VS2015 compiler tools
git-for-windows-ci pushed a commit that referenced this pull request Jan 22, 2018
MSVC Build: Support VS2017 or VS2015 compiler tools
git-for-windows-ci pushed a commit that referenced this pull request Jan 22, 2018
MSVC Build: Support VS2017 or VS2015 compiler tools
dscho added a commit that referenced this pull request Jan 22, 2018
MSVC Build: Support VS2017 or VS2015 compiler tools
dscho added a commit that referenced this pull request Feb 16, 2018
MSVC Build: Support VS2017 or VS2015 compiler tools
dscho added a commit that referenced this pull request Mar 23, 2018
MSVC Build: Support VS2017 or VS2015 compiler tools
dscho added a commit that referenced this pull request Apr 3, 2018
MSVC Build: Support VS2017 or VS2015 compiler tools
dscho added a commit that referenced this pull request May 29, 2018
MSVC Build: Support VS2017 or VS2015 compiler tools
dscho added a commit that referenced this pull request May 29, 2018
MSVC Build: Support VS2017 or VS2015 compiler tools
PKRoma pushed a commit to PKRoma/git-for-windows that referenced this pull request Jun 22, 2018
…ler/vs2017

MSVC Build: Support VS2017 or VS2015 compiler tools
PKRoma pushed a commit to PKRoma/git-for-windows that referenced this pull request Jun 22, 2018
…ler/vs2017

MSVC Build: Support VS2017 or VS2015 compiler tools
PKRoma pushed a commit to PKRoma/git-for-windows that referenced this pull request Jun 22, 2018
…ler/vs2017

MSVC Build: Support VS2017 or VS2015 compiler tools
dscho added a commit that referenced this pull request Aug 22, 2018
MSVC Build: Support VS2017 or VS2015 compiler tools
dscho added a commit to dscho/git that referenced this pull request Aug 22, 2018
…ler/vs2017

MSVC Build: Support VS2017 or VS2015 compiler tools
dscho added a commit that referenced this pull request Aug 23, 2018
MSVC Build: Support VS2017 or VS2015 compiler tools
dscho added a commit that referenced this pull request Aug 23, 2018
MSVC Build: Support VS2017 or VS2015 compiler tools
dscho added a commit that referenced this pull request Aug 23, 2018
MSVC Build: Support VS2017 or VS2015 compiler tools
jamill pushed a commit to jamill/git that referenced this pull request Aug 28, 2018
…ler/vs2017

MSVC Build: Support VS2017 or VS2015 compiler tools
jamill pushed a commit to jamill/git that referenced this pull request Sep 5, 2018
…ler/vs2017

MSVC Build: Support VS2017 or VS2015 compiler tools
git-for-windows-ci pushed a commit that referenced this pull request Sep 10, 2018
MSVC Build: Support VS2017 or VS2015 compiler tools
jamill pushed a commit to jamill/git that referenced this pull request Sep 11, 2018
…ler/vs2017

MSVC Build: Support VS2017 or VS2015 compiler tools
git-for-windows-ci pushed a commit that referenced this pull request Sep 24, 2018
MSVC Build: Support VS2017 or VS2015 compiler tools
dscho added a commit that referenced this pull request Oct 10, 2018
MSVC Build: Support VS2017 or VS2015 compiler tools
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.

6 participants