Skip to content

Commit e2f1e9e

Browse files
Luke Iwanskibenoitsteiner
Luke Iwanski
authored andcommitted
Added sycl_asan target to the bazel
1 parent 7b09eff commit e2f1e9e

File tree

2 files changed

+28
-17
lines changed

2 files changed

+28
-17
lines changed

third_party/sycl/crosstool/computecpp.tpl

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,45 +13,53 @@ COMPUTECPP_DRIVER= COMPUTECPP_ROOT + 'bin/compute++'
1313
COMPUTECPP_INCLUDE = COMPUTECPP_ROOT + 'include'
1414

1515
def main():
16-
computecpp_compiler_flags = [flag for flag in sys.argv[1:]]
16+
compiler_flags = []
1717

18-
output_file_index = computecpp_compiler_flags.index('-o') + 1
19-
output_file_name = computecpp_compiler_flags[output_file_index]
18+
# remove -fsamotoze-coverage from string
19+
if CPU_CXX_COMPILER.find("g++") != -1:
20+
compiler_flags = [flag for flag in sys.argv[1:] if not flag.startswith(('-Wl,--no-undefined', '-fsanitize-coverage', '-Wno-unused-but-set-variable', '-Wignored-attributes'))]
21+
else:
22+
compiler_flags = [flag for flag in sys.argv[1:] if not flag.startswith(('-Wl,--no-undefined', '-Wno-unused-but-set-variable', '-Wignored-attributes'))]
23+
24+
output_file_index = compiler_flags.index('-o') + 1
25+
output_file_name = compiler_flags[output_file_index]
2026

2127
if(output_file_index == 1):
2228
# we are linking
23-
return subprocess.call([CPU_CXX_COMPILER] + computecpp_compiler_flags)
29+
return subprocess.call([CPU_CXX_COMPILER] + compiler_flags)
2430

25-
computecpp_compiler_flags = computecpp_compiler_flags + ['-D_GLIBCXX_USE_CXX11_ABI=0']
31+
compiler_flags = compiler_flags + ['-D_GLIBCXX_USE_CXX11_ABI=0']
2632

2733
# find what we compile
2834
compiling_cpp = 0
29-
if('-c' in computecpp_compiler_flags):
30-
compiled_file_index = computecpp_compiler_flags.index('-c') + 1
31-
compited_file_name = computecpp_compiler_flags[compiled_file_index]
35+
if('-c' in compiler_flags):
36+
compiled_file_index = compiler_flags.index('-c') + 1
37+
compited_file_name = compiler_flags[compiled_file_index]
3238
if(compited_file_name.endswith(('.cc', '.c++', '.cpp', '.CPP', '.C', '.cxx'))):
3339
compiling_cpp = 1;
3440

3541
if(compiling_cpp == 1):
3642
filename, file_extension = os.path.splitext(output_file_name)
3743
bc_out = filename + '.sycl'
3844

39-
computecpp_compiler_flags = ['--sycl-no-diags', '-sycl-compress-name', '-DTENSORFLOW_USE_SYCL', '-Wno-unused-variable', '-I', COMPUTECPP_INCLUDE, '-isystem',
40-
COMPUTECPP_INCLUDE, '-std=c++11', '-sycl', '-emit-llvm', '-no-serial-memop'] + computecpp_compiler_flags
45+
# strip asan for the device
46+
computecpp_device_compiler_flags = [flag for flag in compiler_flags if not flag.startswith(('-fsanitize'))]
47+
computecpp_device_compiler_flags = ['--sycl-no-diags', '-sycl-compress-name', '-DTENSORFLOW_USE_SYCL', '-Wno-unused-variable', '-I', COMPUTECPP_INCLUDE, '-isystem',
48+
COMPUTECPP_INCLUDE, '-std=c++11', '-sycl', '-emit-llvm', '-no-serial-memop'] + computecpp_device_compiler_flags
4149

42-
# dont want that in case of compiling with computecpp first
43-
host_compiler_flags = [flag for flag in sys.argv[1:]
44-
if not flag.startswith(('-MF', '-MD',))
45-
if not '.d' in flag]
46-
47-
x = subprocess.call([COMPUTECPP_DRIVER] + computecpp_compiler_flags )
50+
x = subprocess.call([COMPUTECPP_DRIVER] + computecpp_device_compiler_flags )
4851
if(x == 0):
52+
# dont want that in case of compiling with computecpp first
53+
host_compiler_flags = [flag for flag in compiler_flags
54+
if not flag.startswith(('-MF', '-MD',))
55+
if not '.d' in flag]
56+
4957
host_compiler_flags = ['-D_GLIBCXX_USE_CXX11_ABI=0', '-DTENSORFLOW_USE_SYCL', '-Wno-unused-variable', '-I', COMPUTECPP_INCLUDE, '--include', bc_out] + host_compiler_flags
5058
x = subprocess.call([CPU_CXX_COMPILER] + host_compiler_flags)
5159
return x
5260
else:
5361
# compile for C
54-
return subprocess.call([CPU_C_COMPILER] + computecpp_compiler_flags)
62+
return subprocess.call([CPU_C_COMPILER] + compiler_flags)
5563

5664
if __name__ == '__main__':
5765
sys.exit(main())

tools/bazel.rc.template

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ build:win-cuda --define=using_cuda=true --define=using_cuda_nvcc=true
55
build:sycl --crosstool_top=@local_config_sycl//crosstool:toolchain
66
build:sycl --define=using_sycl=true
77

8+
build:sycl_asan --crosstool_top=@local_config_sycl//crosstool:toolchain
9+
build:sycl_asan --define=using_sycl=true --copt -fno-omit-frame-pointer --copt -fsanitize-coverage=3 --copt -fsanitize=address --copt -DGPR_NO_DIRECT_SYSCALLS --linkopt -fPIC --linkopt -lasan
10+
811
build --force_python=py$PYTHON_MAJOR_VERSION
912
build --host_force_python=py$PYTHON_MAJOR_VERSION
1013
build --python$PYTHON_MAJOR_VERSION_path=$PYTHON_BINARY

0 commit comments

Comments
 (0)