gcccmakenlpg++

Can't compile Marian NMT


I'm using endeavouros. I'm trying to compile Marian with these instructions: https://marian-nmt.github.io/docs/#installation. But it fails.

The error message seemingly indicates a conflict between the code and c++20. But in all the CMakeLists.txt files of the repo, there is the line set (CMAKE_CXX_STANDARD 11).

These are the steps that I followed:

git clone https://github.com/marian-nmt/marian
mkdir marian/build
cd marian/build
cmake ..
make -j4

This is the result I had:

➜ make -j4
[  1%] Built target 3rd_party_installs
[  1%] Built target marian_version
[  6%] Built target sentencepiece_train-static
[ 19%] Built target libyaml-cpp
[ 25%] Built target SQLiteCpp
[ 25%] Built target pathie-cpp
[ 32%] Built target zlib
[ 35%] Built target intgemm
[ 35%] Built target faiss
[ 53%] Built target sentencepiece-static
[ 55%] Built target spm_decode
[ 55%] Built target spm_normalize
[ 55%] Built target spm_encode
[ 55%] Building CXX object src/CMakeFiles/marian.dir/common/aliases.cpp.o
[ 55%] Building CXX object src/CMakeFiles/marian.dir/common/fastopt.cpp.o
[ 56%] Built target spm_train
[ 57%] Built target spm_export_vocab
[ 57%] Building CXX object src/CMakeFiles/marian.dir/common/utils.cpp.o
[ 58%] Building CXX object src/CMakeFiles/marian.dir/common/logging.cpp.o
In file included from /data/tools/marian/src/3rd_party/spdlog/details/spdlog_impl.h:12,
                 from /data/tools/marian/src/3rd_party/spdlog/spdlog.h:139,
                 from /data/tools/marian/src/common/logging.h:5,
                 from /data/tools/marian/src/common/definitions.h:3,
                 from /data/tools/marian/src/common/fastopt.h:3,
                 from /data/tools/marian/src/common/fastopt.cpp:1:
/data/tools/marian/src/3rd_party/spdlog/details/registry.h:138:22: error: template-id not allowed for constructor in C++20 [-Werror=template-id-cdtor]
  138 |     registry_t<Mutex>() {}
      |                      ^
/data/tools/marian/src/3rd_party/spdlog/details/registry.h:138:22: note: remove the ‘< >’
/data/tools/marian/src/3rd_party/spdlog/details/registry.h:139:22: error: template-id not allowed for constructor in C++20 [-Werror=template-id-cdtor]
  139 |     registry_t<Mutex>(const registry_t<Mutex>&) = delete;
      |                      ^
/data/tools/marian/src/3rd_party/spdlog/details/registry.h:139:22: note: remove the ‘< >’
In file included from /data/tools/marian/src/3rd_party/spdlog/details/spdlog_impl.h:12,
                 from /data/tools/marian/src/3rd_party/spdlog/spdlog.h:139,
                 from /data/tools/marian/src/common/logging.h:5,
                 from /data/tools/marian/src/common/utils.cpp:2:
/data/tools/marian/src/3rd_party/spdlog/details/registry.h:138:22: error: template-id not allowed for constructor in C++20 [-Werror=template-id-cdtor]
  138 |     registry_t<Mutex>() {}
      |                      ^
/data/tools/marian/src/3rd_party/spdlog/details/registry.h:138:22: note: remove the ‘< >’
/data/tools/marian/src/3rd_party/spdlog/details/registry.h:139:22: error: template-id not allowed for constructor in C++20 [-Werror=template-id-cdtor]
  139 |     registry_t<Mutex>(const registry_t<Mutex>&) = delete;
      |                      ^
/data/tools/marian/src/3rd_party/spdlog/details/registry.h:139:22: note: remove the ‘< >’
In file included from /data/tools/marian/src/3rd_party/spdlog/details/spdlog_impl.h:12,
                 from /data/tools/marian/src/3rd_party/spdlog/spdlog.h:139,
                 from /data/tools/marian/src/common/logging.h:5,
                 from /data/tools/marian/src/common/logging.cpp:1:
/data/tools/marian/src/3rd_party/spdlog/details/registry.h:138:22: error: template-id not allowed for constructor in C++20 [-Werror=template-id-cdtor]
  138 |     registry_t<Mutex>() {}
      |                      ^
/data/tools/marian/src/3rd_party/spdlog/details/registry.h:138:22: note: remove the ‘< >’
/data/tools/marian/src/3rd_party/spdlog/details/registry.h:139:22: error: template-id not allowed for constructor in C++20 [-Werror=template-id-cdtor]
  139 |     registry_t<Mutex>(const registry_t<Mutex>&) = delete;
      |                      ^
/data/tools/marian/src/3rd_party/spdlog/details/registry.h:139:22: note: remove the ‘< >’
In file included from /data/tools/marian/src/3rd_party/spdlog/details/spdlog_impl.h:12,
                 from /data/tools/marian/src/3rd_party/spdlog/spdlog.h:139,
                 from /data/tools/marian/src/common/logging.h:5,
                 from /data/tools/marian/src/common/definitions.h:3,
                 from /data/tools/marian/src/common/cli_wrapper.h:6,
                 from /data/tools/marian/src/common/config_parser.h:4,
                 from /data/tools/marian/src/common/aliases.cpp:1:
/data/tools/marian/src/3rd_party/spdlog/details/registry.h:138:22: error: template-id not allowed for constructor in C++20 [-Werror=template-id-cdtor]
  138 |     registry_t<Mutex>() {}
      |                      ^
/data/tools/marian/src/3rd_party/spdlog/details/registry.h:138:22: note: remove the ‘< >’
/data/tools/marian/src/3rd_party/spdlog/details/registry.h:139:22: error: template-id not allowed for constructor in C++20 [-Werror=template-id-cdtor]
  139 |     registry_t<Mutex>(const registry_t<Mutex>&) = delete;
      |                      ^
/data/tools/marian/src/3rd_party/spdlog/details/registry.h:139:22: note: remove the ‘< >’
cc1plus: all warnings being treated as errors
make[2]: *** [src/CMakeFiles/marian.dir/build.make:93: src/CMakeFiles/marian.dir/common/fastopt.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
cc1plus: all warnings being treated as errors
make[2]: *** [src/CMakeFiles/marian.dir/build.make:121: src/CMakeFiles/marian.dir/common/utils.cpp.o] Error 1
cc1plus: all warnings being treated as errors
make[2]: *** [src/CMakeFiles/marian.dir/build.make:79: src/CMakeFiles/marian.dir/common/aliases.cpp.o] Error 1
cc1plus: all warnings being treated as errors
make[2]: *** [src/CMakeFiles/marian.dir/build.make:135: src/CMakeFiles/marian.dir/common/logging.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:374: src/CMakeFiles/marian.dir/all] Error 2
make: *** [Makefile:156: all] Error 2

Please help.


Solution

  • The diagnostic that your build is tripping, Wtemplate-id-cdtor, was introduced with GCC 14.1. It is a warning, not an error, but your build promotes all warnings to errors, so it breaks your build.

    Although your build specifies -std=c++11 in src/3rd_party/spdlog/CMakeLists.txt, which generates the failure, g++-14 emits Wtemplate-id-cdtor to warn you that the code would be illegal under the more recent standard c++20 (and later). Then the warning is made an error.

    The warning is made an error by the compile option -Werror. This option is included in the list of compile options ALL_WARNINGS, which is created in the top-level marian/CMakeLists.txt at line 227 et seq:

    # These are used in src/CMakeLists.txt on a per-target basis
    list(APPEND ALL_WARNINGS -Wall; -Werror; -Wextra; -Wno-unused-result; -Wno-deprecated;
    -Wno-pragmas; -Wno-unused-parameter; -Wno-unused-function;
    -Wno-unused-value; -Wno-unknown-pragmas; -Wno-sign-compare;
    -Wno-missing-field-initializers;)
    

    and then applied as compile options for the marian library target in src/CMakeLists.txt at line 133:

    target_compile_options(marian PRIVATE ${ALL_WARNINGS})
    

    whence the options are operative for the failing compilation of src/CMakeFiles/marian.dir/common/logging.cpp.

    This failure is a bug in the marian repo which you should report to the maintainers, as it does not seem to have been reported already. The head revision v1.12.0 is more than a year older than GCC 14.

    Pending a fix, you seem to have three interim options to get your build done. Either:

    e.g. make it registry_t(const registry_t<Mutex>&) = delete; in this occurrence.

    Or:

    Or:

    I haven't tested any of these options as I'd need to go to the trouble of installing CUDA.