1- diff -r -wBu "Python37 \\Lib\\distutils/_msvccompiler.py" "Python3\\Lib\\distutils/_msvccompiler.py"
2- --- "Python37 \\Lib\\distutils/_msvccompiler.py" 2019-03-25 21:21:20.000000000 +0800
3- +++ "Python3\\Lib\\distutils/_msvccompiler.py" 2019-05-30 19:19:32.243676500 +0800
4- @@ -172 ,6 +172 ,27 @@
1+ diff -r -wBu "Python38 \\Lib\\distutils/_msvccompiler.py" "Python3\\Lib\\distutils/_msvccompiler.py"
2+ --- "Python38 \\Lib\\distutils/_msvccompiler.py" 2020-02-28 07:14:35.913264300 +0800
3+ +++ "Python3\\Lib\\distutils/_msvccompiler.py" 2020-02-28 07:16:36.205506000 +0800
4+ @@ -184 ,6 +184 ,27 @@
55 return fn
66 return exe
77
@@ -29,20 +29,21 @@ diff -r -wBu "Python37\\Lib\\distutils/_msvccompiler.py" "Python3\\Lib\\distutil
2929 # A map keyed by get_platform() return values to values accepted by
3030 # 'vcvarsall.bat'. Always cross-compile from x86 to work with the
3131 # lighter-weight MSVC installs that do not include native 64-bit tools.
32- @@ -180 ,6 +201,12 @@
33- 'win-amd64 ' : 'x86_amd64',
32+ @@ -194 ,6 +215,13 @@
33+ 'win-arm64 ' : 'x86_arm64'
3434 }
3535
3636+ PLAT_TO_LLVM_TARGETS = {
37- + 'win32': '-m32',
38- + 'win-amd64': '-m64',
39- + 'win-arm64': '--target=aarch64-pc-windows-msvc',
37+ + 'win32': 'i686-pc-windows-msvc',
38+ + 'win-amd64': 'x86_64-pc-windows-msvc',
39+ + 'win-arm32' : 'arm-pc-windows-msvc',
40+ + 'win-arm64': 'aarch64-pc-windows-msvc',
4041+ }
4142+
4243 # A set containing the DLLs that are guaranteed to be available for
4344 # all micro versions of this Python version. Known extension
4445 # dependencies that are not in this set will be copied to the output
45- @@ -217 ,11 +244 ,12 @@
46+ @@ -231 ,11 +259 ,12 @@
4647 exe_extension = '.exe'
4748
4849
@@ -56,38 +57,39 @@ diff -r -wBu "Python37\\Lib\\distutils/_msvccompiler.py" "Python3\\Lib\\distutil
5657
5758 def initialize(self, plat_name=None):
5859 # multi-init means we would need to check platform same each time...
59- @@ -243,7 +271,14 @@
60+ @@ -257,6 +286,13 @@
6061
6162 self._paths = vc_env.get('path', '')
6263 paths = self._paths.split(os.pathsep)
63- - self.cc = _find_exe("cl.exe", paths)
6464+ if self.use_clang_cl:
6565+ llvm_dir = _find_llvm()
6666+ if llvm_dir:
6767+ self.cc = os.path.join(llvm_dir, 'bin', 'clang-cl.exe')
6868+ else:
6969+ self.cc = _find_exe("clang-cl.exe", paths)
7070+ else:
71- + self.cc = _find_exe('cl.exe', paths)
71+ self.cc = _find_exe('cl.exe', paths)
7272 self.linker = _find_exe("link.exe", paths)
7373 self.lib = _find_exe("lib.exe", paths)
74- self.rc = _find_exe("rc.exe", paths) # resource compiler
75- @@ -282,6 +317,14 @@
74+ @@ -296,6 +332,17 @@
7675 '/nologo', '/INCREMENTAL:NO', '/LTCG', '/DEBUG:FULL'
7776 ]
7877
7978+ if self.use_clang_cl:
80- + target_flag = PLAT_TO_LLVM_TARGETS[plat_name]
81- + self.compile_options.remove('/GL')
79+ + # Add target flags for clang
80+ + target_flag = '--target=' + PLAT_TO_LLVM_TARGETS[plat_name]
8281+ self.compile_options.append(target_flag)
8382+ self.compile_options_debug.append(target_flag)
83+ + # Remove whole program optimization and Link-time code generation flags
84+ + # to avoid warnings about unrecognized options
85+ + self.compile_options.remove('/GL')
8486+ ldflags.remove('/LTCG')
8587+ ldflags_debug.remove('/LTCG')
8688+
8789 self.ldflags_exe = [*ldflags, '/MANIFEST:EMBED,ID=1']
8890 self.ldflags_exe_debug = [*ldflags_debug, '/MANIFEST:EMBED,ID=1']
8991 self.ldflags_shared = [*ldflags, '/DLL', '/MANIFEST:EMBED,ID=2', '/MANIFESTUAC:NO']
90- @@ -573 ,3 +616 ,9 @@
92+ @@ -587 ,3 +634 ,9 @@
9193 else:
9294 # Oops, didn't find it in *any* of 'dirs'
9395 return None
@@ -96,11 +98,11 @@ diff -r -wBu "Python37\\Lib\\distutils/_msvccompiler.py" "Python3\\Lib\\distutil
9698+ compiler_type = 'clang-cl'
9799+
98100+ def __init__(self, verbose=0, dry_run=0, force=0):
99- + MSVCCompiler .__init__(self, verbose, dry_run, force, True)
100- diff -r -wBu "Python37 \\Lib\\distutils/ccompiler.py" "Python3\\Lib\\distutils/ccompiler.py"
101- --- "Python37 \\Lib\\distutils/ccompiler.py" 2019-03-25 21:21:20.000000000 +0800
102- +++ "Python3\\Lib\\distutils/ccompiler.py" 2019-05-30 14:28:06.399830100 +0800
103- @@ -961 ,6 +961 ,8 @@
101+ + super() .__init__(verbose, dry_run, force, True)
102+ diff -r -wBu "Python38 \\Lib\\distutils/ccompiler.py" "Python3\\Lib\\distutils/ccompiler.py"
103+ --- "Python38 \\Lib\\distutils/ccompiler.py" 2020-02-28 07:13:24.454796200 +0800
104+ +++ "Python3\\Lib\\distutils/ccompiler.py" 2020-02-28 07:16:27.720815000 +0800
105+ @@ -962 ,6 +962 ,8 @@
104106 "standard UNIX-style compiler"),
105107 'msvc': ('_msvccompiler', 'MSVCCompiler',
106108 "Microsoft Visual C++"),
0 commit comments