Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fmt fail to compile with icc 15 (intel compiler) #822

Closed
rafiw opened this issue Jul 24, 2018 · 11 comments
Closed

fmt fail to compile with icc 15 (intel compiler) #822

rafiw opened this issue Jul 24, 2018 · 11 comments

Comments

@rafiw
Copy link

rafiw commented Jul 24, 2018

 make V=1
[  2%] Building CXX object CMakeFiles/fmt.dir/src/format.cc.o
In file included from /git/fmt/include/fmt/format.h(54),
                 from /git/fmt/include/fmt/format-inl.h(11),
                 from /git/fmt/src/format.cc(8):
/git/fmt/include/fmt/core.h(185): error: missing closing quote
  #if (FMT_HAS_INCLUDE(<string_view>) && \
       ^

/git/fmt/include/fmt/core.h(185): internal error: assertion failed at: "shared/cfe/edgcpfe/literals.c", line 1081

  #if (FMT_HAS_INCLUDE(<string_view>) && \
       ^

compilation aborted for /git/fmt/src/format.cc (code 4)
make[2]: *** [CMakeFiles/fmt.dir/src/format.cc.o] Error 4
make[1]: *** [CMakeFiles/fmt.dir/all] Error 2
make: *** [all] Error 2

@vitaut
Copy link
Contributor

vitaut commented Jul 25, 2018

Unfortunately I don't have an access to icc to debug this. Does changing

#ifdef __has_include

to

#ifdef __has_include && (!defined(__INTEL_COMPILER) || __INTEL_COMPILER >= 1600)

in https://github.com/fmtlib/fmt/blob/master/include/fmt/core.h#L27 fix the issue? I also recommend reporting to ICC developers since it looks like a compiler bug.

@rafiw
Copy link
Author

rafiw commented Jul 26, 2018

hi @vitaut what you gave didn't work but this did

diff --git a/include/fmt/core.h b/include/fmt/core.h
index eb80cc2..5abcddf 100644
--- a/include/fmt/core.h
+++ b/include/fmt/core.h
@@ -24,7 +24,7 @@
 # define FMT_HAS_FEATURE(x) 0
 #endif

-#ifdef __has_include
+#if defined(__has_include) && (!defined(__INTEL_COMPILER) || __INTEL_COMPILER >= 1600)
 # define FMT_HAS_INCLUDE(x) __has_include(x)

but now i have this issue

Scanning dependencies of target header-only-test
[ 37%] Building CXX object test/CMakeFiles/header-only-test.dir/header-only-test.cc.o
[ 39%] Building CXX object test/CMakeFiles/header-only-test.dir/header-only-test2.cc.o
[ 41%] Building CXX object test/CMakeFiles/header-only-test.dir/test-main.cc.o
[ 44%] Linking CXX executable ../bin/header-only-test
[ 44%] Built target header-only-test
[ 46%] Building CXX object test/CMakeFiles/noexception-test.dir/__/src/format.cc.o
/git/fmt/include/fmt/format.h(494): internal error: assertion failed at: "shared/cfe/edgcpfe/class_decl.c", line 11359

  class u8string_view : public basic_string_view<char8_t> {
        ^

compilation aborted for /git/fmt/src/format.cc (code 4)
make[2]: *** [test/CMakeFiles/noexception-test.dir/__/src/format.cc.o] Error 4
make[1]: *** [test/CMakeFiles/noexception-test.dir/all] Error 2
make: *** [all] Error 2

if i compile with tests disable it works, so it's good enough for me.
cmake .. -DFMT_TEST=no
I have no relation to Intel but i will point them to this thread somehow.
Thanks
Rafi

@rafiw
Copy link
Author

rafiw commented Jul 26, 2018

BTW it compiles well (without tests) with ICC V15 and V17

@rafiw
Copy link
Author

rafiw commented Jul 26, 2018

@vitaut
Copy link
Contributor

vitaut commented Jul 26, 2018

The first issue is fixed (or rather worked around since it's a compiler bug) in ce19309.

@vitaut
Copy link
Contributor

vitaut commented Jul 26, 2018

Regarding the second issue (which is even more obviously a compiler bug), do the tests compile if you replace

if (HAVE_FNO_EXCEPTIONS_FLAG)

with

if (FALSE)

in https://github.com/fmtlib/fmt/blob/master/test/CMakeLists.txt#L127 ?

@rafiw
Copy link
Author

rafiw commented Jul 29, 2018

now i get this error

[ 68%] Building CXX object test/CMakeFiles/printf-test.dir/printf-test.cc.o
/git/fmt/include/fmt/core.h(574): error: no instance of function template "fmt::v5::printf_formatter<T>::format [with T=TestString]" matches the argument list
            argument types are: (const TestString, fmt::v5::basic_printf_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char>>, char, fmt::v5::printf_arg_formatter<fmt::v5::back_insert_range<fmt::v5::internal::buffer>>>)
            object type is: fmt::v5::printf_formatter<TestString>
      ctx.advance_to(f.format(*static_cast<const T*>(arg), ctx));
                       ^
          detected during:
            instantiation of "void fmt::v5::internal::value<Context>::format_custom_arg<T>(const void *, Context &) [with Context=fmt::v5::basic_printf_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char>>, char, fmt::v5::printf_arg_formatter<fmt::v5::back_insert_range<fmt::v5::internal::buffer>>>, T=TestString]" at line 557
            instantiation of "fmt::v5::internal::value<Context>::value(const T &) [with Context=fmt::v5::basic_printf_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char>>, char, fmt::v5::printf_arg_formatter<fmt::v5::back_insert_range<fmt::v5::internal::buffer>>>, T=TestString]" at line 583
            instantiation of "fmt::v5::internal::typed_value<Context, TYPE>::typed_value(const T &) [with Context=fmt::v5::basic_printf_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char>>, char, fmt::v5::printf_arg_formatter<fmt::v5::back_insert_range<fmt::v5::internal::buffer>>>, TYPE=fmt::v5::internal::custom_type, T=TestString]" at line 691
            instantiation of "std::enable_if<<expression>, fmt::v5::internal::typed_value<C, fmt::v5::internal::custom_type>>::type fmt::v5::internal::make_value<C,T,Char>(const T &) [with C=fmt::v5::basic_printf_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char>>, char, fmt::v5::printf_arg_formatter<fmt::v5::back_insert_range<fmt::v5::internal::buffer>>>, T=TestString, Char=char]" at line 989
            instantiation of "std::enable_if<IS_PACKED, fmt::v5::internal::value<Context>>::type fmt::v5::internal::make_arg<IS_PACKED,Context,T>(const T &) [with IS_PACKED=true, Context=fmt::v5::basic_printf_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char>>, char, fmt::v5::printf_arg_formatter<fmt::v5::back_insert_range<fmt::v5::internal::buffer>>>, T=TestString]" at line 1047
            instantiation of "fmt::v5::format_arg_store<Context, Args...>::format_arg_store(const Args &...) [with Context=fmt::v5::basic_printf_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char>>, char, fmt::v5::printf_arg_formatter<fmt::v5::back_insert_range<fmt::v5::internal::buffer>>>, Args=<TestString>]" at line 1066
            instantiation of "fmt::v5::format_arg_store<Context, Args...> fmt::v5::make_format_args<Context,Args...>(const Args &...) [with Context=fmt::v5::basic_printf_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char>>, char, fmt::v5::printf_arg_formatter<fmt::v5::back_insert_range<fmt::v5::internal::buffer>>>, Args=<TestString>]" at line 604 of "/git/fmt/include/fmt/printf.h"
            instantiation of "std::string fmt::v5::sprintf(fmt::v5::string_view, const Args &...) [with Args=<TestString>]" at line 493 of "/git/fmt/test/printf-test.cc"

compilation aborted for /git/fmt/test/printf-test.cc (code 2)
make[2]: *** [test/CMakeFiles/printf-test.dir/printf-test.cc.o] Error 2
make[1]: *** [test/CMakeFiles/printf-test.dir/all] Error 2
make: *** [all] Error 2

@rafiw
Copy link
Author

rafiw commented Aug 2, 2018

@vitaut can you help me with Intel here i have no idea what they want and how to get it

@vitaut
Copy link
Contributor

vitaut commented Aug 3, 2018

To get preprocessed file, first run make with VERBOSE=1:

$ VERBOSE=1 make
...
[  2%] Building CXX object CMakeFiles/fmt.dir/src/format.cc.o
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++   -I/Users/viz/work/fmt/include  -g   -std=gnu++14 -o CMakeFiles/fmt.dir/src/format.cc.o -c /Users/viz/work/fmt/src/format.cc

Then copy the compile command that gives an error, replace -c with -E and the name of the output file (argument after -o) with the name of the you want the preprocessed code to go (e.g. format.cc.i).

And finally run it:

$ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++   -I/Users/viz/work/fmt/include  -g   -std=gnu++14 -o format.cc.i -E /Users/viz/work/fmt/src/format.cc

format.cc.i will contain the preprocessed code.

vitaut added a commit that referenced this issue Aug 22, 2018
@vitaut
Copy link
Contributor

vitaut commented Aug 22, 2018

I've implemented the proposed workarounds in a11eb3a (not merged yet).

@vitaut
Copy link
Contributor

vitaut commented Aug 25, 2018

Merged workarounds for known icc bugs so closing for now.

@vitaut vitaut closed this as completed Aug 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants