fmtlib / fmt

A modern formatting library
https://fmt.dev
Other
19.84k stars 2.42k forks source link

Fix missing includes in fmt.cc #3994

Closed yujincheng08 closed 4 weeks ago

yujincheng08 commented 1 month ago

This causes duplicated std definitions in the fmt module, e.g.,

ld.lld: error: undefined symbol: std::_LIBCPP_ABI_NAMESPACE::source_location@fmt::file_name[abi:v170000]() const
vitaut commented 4 weeks ago

Thank you!

yujincheng08 commented 4 weeks ago

-Winclude-angled-in-module-purview becomes worse when I am using libstdc++ instead of libc++. Maybe we should guard all includes in headers by FMT_MODULE.

vitaut commented 3 weeks ago

-Winclude-angled-in-module-purview becomes worse when I am using libstdc++ instead of libc++

@yujincheng08, what warnings do you get?

yujincheng08 commented 3 weeks ago

@vitaut The warnings are:

[10/14] /usr/bin/clang++-18 -DFMT_MODULE -Ifmt/include -O3 -DNDEBUG -std=gnu++20 -fvisibility=hidden -fvisibility-inlines-hidden -MD -MT CMakeFiles/fmt.dir/src/fmt.cc.o -MF CMakeFiles/fmt.dir/src/fmt.cc.o.d @CMakeFiles/fmt.dir/src/fmt.cc.o.modmap -o CMakeFiles/fmt.dir/src/fmt.cc.o -c fmt/src/fmt.cc
In file included from fmt/src/fmt.cc:102:
In file included from fmt/include/fmt/args.h:17:
fmt/include/fmt/format.h:42:12: warning: '#include <filename>' attaches the declarations to the named module 'fmt', which is not usually intended; consider moving that directive before the module declaration [-Winclude-angled-in-module-purview]
   42 | #  include <cmath>             // std::signbit
      |            ^
fmt/include/fmt/format.h:44:12: warning: '#include <filename>' attaches the declarations to the named module 'fmt', which is not usually intended; consider moving that directive before the module declaration [-Winclude-angled-in-module-purview]
   44 | #  include <cstring>           // std::memcpy
      |            ^
In file included from fmt/src/fmt.cc:103:
fmt/include/fmt/chrono.h:14:12: warning: '#include <filename>' attaches the declarations to the named module 'fmt', which is not usually intended; consider moving that directive before the module declaration [-Winclude-angled-in-module-purview]
   14 | #  include <cmath>    // std::isfinite
      |            ^
fmt/include/fmt/chrono.h:15:12: warning: '#include <filename>' attaches the declarations to the named module 'fmt', which is not usually intended; consider moving that directive before the module declaration [-Winclude-angled-in-module-purview]
   15 | #  include <cstring>  // std::memcpy
      |            ^
fmt/include/fmt/chrono.h:16:12: warning: '#include <filename>' attaches the declarations to the named module 'fmt', which is not usually intended; consider moving that directive before the module declaration [-Winclude-angled-in-module-purview]
   16 | #  include <ctime>
      |            ^
In file included from fmt/src/fmt.cc:108:
fmt/include/fmt/os.h:11:10: warning: '#include <filename>' attaches the declarations to the named module 'fmt', which is not usually intended; consider moving that directive before the module declaration [-Winclude-angled-in-module-purview]
   11 | #include <cerrno>
      |          ^
fmt/include/fmt/os.h:14:12: warning: '#include <filename>' attaches the declarations to the named module 'fmt', which is not usually intended; consider moving that directive before the module declaration [-Winclude-angled-in-module-purview]
   14 | #  include <cstdio>
      |            ^
In file included from fmt/src/fmt.cc:113:
fmt/include/fmt/std.h:13:12: warning: '#include <filename>' attaches the declarations to the named module 'fmt', which is not usually intended; consider moving that directive before the module declaration [-Winclude-angled-in-module-purview]
   13 | #  include <bitset>
      |            ^
fmt/include/fmt/std.h:15:12: warning: '#include <filename>' attaches the declarations to the named module 'fmt', which is not usually intended; consider moving that directive before the module declaration [-Winclude-angled-in-module-purview]
   15 | #  include <cstdlib>
      |            ^
In file included from fmt/src/fmt.cc:114:
fmt/include/fmt/xchar.h:12:12: warning: '#include <filename>' attaches the declarations to the named module 'fmt', which is not usually intended; consider moving that directive before the module declaration [-Winclude-angled-in-module-purview]
   12 | #  include <cwchar>
      |            ^
In file included from fmt/src/fmt.cc:125:
In file included from fmt/src/format.cc:8:
fmt/include/fmt/format-inl.h:13:12: warning: '#include <filename>' attaches the declarations to the named module 'fmt', which is not usually intended; consider moving that directive before the module declaration [-Winclude-angled-in-module-purview]
   13 | #  include <cmath>
      |            ^
fmt/include/fmt/format-inl.h:16:10: warning: '#include <filename>' attaches the declarations to the named module 'fmt', which is not usually intended; consider moving that directive before the module declaration [-Winclude-angled-in-module-purview]
   16 | #include <cerrno>  // errno
      |          ^
fmt/include/fmt/format-inl.h:17:10: warning: '#include <filename>' attaches the declarations to the named module 'fmt', which is not usually intended; consider moving that directive before the module declaration [-Winclude-angled-in-module-purview]
   17 | #include <climits>
      |          ^
In file included from fmt/src/fmt.cc:127:
fmt/src/os.cc:15:10: warning: '#include <filename>' attaches the declarations to the named module 'fmt', which is not usually intended; consider moving that directive before the module declaration [-Winclude-angled-in-module-purview]
   15 | #include <climits>
      |          ^
14 warnings generated.