Hyprland icon indicating copy to clipboard operation
Hyprland copied to clipboard

Build fails with clang/llvm

Open JohnRTitor opened this issue 1 year ago • 9 comments

Regression?

Yes

System Info and Version

System/Version info

NixOS 24.11, but irrelevant

Description

Build fails with Clang. Happens on Clang 18, 19.

How to reproduce

Compile Hyprland on NixOS with clang.

On nix, you can just override stdenv, set pkgs.clangStdenv or pkgs.llvmPackages.stdenv.

Crash reports, logs, images, videos

@nix { "action": "setPhase", "phase": "configurePhase" }
fixing cmake files...
cmake flags: -GNinja -DCMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY=OFF -DCMAKE_FIND_USE_PACKAGE_REGISTRY=OFF -DCMAKE_EXPORT_NO_PACKAGE>
-- The C compiler identification is Clang 19.1.0
-- The CXX compiler identification is Clang 19.1.0
-- Detecting C compiler ABI info
...skipping...
[53/247] Building CXX object CMakeFiles/Hyprland.dir/cmake_pch.hxx.pch
[54/247] Building CXX object CMakeFiles/Hyprland.dir/src/debug/Log.cpp.o
FAILED: CMakeFiles/Hyprland.dir/src/debug/Log.cpp.o 
/nix/store/rjsfx6sxjpkgd4f9hl9apm0n8dk7jd9w-clang-wrapper-19.1.0-rc2/bin/clang++ -DDATAROOTDIR=\"/nix/store/srlw63sjjl2xirnlv9qxn>
/build/source/src/debug/Log.cpp:13:26: error: no member named 'native_handle' in 'std::basic_ofstream<char>'
   13 |     auto handle = logOfs.native_handle();
      |                   ~~~~~~ ^
1 error generated.
[55/247] Building CXX object hyprpm/CMakeFiles/hyprpm.dir/src/core/DataState.cpp.o
[56/247] Building CXX object hyprctl/CMakeFiles/hyprctl.dir/main.cpp.o
[57/247] Building CXX object hyprpm/CMakeFiles/hyprpm.dir/src/core/PluginManager.cpp.o
[58/247] Building CXX object CMakeFiles/Hyprland.dir/src/debug/HyprNotificationOverlay.cpp.o
[59/247] Building CXX object CMakeFiles/Hyprland.dir/src/debug/CrashReporter.cpp.o
/build/source/src/debug/CrashReporter.cpp:126:26: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extensi>
  126 |         CPlugin* plugins[count];
      |                          ^~~~~
/build/source/src/debug/CrashReporter.cpp:126:26: note: read of non-const variable 'count' is not allowed in a constant expression
/build/source/src/debug/CrashReporter.cpp:125:18: note: declared here
  125 |         size_t   count = g_pPluginSystem->pluginCount();
      |                  ^
1 warning generated.
[60/247] Building CXX object CMakeFiles/Hyprland.dir/src/debug/HyprDebugOverlay.cpp.o
[61/247] Building CXX object CMakeFiles/Hyprland.dir/src/desktop/Popup.cpp.o
[62/247] Building CXX object CMakeFiles/Hyprland.dir/src/desktop/LayerSurface.cpp.o
[63/247] Building CXX object CMakeFiles/Hyprland.dir/src/debug/HyprCtl.cpp.o
[64/247] Building CXX object CMakeFiles/Hyprland.dir/src/Compositor.cpp.o
[65/247] Building CXX object CMakeFiles/Hyprland.dir/src/config/ConfigManager.cpp.o
ninja: build stopped: subcommand failed.

JohnRTitor avatar Aug 25 '24 16:08 JohnRTitor

CC @fufexan

JohnRTitor avatar Aug 25 '24 16:08 JohnRTitor

sounds like std version is not propagating properly

vaxerski avatar Aug 25 '24 17:08 vaxerski

@JohnRTitor can you pull again and check the logs for any occurrence of -std=c++26?

fufexan avatar Aug 26 '24 19:08 fufexan

FYI:

I guess Clang is using the Libcxx provided by GCC, instead of the one from LLVM...

This should be a platform-specific issue. I had the same issue before in Gentoo. Changing the USE flag of clang-runtime fixed this issue:

➤ ~/.dot-files/shell/.zshrc.d [master] $ equery u clang-runtime
[ Legend : U - final flag setting for installation]
[        : I - package is installed with flag     ]
[ Colors : set, unset                             ]
 * Found these USE flags for sys-devel/clang-runtime-18.1.8:
 U I
 + + abi_x86_32  : 32-bit (x86) libraries
 + + compiler-rt : Install sys-libs/compiler-rt for -rtlib=compiler-rt
 + + libcxx      : Install sys-libs/libcxx for -stdlib=libc++
 + + openmp      : Install sys-libs/libomp for -fopenmp support
 + + sanitize    : Enable compiler-rt sanitizer (-fsanitize*) support

yangyingchao avatar Aug 27 '24 07:08 yangyingchao

should this be closed then...?

vaxerski avatar Aug 27 '24 18:08 vaxerski

I can build it with a ton of warnings, but it builds fine. clangBuild.log

It seems @yangyingchao is correct. His standard lib is messed up.

Vax any specific reason why hyperpm still has set(CMAKE_CXX_STANDARD 23)?

romanstingler avatar Aug 27 '24 18:08 romanstingler

should this be closed then...?

I think so.

yangyingchao avatar Aug 27 '24 22:08 yangyingchao

@JohnRTitor can you pull again and check the logs for any occurrence of -std=c++26?

❯  nix log /nix/store/qs5bzckc4r2blibl668xw1nyf90vclxc-hyprland-0.42.0+date=2024-08-27_17ed4fc.drv | grep c++26
warning: The interpretation of store paths arguments ending in `.drv` recently changed. If this command is now failing try again with '/nix/store/qs5bzckc4r2blibl668xw1nyf90vclxc-hyprland-0.42.0+date=2024-08-27_17ed4fc.drv^*'
/nix/store/k4l2mg07nyd7flfkxgbz63j63hnwfvnw-clang-wrapper-18.1.8/bin/clang++ -DDATAROOTDIR=\"/nix/store/lf87khzkc5nq088ngzc1vckc7g74cfwp-hyprland-0.42.0+date=2024-08-27_17ed4fc/share\" -DHAS_EXECINFO -DHyprland_EXPORTS -DUSES_SYSTEMD -I/build/source/. -I/build/source/src -I/build/source/subprojects/udis86 -I/build/source/protocols -I/build/source/subprojects/udis86/libudis86 -isystem /nix/store/3v10x1zfcd17wlkd87rl1q8gk3d878vw-cairo-1.18.0-dev/include/cairo -isystem /nix/store/sa2vr5rkh19pvy9j4hkb4lk95nlhqpix-glib-2.80.4-dev/include/glib-2.0 -isystem /nix/store/7lr9qdizm42pf6clysg7syrky0si8aab-glib-2.80.4/lib/glib-2.0/include -isystem /nix/store/7c6z1pgh5s0sxc8i75qdm1qs02ihmh7j-libdrm-2.4.122-dev/include/libdrm -isystem /nix/store/b9609cffnpms4vqsyxa0f1ixc7prffdp-util-linux-minimal-2.39.4-dev/include/uuid -isystem /nix/store/f6a81f3wnj3xrr06x0yydz6q5z5h81rw-pango-1.52.2-dev/include/pango-1.0 -isystem /nix/store/72ddhqsm72lbzdv1izi97fdxbc7215i8-harfbuzz-9.0.0-dev/include/harfbuzz -O2 -g -DNDEBUG -std=gnu++26 -O3 -std=c++26 -Wall -Wextra -Wno-unused-parameter -Wno-unused-value -Wno-missing-field-initializers -Wno-narrowing -Wno-pointer-arith -fmacro-prefix-map=/build/source/= -Winvalid-pch -Xclang -include-pch -Xclang /build/source/build/CMakeFiles/Hyprland.dir/cmake_pch.hxx.pch -Xclang -include -Xclang /build/source/build/CMakeFiles/Hyprland.dir/cmake_pch.hxx -MD -MT CMakeFiles/Hyprland.dir/src/debug/Log.cpp.o -MF CMakeFiles/Hyprland.dir/src/debug/Log.cpp.o.d -o CMakeFiles/Hyprland.dir/src/debug/Log.cpp.o -c /build/source/src/debug/Log.cpp

JohnRTitor avatar Aug 28 '24 07:08 JohnRTitor

Vax any specific reason why hyperpm still has set(CMAKE_CXX_STANDARD 23)?

I just haven't changed it and hyprpm doesn't need 26 unlike hyprland

vaxerski avatar Aug 28 '24 11:08 vaxerski

@JohnRTitor can you pull again and check the logs for any occurrence of -std=c++26?

❯  nix log /nix/store/qs5bzckc4r2blibl668xw1nyf90vclxc-hyprland-0.42.0+date=2024-08-27_17ed4fc.drv | grep c++26
warning: The interpretation of store paths arguments ending in `.drv` recently changed. If this command is now failing try again with '/nix/store/qs5bzckc4r2blibl668xw1nyf90vclxc-hyprland-0.42.0+date=2024-08-27_17ed4fc.drv^*'
/nix/store/k4l2mg07nyd7flfkxgbz63j63hnwfvnw-clang-wrapper-18.1.8/bin/clang++ -DDATAROOTDIR=\"/nix/store/lf87khzkc5nq088ngzc1vckc7g74cfwp-hyprland-0.42.0+date=2024-08-27_17ed4fc/share\" -DHAS_EXECINFO -DHyprland_EXPORTS -DUSES_SYSTEMD -I/build/source/. -I/build/source/src -I/build/source/subprojects/udis86 -I/build/source/protocols -I/build/source/subprojects/udis86/libudis86 -isystem /nix/store/3v10x1zfcd17wlkd87rl1q8gk3d878vw-cairo-1.18.0-dev/include/cairo -isystem /nix/store/sa2vr5rkh19pvy9j4hkb4lk95nlhqpix-glib-2.80.4-dev/include/glib-2.0 -isystem /nix/store/7lr9qdizm42pf6clysg7syrky0si8aab-glib-2.80.4/lib/glib-2.0/include -isystem /nix/store/7c6z1pgh5s0sxc8i75qdm1qs02ihmh7j-libdrm-2.4.122-dev/include/libdrm -isystem /nix/store/b9609cffnpms4vqsyxa0f1ixc7prffdp-util-linux-minimal-2.39.4-dev/include/uuid -isystem /nix/store/f6a81f3wnj3xrr06x0yydz6q5z5h81rw-pango-1.52.2-dev/include/pango-1.0 -isystem /nix/store/72ddhqsm72lbzdv1izi97fdxbc7215i8-harfbuzz-9.0.0-dev/include/harfbuzz -O2 -g -DNDEBUG -std=gnu++26 -O3 -std=c++26 -Wall -Wextra -Wno-unused-parameter -Wno-unused-value -Wno-missing-field-initializers -Wno-narrowing -Wno-pointer-arith -fmacro-prefix-map=/build/source/= -Winvalid-pch -Xclang -include-pch -Xclang /build/source/build/CMakeFiles/Hyprland.dir/cmake_pch.hxx.pch -Xclang -include -Xclang /build/source/build/CMakeFiles/Hyprland.dir/cmake_pch.hxx -MD -MT CMakeFiles/Hyprland.dir/src/debug/Log.cpp.o -MF CMakeFiles/Hyprland.dir/src/debug/Log.cpp.o.d -o CMakeFiles/Hyprland.dir/src/debug/Log.cpp.o -c /build/source/src/debug/Log.cpp

So it looks like CMake is finally passing a good flag (-std=gnu++26). Could you try removing the patch from the derivation and checking if it builds?

fufexan avatar Aug 29 '24 13:08 fufexan

This is that nixos moment. I still haven't figured out how I can make sure wrappers aren't appending -std=gnu++23 in the dev shell. Works fine with nix build .\?submodules=1#hyprland-debug, but not with using cmake in the dev shell. But the nix build variant denies me incremental builds, so if someone has a solution for me please let me know <3.

Edit: I missed ./nix/stdcxx.patch using that fixes it :)

PaideiaDilemma avatar Sep 01 '24 12:09 PaideiaDilemma

This was caused by #7219, src/debug/Log.cpp needs native_handle which isn't implemented until C++26. If we replace std::ofstream with just int and use open, write, and other POSIX methods for fd's then we can change the stdlib requirement back to C++23.

This is probably the best option since many distro's will likely not support C++26 for quite some time. Being one of the maintainers for LLVM in Nixpkgs, I can't guarantee that we will actually support C++26 with LLVM in Nixpkgs.

RossComputerGuy avatar Sep 10 '24 03:09 RossComputerGuy

I guess C++26 might not be ready for widespread adoption for lots of distors in several years...

So I'm afraid that this might block some people from upgrading to 0.43...

yangyingchao avatar Sep 10 '24 09:09 yangyingchao

cmake dep bumped, so this can be closed. clang and gcc will build hyprland provided they are up to date (and so is cmake)

vaxerski avatar Sep 10 '24 14:09 vaxerski

I guess C++26 might not be ready for widespread adoption for lots of distors in several years...

Spec won't be finalized until January 2026 (https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p1000r6.pdf). This means that the earliest which LLVM could implement support is July 2026. That is essentially two years from now.

clang and gcc will build hyprland provided they are up to date (and so is cmake)

That's for Nix, what should other distros do that don't have a new enough LLVM or GCC. Should everyone just compile the compiler just for this one package?

RossComputerGuy avatar Sep 10 '24 14:09 RossComputerGuy

Spec won't be finalized until January 2026 (https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p1000r6.pdf). This means that the earliest which LLVM could implement support is July 2026. That is essentially two years from now.

This is plain wrong.

what should other distros do that don't have a new enough LLVM or GCC

update their llvm/gcc before updating hyprland.

vaxerski avatar Sep 10 '24 15:09 vaxerski

This is plain wrong.

2026.1 – tbd CD ballot comment resolution C++26 technically finalized, start DIS ballot

RossComputerGuy avatar Sep 10 '24 15:09 RossComputerGuy

No, the wrong part is "This means that the earliest which LLVM could implement support is July 2026"

Easily disproven by the fact clang18 supports the C++26 method we use.

vaxerski avatar Sep 10 '24 18:09 vaxerski

Easily disproven by the fact clang18 supports the C++26 method we use.

That is true however, not everyone is going to use the same C++ implementation. Most people do use libstdc++ and libc++ but not everyone might not. Plus versions which aren't finalized are not stable. Using a non stable version is a concern of mine because of possible side effects which could cause unwanted behavior during runtime.

Another concern is people might not want to mix compiler versions, especially if it's an unstable version.

RossComputerGuy avatar Sep 10 '24 19:09 RossComputerGuy

once a paper is approved for C++26, it's approved. It won't be "un-approved".

vaxerski avatar Sep 10 '24 19:09 vaxerski

This is still an issue by the way @fufexan

Tried to nix-build but failing to build the drv?

❯  nix-build b08dk0zmaxyi73z4m1gb201h7lznql5c-hyprland-0.43.0+date=2024-09-10_155d440.drv
error: syntax error, expecting ')'
       at /home/masum/b08dk0zmaxyi73z4m1gb201h7lznql5c-hyprland-0.43.0+date=2024-09-10_155d440.drv:1:15:
            1| Derive([("dev","/nix/store/3w2620zjd9ndafblf11i59bfib01fapy-hyprland-0.43.0+date=2024-09-10_155d440-dev","",""),("man","/nix/store/6pcid89czq1dvmyd7s7d9887li5zfcgc-hyprland-0.43.0+date=2024-09-10_155d440-man","",""),("out","/nix/store/xv7gmh12ir7xxgippq9y8pigm9j22pal-hyprland-0.43.0+date=2024-09-10_155d440","","")],[("/

(vaxry: just use rust ;)

JohnRTitor avatar Sep 11 '24 12:09 JohnRTitor

@JohnRTitor clang18Stdenv is not configured to use the correct stdlib from what I've seen, and it has to be forced. We could add a patch for it and enable it only for clang builds (which means we will introduce separate *-clang packages). Here's a command that worked for me for a simple test of using std::basic_ofstream<char>'s native_handle:

$ c++ -std=c++26 -stdlib=libc++ -nostdinc++ -I /nix/store/c55xcry32njvs6q3b40qnsw283c4jdx2-libcxx-18.1.8-dev/include/c++/v1 -L /nix/store/pfdygjng4hdnwmnll4qmxnycxkkbbwla-libcxx-18.1.8/lib -Wl,-rpath,/nix/store/pfdygjng4hdnwmnll4qmxnycxkkbbwla-libcxx-18.1.8/lib native_handle_test.cpp

I got the syntax above from https://stackoverflow.com/a/65004156.

fufexan avatar Sep 11 '24 13:09 fufexan

clang18Stdenv is not configured to use the correct stdlib from what I've seen

If we could patch on the nixpkgs side, that would be great, this likely affects other packages as well.

which means we will introduce separate *-clang packages

I am not sure if there's a need to introduce seperate packages.

JohnRTitor avatar Sep 11 '24 13:09 JohnRTitor

clang18Stdenv is not configured to use the correct stdlib from what I've seen, and it has to be forced.

That is kinda true, it's designed to use the main stdenv's C++ implement. You'll have to override it to use libc++ if you want to use that.

RossComputerGuy avatar Sep 11 '24 14:09 RossComputerGuy

Looks like libcxxStdenv almost does the trick, except I get a few linking failures.

hyprland> [233/250] Linking CXX executable hyprctl/hyprctl
hyprland> FAILED: hyprctl/hyprctl
hyprland> : && /nix/store/4wphwqdc7jz18nl9z2sda5ryafl4fm1y-clang-wrapper-18.1.8/bin/clang++ -O2 -g -DNDEBUG -Wl,--export-dynamic -rdynamic hyprctl/CMakeFiles/hyprctl.dir/main.cpp.o -o hyprctl/hyprctl  /nix/store/gf5bjfck5c7sl4mdkbw8qawb3vw5xmyl-hyprutils-0.2.1+date=2024-08-29_8976e3f/lib/libhyprutils.so && :
hyprland> /nix/store/d828ccvc2148g7m49hh3mzvyzwpipy46-binutils-2.42/bin/ld: hyprctl/CMakeFiles/hyprctl.dir/main.cpp.o: in function `main':
hyprland> /build/source/hyprctl/main.cpp:343:(.text+0x3f43): undefined reference to `Hyprutils::String::isNumber(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool)'
hyprland> /nix/store/d828ccvc2148g7m49hh3mzvyzwpipy46-binutils-2.42/bin/ld: /build/source/hyprctl/main.cpp:424:(.text+0x4c2c): undefined reference to `Hyprutils::String::isNumber(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool)'
hyprland> clang++: error: linker command failed with exit code 1 (use -v to see invocation)
hyprland> [234/250] Building CXX object CMakeFiles/Hyprland.dir/protocols/ext-session-lock-v1.cpp.o
hyprland> [235/250] Building CXX object CMakeFiles/Hyprland.dir/protocols/presentation-time.cpp.o
hyprland> [236/250] Building CXX object CMakeFiles/Hyprland.dir/protocols/xwayland-shell-v1.cpp.o
hyprland> [237/250] Building CXX object CMakeFiles/Hyprland.dir/protocols/primary-selection-unstable-v1.cpp.o
hyprland> [238/250] Building CXX object CMakeFiles/Hyprland.dir/protocols/tablet-v2.cpp.o
hyprland> [239/250] Building CXX object CMakeFiles/Hyprland.dir/protocols/viewporter.cpp.o
hyprland> [240/250] Linking CXX executable hyprpm/hyprpm
hyprland> FAILED: hyprpm/hyprpm
hyprland> : && /nix/store/4wphwqdc7jz18nl9z2sda5ryafl4fm1y-clang-wrapper-18.1.8/bin/clang++ -O2 -g -DNDEBUG -Wl,--export-dynamic -rdynamic hyprpm/CMakeFiles/hyprpm.dir/src/core/DataState.cpp.o hyprpm/CMakeFiles/hyprpm.dir/src/core/Manifest.cpp.o hyprpm/CMakeFiles/hyprpm.dir/src/core/PluginManager.cpp.o hyprpm/CMakeFiles/hyprpm.dir/src/main.cpp.o hyprpm/CMakeFiles/hyprpm.dir/src/progress/CProgressBar.cpp.o -o hyprpm/hyprpm  /nix/store/6n7mjzp32m0srz21s5n82cgly7pg1h00-aquamarine-0.3.3+date=2024-09-01_f8a687d/lib/libaquamarine.so  /nix/store/rnlflxkgglrdiii7wl7k99893zr4iamc-libxkbcommon-1.7.0/lib/libxkbcommon.so  /nix/store/5dwg0biim3ws7a2hyadmvfzsazqcgkk5-util-linux-minimal-2.39.4-lib/lib/libuuid.so  /nix/store/0xxjgp8nqgdwfnqbvavp1g61n8vbvyh1-wayland-1.23.0/lib/libwayland-server.so  /nix/store/17ligilsrswqnrfdvv0al2mvqpvlcr96-pango-1.52.2/lib/libpangocairo-1.0.so  /nix/store/17ligilsrswqnrfdvv0al2mvqpvlcr96-pango-1.52.2/lib/libpango-1.0.so  /nix/store/lsrix2cqck6rcsshjpn4y6j9dysni78f-harfbuzz-9.0.0/lib/libharfbuzz.so  /nix/store/rflkfhqh794nw7vgdzrg0lhjii6v3w8r-cairo-1.18.0/lib/libcairo.so  /nix/store/fbs3ykc63n06yczp4bq3pr53g5l4crwx-pixman-0.43.4/lib/libpixman-1.so  /nix/store/j7pclr7nq518ld7fhl1g79w4amdb4p2l-libXcursor-1.2.2/lib/libXcursor.so  /nix/store/n2aif1mg86whm5ls99w33558whkyh4za-libdrm-2.4.122/lib/libdrm.so  /nix/store/4h5k8gvvx52cwm1hlqvlaj6k6gmnqllb-libinput-1.26.1/lib/libinput.so  /nix/store/hykhzxanlm463wpcw2546rp9ba8hjcz6-mesa-24.2.1/lib/libgbm.so  /nix/store/d1jna110cihfr8024bgb504r5pvamrnv-glib-2.80.4/lib/libgio-2.0.so  /nix/store/d1jna110cihfr8024bgb504r5pvamrnv-glib-2.80.4/lib/libgobject-2.0.so  /nix/store/d1jna110cihfr8024bgb504r5pvamrnv-glib-2.80.4/lib/libglib-2.0.so  /nix/store/8a0xnfn0d6xd6hhwarqqaaa42bap96by-hyprlang-0.5.2+date=2024-09-01_c12ab78/lib/libhyprlang.so  /nix/store/cj5d1x363hkl5g2z3vdw9yf9kp4a4yw7-hyprcursor-0.1.9+date=2024-08-02_912d560-lib/lib/libhyprcursor.so  /nix/store/gf5bjfck5c7sl4mdkbw8qawb3vw5xmyl-hyprutils-0.2.1+date=2024-08-29_8976e3f/lib/libhyprutils.so && :
hyprland> /nix/store/d828ccvc2148g7m49hh3mzvyzwpipy46-binutils-2.42/bin/ld: hyprpm/CMakeFiles/hyprpm.dir/src/core/PluginManager.cpp.o: in function `CPluginManager::headersValid()':
hyprland> /build/source/hyprpm/src/core/PluginManager.cpp:371:(.text+0x7cfb): undefined reference to `Hyprutils::String::trim(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)'
hyprland> /nix/store/d828ccvc2148g7m49hh3mzvyzwpipy46-binutils-2.42/bin/ld: hyprpm/CMakeFiles/hyprpm.dir/src/core/PluginManager.cpp.o: in function `CPluginManager::updateHeaders(bool)':
hyprland> /build/source/hyprpm/src/core/PluginManager.cpp:444:(.text+0x97cf): undefined reference to `Hyprutils::String::trim(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)'
hyprland> clang++: error: linker command failed with exit code 1 (use -v to see invocation)

fufexan avatar Sep 11 '24 17:09 fufexan

FYI:

I guess Clang is using the Libcxx provided by GCC, instead of the one from LLVM...

This should be a platform-specific issue. I had the same issue before in Gentoo. Changing the USE flag of clang-runtime fixed this issue:

➤ ~/.dot-files/shell/.zshrc.d [master] $ equery u clang-runtime
[ Legend : U - final flag setting for installation]
[        : I - package is installed with flag     ]
[ Colors : set, unset                             ]
 * Found these USE flags for sys-devel/clang-runtime-18.1.8:
 U I
 + + abi_x86_32  : 32-bit (x86) libraries
 + + compiler-rt : Install sys-libs/compiler-rt for -rtlib=compiler-rt
 + + libcxx      : Install sys-libs/libcxx for -stdlib=libc++
 + + openmp      : Install sys-libs/libomp for -fopenmp support
 + + sanitize    : Enable compiler-rt sanitizer (-fsanitize*) support

@yangyingchao, I tried this on Gentoo, but still get the same error as before (see build log: https://pastebin.com/GXGCnVDS). I'm on gcc-13 in general (gcc-14 is still unstable and I won't compile my whole system with an unstable compiler), but I tried compiling hyprland-0.43.0 with clang-18, which should work as clang aims to be compatible with gcc. I'm a bit stuck with this now, do you have any ideas what else I can try to work around this issue?

Also, I agree with @RossComputerGuy, why not try the following to avoid using C++26 for now?

This was caused by #7219, src/debug/Log.cpp needs native_handle which isn't implemented until C++26. If we replace std::ofstream with just int and use open, write, and other POSIX methods for fd's then we can change the stdlib requirement back to C++23.

This is probably the best option since many distro's will likely not support C++26 for quite some time. Being one of the maintainers for LLVM in Nixpkgs, I can't guarantee that we will actually support C++26 with LLVM in Nixpkgs.

g-regex avatar Sep 21 '24 13:09 g-regex

FYI: I guess Clang is using the Libcxx provided by GCC, instead of the one from LLVM... This should be a platform-specific issue. I had the same issue before in Gentoo. Changing the USE flag of clang-runtime fixed this issue:

➤ ~/.dot-files/shell/.zshrc.d [master] $ equery u clang-runtime
[ Legend : U - final flag setting for installation]
[        : I - package is installed with flag     ]
[ Colors : set, unset                             ]
 * Found these USE flags for sys-devel/clang-runtime-18.1.8:
 U I
 + + abi_x86_32  : 32-bit (x86) libraries
 + + compiler-rt : Install sys-libs/compiler-rt for -rtlib=compiler-rt
 + + libcxx      : Install sys-libs/libcxx for -stdlib=libc++
 + + openmp      : Install sys-libs/libomp for -fopenmp support
 + + sanitize    : Enable compiler-rt sanitizer (-fsanitize*) support

@yangyingchao, I tried this on Gentoo, but still get the same error as before (see build log: https://pastebin.com/GXGCnVDS). I'm on gcc-13 in general (gcc-14 is still unstable and I won't compile my whole system with an unstable compiler), but I tried compiling hyprland-0.43.0 with clang-18, which should work as clang aims to be compatible with gcc. I'm a bit stuck with this now, do you have any ideas what else I can try to work around this issue?

These are errors of link stage. I guess maybe you need to recompile hyprland's dependencies with clang + libcxx to avoid string abi breakage.

I maintained a fork with #7219 reverted: that change is not really necessary to me. Maybe you can try it too…

yangyingchao avatar Sep 21 '24 14:09 yangyingchao

Thanks for your quick response. Your suggestion seems to make sense, but looking at Hyprland's dependencies I see things like glibc and cairo. If I recompile them with clang, I will probably cause more harm than good and end up having to compile everything that depends on them with clang as well. That's not really an option for me.

Reverting the changes sounds like a good idea. Probably I could manually create a portage user patch for now. Doing that for the next two years seems to be a bit tedious though :D

g-regex avatar Sep 21 '24 21:09 g-regex

Ok, I have created a patch to revert the changes in #7219 (see: https://pastebin.com/fyaVL4Az). Like this it builds with clang-18. Maybe it would be possible to have a compile flag to turn these changes on and off for people like me who run into issues building according to the C++26 standard. Would that be an option, @vaxerski?

g-regex avatar Sep 24 '24 13:09 g-regex

no. Adding options to introduce bugs do not interest us.

Hyprland builds just fine with gcc (arch, fedora, etc) and clang (freebsd) if your distro can't build it, wait for your distro to update whatever is out of date.

vaxerski avatar Sep 24 '24 13:09 vaxerski