summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpeter <peterghost86@gmail.com>2019-04-01 12:37:00 -0700
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>2019-04-01 12:42:51 -0700
commit929258a680621ff06230263f71df02e471038d5d (patch)
tree2b59fd32895d32089f03544adb95de5947ee0b50
parentd6c269c33e73f47cd5f244d7ec989629f1fe592e (diff)
downloadpytorch-929258a680621ff06230263f71df02e471038d5d.tar.gz
pytorch-929258a680621ff06230263f71df02e471038d5d.tar.bz2
pytorch-929258a680621ff06230263f71df02e471038d5d.zip
Some fixes for the build script on Windows (#18681)
Summary: Fixes https://discuss.pytorch.org/t/pytorch-build-from-source-on-windows/40288/13?u=peterjc123. Pull Request resolved: https://github.com/pytorch/pytorch/pull/18681 Differential Revision: D14711039 Pulled By: soumith fbshipit-source-id: f7e1a94b163064c055670b2925cd4502e7773599
-rw-r--r--tools/build_pytorch_libs.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/tools/build_pytorch_libs.py b/tools/build_pytorch_libs.py
index 6c163f5799..aa0ed89cb8 100644
--- a/tools/build_pytorch_libs.py
+++ b/tools/build_pytorch_libs.py
@@ -112,6 +112,13 @@ def create_build_env():
if IS_WINDOWS:
my_env = overlay_windows_vcvars(my_env)
+ # When using Ninja under Windows, the gcc toolchain will be chosen as default.
+ # But it should be set to MSVC as the user's first choice.
+ if USE_NINJA:
+ cc = my_env.get('CC', 'cl')
+ cxx = my_env.get('CXX', 'cl')
+ my_env['CC'] = cc
+ my_env['CXX'] = cxx
return my_env
@@ -258,7 +265,7 @@ def build_caffe2(version,
check_call(['cmake', '--build', '.', '--target', 'install', '--config', build_type, '--', '-j', str(j)],
cwd=build_dir, env=my_env)
else:
- check_call(['msbuild', 'INSTALL.vcxproj', '/p:Configuration={}'.format(build_type)],
+ check_call(['msbuild', 'INSTALL.vcxproj', '/p:Configuration={} /maxcpucount:{}'.format(build_type, j)],
cwd=build_dir, env=my_env)
else:
if USE_NINJA: