You are not logged in.

#1 2024-12-16 16:24:17

mexanoz
Member
Registered: 2022-08-12
Posts: 4

Failing to build hyprland with clang

I've failed to build two packages from the Hyprland ecosystem, hyprland-git and hyprlang-git, with "no template in namespace" / "no member in namespace" errors.  It builds fine with the default Arch makepkg.conf, with GCC. I'm using clang with libstdc++, and the error happens with or without LTO enabled. I suspect my configuration might be the problem, so I'm posting here first and not to the upstream.
My makepkg.conf:

MAKEFLAGS="-j4"
export CC=clang
export CPP=clang-cpp
export CXX=clang++
export AR=llvm-ar
export NM=llvm-nm
export RANLIB=llvm-ranlib
CFLAGS="-march=native -mtune=native -O2 -pipe -fno-plt -fexceptions \
        -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security \
        -fstack-clash-protection -fcf-protection \
        -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer"
CXXFLAGS="$CFLAGS -Wp,-D_GLIBCXX_ASSERTIONS"
LDFLAGS="-Wl,-O1 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now \
         -Wl,-z,pack-relative-relocs -fuse-ld=lld"
export QMAKESPEC=linux-clang
...
BUILDENV=(!distcc color ccache !check !sign)
OPTIONS=(strip docs !libtool !staticlibs emptydirs zipman purge !debug lto)

The error when building hyprlang-git:

/home/mex/.aur/hyprlang-git/src/hyprlang/src/config.cpp:164:13: error: no template named 'expected' in namespace 'std'
  164 | static std::expected<int64_t, std::string> configStringToInt(const std::string& VALUE) {
      |        ~~~~~^
/home/mex/.aur/hyprlang-git/src/hyprlang/src/config.cpp:165:58: error: no template named 'expected' in namespace 'std'
  165 |     auto parseHex = [](const std::string& value) -> std::expected<int64_t, std::string> {
      |                                                     ~~~~~^
/home/mex/.aur/hyprlang-git/src/hyprlang/src/config.cpp:172:21: error: no member named 'unexpected' in namespace 'std'
  172 |         return std::unexpected("invalid hex " + value);
      |                ~~~~~^
/home/mex/.aur/hyprlang-git/src/hyprlang/src/config.cpp:193:55: error: no member named 'unexpected' in namespace 'std'
  193 |             } catch (std::exception& e) { return std::unexpected("failed parsing " + VALUEWITHOUTFUNC); }
      |                                                  ~~~~~^

and several more of the same kind.

Offline

#2 2024-12-16 22:58:12

loqs
Member
Registered: 2014-03-06
Posts: 18,241

Re: Failing to build hyprland with clang

Adding ` -D__cpp_concepts=202002L` to CXXFLAGS as suggested in https://www.reddit.com/r/cpp_questions/ … t/l12gy8i/ allowed me to build hyprlang-git with your changes. As this is redefining a built in macro I would suggest investigating other ways to control the macro.

Offline

Board footer

Powered by FluxBB