If you use clang, then yes.
Clang-16 cannot be used to build hyprland without using libc++ and some obscure flags. It doesn't work with libstdc++ (GNU's C++ library) for some reason.
Install libc++
, then
CC="clang" CXX="clang++" CC_LD=lld CXX_LD=lld meson setup build -Dcpp_args="-stdlib=libc++ -fexperimental-library" -Dcpp_link_args="-stdlib=libc++ -fexperimental-library"
As a rule of thumb, you generally need these flags if you are using clang to build anything that uses C++20 or C++23 features such as ranges or format. You can create a meson native file, for example, to simplify the process
~/.local/share/meson/native/clang_release
[constants]
ldflags=['-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now']
cflags=['-march=native', '-mtune=native', '-O3', '-pipe',
'-fno-plt', '-fstack-clash-protection', '-fcf-protection']
libcxx = ['-stdlib=libc++', '-fexperimental-library']
[binaries]
c_ld = 'lld'
cpp_ld = 'lld'
rust_ld = '/usr/bin/clang'
[built-in options]
b_lto = true
b_lto_mode = 'thin'
b_thinlto_cache = true
c_args = cflags
c_link_args = ldflags
cpp_args = cflags + libcxx
cpp_link_args = ldflags + libcxx
Use it in meson like this: meson setup build --native-file=clang_release
Pinned Comments
zjeffer commented on 2024-07-17 16:50 (UTC) (edited on 2024-07-17 16:52 (UTC) by zjeffer)
Tips & tricks, common issues
using ccache/sccache
Precompiled headers (PCH) was enabled by default, this would most likely invalidate the compiler cache if any of the upstream header files change. To disable PCH, add the meson build option
-Db_pch=false
tobuild()
.Build with specific pull requests
Use
pick_mr <pull request number>
at the end ofprepare()
to merge pull requests locally. For example, to merge https://github.com/hyprwm/Hyprland/pull/6268, useEnable legacy renderer
In the
build()
function, add-D legacy_renderer=true
to meson setupCompilation errors
If you encounter compilation errors, try the following first:
protocols/
, such asprotocols/linux-dmabuf-v1.hpp
, then rebuild or installhyprwayland-scanner-git
;makepkg --cleanbuild
.Symbol not declared
Errors like
<symbol> was not declared in this scope
<symbol> has not been declared
are usually caused by missing headers. Please consider reporting this upstream or creating a pull request if it has not already been done.