Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

oneAPI: Build the support library for Windows. #8285

Closed
wants to merge 1 commit into from

Conversation

maleadt
Copy link
Contributor

@maleadt maleadt commented Mar 12, 2024

Requires a bunch of hacks (libraries are named differently, and somehow end up depending on libMSVCRT.a and libOLDNAMES.a), and even then I'm running into a linker error:

# clang++ -L/workspace/destdir/bin -shared -o liboneapi_support.dll -lsycl7 ...
ld.lld: error: undefined symbol: __declspec(dllimport) sycl::_V1::ext::oneapi::level_zero::make_platform(unsigned long long)
>>> referenced by /workspace/srcdir/oneAPI.jl/deps/src/sycl.cpp:9
>>>               CMakeFiles/oneapi_support.dir/src/sycl.cpp.obj:(syclPlatformCreate)

... even though:

# nm /workspace/destdir/bin/sycl7.lib | grep make_platform
0000000000000000 T ?make_platform@level_zero@oneapi@ext@_V1@sycl@@YA?AVplatform@45@_K@Z
0000000000000000 I __imp_?make_platform@level_zero@oneapi@ext@_V1@sycl@@YA?AVplatform@45@_K@Z

Any thoughts appreciated (also on how to get rid of the ugly things I'm doing).

@maleadt maleadt added Windows 🙄 Doesn't build for Windows oneAPI 1️⃣ Builders related to the oneAPI toolkit. labels Mar 12, 2024
@maleadt
Copy link
Contributor Author

maleadt commented Mar 12, 2024

The same error when using ld instead of ldd:

# ld ...
ld: CMakeFiles/oneapi_support.dir/src/sycl.cpp.obj: in function `syclPlatformCreate':
/workspace/srcdir/oneAPI.jl/deps/src/sycl.cpp:9: undefined reference to `__imp__ZN4sycl3_V13ext6oneapi10level_zero13make_platformEy'

# nm /workspace/destdir/bin/sycl7.lib | grep make_platform | grep level
0000000000000000 T ?make_platform@level_zero@oneapi@ext@_V1@sycl@@YA?AVplatform@45@_K@Z
0000000000000000 I __imp_?make_platform@level_zero@oneapi@ext@_V1@sycl@@YA?AVplatform@45@_K@Z

@maleadt
Copy link
Contributor Author

maleadt commented Mar 12, 2024

mwe.cpp

#include <CL/sycl.hpp>
#include <sycl/ext/oneapi/backend/level_zero.hpp>

extern "C" int syclPlatformCreate(ze_driver_handle_t driver) {
    sycl::ext::oneapi::level_zero::make_platform((pi_native_handle) driver);
    return 0;
}
# /opt/bin/x86_64-w64-mingw32-libgfortran5-cxx11/x86_64-w64-mingw32-clang++ -isystem /workspace/destdir/include -L/workspace/destdir/bin -shared -o mwe.dll mwe.cpp -lsycl7
ld.lld: error: undefined symbol: __declspec(dllimport) sycl::_V1::ext::oneapi::level_zero::make_platform(unsigned long long)
>>> referenced by /tmp/main-0b612a.o:(syclPlatformCreate)
clang-16: error: linker command failed with exit code 1 (use -v to see invocation)

I guess this is a name mangling issue, with MinGW using a different ABI than MSVC. Compare:

# nm /workspace/destdir/bin/sycl7.lib | grep make_platform | grep level_zero
0000000000000000 T ?make_platform@level_zero@oneapi@ext@_V1@sycl@@YA?AVplatform@45@_K@Z
0000000000000000 I __imp_?make_platform@level_zero@oneapi@ext@_V1@sycl@@YA?AVplatform@45@_K@Z

vs.

# /opt/bin/x86_64-w64-mingw32-libgfortran5-cxx11/x86_64-w64-mingw32-clang++ -isystem /workspace/destdir/include -o main.o -c main.cpp

# nm main.o | grep make_platform
                 U __imp__ZN4sycl3_V13ext6oneapi10level_zero13make_platformEy

From llvm/llvm-project#60847:

The MinGW C++ ABI is very much incompatible with the MSVC ABI, and name mangling is only a very small part of it. Making the name mangling "compatible" does not magically make them compatible.

@maleadt
Copy link
Contributor Author

maleadt commented Mar 12, 2024

Hmm, there is https://clang.llvm.org/docs/MSVCCompatibility.html, but I'm not sure how to use it. Running with -fms-compatibility breaks the sysroot's C++ headers, forcing MSVC ABI by linking clang to clang-cl doesn't seem to work, and passing --target=x86_64-pc-windows-msvc chokes on libgcc (unsupported runtime library 'libgcc' for platform 'MSVC')...

@maleadt
Copy link
Contributor Author

maleadt commented Mar 13, 2024

Not going to bother with this. Intel should provide either MinGW-compatible C++ binaries, or a C API (which IIUC is portable across MSVC/MinGW).

@maleadt maleadt closed this Mar 13, 2024
@giordano giordano deleted the tb/oneapi_support_windows branch March 13, 2024 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
oneAPI 1️⃣ Builders related to the oneAPI toolkit. Windows 🙄 Doesn't build for Windows
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant