abseil / abseil/abseil-cpp

[Bug]: CMake build not working on MSYS/MINGW64

Open
#1,377 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
C++
Stars
18.1k
Forks
3.2k
Avg merge
20h 36m
Merged PRs (30d)
1

Description

### Describe the issue

When incorporating absl::base into a CMake-based project built on MSYS/MINGW64 you get a dependency to `librt`.

AFAIU abseil CMake finds the msys cygwin-based librt, not the native one that MINGW toolchain would require. The `find_library` call yields a `/usr/lib/librt.a` while the native part lives under `/mingw64`. Of course librt does not exist on windows devices, and while it could make sense to have it in CYGWIN builds (don't know, I don't use it), it definitely does not do the job on MINGW64.

[Apparently other people have run into this](https://github.com/YosysHQ/nextpnr/issues/666).

Platform: windows 10, msys2, g++ 12.2.0, cmake 3.24.3

### Steps to reproduce the problem

Build an hello-world example linking absl::base on the platform:
windows 10, msys2, g++ 12.2.0, cmake 3.24.3

### What version of Abseil are you using?

tag: 20220623.0
commit: 273292d1cfc0a94a65082ee350509af1d113344d

### What operating system and version are you using?

Windows 10 19043.1237

### What compiler and version are you using?

Using built-in specs.
COLLECT_GCC=C:\msys64\mingw64\bin\gcc.exe
COLLECT_LTO_WRAPPER=C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../gcc-12.2.0/configure --prefix=/mingw64 --with-local-prefix=/mingw64/local --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --with-native-system-header-dir=/mingw64/include --libexecdir=/mingw64/lib --enable-bootstrap --enable-checking=release --with-arch=x86-64 --with-tune=generic --enable-languages=c,lto,c++,fortran,ada,objc,obj-c++,jit --enable-shared --enable-static --enable-libatomic --enable-threads=posix --enable-graphite --enable-fully-dynamic-string --enable-libstdcxx-filesystem-ts --enable-libstdcxx-time --disable-libstdcxx-pch --enable-lto --enable-libgomp --disable-multilib --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-libiconv --with-system-zlib --with-gmp=/mingw64 --with-mpfr=/mingw64 --with-mpc=/mingw64 --with-isl=/mingw64 --with-pkgversion='Rev6, Built by MSYS2 project' --with-bugurl=https://github.com/msys2/MINGW-packages/issues --with-gnu-as --with-gnu-ld --disable-libstdcxx-debug --with-boot-ldflags=-static-libstdc++ --with-stage1-ldflags=-static-libstdc++
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.2.0 (Rev6, Built by MSYS2 project)

### What build system are you using?

cmake version 3.24.3

### Additional context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.