Open borg323 opened 1 year ago
I am also having this problem, and am surprised to see it remains... Why is xilink.exe
being detected as the linker when icx
is the selected compiler?
I found XILINK is the Intel "pre-linker"
I managed to get it to work with meson.add_postconf_script('sycl_build_hack.py')
and the following sycl_build_hack.py
:
#!/usr/bin/env python3
import os
dir = os.getenv('MESON_BUILD_ROOT')
with open(dir + '/build.ninja', 'r') as file:
lines = file.readlines()
updated = []
dep_flag = False
link_flag = False
for line in lines:
# Replace xilink with icx -fsycl as the linker.
if not link_flag:
link_flag = 'xilink.exe' in line
if link_flag:
line = line.replace('xilink.exe', 'icx')
line = line.replace('/MACHINE:x64', '-fsycl')
line = line.replace('/OUT:', '-o ')
line = line.replace('/SUBSYSTEM:CONSOLE', '')
line = line.replace('/OPT:REF', '')
# Replace msvc compatible dependencies with gcc ones as icx output with /showincludes includes
# temporary header files causing full project rebuilds.
if line.startswith('rule') or line.startswith('build'):
dep_flag = 'cpp_COMPILER' in line
if dep_flag:
line = line.replace('deps = msvc', 'deps = gcc\n depfile = $out.d')
line = line.replace('/showIncludes', '/QMD')
if 'icx' in line:
line = line.replace('/Fo$out', '/Fo$out /QMF$out.d')
updated.append(line)
with open(dir + '/build.ninja', 'w') as file:
file.writelines(updated)
It seems based on other issues I've seen that lots of others are able to compile with oneAPI just fine without doing weird crap like this, but I don't know what their meson files look like
I would be very interested in a cleaner solution, so if you have any pointer do let me know. Note that you only need this if you want to offload to the GPU and build under Windows, for Linux it works with no hacks.
Ah, my bet is that the development focus is higher on Linux, and most people that do HPC do on Linux, which is what oneAPI is usually used for. Seems to me like the cleaner solution is going to need to be a pull request. I'll look into doing that when I can
I do still have a couple warnings generated even when I use that script:
[1/2] Compiling C++ object vector_add.exe.p/src_main.cpp.obj
icx: warning: ignoring '-traceback' option as it is not currently supported for target 'spir64-unknown-unknown' [-Woption-ignored]
[2/2] Linking target vector_add.exe
icx: warning: unknown argument ignored in clang-cl: '-PDB:vector_add.pdb' [-Wunknown-argument]
I was planning to revisit it this month, will post here if I make a new version. Does it otherwise work?
Describe the bug Meson forces the linker to
xilink.exe
which doesn't do the required offload code generation. Usingicx -fsycl
to link works fine.To Reproduce I used the vector-add example from https://github.com/oneapi-src/oneAPI-samples/tree/master/DirectProgramming/C%2B%2BSYCL/DenseLinearAlgebra/vector-add with the following minimal
meson.build
and settingCXX=icx
:Expected behavior Here is a full transcript of the issue and the expected correct behavior when using icx to link:
system parameters