diff options
Diffstat (limited to 'third_party')
-rw-r--r-- | third_party/gpus/cuda_configure.bzl | 4 | ||||
-rw-r--r-- | third_party/py/BUILD.tpl | 12 | ||||
-rw-r--r-- | third_party/py/python_configure.bzl | 56 | ||||
-rwxr-xr-x | third_party/sycl/crosstool/computecpp.tpl | 6 | ||||
-rwxr-xr-x | third_party/sycl/sycl/BUILD.tpl | 2 |
5 files changed, 62 insertions, 18 deletions
diff --git a/third_party/gpus/cuda_configure.bzl b/third_party/gpus/cuda_configure.bzl index 83a377dde5..1e29f23d90 100644 --- a/third_party/gpus/cuda_configure.bzl +++ b/third_party/gpus/cuda_configure.bzl @@ -847,10 +847,10 @@ def _genrule(src_dir, genrule_name, command, outs): genrule_name + '",\n' + ' outs = [\n' + outs + - ' ],\n' + + '\n ],\n' + ' cmd = """\n' + command + - ' """,\n' + + '\n """,\n' + ')\n\n' ) diff --git a/third_party/py/BUILD.tpl b/third_party/py/BUILD.tpl index 1ee9c071ad..cdfe9c9b45 100644 --- a/third_party/py/BUILD.tpl +++ b/third_party/py/BUILD.tpl @@ -6,6 +6,16 @@ cc_library( name = "python_headers", hdrs = [":python_include"], includes = ["python_include"], + data = select({ + ":windows" : [":python_import_lib"], + "//conditions:default": [], + }), + linkopts = select({ + # TODO(pcloudy): Ideally, this should just go into deps after resolving + # https://github.com/bazelbuild/bazel/issues/3237, + ":windows" : ["$(locations :python_import_lib)"], + "//conditions:default": [], + }), ) cc_library( @@ -22,4 +32,6 @@ config_setting( %{PYTHON_INCLUDE_GENRULE} +%{PYTHON_IMPORT_LIB_GENRULE} + %{NUMPY_INCLUDE_GENRULE} diff --git a/third_party/py/python_configure.bzl b/third_party/py/python_configure.bzl index 19a6f1e749..31c4d2b98a 100644 --- a/third_party/py/python_configure.bzl +++ b/third_party/py/python_configure.bzl @@ -117,10 +117,10 @@ def _genrule(src_dir, genrule_name, command, outs): genrule_name + '",\n' + ' outs = [\n' + outs + - ' ],\n' + + '\n ],\n' + ' cmd = """\n' + command + - ' """,\n' + + '\n """,\n' + ')\n\n' ) @@ -133,15 +133,20 @@ def _norm_path(path): return path -def _symlink_genrule_for_dir(repository_ctx, src_dir, dest_dir, genrule_name): +def _symlink_genrule_for_dir(repository_ctx, src_dir, dest_dir, genrule_name, + src_files = [], dest_files = []): """Returns a genrule to symlink(or copy if on Windows) a set of files. + + If src_dir is passed, files will be read from the given directory; otherwise + we assume files are in src_files and dest_files """ - src_dir = _norm_path(src_dir) - dest_dir = _norm_path(dest_dir) - files = _read_dir(repository_ctx, src_dir) - # Create a list with the src_dir stripped to use for outputs. - dest_files = files.replace(src_dir, '').splitlines() - src_files = files.splitlines() + if src_dir != None: + src_dir = _norm_path(src_dir) + dest_dir = _norm_path(dest_dir) + files = _read_dir(repository_ctx, src_dir) + # Create a list with the src_dir stripped to use for outputs. + dest_files = files.replace(src_dir, '').splitlines() + src_files = files.splitlines() command = [] outs = [] for i in range(len(dest_files)): @@ -217,11 +222,23 @@ def _get_python_include(repository_ctx, python_bin): 'print(sysconfig.get_python_inc())'], error_msg="Problem getting python include path.", error_details=("Is the Python binary path set up right? " + - "(See ./configure or BAZEL_BIN_PATH.) " + + "(See ./configure or PYTHON_BIN_PATH.) " + "Is distutils installed?")) return result.stdout.splitlines()[0] +def _get_python_import_lib_name(repository_ctx, python_bin): + """Get Python import library name (pythonXY.lib) on Windows.""" + result = _execute(repository_ctx, + [python_bin, "-c", + 'import sys;' + + 'print("python" + str(sys.version_info[0]) + str(sys.version_info[1]) + ".lib")'], + error_msg="Problem getting python import library.", + error_details=("Is the Python binary path set up right? " + + "(See ./configure or PYTHON_BIN_PATH.) ")) + return result.stdout.splitlines()[0] + + def _get_numpy_include(repository_ctx, python_bin): """Gets the numpy include path.""" return _execute(repository_ctx, @@ -240,11 +257,11 @@ def _create_local_python_repository(repository_ctx): empty_config = False # If local checks were requested, the python and numpy include will be auto # detected on the host config (using _PYTHON_BIN_PATH). + python_bin = _get_env_var(repository_ctx, _PYTHON_BIN_PATH, + "/usr/bin/python") if repository_ctx.attr.local_checks: # TODO(nlopezgi): The default argument here is a workaround until # bazelbuild/bazel#3057 is resolved. - python_bin = _get_env_var(repository_ctx, _PYTHON_BIN_PATH, - "/usr/bin/python") _check_python_bin(repository_ctx, python_bin) python_lib = _get_env_var(repository_ctx, _PYTHON_LIB_PATH, _get_python_lib(repository_ctx, python_bin)) @@ -263,6 +280,10 @@ def _create_local_python_repository(repository_ctx): ' name = "python_include",\n' + ' srcs = [],\n' + ')\n'), + "%{PYTHON_IMPORT_LIB_GENRULE}": ('filegroup(\n' + + ' name = "python_import_lib",\n' + + ' srcs = [],\n' + + ')\n'), "%{NUMPY_INCLUDE_GENRULE}": ('filegroup(\n' + ' name = "numpy_include",\n' + ' srcs = [],\n' + @@ -271,10 +292,21 @@ def _create_local_python_repository(repository_ctx): else: python_include_rule = _symlink_genrule_for_dir( repository_ctx, python_include, 'python_include', 'python_include') + python_import_lib_genrule = "" + # To build Python C/C++ extension on Windows, we need to link to python import library pythonXY.lib + # See https://docs.python.org/3/extending/windows.html + if _is_windows(repository_ctx): + python_include = _norm_path(python_include) + python_import_lib_name = _get_python_import_lib_name(repository_ctx, python_bin) + python_import_lib_src = python_include.rsplit('/', 1)[0] + "/libs/" + python_import_lib_name + python_import_lib_genrule = _symlink_genrule_for_dir( + repository_ctx, None, '', 'python_import_lib', + [python_import_lib_src], [python_import_lib_name]) numpy_include_rule = _symlink_genrule_for_dir( repository_ctx, numpy_include, 'numpy_include/numpy', 'numpy_include') _tpl(repository_ctx, "BUILD", { "%{PYTHON_INCLUDE_GENRULE}": python_include_rule, + "%{PYTHON_IMPORT_LIB_GENRULE}": python_import_lib_genrule, "%{NUMPY_INCLUDE_GENRULE}": numpy_include_rule, }) diff --git a/third_party/sycl/crosstool/computecpp.tpl b/third_party/sycl/crosstool/computecpp.tpl index 94c5e6aaad..8b0a7a7d4a 100755 --- a/third_party/sycl/crosstool/computecpp.tpl +++ b/third_party/sycl/crosstool/computecpp.tpl @@ -15,7 +15,7 @@ COMPUTECPP_INCLUDE = COMPUTECPP_ROOT + 'include' def main(): remove_flags = ('-Wl,--no-undefined', '-Wno-unused-but-set-variable', '-Wignored-attributes') - # remove -fsamotoze-coverage from string with g++ + # remove -fsanitize-coverage from string with g++ if 'g++' in CPU_CXX_COMPILER: remove_flags += ('-fsanitize-coverage',) compiler_flags = [flag for flag in sys.argv[1:] if not flag.startswith(remove_flags)] @@ -43,7 +43,7 @@ def main(): # create a blacklist of folders that will be skipped when compiling with ComputeCpp skip_extensions = [".cu.cc"] - skip_folders = ["tensorflow/compiler", "tensorflow/docs_src", "tensorflow/tensorboard", "third_party", "external", "hexagon"] + skip_folders = ["tensorflow/compiler", "tensorflow/docs_src", "third_party", "external", "hexagon"] skip_folders = [(folder + '/') for folder in skip_folders] # if compiling external project skip computecpp if any(compiled_file_name.endswith(_ext) for _ext in skip_extensions) or any(_folder in output_file_name for _folder in skip_folders): @@ -79,7 +79,7 @@ def main(): '-Xclang', '-cl-denorms-are-zero', '-Xclang', '-cl-fp32-correctly-rounded-divide-sqrt'] # disable flags enabling SIMD instructions computecpp_device_compiler_flags += [flag for flag in compiler_flags if \ - not any(x in flag.lower() for x in ('-fsanitize', '=native', '=core2', 'msse', 'vectorize', 'mavx', 'mmmx', 'm3dnow', 'fma'))] + not any(x in flag.lower() for x in ('-fsanitize', '-fno-canonical-system-headers', '=native', '=core2', 'msse', 'vectorize', 'mavx', 'mmmx', 'm3dnow', 'fma'))] x = call([COMPUTECPP_DRIVER] + computecpp_device_compiler_flags) if x == 0: diff --git a/third_party/sycl/sycl/BUILD.tpl b/third_party/sycl/sycl/BUILD.tpl index c66a9f007d..6cad190630 100755 --- a/third_party/sycl/sycl/BUILD.tpl +++ b/third_party/sycl/sycl/BUILD.tpl @@ -33,7 +33,7 @@ cc_library( sycl_library_path("ComputeCpp") ], includes = ["include/"], - linkstatic = 1, + linkstatic = 0, ) cc_library( |