diff --git a/SYCL/lit.cfg.py b/SYCL/lit.cfg.py index b4c078a3b9..4aae079fef 100644 --- a/SYCL/lit.cfg.py +++ b/SYCL/lit.cfg.py @@ -188,10 +188,21 @@ else: arch_flag = "" -# extra_include points to sycl/sycl.hpp location to workaround compiler -# versions which supports only CL/sycl.hpp -config.substitutions.append( ('%clangxx', ' '+ config.dpcpp_compiler + ' ' + config.cxx_flags + ' ' + arch_flag + ' ' + ( "/I" if cl_options else "-I") + config.extra_include ) ) -config.substitutions.append( ('%clang', ' ' + config.dpcpp_compiler + ' ' + config.c_flags + ( "/I" if cl_options else "-I") + config.extra_include ) ) +# Add an extra include directory which points to a fake sycl/sycl.hpp (which just points to CL/sycl.hpp) +# location to workaround compiler versions which do not provide this header +check_sycl_hpp_file='sycl_hpp_include.cpp' +with open(check_sycl_hpp_file, 'w') as fp: + fp.write('#include \n') + fp.write('int main() {}') + +extra_sycl_include = "" +sycl_hpp_available = subprocess.getstatusoutput(config.dpcpp_compiler+' -fsycl ' + check_sycl_hpp_file) +if sycl_hpp_available != 0: + extra_sycl_include = " " + ("/I" if cl_options else "-I") + config.extra_include + +config.substitutions.append( ('%clangxx', ' '+ config.dpcpp_compiler + ' ' + config.cxx_flags + ' ' + arch_flag + extra_sycl_include) ) +config.substitutions.append( ('%clang', ' ' + config.dpcpp_compiler + ' ' + config.c_flags + extra_sycl_include) ) + config.substitutions.append( ('%threads_lib', config.sycl_threads_lib) ) # Configure device-specific substitutions based on availability of corresponding