@@ -13,45 +13,53 @@ COMPUTECPP_DRIVER= COMPUTECPP_ROOT + 'bin/compute++'
13
13
COMPUTECPP_INCLUDE = COMPUTECPP_ROOT + 'include'
14
14
15
15
def main ():
16
- computecpp_compiler_flags = [flag for flag in sys . argv [ 1 :] ]
16
+ compiler_flags = []
17
17
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 ]
20
26
21
27
if (output_file_index == 1 ):
22
28
# we are linking
23
- return subprocess .call ([CPU_CXX_COMPILER ] + computecpp_compiler_flags )
29
+ return subprocess .call ([CPU_CXX_COMPILER ] + compiler_flags )
24
30
25
- computecpp_compiler_flags = computecpp_compiler_flags + ['-D_GLIBCXX_USE_CXX11_ABI=0' ]
31
+ compiler_flags = compiler_flags + ['-D_GLIBCXX_USE_CXX11_ABI=0' ]
26
32
27
33
# find what we compile
28
34
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 ]
32
38
if (compited_file_name .endswith (('.cc' , '.c++' , '.cpp' , '.CPP' , '.C' , '.cxx' ))):
33
39
compiling_cpp = 1 ;
34
40
35
41
if (compiling_cpp == 1 ):
36
42
filename , file_extension = os .path .splitext (output_file_name )
37
43
bc_out = filename + '.sycl'
38
44
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
41
49
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 )
48
51
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
+
49
57
host_compiler_flags = ['-D_GLIBCXX_USE_CXX11_ABI=0' , '-DTENSORFLOW_USE_SYCL' , '-Wno-unused-variable' , '-I' , COMPUTECPP_INCLUDE , '--include' , bc_out ] + host_compiler_flags
50
58
x = subprocess .call ([CPU_CXX_COMPILER ] + host_compiler_flags )
51
59
return x
52
60
else :
53
61
# compile for C
54
- return subprocess .call ([CPU_C_COMPILER ] + computecpp_compiler_flags )
62
+ return subprocess .call ([CPU_C_COMPILER ] + compiler_flags )
55
63
56
64
if __name__ == '__main__' :
57
65
sys .exit (main ())
0 commit comments