33from __future__ import annotations
44
55import os
6+ import shutil
67import sys
78from pathlib import Path
89
@@ -276,6 +277,7 @@ def setup_unix_compilers(sycl_root: Path) -> None:
276277
277278 if require_env ("RUNNER_OS" ) == "Linux" :
278279 export_openmp_include_dir = True
280+ openmp_header = None
279281 openmp_library = find_file ([sycl_root , Path ("/opt/intel/oneapi" )], "libiomp5.so" )
280282 openmp_library_name = "iomp5"
281283 openmp_flags = "-fopenmp=libiomp5"
@@ -289,27 +291,31 @@ def setup_unix_compilers(sycl_root: Path) -> None:
289291 gcc_openmp_header = find_file ([gcc_include_root ], "omp.h" )
290292 gcc_openmp_library = Path (capture (["gcc-13" , "-print-file-name=libgomp.so" ]))
291293 if gcc_openmp_header is not None and gcc_openmp_library .exists ():
294+ staged_openmp_include_dir = Path (require_env ("RUNNER_TEMP" )) / "gcc-openmp-include"
295+ staged_openmp_include_dir .mkdir (parents = True , exist_ok = True )
296+ shutil .copy2 (gcc_openmp_header , staged_openmp_include_dir / "omp.h" )
292297 openmp_library = gcc_openmp_library
293298 openmp_library_name = "gomp"
294299 openmp_flags = "-fopenmp=libgomp"
295- export_openmp_include_dir = False
300+ openmp_header = staged_openmp_include_dir / "omp.h"
296301 if openmp_library is None and not source_built_linux_toolchain :
297302 main_error ("Unable to locate an Intel toolchain OpenMP runtime library" )
298303
299- resource_dir = Path (capture ([str (cxx_path ), "-print-resource-dir" ]))
300- openmp_header = find_file (
301- [
302- resource_dir / "include" ,
303- sycl_root ,
304- Path ("/opt/intel/oneapi" ),
305- ],
306- "omp.h" ,
307- )
308- if openmp_header is None and source_built_linux_toolchain :
304+ if openmp_library_name != "gomp" :
305+ resource_dir = Path (capture ([str (cxx_path ), "-print-resource-dir" ]))
306+ openmp_header = find_file (
307+ [
308+ resource_dir / "include" ,
309+ sycl_root ,
310+ Path ("/opt/intel/oneapi" ),
311+ ],
312+ "omp.h" ,
313+ )
314+ if openmp_library_name != "gomp" and openmp_header is None and source_built_linux_toolchain :
309315 gcc_root = Path (require_env ("ITLABAI_GCC_INSTALL_DIR" ))
310316 openmp_header = find_file ([gcc_root / "include" ], "omp.h" )
311317 export_openmp_include_dir = False
312- if openmp_header is None and not source_built_linux_toolchain :
318+ if openmp_library_name != "gomp" and openmp_header is None and not source_built_linux_toolchain :
313319 main_error (
314320 "Unable to locate Intel-provided omp.h under the SYCL toolchain"
315321 )
0 commit comments