hyprwm / hyprlock

Hyprland's GPU-accelerated screen locking utility
BSD 3-Clause "New" or "Revised" License
826 stars 57 forks source link

Fails to build with libc++ #70

Closed jbeich closed 8 months ago

jbeich commented 9 months ago

Affects FreeBSD, OpenBSD and Chimera Linux. Working around requires hyprlang (not just hyprlock) built with GCC/libstdc++.

$ export CC=clang CXX=clang++ CXXFLAGS=-stdlib=libc++
$ cmake -G Ninja -B _build
$ cmake --build _build
[...]
src/renderer/AsyncResourceGatherer.cpp:98:22: error: no viable overloaded '+='
   98 |             progress += 1.0 / (preloads + 1.0);
      |             ~~~~~~~~ ^  ~~~~~~~~~~~~~~~~~~~~~~
src/renderer/widgets/IWidget.cpp:41:44: error: no member named 'current_zone' in namespace 'std::chrono'
   41 |     const auto current_zone = std::chrono::current_zone();
      |                               ~~~~~~~~~~~~~^
Matthieu-Sauer commented 8 months ago

After looking quickly at the status of c++20 in LLVM libc++, it seems std::chrono::current_zone is not yet implemented in it. this would explain that issue there. the same function is implemented in GCC libstdc++.

MrDuartePT commented 8 months ago

I can confirm the same behaviour as @jbeich using the LLVM profile on gentoo (Clang + libc++).

Also using gcc as the compiler for hyprlock when hyprland is compilied with clang it will create a segmentation fault (using latest commit):

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7581899 in ?? () from /usr/lib64/libc.so.6
(gdb) bt -full
#0  0x00007ffff7581899 in ??? () at /usr/lib64/libc.so.6
#1  0x0000555555579ffc in ??? ()
#2  0x000055555557ae0e in ??? ()
#3  0x000055555556d600 in ??? ()
#4  0x000055555556628d in ??? ()
#5  0x00007ffff745feea in ??? () at /usr/lib64/libc.so.6
#6  0x00007ffff745ffa5 in __libc_start_main () at /usr/lib64/libc.so.6
#7  0x0000555555567191 in ??? ()

I have some info in this issue: https://github.com/hyprwm/hyprlock/issues/43

The solution for me was to compile hyprlock and hyprlang with gcc but for some reason the background image never shows up (everthing else seems to work)

Matthieu-Sauer commented 8 months ago

is gcc even compatible with libc++ @MrDuartePT ? if not, it seems to me a terrible idea to use one standard library for some package and another for other packages as the abi would not be compatible

MrDuartePT commented 8 months ago

Yes libc++ is compatible with gcc. The LLVM profile just use the LLVM toolchain as the default compiler system wide. But gcc is also present as fallback to compile program that dont work with LLVM (for exemple gnu-efi requires to be compile and link with gcc utils)

This is a quote of https://libcxx.llvm.org/ website:

ABI compatibility with gcc’s libstdc++ for some low-level features such as exception objects, rtti and memory allocation.

Matthieu-Sauer commented 8 months ago

ok ok, so I'm guessing gcc is not trying to link libstdc++ there, so the cpp std abi cannot be the issue.

MrDuartePT commented 8 months ago

Exactly