Skip to content

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

@Maetveis

Description

@Maetveis

Environment Information

  • UMF version (hash commit or a tag): 27d2ce8
  • OS(es) version(s): Windows Server 2022 (10.0.20348 Build 20348)
  • compiler, libraries, and other related tools version(s): CMake 3.28.2 (versions >= 3.25 should be affected)

Please provide a reproduction of the bug:

cmake.exe -DCMAKE_CXX_COMPILER=icx -DCMAKE_C_COMPILER=icx -S . -B build -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" -DCMAKE_BUILD_TYPE=Debug -G Ninja -DUMF_DISABLE_HWLOC=ON
cmake --build build

How often bug is revealed:

always

Actual behavior:

Building fails with the following errors.

[57/65] Linking CXX executable test\umf_test-memoryProvider.exe
FAILED: test/umf_test-memoryProvider.exe
C:\WINDOWS\system32\cmd.exe /C "cd . && cmake.exe -E vs_link_exe --intdir=test\CMakeFiles\umf_test-memoryProvider.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 test\CMakeFiles\umf_test-memoryProvider.dir\memoryProviderAPI.cpp.obj  -Werror=unknown-argument /Qoption,link,/machine:x64 /Qoption,link,/debug /Qoption,link,/INCREMENTAL /Qoption,link,/subsystem:console  /ALLOWISOLATION /DYNAMICBASE /HIGHENTROPYVA /NXCOMPAT  lib\umf_test_common.lib  lib\gtest_main.lib  lib\umf.lib  lib\gtest.lib  kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /link /out:test\umf_test-memoryProvider.exe /implib:lib\umf_test-memoryProvider.lib /pdb:test\umf_test-memoryProvider.pdb /version:0.0 && cd ."
LINK: command "icx.exe /nologo test\CMakeFiles\umf_test-memoryProvider.dir\memoryProviderAPI.cpp.obj -Werror=unknown-argument /Qoption,link,/machine:x64 /Qoption,link,/debug /Qoption,link,/INCREMENTAL /Qoption,link,/subsystem:console /ALLOWISOLATION /DYNAMICBASE /HIGHENTROPYVA /NXCOMPAT lib\umf_test_common.lib lib\gtest_main.lib lib\umf.lib lib\gtest.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /link /out:test\umf_test-memoryProvider.exe /implib:lib\umf_test-memoryProvider.lib /pdb:test\umf_test-memoryProvider.pdb /version:0.0 /MANIFEST:EMBED,ID=1" failed (exit code 1) with the following output:
icx: error: unknown argument ignored in clang-cl: '-ALLOWISOLATION' [-Werror,-Wunknown-argument]
icx: error: unknown argument ignored in clang-cl: '-HIGHENTROPYVA' [-Werror,-Wunknown-argument]
icx: error: unknown argument ignored in clang-cl: '-NXCOMPAT' [-Werror,-Wunknown-argument]

Expected behavior:

Build succeeds without errors.

Details

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 onknown flags.

Additional information about Priority and Help Requested:

Are you willing to submit a pull request with a proposed change? Yes

Requested priority: High

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions