-
Notifications
You must be signed in to change notification settings - Fork 510
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
15 changed files
with
1,544 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# This file is expanded from a template sycl_configure.bzl | ||
# Update sycl_configure.bzl#verify_build_defines when adding new variables. | ||
|
||
load(":cc_toolchain_config.bzl", "cc_toolchain_config") | ||
|
||
licenses(["restricted"]) | ||
|
||
package(default_visibility = ["//visibility:public"]) | ||
|
||
toolchain( | ||
name = "toolchain-linux-x86_64", | ||
exec_compatible_with = [ | ||
"@bazel_tools//platforms:linux", | ||
"@bazel_tools//platforms:x86_64", | ||
], | ||
target_compatible_with = [ | ||
"@bazel_tools//platforms:linux", | ||
"@bazel_tools//platforms:x86_64", | ||
], | ||
toolchain = ":cc-compiler-local", | ||
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", | ||
) | ||
|
||
cc_toolchain_suite( | ||
name = "toolchain", | ||
toolchains = { | ||
"local|compiler": ":cc-compiler-local", | ||
"k8": ":cc-compiler-local", | ||
}, | ||
) | ||
|
||
cc_toolchain( | ||
name = "cc-compiler-local", | ||
all_files = ":crosstool_wrapper_driver_is_not_gcc", | ||
compiler_files = ":crosstool_wrapper_driver_is_not_gcc", | ||
ar_files = ":crosstool_wrapper_driver_is_not_gcc", | ||
as_files = ":crosstool_wrapper_driver_is_not_gcc", | ||
dwp_files = ":empty", | ||
linker_files = ":crosstool_wrapper_driver_is_not_gcc", | ||
objcopy_files = ":empty", | ||
strip_files = ":empty", | ||
# To support linker flags that need to go to the start of command line | ||
# we need the toolchain to support parameter files. Parameter files are | ||
# last on the command line and contain all shared libraries to link, so all | ||
# regular options will be left of them. | ||
supports_param_files = 1, | ||
toolchain_identifier = "local_linux", | ||
toolchain_config = ":cc-compiler-local-config", | ||
) | ||
|
||
cc_toolchain_config( | ||
name = "cc-compiler-local-config", | ||
cpu = "local", | ||
builtin_include_directories = [%{cxx_builtin_include_directories}], | ||
extra_no_canonical_prefixes_flags = [%{extra_no_canonical_prefixes_flags}], | ||
host_compiler_path = "%{host_compiler_path}", | ||
host_compiler_prefix = "%{host_compiler_prefix}", | ||
host_unfiltered_compile_flags = [%{unfiltered_compile_flags}], | ||
linker_bin_path = "%{linker_bin_path}", | ||
compiler = "unknown", | ||
) | ||
|
||
filegroup( | ||
name = "empty", | ||
srcs = [], | ||
) | ||
|
||
filegroup( | ||
name = "crosstool_wrapper_driver_is_not_gcc", | ||
srcs = ["clang/bin/crosstool_wrapper_driver_is_not_gcc"] | ||
) |
64 changes: 64 additions & 0 deletions
64
third_party/tsl/third_party/gpus/crosstool/clang/bin/crosstool_wrapper_driver_sycl.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#!/usr/bin/env python | ||
"""Crosstool wrapper for compiling SYCL program | ||
SYNOPSIS: | ||
crosstool_wrapper_driver_sycl [options passed in by cc_library() | ||
or cc_binary() rule] | ||
DESCRIPTION: | ||
This script is expected to be called by the cc_library() or cc_binary() bazel | ||
rules. When the option "sycl_compile" is present in the list of arguments passed | ||
to this script, it invokes the sycl compiler. When "sycl_compile" is not | ||
present, this wrapper invokes gcc with the input arguments as is. | ||
""" | ||
|
||
from __future__ import print_function | ||
from argparse import ArgumentParser | ||
import os | ||
import subprocess | ||
import sys | ||
import shlex | ||
|
||
CPU_COMPILER = ('%{cpu_compiler}') | ||
|
||
def system(cmd): | ||
"""Invokes cmd with os.system()""" | ||
|
||
ret = os.system(cmd) | ||
if os.WIFEXITED(ret): | ||
return os.WEXITSTATUS(ret) | ||
else: | ||
return -os.WTERMSIG(ret) | ||
|
||
def call_compiler(argv): | ||
parser = ArgumentParser() | ||
parser.add_argument('-c', nargs=1, action='append') | ||
parser.add_argument('-o', nargs=1, action='append') | ||
args, leftover = parser.parse_known_args(argv) | ||
|
||
flags = leftover | ||
|
||
common_flags = [] | ||
common_flags.append("-fno-finite-math-only") | ||
common_flags.append("-fno-fast-math") | ||
common_flags.append("-fexceptions") | ||
|
||
in_files, out_files = [], [] | ||
if args.c: | ||
in_files.append('-c') | ||
in_files.extend(args.c[0]) | ||
if args.o: | ||
out_files.append('-o') | ||
out_files.extend(args.o[0]) | ||
flags += (common_flags + in_files + out_files) | ||
print("cmd: ", " ".join([CPU_COMPILER] + flags)) | ||
return subprocess.call([CPU_COMPILER] + flags) | ||
|
||
def main(): | ||
parser = ArgumentParser() | ||
parser = ArgumentParser(fromfile_prefix_chars='@') | ||
parser.add_argument('-sycl_compile', action='store_true') | ||
args, leftover = parser.parse_known_args(sys.argv[1:]) | ||
|
||
return call_compiler(leftover) | ||
|
||
if __name__ == '__main__': | ||
sys.exit(main()) |
Oops, something went wrong.