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

Can't link to MSVC built abseil with clang/LLVM #1712

Open
kotten73 opened this issue Jul 12, 2024 · 1 comment
Open

Can't link to MSVC built abseil with clang/LLVM #1712

kotten73 opened this issue Jul 12, 2024 · 1 comment

Comments

@kotten73
Copy link

kotten73 commented Jul 12, 2024

Observation

When abseil is build with MSVC it generates CMake targets with the property INTERFACE_LINK_LIBRARIES set with flags not compatible with clang/LLVM, -ignore:4221. This makes it impossible to link to the MSVC built abseil library with a program built with clang/LLVM.

For example see the generated file abslTargets.cmake:

set_target_properties(absl::atomic_hook PROPERTIES
  INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
  INTERFACE_LINK_LIBRARIES "absl::config;absl::core_headers;-ignore:4221"
)

Expected behavior

It should be possible to link a clang/LLVM built binary with a MSVC built abseil library.

Steps to reproduce the problem

I have created a GitHub repo for the purpose of reproducing this, https://github.com/kotten73/abseil_repro .

Prerequisites

  • Windows build environment with the following installed:
    • Visual Sudio and LLVM installed. My current LLVM version is 17.0.6 and MSVC version is 19.38.33134 but this is most probably reproducable with the latest versions of these tools.
    • CMake
    • Ninja

How to Reproduce

This example is using abseil from VCPKG where VCPKG will build the libraries with MSVC and the example is explicitly built with clang/LLVM.
Make sure to clear your VCPKG cache first.

Steps to reproduce:

git clone https://github.com/kotten73/abseil_repro
cd abseil_repro
mkdir build
cd build
cmake -G "Ninja" .. -DCMAKE_C_COMPILER="clang" -DCMAKE_CXX_COMPILER="clang++" -DCMAKE_RC_COMPILER="llvm-rc"
ninja

The error I get is:

D:\Projects\abseil_repro\build [main ≡ +1 ~0 -0 !]> ninja
[2/2] Linking CXX executable abseil_repro.exe
FAILED: abseil_repro.exe
C:\WINDOWS\system32\cmd.exe /C "cd . && C:\Users\maka\scoop\apps\llvm\current\bin\clang++.exe -nostartfiles -nostdlib -O0 -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd -g -Xclang -gcodeview -Xlinker /subsystem:console  -fuse-ld=lld-link CMakeFiles/abseil_repro.dir/src/main.cpp.obj -o abseil_repro.exe -Xlinker /MANIFEST:EMBED -Xlinker /implib:abseil_repro.lib -Xlinker /pdb:abseil_repro.pdb -Xlinker /version:0.0   vcpkg_installed/x64-windows-static/debug/lib/absl_bad_any_cast_impl.lib  vcpkg_installed/x64-windows-static/debug/lib/absl_raw_logging_internal.lib  vcpkg_installed/x64-windows-static/debug/lib/absl_log_severity.lib  -ignore:4221  -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 -loldnames  && C:\WINDOWS\system32\cmd.exe /C "cd /D D:\Projects\abseil_repro\build && "C:\Program Files\PowerShell\7\pwsh.exe" -noprofile -executionpolicy Bypass -file D:/Projects/vcpkg/scripts/buildsystems/msbuild/applocal.ps1 -targetBinary D:/Projects/abseil_repro/build/abseil_repro.exe -installedDir D:/Projects/abseil_repro/build/vcpkg_installed/x64-windows-static/debug/bin -OutVariable out""
clang++: error: unknown argument: '-ignore:4221'
ninja: build stopped: subcommand failed.

What version of Abseil are you using?

074a32a

What operating system and version are you using?

Windows 11

What compiler and version are you using?

LLVM version is 17.0.6 and MSVC version is 19.38.33134

What build system are you using?

cmake version 3.29.5
ninja version 1.12.1

Additional context

No response

@Chrys4lisfag
Copy link

Same here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants