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

Unescaped linker flags when building with the Intel C++ Compiler on Windows and CMake > 3.25 #15755

Open
Maetveis opened this issue Oct 18, 2024 · 0 comments · May be fixed by #15756
Open

Unescaped linker flags when building with the Intel C++ Compiler on Windows and CMake > 3.25 #15755

Maetveis opened this issue Oct 18, 2024 · 0 comments · May be fixed by #15756
Labels
bug Something isn't working

Comments

@Maetveis
Copy link
Contributor

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

  1. 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
  1. 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 ../..
  1. 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

@Maetveis Maetveis added the bug Something isn't working label Oct 18, 2024
Maetveis added a commit to Maetveis/llvm that referenced this issue Oct 18, 2024
From CMake 3.25+ linker options need to be wrapped for ICX on Windows.
Use the `LINKER:` prefix, which expands to the correct option for ICX,
and for the empty string for MSVC or clang-cl.

See also LLVM RFC: https://discourse.llvm.org/t/rfc-cmake-linker-flags-need-wl-equivalent-for-intel-c-icx-on-windows/82446

Fixes: intel#15755
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant