Skip to content

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

@Maetveis

Description

@Maetveis

Description

Building with icx on Windows with CMake 3.25 fails, because CMake requires the linker flags to be wrapped for this compiler since CMake 3.25.

Steps to reproduce

  1. Setup the workspace and clone the project & dependencies as described at in-tree build as described in the README
  2. Setup the environment for using icx: https://www.intel.com/content/www/us/en/docs/oneapi/programming-guide/2024-2/use-the-setvars-script-with-windows.html
  3. Apply llvm.patch to LLVM. The LLVM changes to fix this issue in LLVM are not yet upstreamed.
  4. Configure turning linker warnings into errors to see the problem easier:
cmake_3_35/bin/cmake -S <workspace>\llvm -B build -G Ninja ^
-DLLVM_TARGETS_TO_BUILD="X86" ^
-DLLVM_ENABLE_PROJECTS="clang" ^
-DLLVM_EXTERNAL_PROJECTS="llvm-spirv;opencl-clang" ^
-DLLVM_EXTERNAL_OPENCL_CLANG_SOURCE_DIR:PATH="<workspace>\opencl-clang" ^
-DLLVM_EXTERNAL_LLVM_SPIRV_SOURCE_DIR:PATH="<workspace>\SPIRV-LLVM-Translator" ^
-DCMAKE_BUILD_TYPE=Release ^
-DCMAKE_EXE_LINKER_FLAGS_INIT=-Werror=unknown-argument ^
-DCMAKE_SHARED_LINKER_FLAGS_INIT=-Werror=unknown-argument ^
-DCMAKE_MODULE_LINKER_FLAGS_INIT=-Werror=unknown-argument ^
-DCMAKE_STATIC_LINKER_FLAGS_INIT=-Werror=unknown-argument
  1. Build: cmake_3_25/bin/cmake.exe --build build

Observed behaviour

The build fails with the error:

[3283/3283] Linking CXX shared library bin\opencl-clang64.dll
FAILED: bin/opencl-clang64.dll lib/opencl-clang64.lib
C:\WINDOWS\system32\cmd.exe /C "cd . && cmake_3_25\bin\cmake.exe -E vs_link_dll --intdir=tools\opencl-clang\CMakeFiles\opencl-clang64.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\opencl-clang64.rsp  -LD -Werror=unknown-argument /Qoption,link,/machine:x64 /Qoption,link,/INCREMENTAL:NO /DYNAMICBASE /GUARD:CF  /DEBUG /PDBSTRIPPED:<workdir>\opencl-clang\build\.\bin\.\opencl-clang64_stripped.pdb -link /out:bin\opencl-clang64.dll /implib:lib\opencl-clang64.lib /pdb:bin\opencl-clang64.pdb /version:0.0 && cd ."
LINK: command "icx.exe /nologo @CMakeFiles\opencl-clang64.rsp -LD -Werror=unknown-argument /Qoption,link,/machine:x64 /Qoption,link,/INCREMENTAL:NO /DYNAMICBASE /GUARD:CF /DEBUG /PDBSTRIPPED:<workspace>\opencl-clang\build\.\bin\.\opencl-clang64_stripped.pdb -link /out:bin\opencl-clang64.dll /implib:lib\opencl-clang64.lib /pdb:bin\opencl-clang64.pdb /version:0.0 /MANIFEST:EMBED,ID=2" failed (exit code 1) with the following output:
icx: error: unknown argument ignored in clang-cl: '-PDBSTRIPPED:<workspace>\opencl-clang\build\.\bin\.\opencl-clang64_stripped.pdb' [-Werror,-Wunknown-argument]
ninja: build stopped: subcommand failed.

Expected behaviour

Build completes without any errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions