msys2 / MINGW-packages

Package scripts for MinGW-w64 targets to build under MSYS2.
https://packages.msys2.org
BSD 3-Clause "New" or "Revised" License
2.29k stars 1.22k forks source link

clang++ link asbl lib failed #21904

Open WittonBell opened 2 months ago

WittonBell commented 2 months ago

Description / Steps to reproduce the issue

  1. create main.cpp:
    
    #include <absl/log/log.h>

int main(int, char**){ LOG(INFO) << (unsigned long long)1; }

2. create `CMakeLists.txt":
```txt
cmake_minimum_required(VERSION 3.5.0)
project(t VERSION 0.1.0 LANGUAGES C CXX)

find_package(absl REQUIRED)
add_executable(t main.cpp)
target_link_libraries(t PUBLIC absl_log_internal_message)
  1. run cmake -DCMAKE_CXX_COMPILER=clang++ . in mingw64 terminal
  2. run cmake --build . it report:
    ld: CMakeFiles/t.dir/main.cpp.obj:main.cpp:(.text$_ZN4absl12lts_2024072212log_internal10LogMessagelsEy[_ZN4absl12lts_2024072212log_internal10LogMessagelsEy]+0x19): undefined reference to `_ZN4absl12lts_2024072212log_internal10LogMessagelsIyTnNSt9ena
    ble_ifIXntsr4absl16HasAbslStringifyIT_EE5valueEiE4typeELi0EEERS2_RKS5_

btw: use g++ build success.

Expected behavior

build success.

Actual behavior

build failed

Verification

Windows Version

MINGW64_NT-10.0-19045

MINGW environments affected

Are you willing to submit a PR?

No response

Biswa96 commented 2 months ago

If I use clang++ in clang64 environment the program compiles fine. Probably, there are some difference in abseil-cpp package in gcc and clang based environment.

oltolm commented 2 months ago

You can also try adding -fuse-ld=lld to link options and -stdlib=libc++ to compile options.

WittonBell commented 2 months ago

You can also try adding -fuse-ld=lld to link options and -stdlib=libc++ to compile options.

@oltolm It does not take effect, also has the issue.

oltolm commented 2 months ago

Then the mingw64 version is not binary compatible with clang and you should use the clang64 environment like Biswa96 said.