Closed
Description
Describe the bug
From CMake 3.25 onwards when using the Intel C++ Compiler linking flags need to be wrapped with LINKER: or /Qoption,link because CMake uses the compiler driver for linking.
If the options are not wrapped they are ignored by icx with a warning. In the reproducer I set the linker to error on unknown flags.
To reproduce
- Apply the LLVM patches (these fix similar errors in the upstream code):
[LLVM][CMake][MSVC] Wrap linker flags for ICX on Windows llvm/llvm-project#112680
[clang-repl][CMake][MSVC] Wrap /EXPORT linker option for ICX llvm/llvm-project#112867
Invoke-WebRequest https://github.com/llvm/llvm-project/pull/112680.patch | Set-Content -Encoding UTF8 pull-112680.patch
Invoke-WebRequest https://github.com/llvm/llvm-project/pull/112867.patch | Set-Content -Encoding UTF8 pull-112867.patch
git apply pull-112680.patch pull-112867.patch
- Download and apply the patch to unified-runtime:
Wrap linker flags on Windows for IntelLLLVM oneapi-src/unified-runtime#2179
cd sycl
git clone https://github.com/oneapi-src/unified-runtime.git
cd unified-runtime
Invoke-WebRequest https://github.com/oneapi-src/unified-runtime/pull/2179.patch | Set-Content -Encoding UTF8 pull-2179.patch
git apply pull-2179.patch
cd ../..
- Compile and Build
python buildbot\configure.py `
--cmake-opt=-DCMAKE_EXE_LINKER_FLAGS_INIT=-Werror=unknown-argument `
--cmake-opt=-DCMAKE_SHARED_LINKER_FLAGS_INIT=-Werror=unknown-argument `
--cmake-opt=-DCMAKE_MODULE_LINKER_FLAGS_INIT=-Werror=unknown-argument `
--cmake-opt=-DCMAKE_STATIC_LINKER_FLAGS_INIT=-Werror=unknown-argument `
--cmake-opt=-DSYCL_UR_USE_FETCH_CONTENT=OFF `
--cmake-opt=-DUMF_TAG=e6ff45e1636bd172117bab6d9f4d00638113f592 `
--cmake-opt=-DUMF_DISABLE_HWLOC=ON
python buildbot\compile.py
Expected:
Compilation succeeds without any errors.
Observed:
Compilation fails with errors like:
[3737/3893] Linking CXX shared library bin\sycl8d.dll
FAILED: bin/sycl8d.dll lib/sycl8d.lib
C:\WINDOWS\system32\cmd.exe /C "cd . && cmake.exe -E vs_link_dll --intdir=tools\sycl\source\CMakeFiles\sycl8d.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100220~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100220~1.0\x64\mt.exe --manifests -- icx.exe /nologo @CMakeFiles\sycl8d.rsp -LD -Werror=unknown-argument /Qoption,link,/machine:x64 /Qoption,link,/INCREMENTAL:NO /DEBUG /OPT:REF /OPT:ICF /DEPENDENTLOADFLAG:0x2000 /MANIFEST:NO /MANIFEST:EMBED /MANIFESTINPUT:<workspace>/sycl/source/sycld.manifest -link /out:bin\sycl8d.dll /implib:lib\sycl8d.lib /pdb:bin\sycl8d.pdb /version:8.0 && C:\WINDOWS\system32\cmd.exe /C "cd /D <workspace>\build\tools\sycl\source && cmake.exe -E copy <workspace>/build/./lib/sycl8d.lib <workspace>/llvm/build/./lib/sycld.lib""
LINK: command "icx.exe /nologo @CMakeFiles\sycl8d.rsp -LD -Werror=unknown-argument /Qoption,link,/machine:x64 /Qoption,link,/INCREMENTAL:NO /DEBUG /OPT:REF /OPT:ICF /DEPENDENTLOADFLAG:0x2000 /MANIFEST:NO /MANIFEST:EMBED /MANIFESTINPUT:<workspace>/sycl/source/sycld.manifest -link /out:bin\sycl8d.dll /implib:lib\sycl8d.lib /pdb:bin\sycl8d.pdb /version:8.0" failed (exit code 1) with the following output:
icx: error: unknown argument ignored in clang-cl: '-MANIFEST:NO' [-Werror,-Wunknown-argument]
icx: error: unknown argument ignored in clang-cl: '-MANIFEST:EMBED' [-Werror,-Wunknown-argument]
icx: error: unknown argument ignored in clang-cl: '-MANIFESTINPUT:<workspace>/sycl/source/sycld.manifest' [-Werror,-Wunknown-argument]
Environment
- CMake Version: 3.29.2
- OS: Windows Server 2022
- Target device and vendor: Not Relevant
- DPC++ version: 2024.2
- Dependencies version: Not Relevant
Additional context
No response