Skip to content

Building 1.5.4 with clang-cl and lld-link fails because faulty linker checks in CMake. #3522

@tru

Description

@tru

Describe the bug

Build 1.5.4 with clang-cl/lld-link on Windows with CMake you get this:

11:19:41 lld-link: warning : ignoring unknown argument '-z'
11:19:41 lld-link: error : could not open 'noexecstack': no such file or directory

To Reproduce

cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl -DCMAKE_LINKER=lld-link ..\build\cmake && ninja

Expected behavior
The problem is the check here:
https://github.com/facebook/zstd/blob/dev/build/cmake/CMakeModules/AddZstdCompilationFlags.cmake#L74

This is in the block for Clang, but checks linker flags by calling the compiler. On Windows the compiler is not used as the linker like on Unix systems.

It needs to be a check around this to correctly detect lld-link or re-tool the linker checks to use CMAKE_LINKER instead to perform these checks.

Screenshots and charts
n/a

Desktop (please complete the following information):

  • OS: Windows 11
  • Compiler: Clang-cl 15.0.7
  • Build system: CMake

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions