Merge pull request #4421 from KoolJBlack/google-to-main
* d6fa00dd Format ConvertToLLVM2.cpp.
* 4fc1a352 Merge pull request #4413 from KoolJBlack:main-to-google
* 594e06cb Merge branch 'google' into main-to-google
* 0c7d6512 Synchronize submodules
* 78170d0a Synchronize submodules with LLVM at llvm/llvm-project@d38a0258a5f4
* 7725556c Synchronize submodules
* 4c8cfe75 Integrate LLVM at llvm/llvm-project@7f7b0dc4e15f
* 14fbe4d9 Synchronize submodules
* f606a8e6 Integrate LLVM at llvm/llvm-project@d38a0258a5f4
* 3ac7e078 Update from StrJoin to !interleave
diff --git a/build_tools/cmake/bazel.bat.in b/build_tools/cmake/bazel.bat.in
index 7c119be..234a535 100644
--- a/build_tools/cmake/bazel.bat.in
+++ b/build_tools/cmake/bazel.bat.in
@@ -13,5 +13,5 @@
REM See the License for the specific language governing permissions and
REM limitations under the License.
-cd /d "@_bazel_src_root@"
-@IREE_BAZEL_EXECUTABLE@ @_bazel_startup_options@ %* @_bazel_build_options@ || exit /b
+cd /d "@IREE_BAZEL_SRC_ROOT@"
+@IREE_BAZEL_EXECUTABLE@ @_bazel_startup_options_joined@ %* || exit /b
diff --git a/build_tools/cmake/bazel.sh.in b/build_tools/cmake/bazel.sh.in
index 2ce985a..3296162 100644
--- a/build_tools/cmake/bazel.sh.in
+++ b/build_tools/cmake/bazel.sh.in
@@ -13,5 +13,5 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-cd "@_bazel_src_root@"
-exec '@IREE_BAZEL_EXECUTABLE@' @_bazel_startup_options@ "$@" @_bazel_build_options@
+cd "@IREE_BAZEL_SRC_ROOT@"
+exec '@IREE_BAZEL_EXECUTABLE@' @_bazel_startup_options_joined@ "$@" --color=yes
diff --git a/build_tools/cmake/cmake_ci.py b/build_tools/cmake/cmake_ci.py
index 3236a13..3f25112 100644
--- a/build_tools/cmake/cmake_ci.py
+++ b/build_tools/cmake/cmake_ci.py
@@ -154,7 +154,18 @@
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.
+ 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. '
+ 'I didn\'t make this mess... just the messenger')
cmake_environ = compute_vcvars_environ()
+ report('New Windows Path:', cmake_environ['PATH'])
def invoke_generate():
@@ -208,6 +219,9 @@
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 bf67dab..d86991a 100644
--- a/build_tools/cmake/configure_bazel.cmake
+++ b/build_tools/cmake/configure_bazel.cmake
@@ -14,6 +14,8 @@
set(IREE_BAZEL_EXECUTABLE "bazel"
CACHE STRING "Bazel executable to use for bazel builds")
+set(IREE_BAZEL_SH "bash"
+ CACHE STRING "Bash command for bazel (on Windows cannot be system32 bash)")
# iree_configure_bazel
#
@@ -29,8 +31,9 @@
# IREE_BAZEL_WRAPPER: Executable wrapper to invoke to run bazel
# IREE_BAZEL_BIN: Path to the bazel-bin directory
function(iree_configure_bazel)
+ message(STATUS "Using bazel executable: ${IREE_BAZEL_EXECUTABLE}")
set(_bazel_output_base "${CMAKE_BINARY_DIR}/bazel-out")
- set(_bazel_src_root "${CMAKE_SOURCE_DIR}")
+ set(IREE_BAZEL_SRC_ROOT "${CMAKE_SOURCE_DIR}")
# Configure comilation mode.
set(_bazel_compilation_mode_opt "")
@@ -45,38 +48,43 @@
# Use the utility to emit _bazelrc_file configuration options.
set(_bazelrc_file "${CMAKE_BINARY_DIR}/bazelrc")
- if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
+ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(_bazel_platform_config generic_clang)
- elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
+ elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
message(WARNING "Configuring bazel build for GCC: This receives minimal testing (recommend clang)")
set(_bazel_platform_config generic_gcc)
- elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")
+ elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
set(_bazel_platform_config windows)
else()
- message(WARNING "Did not recognize C++ compiler R{CMAKE_CXX_COMPILER_ID}. Configuring bazel for gcc mode and hoping for the best.")
+ message(WARNING "Did not recognize C++ compiler ${CMAKE_CXX_COMPILER_ID}. Configuring bazel for gcc mode and hoping for the best.")
set(_bazel_platform_config generic_gcc)
endif()
# Now add an import to the configured.bazelrc to load the project-wide
# bazelrc file.
+ # Note that the PYTHON_BIN_PATH is for TensorFlow's benefit on
+ # Windows. Just because. Everything has to be special. And the BAZEL_SH
+ # *HAS* to be non system32 bash (WSL). Because, why? Just because.
file(WRITE "${_bazelrc_file}" "
build --config ${_bazel_platform_config}
build --progress_report_interval=30
build --python_path='${Python3_EXECUTABLE}'
+build --action_env BAZEL_SH='${IREE_BAZEL_SH}'
+build --action_env PYTHON_BIN_PATH='${Python3_EXECUTABLE}'
build --action_env CC='${CMAKE_C_COMPILER}'
build --action_env CXX='${CMAKE_CXX_COMPILER}'
${_bazel_compilation_mode_opt}
${_bazel_strip_opt}
-import ${_bazel_src_root}/build_tools/bazel/iree.bazelrc
+import ${IREE_BAZEL_SRC_ROOT}/build_tools/bazel/iree.bazelrc
")
# Note that we do allow a .bazelrc in the home directory (otherwise we
# would have --nohome_rc). This is mainly about disabling interference from
# interactive builds in the workspace.
- set(_bazel_startup_options "--nosystem_rc --noworkspace_rc '--bazelrc=${_bazelrc_file}' '--output_base=${_bazel_output_base}'")
- set(_bazel_build_options "--color=yes")
+ set(_bazel_startup_options --nosystem_rc --noworkspace_rc "--bazelrc=${_bazelrc_file}" "--output_base=${_bazel_output_base}")
# And emit scripts to delegate to bazel.
set(IREE_BAZEL_WRAPPER "${CMAKE_BINARY_DIR}/bazel")
+ string(REPLACE ";" " " _bazel_startup_options_joined "${_bazel_startup_options}")
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/build_tools/cmake/bazel.sh.in"
"${IREE_BAZEL_WRAPPER}"
@@ -91,27 +99,35 @@
)
endif()
+ # On windows, the vagaries of tunneling through cmd.exe are not worth it
+ # (nested quoting...), so we just invoke bazel directly and accept that
+ # there can be a variance with an interactive launch.
+ if(WIN32)
+ set(IREE_BAZEL_COMMAND ${IREE_BAZEL_EXECUTABLE} ${_bazel_startup_options})
+ else()
+ set(IREE_BAZEL_COMMAND ${IREE_BAZEL_WRAPPER})
+ endif()
+
+ message(STATUS "Full bazel command: ${IREE_BAZEL_COMMAND}")
# Now ready to start bazel and ask it things.
message(STATUS "Detecting bazel version...")
execute_process(
RESULT_VARIABLE RC
OUTPUT_VARIABLE BAZEL_RELEASE
OUTPUT_STRIP_TRAILING_WHITESPACE
- COMMAND
- "${IREE_BAZEL_WRAPPER}" info release
- )
+ WORKING_DIRECTORY "${IREE_BAZEL_SRC_ROOT}"
+ COMMAND ${IREE_BAZEL_COMMAND} info release)
if(NOT RC EQUAL 0)
- message(FATAL_ERROR "Failed to launch bazel using wrapper ${IREE_BAZEL_WRAPPER}. Inspect that script and ensure bazel is installed properly.")
+ message(FATAL_ERROR "Failed to launch bazel: ${IREE_BAZEL_COMMAND}")
endif()
execute_process(
RESULT_VARIABLE RC
OUTPUT_VARIABLE IREE_BAZEL_BIN
OUTPUT_STRIP_TRAILING_WHITESPACE
- COMMAND
- "${IREE_BAZEL_WRAPPER}" info bazel-bin
- )
+ WORKING_DIRECTORY "${IREE_BAZEL_SRC_ROOT}"
+ COMMAND ${IREE_BAZEL_COMMAND} info bazel-bin)
if(NOT RC EQUAL 0)
- message(FATAL_ERROR "Failed to run 'info bazel-bin' via ${IREE_BAZEL_WRAPPER}. Inspect that script and ensure bazel is installed properly.")
+ message(FATAL_ERROR "Failed to run 'info bazel-bin' via ${IREE_BAZEL_COMMAND}")
endif()
message(STATUS "Found bazel ${BAZEL_RELEASE}, bin directory: ${IREE_BAZEL_BIN}")
message(STATUS "Bazel wrapper script generated at: ${IREE_BAZEL_WRAPPER}")
@@ -130,7 +146,9 @@
endif()
endif()
+ set(IREE_BAZEL_SRC_ROOT "${IREE_BAZEL_SRC_ROOT}" PARENT_SCOPE)
set(IREE_BAZEL_WRAPPER "${IREE_BAZEL_WRAPPER}" PARENT_SCOPE)
+ set(IREE_BAZEL_COMMAND "${IREE_BAZEL_COMMAND}" PARENT_SCOPE)
set(IREE_BAZEL_BIN "${IREE_BAZEL_BIN}" PARENT_SCOPE)
endfunction()
@@ -158,9 +176,10 @@
endif()
add_custom_target(${ARG_INVOCATION_TARGET} ${_all_option}
USES_TERMINAL
+ WORKING_DIRECTORY "${IREE_BAZEL_SRC_ROOT}"
COMMAND ${CMAKE_COMMAND} -E echo
"Starting bazel build of targets '${ARG_BAZEL_TARGETS}'"
- COMMAND "${IREE_BAZEL_WRAPPER}" build ${ARG_BAZEL_TARGETS}
+ COMMAND ${IREE_BAZEL_COMMAND} build ${ARG_BAZEL_TARGETS}
COMMAND ${CMAKE_COMMAND} -E echo "Bazel build complete."
)
diff --git a/build_tools/third_party/pffft/BUILD.overlay b/build_tools/third_party/pffft/BUILD.overlay
index 13eccec..e4c8d79 100644
--- a/build_tools/third_party/pffft/BUILD.overlay
+++ b/build_tools/third_party/pffft/BUILD.overlay
@@ -13,7 +13,6 @@
"pffft.h",
],
deps = [":pffft_internal"],
- include_prefix = "third_party/pffft",
)
cc_library(
diff --git a/build_tools/third_party/pffft/CMakeLists.txt b/build_tools/third_party/pffft/CMakeLists.txt
index 9ead8fc..05dfe67 100644
--- a/build_tools/third_party/pffft/CMakeLists.txt
+++ b/build_tools/third_party/pffft/CMakeLists.txt
@@ -25,6 +25,8 @@
"pffft.c"
HDRS
"pffft.h"
+ INCLUDES
+ ${PFFFT_ROOT}
)
external_cc_library(
diff --git a/iree/hal/vmla/op_kernels_fft.h b/iree/hal/vmla/op_kernels_fft.h
index ab376d0..e6ac58b 100644
--- a/iree/hal/vmla/op_kernels_fft.h
+++ b/iree/hal/vmla/op_kernels_fft.h
@@ -37,7 +37,7 @@
#include "absl/types/span.h"
#include "iree/base/logging.h"
#include "iree/base/status.h"
-#include "third_party/pffft/pffft.h"
+#include "pffft.h"
namespace iree {
namespace hal {