Index: zorg/trunk/buildbot/osuosl/master/config/builders.py =================================================================== --- zorg/trunk/buildbot/osuosl/master/config/builders.py +++ zorg/trunk/buildbot/osuosl/master/config/builders.py @@ -391,20 +391,12 @@ extra_cmake_args=["-DLLVM_TARGETS_TO_BUILD='ARM;AArch64'"], )}, - {'name': 'clang-x86-windows-msvc2015', + {'name': 'clang-x64-windows-msvc', 'slavenames': ['windows-gcebot2'], - 'builddir': 'clang-x86-windows-msvc2015', - 'factory' : ClangBuilder.getClangCMakeBuildFactory( - clean=False, - vs='%VS140COMNTOOLS%', - vs_target_arch='x86', - checkout_compiler_rt=False, - checkout_lld=False, - testStage1=True, - useTwoStage=True, - stage1_config='RelWithDebInfo', - stage2_config='RelWithDebInfo', - extra_cmake_args=["-DLLVM_ENABLE_ASSERTIONS=ON"])}, + 'builddir': 'clang-x64-windows-msvc', + 'factory' : AnnotatedBuilder.getAnnotatedBuildFactory( + script="clang-windows.py", + depends_on_projects=['llvm', 'clang', 'lld'])}, {'name' : "clang-ppc64be-linux-lnt", 'slavenames' :["ppc64be-clang-lnt-test"], Index: zorg/trunk/zorg/buildbot/builders/annotated/annotated_builder.py =================================================================== --- zorg/trunk/zorg/buildbot/builders/annotated/annotated_builder.py +++ zorg/trunk/zorg/buildbot/builders/annotated/annotated_builder.py @@ -12,6 +12,8 @@ from os.path import join as pjoin +VSWHERE_PATH = "C:/Program Files (x86)/Microsoft Visual Studio/Installer/vswhere.exe" + def get_argument_parser(*args, **kwargs): ap = argparse.ArgumentParser(*args, **kwargs) ap.add_argument('--jobs', help='Number of concurrent jobs to run') @@ -212,19 +214,7 @@ 'TERM': 'dumb', } if os.name == 'nt': - if vs_tools is None: - vs_tools = os.path.expandvars('%VS140COMNTOOLS%') - if arch is None: - arch = os.environ['PROCESSOR_ARCHITECTURE'].lower() - else: - arch = arch.lower() - vcvars_path = pjoin( - vs_tools, '..', '..', 'VC', 'vcvarsall.bat') - cmd = util.shquote_cmd([vcvars_path, arch]) + ' && set' - output = subprocess.check_output(cmd, shell=True) - for line in output.splitlines(): - var, val = line.split('=', 1) - new_env[var] = val + new_env.update(get_vcvars(vs_tools, arch)) if env is not None: new_env.epdate(env) @@ -309,6 +299,13 @@ self.set_environment(env) + # On Windows, if we're building clang-cl, make sure stage1 is built with + # MSVC (cl.exe), and not gcc from mingw. CMake will prefer gcc if it is + # available. + if c_compiler == 'clang-cl': + stage1_extra_cmake_args += ['-DCMAKE_C_COMPILER=cl', + '-DCMAKE_CXX_COMPILER=cl'] + # Update sources. cwd = os.getcwd() source_dir = pjoin(cwd, 'llvm.src') @@ -342,6 +339,42 @@ return 0 +def get_vcvars(vs_tools, arch): + """Get the VC tools environment using vswhere.exe from VS 2017 + + This code is following the guidelines from strategy 1 in this blog post: + https://blogs.msdn.microsoft.com/vcblog/2017/03/06/finding-the-visual-c-compiler-tools-in-visual-studio-2017/ + + It doesn't work when VS is not installed at the default location. + """ + if not arch: + arch = os.environ['PROCESSOR_ARCHITECTURE'].lower() + else: + arch = arch.lower() + + # Use vswhere.exe if it exists. + if os.path.exists(VSWHERE_PATH): + vs_path = subprocess.check_output([VSWHERE_PATH, "-latest", "-property", + "installationPath"]).strip() + if not os.path.isdir(vs_path): + raise ValueError("VS install path does not exist: " + vs_path) + vcvars_path = pjoin(vs_path, 'VC', 'Auxiliary', 'Build', + 'vcvarsall.bat') + elif vs_tools is None: + vs_tools = os.path.expandvars('%VS140COMNTOOLS%') + vcvars_path = pjoin(vs_tools, '..', '..', 'VC', 'vcvarsall.bat') + + # Newer vcvarsall.bat scripts aren't quiet, so direct them to NUL, aka + # Windows /dev/null. + cmd = util.shquote_cmd([vcvars_path, arch]) + ' > NUL && set' + output = subprocess.check_output(cmd, shell=True) + new_env = {} + for line in output.splitlines(): + var, val = line.split('=', 1) + new_env[var] = val + return new_env + + def main(argv): ap = get_argument_parser() args = ap.parse_args(argv[1:]) Index: zorg/trunk/zorg/buildbot/builders/annotated/clang-windows.py =================================================================== --- zorg/trunk/zorg/buildbot/builders/annotated/clang-windows.py +++ zorg/trunk/zorg/buildbot/builders/annotated/clang-windows.py @@ -0,0 +1,42 @@ +#!/usr/bin/python + +import os +import sys +import annotated_builder + +def main(argv): + ap = annotated_builder.get_argument_parser() + args = ap.parse_args(argv[1:]) + + stages = 2 + stage1_extra_cmake_args = [ + '-DCMAKE_BUILD_TYPE=Release', + '-DLLVM_ENABLE_PDB=ON', + '-DLLVM_ENABLE_ASSERTIONS=ON', + '-DLLVM_TARGETS_TO_BUILD=all', + ] + extra_cmake_args = stage1_extra_cmake_args + [ + '-DLLVM_USE_LINKER=lld', + ] + check_targets = ['check-llvm', 'check-clang', 'check-lld'] + + # Check both stage 1 and stage 2. + check_stages = [True] * stages + + compiler = 'clang-cl' + linker = 'lld-link' + + builder = annotated_builder.AnnotatedBuilder() + builder.run_steps(stages=stages, + extra_cmake_args=extra_cmake_args, + stage1_extra_cmake_args=stage1_extra_cmake_args, + check_targets=check_targets, + check_stages=check_stages, + compiler=compiler, + linker=linker, + jobs=args.jobs) + + +if __name__ == '__main__': + sys.path.append(os.path.dirname(__file__)) + sys.exit(main(sys.argv))