Also switches to an action to setup the vs env.
* And doesn't actually tell bazel what shell to use because spaces and backslashes are a thing.
diff --git a/.github/workflows/build_package.yml b/.github/workflows/build_package.yml
index 6691503..7d1e537 100644
--- a/.github/workflows/build_package.yml
+++ b/.github/workflows/build_package.yml
@@ -30,7 +30,7 @@
strategy:
fail-fast: false
matrix:
- os: [ubuntu-18.04, windows-2019, macos-latest]
+ os: [ubuntu-18.04]
build_package:
- py-compiler-pkg
- py-runtime-pkg
@@ -38,12 +38,50 @@
- py-tflite-compiler-tools-pkg
- py-tf-compiler-tools-pkg
experimental: [false]
- # Add experimental one off combinations below:
- # include:
- # - os: macos-latest
- # build_package: compiler
- # experimental: true
-
+ needs_bazel: [false] # Bazel comes in with the container.
+ include:
+ # Windows packages.
+ - os: windows-2019
+ build_package: py-compiler-pkg
+ experimental: true
+ needs_bazel: false
+ - os: windows-2019
+ build_package: py-runtime-pkg
+ experimental: true
+ needs_bazel: false
+ - os: windows-2019
+ build_package: py-xla-compiler-tools-pkg
+ experimental: true
+ needs_bazel: true
+ - os: windows-2019
+ build_package: py-tflite-compiler-tools-pkg
+ experimental: true
+ needs_bazel: true
+ - os: windows-2019
+ build_package: py-tf-compiler-tools-pkg
+ experimental: true
+ needs_bazel: true
+ # Macos packages.
+ - os: macos-latest
+ build_package: py-compiler-pkg
+ experimental: true
+ needs_bazel: false
+ - os: macos-latest
+ build_package: py-runtime-pkg
+ experimental: true
+ needs_bazel: false
+ - os: macos-latest
+ build_package: py-xla-compiler-tools-pkg
+ experimental: true
+ needs_bazel: true
+ - os: macos-latest
+ build_package: py-tflite-compiler-tools-pkg
+ experimental: true
+ needs_bazel: true
+ - os: macos-latest
+ build_package: py-tf-compiler-tools-pkg
+ experimental: true
+ needs_bazel: true
env:
CIBW_BUILD_VERBOSITY: 1
# Note that on Linux, we run under docker with an altered path.
@@ -87,12 +125,30 @@
run: |
python -m pip install cibuildwheel==1.7.2
+ # It is 2021. And the Windows Path is still a mess.
+ - name: Set up Visual Studio shell
+ if: "contains(matrix.os, 'windows')"
+ uses: egor-tensin/vs-shell@v2
+ with:
+ arch: x64
+ - name: Unbreak the system path
+ if: "contains(matrix.os, 'windows')"
+ shell: cmd
+ run: |
+ echo ::add-path::C:\msys64\usr\bin
+ - name: Make sure WSL bash is not enabled
+ if: "contains(matrix.os, 'windows')"
+ shell: cmd
+ run: |
+ # Should display either an msys mount table or an "install from the windows store" banner
+ bash -c mount
+
# Compiler wheels are not python version specific, so we just shard and
# build once for an examplar version of python. This could save a bit of
# time by not building IREE's runtime, but it is small compared to
# the compiler build.
- name: Build compiler wheels
- if: "contains(matrix.build_package, 'py-compiler-pkg')"
+ if: "matrix.build_package == 'py-compiler-pkg'"
shell: bash
run: |
# Just need to build for one examplar python3 variant.
@@ -118,7 +174,7 @@
# directory between runs. Most of the build will be incremental.
# We save a little bit of time by disabling the compiler build.
- name: Build runtime wheels
- if: "contains(matrix.build_package, 'py-runtime-pkg')"
+ if: "matrix.build_package == 'py-runtime-pkg'"
shell: bash
run: |
# Just need to build for one examplar python3 variant.
@@ -141,7 +197,7 @@
# Compiler tools wheels are not python version specific, so just build
# for one examplar python version.
- name: Build XLA Compiler Tools wheels
- if: "contains(matrix.build_package, 'py-xla-compiler-tools-pkg')"
+ if: "matrix.build_package == 'py-xla-compiler-tools-pkg'"
shell: bash
run: |
# Just need to build for one examplar python3 variant.
@@ -165,7 +221,7 @@
# Compiler tools wheels are not python version specific, so just build
# for one examplar python version.
- name: Build TFLite Compiler Tools wheels
- if: "contains(matrix.build_package, 'py-tflite-compiler-tools-pkg')"
+ if: "matrix.build_package == 'py-tflite-compiler-tools-pkg'"
shell: bash
run: |
# Just need to build for one examplar python3 variant.
@@ -190,7 +246,7 @@
# Compiler tools wheels are not python version specific, so just build
# for one examplar python version.
- name: Build TF Compiler Tools wheels
- if: "contains(matrix.build_package, 'py-tf-compiler-tools-pkg')"
+ if: "matrix.build_package == 'py-tf-compiler-tools-pkg'"
shell: bash
run: |
# Just need to build for one examplar python3 variant.
diff --git a/build_tools/cmake/cmake_ci.py b/build_tools/cmake/cmake_ci.py
index 3f25112..76bbf36 100644
--- a/build_tools/cmake/cmake_ci.py
+++ b/build_tools/cmake/cmake_ci.py
@@ -108,64 +108,19 @@
return cmake_command_prefix + args
-### On Windows, we need to make sure to wrap any cmake invocation to populate
-### vcvars. In order to do this robustly, we have to get another tool. Because,
-### why wouldn't we?
-### So we install vswhere if needed. Then we create a temporary batch file
-### that calls vcvarsall.bat and prints the resulting environment (because for
-### the life of me, I could not figure out the god-forsaken quoting incantation
-### to do a "cmd /c ... & ..."), capture the environment and use it in any
-### calls to cmake. Awesome.
if is_windows:
-
- def compute_vcvars_environ():
- if os.environ.get('VCINSTALLDIR'):
- report('Appear to be running with vcvars set. Not resetting.')
- use_vswhere = use_tool_path('vswhere')
- if not use_vswhere:
- report('vswhere not found. attempting to install it.')
- subprocess.check_call(['choco', 'install', 'vswhere'])
- use_vswhere = use_tool_path('vswhere')
- if not use_vswhere:
- report('Still could not find vswhere after attempting to install it')
- vs_install_path = subprocess.check_output(
- ['vswhere', '-property', 'installationPath']).decode('utf-8').strip()
- report('Found visual studio installation:', vs_install_path)
- vcvars_all = os.path.join(vs_install_path, 'VC', 'Auxiliary', 'Build',
- 'vcvarsall.bat')
- vcvars_arch = get_setting('VCVARS_ARCH', 'x64')
- with tempfile.NamedTemporaryFile(mode='wt', delete=False,
- suffix='.cmd') as f:
- f.write('@echo off\n')
- f.write(f'call "{vcvars_all}" {vcvars_arch} > NUL\n')
- f.write('set\n')
- try:
- env_vars = subprocess.check_output(["cmd", "/c",
- f.name]).decode('utf-8').splitlines()
- finally:
- os.unlink(f.name)
-
- cmake_environ = {}
- for env_line in env_vars:
- name, value = env_line.split('=', maxsplit=1)
- cmake_environ[name] = value
- if 'VCINSTALLDIR' not in cmake_environ:
- report('vcvars environment did not include VCINSTALLDIR:\n',
- cmake_environ)
- return cmake_environ
-
- # Note that we search for bash in the *original environment* because
- # that may be more likely to retain user overrides. Bazel needs msys
- # bash and TensorFlow will melt down and cry if it finds system bash.
- # Because, of course it will.
+ # Bazel needs msys bash and TensorFlow will melt down and cry if it finds
+ # system bash. Because, of course it will.
+ # Note that we don't set this as a CMake option because it may have spaces
+ # in the path, use backslashes or various other things that get corrupted
+ # in the five or six layers of shoddy string transformations between here
+ # and where it gets used.
bash_exe = which('bash')
report('Found Windows bash:', bash_exe)
report('NOTE: If the above is system32 bash and you are using bazel to build '
'TensorFlow, you are going to have a bad time. Suggest being explicit '
- 'by setting USE_BASH in the environment. I\'m really sorry. '
+ 'adding the correct directory to your path. I\'m really sorry. '
'I didn\'t make this mess... just the messenger')
- cmake_environ = compute_vcvars_environ()
- report('New Windows Path:', cmake_environ['PATH'])
def invoke_generate():
@@ -219,9 +174,6 @@
f'-DIREE_RELEASE_REVISION:STRING={version_info.get("iree-revision") or "HEAD"}',
]
- if is_windows and bash_exe:
- cmake_args.append(f'-DIREE_BAZEL_SH={bash_exe}')
-
### HACK: Add a Python3_LIBRARY because cmake needs it, but it legitimately
### does not exist on manylinux (or any linux static python).
# Need to explicitly tell cmake about the python library.
diff --git a/build_tools/cmake/configure_bazel.cmake b/build_tools/cmake/configure_bazel.cmake
index d86991a..6cf77ee 100644
--- a/build_tools/cmake/configure_bazel.cmake
+++ b/build_tools/cmake/configure_bazel.cmake
@@ -43,7 +43,9 @@
set(_bazel_compilation_mode_opt "build --compilation_mode=opt")
# Note: Bazel --strip is not strip.
# https://docs.bazel.build/versions/master/user-manual.html#flag--strip
- set(_bazel_strip_opt "build --linkopt=-Wl,--strip-all")
+ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ set(_bazel_strip_opt "build --linkopt=-Wl,--strip-all")
+ endif()
endif()
# Use the utility to emit _bazelrc_file configuration options.