Skip to content

Can't build as C++20 module since 10.1.0 #3587

Description

@GregTheMadMonk

Issue in the title. 10.0.0 builds successfully with -DFMT_MODULE=ON, 10.1.0 doesn't.

Compiler versions and build logs:

$ gcc --version
gcc (GCC) 13.2.1 20230801
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ cmake .. -DFMT_MODULE=ON && make
-- CMake version: 3.27.1
-- The CXX compiler identification is GNU 13.2.1
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Testing is incompatible with build mode 'module'.
-- Version: 10.1.0
-- Build type: Release
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Configuring done (1.9s)
-- Generating done (0.0s)
-- Build files have been written to: /home/greg/tmp/fmt/build
[ 12%] Building CXX object CMakeFiles/fmt.dir/src/fmt.cc.o
/home/greg/tmp/fmt/src/fmt.cc:75:20: error: ‘export’ may only occur once in an export declaration
   75 | #define FMT_EXPORT export
      |                    ^~~~~~
/home/greg/tmp/fmt/include/fmt/core.h:1665:1: note: in expansion of macro ‘FMT_EXPORT’
 1665 | FMT_EXPORT
      | ^~~~~~~~~~
In file included from /home/greg/tmp/fmt/include/fmt/chrono.h:21,
                 from /home/greg/tmp/fmt/src/fmt.cc:91:
/home/greg/tmp/fmt/include/fmt/format.h:1484:57: error: conflicting exporting declaration ‘fmt::v10::detail::uint128_fallback fmt::v10::detail::umul128(uint64_t, uint64_t)’
 1484 | inline uint128_fallback umul128(uint64_t x, uint64_t y) noexcept {
      |                                                         ^~~~~~~~
/home/greg/tmp/fmt/include/fmt/format.h:371:27: note: previous declaration ‘fmt::v10::detail::uint128_fallback fmt::v10::detail::umul128(uint64_t, uint64_t)’ here
  371 |   friend uint128_fallback umul128(uint64_t x, uint64_t y) noexcept;
      |                           ^~~~~~~
/home/greg/tmp/fmt/include/fmt/format.h:4319:71: error: conflicting exporting declaration ‘template<class Char> void fmt::v10::detail::vformat_to(buffer<T>&, fmt::v10::basic_string_view<Char>, typename vformat_args<Char>::type, locale_ref)’
 4319 |              typename vformat_args<Char>::type args, locale_ref loc) {
      |                                                                    ^

In file included from /home/greg/tmp/fmt/include/fmt/args.h:15,
                 from /home/greg/tmp/fmt/src/fmt.cc:90:
/home/greg/tmp/fmt/include/fmt/core.h:2676:6: note: previous declaration ‘template<class Char> void fmt::v10::detail::vformat_to(buffer<T>&, fmt::v10::basic_string_view<Char>, typename vformat_args<Char>::type, locale_ref)’ here
 2676 | void vformat_to(buffer<Char>& buf, basic_string_view<Char> fmt,
      |      ^~~~~~~~~~
/home/greg/tmp/fmt/src/fmt.cc:73:8: warning: not writing module ‘fmt’ due to errors
   73 | export module fmt;
      |        ^~~~~~
make[2]: *** [CMakeFiles/fmt.dir/build.make:76: CMakeFiles/fmt.dir/src/fmt.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:135: CMakeFiles/fmt.dir/all] Error 2
make: *** [Makefile:166: all] Error 2
$ clang --version
clang version 15.0.7
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
$ CXX=clang++ CC=clang cmake .. -DFMT_MODULE=ON && make
-- CMake version: 3.27.1
-- The CXX compiler identification is Clang 15.0.7
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Testing is incompatible with build mode 'module'.
-- Version: 10.1.0
-- Build type: Release
-- Performing Test HAS_NULLPTR_WARNING
-- Performing Test HAS_NULLPTR_WARNING - Success
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Configuring done (2.7s)
-- Generating done (0.0s)
-- Build files have been written to: /home/greg/tmp/fmt/build
[ 11%] Generating fmt.pcm
In file included from /home/greg/tmp/fmt/src/fmt.cc:90:
In file included from /home/greg/tmp/fmt/include/fmt/args.h:15:
/home/greg/tmp/fmt/include/fmt/core.h:1665:1: error: export declaration appears within another export declaration
FMT_EXPORT
^
/home/greg/tmp/fmt/src/fmt.cc:75:20: note: expanded from macro 'FMT_EXPORT'
#define FMT_EXPORT export
                   ^
/home/greg/tmp/fmt/include/fmt/core.h:1600:1: note: export block begins here
FMT_BEGIN_EXPORT
^
/home/greg/tmp/fmt/src/fmt.cc:76:26: note: expanded from macro 'FMT_BEGIN_EXPORT'
#define FMT_BEGIN_EXPORT export {
                         ^
In file included from /home/greg/tmp/fmt/src/fmt.cc:91:
In file included from /home/greg/tmp/fmt/include/fmt/chrono.h:21:
/home/greg/tmp/fmt/include/fmt/format.h:4318:6: error: cannot export redeclaration 'vformat_to' here since the previous declaration has module linkage
void vformat_to(buffer<Char>& buf, basic_string_view<Char> fmt,
     ^
/home/greg/tmp/fmt/include/fmt/core.h:2676:6: note: previous declaration is here
void vformat_to(buffer<Char>& buf, basic_string_view<Char> fmt,
     ^
In file included from /home/greg/tmp/fmt/src/fmt.cc:109:
In file included from /home/greg/tmp/fmt/src/format.cc:8:
/home/greg/tmp/fmt/include/fmt/format-inl.h:1424:11: error: explicit instantiation of undefined function template 'vformat_to'
  detail::vformat_to(buffer, fmt, args);
          ^
/home/greg/tmp/fmt/include/fmt/core.h:2676:6: note: explicit instantiation refers here
void vformat_to(buffer<Char>& buf, basic_string_view<Char> fmt,
     ^
3 errors generated.
make[2]: *** [CMakeFiles/fmt.dir/build.make:74: fmt.pcm] Error 1
make[1]: *** [CMakeFiles/Makefile2:134: CMakeFiles/fmt.dir/all] Error 2
make: *** [Makefile:166: all] Error 2

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions