Skip to content

ROOT Cling cannot run with libfmt using C++23 #553

@YanzhaoW

Description

@YanzhaoW
  • Checked for duplicates

This issue is forwarded from root-project/root#19335

Describe the bug

ROOT Cling cannot compile the code with libfmt. It emits the following error:

ROOT_prompt_3:1:14: error: call to consteval function 'fmt::fstring<>::fstring<12UL>' is not a constant expression
fmt::println("hello world");
             ^
note: cast that performs the conversions of a reinterpret_cast is not allowed in a constant expression
/opt/FairSoft/include/fmt/base.h:2736:54: note: in call to 'basic_string_view(&"hello world"[0])'
    if (FMT_USE_CONSTEVAL) parse_format_string<char>(s, checker(s, arg_pack()));
                                                     ^
ROOT_prompt_3:1:14: note: in call to 'fstring<12UL>("hello world")'
fmt::println("hello world");
             ^~~~~~~~~~~~~

To Reproduce

  1. build a docker container with ROOT and libfmt using the following Dockerfile:
ARG BUILD_REPO=fedora
FROM ${BUILD_REPO}:latest

ARG THREAD_NUM=4

ENV SIMPATH="/opt/FairSoft"

RUN yes | dnf upgrade --refresh &&\
        echo "strict=False" >> /etc/dnf/dnf.conf &&\
        echo "skip_if_unavailable=True" >> /etc/dnf/dnf.conf &&\
        mkdir -p /tmp/download && cd /tmp/download &&\
        export CC=clang && export FC=gfortran && export CXX=clang++ &&\
        mkdir -p ${SIMPATH} &&\
        dnf install -y ninja-build clang git make cmake gcc-c++ gcc binutils libX11-devel libXpm-devel libXft-devel libXext-devel python openssl-devel xrootd-client-devel xrootd-libs-devel gcc-gfortran pcre-devel mesa-libGL-devel mesa-libGLU-devel glew-devel ftgl-devel mysql-devel fftw-devel cfitsio-devel graphviz-devel libuuid-devel avahi-compat-libdns_sd-devel openldap-devel python-devel python3-numpy libxml2-devel gsl-devel readline-devel qt5-qtwebengine-devel R-devel R-Rcpp-devel R-RInside-devel &&\
        cd /tmp/download &&\
        git clone --depth 1 --branch v6-36-00 https://github.com/root-project/root.git &&\
        cd root && mkdir build && cd build &&\
        cmake -DCMAKE_CXX_STANDARD=23 -DCMAKE_INSTALL_PREFIX=$SIMPATH -Dasimage=ON -Ddavix=OFF -Dfftw3=ON -Dfortran=ON -Dgdml=ON -Dgnuinstall=ON -Dhttp=ON -Dmathmore=ON -Dmlp=ON -Dpyroot=ON -Dpythia8=ON -Droofit=ON -Druntime_cxxmodules=OFF -Drpath=ON -Dsoversion=ON -Dspectrum=ON -Dsqlite=ON -Dtmva=ON -Dvc=ON -Dvdt=OFF -Dxml=ON -Dxrootd=ON -Dx11=ON -GNinja .. &&\
        ninja -j ${THREAD_NUM} &&\
        ninja install &&\
        cd /tmp/download &&\
        git clone --depth 1 --branch 11.2.0 https://github.com/fmtlib/fmt.git &&\
        cd fmt && mkdir build && cd build &&\
        cmake -DCMAKE_INSTALL_PREFIX=$SIMPATH -GNinja .. &&\
        ninja -j ${THREAD_NUM} &&\
        ninja install &&\
        rm -rf /tmp/download/*
  1. Build the docker image and run the container:
docker build -t test .
docker run -it --name test_root test "/bin/bash"
  1. Enter the container environment and launch root:
${SIMPATH}/bin/root
  1. Run the code with libfmt in root environment:
#include <fmt/format.h>
fmt::println("hello world");

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions