This is an archive of the discontinued LLVM Phabricator instance.

Fix for compiling with clang <= 3.7 and g++6 headers.
Needs ReviewPublic

Authored by marsupial on Jul 25 2016, 10:49 PM.

Details

Reviewers
rsmith
dexonsmith
Summary

A few tuple constructors are not getting resolved properly and causing errors when built with clang 3.6, 3.7 and gcc 6.1.1 libstdc++ headers.

Diff Detail

Repository
rL LLVM

Event Timeline

marsupial updated this revision to Diff 65475.Jul 25 2016, 10:49 PM
marsupial retitled this revision from to Fix for compiling with clang <= 3.7 and g++6 headers..
marsupial updated this object.
marsupial set the repository for this revision to rL LLVM.
marsupial added a subscriber: llvm-commits.
marsupial updated this object.Jul 28 2016, 10:25 AM

I'd prefer not to fix this this way (by not copying the LexicalScope, then fixing it up)

Is there some reasonable way to fix the ambiguity directly? Do you have a link to the build failure, etc, so we can take a look?

It's definitely a bit more intrusive than I'd like, but was the only thing that worked.
The log's have been overwritten by now, but easily reproduced with gcc-6 and clang-3.7.
The arguments forwarded to LexicalScope::LexicalScope were not being resolving properly.

Found one:

In file included from ../../lib/CodeGen/LexicalScopes.cpp:17:
In file included from ../../include/llvm/CodeGen/LexicalScopes.h:20:
In file included from ../../include/llvm/ADT/ArrayRef.h:13:
In file included from ../../include/llvm/ADT/Hashing.h:49:
In file included from ../../include/llvm/Support/Host.h:17:
In file included from ../../include/llvm/ADT/StringMap.h:18:
In file included from ../../include/llvm/Support/Allocator.h:24:
In file included from ../../include/llvm/ADT/SmallVector.h:29:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/memory:79:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/functional:55:
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/tuple:1400:14: error: 
      no matching constructor for initialization of 'tuple<llvm::LexicalScope
      *&&, const llvm::DILocalScope *&&, nullptr_t &&, bool &&>'
    { return tuple<_Elements&&...>(std::forward<_Elements>(__args)...); }
             ^                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../lib/CodeGen/LexicalScopes.cpp:155:36: note: in instantiation of function
      template specialization 'std::forward_as_tuple<llvm::LexicalScope *&,
      const llvm::DILocalScope *&, nullptr_t, bool>' requested here
                              std::forward_as_tuple(Parent, Scope, nullptr,
                                   ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/tuple:600:18: note: 
      candidate template ignored: disabled by 'enable_if' [with _Dummy = void]
                 _TCC<_Dummy>::template
                 ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/tuple:611:18: note: 
      candidate template ignored: disabled by 'enable_if' [with _Dummy = void]
                 _TCC<_Dummy>::template
                 ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/tuple:628:5: note: 
      candidate template ignored: disabled by 'enable_if' [with _UElements =
      <llvm::LexicalScope *&, const llvm::DILocalScope *&, nullptr_t, bool>]
                  _TC<sizeof...(_UElements) == 1, _Elements...>::template
                  ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/tuple:641:5: note: 
      candidate template ignored: disabled by 'enable_if' [with _UElements =
      <llvm::LexicalScope *&, const llvm::DILocalScope *&, nullptr_t, bool>]
                  _TC<sizeof...(_UElements) == 1, _Elements...>::template
                  ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/tuple:737:19: note: 
      candidate template ignored: disabled by 'enable_if' [with _Alloc = const
      llvm::DILocalScope *, _UElements = <nullptr_t, bool>]
        enable_if<_TMC<_UElements...>::template
                  ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/tuple:748:19: note: 
      candidate template ignored: disabled by 'enable_if' [with _Alloc = const
      llvm::DILocalScope *, _UElements = <nullptr_t, bool>]
        enable_if<_TMC<_UElements...>::template
                  ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/tuple:579:17: note: 
      candidate constructor template not viable: requires 0 arguments, but 4
      were provided
      constexpr tuple()
                ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/tuple:589:26: note: 
      candidate constructor template not viable: requires 0 arguments, but 4
      were provided
      explicit constexpr tuple()
                         ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/tuple:670:19: note: 
      candidate constructor template not viable: requires single argument
      '__in', but 4 arguments were provided
        constexpr tuple(const tuple<_UElements...>& __in)
                  ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/tuple:682:28: note: 
      candidate constructor template not viable: requires single argument
      '__in', but 4 arguments were provided
        explicit constexpr tuple(const tuple<_UElements...>& __in)
                           ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/tuple:694:19: note: 
      candidate constructor template not viable: requires single argument
      '__in', but 4 arguments were provided
        constexpr tuple(tuple<_UElements...>&& __in)
                  ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/tuple:705:28: note: 
      candidate constructor template not viable: requires single argument
      '__in', but 4 arguments were provided
        explicit constexpr tuple(tuple<_UElements...>&& __in)
                           ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/tuple:721:2: note: 
      candidate constructor template not viable: requires 6 arguments, but 4
      were provided
        tuple(allocator_arg_t __tag, const _Alloc& __a,
        ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/tuple:732:11: note: 
      candidate constructor template not viable: requires 6 arguments, but 4
      were provided
        explicit tuple(allocator_arg_t __tag, const _Alloc& __a,
                 ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/tuple:711:2: note: 
      candidate constructor template not viable: requires 2 arguments, but 4
      were provided
        tuple(allocator_arg_t __tag, const _Alloc& __a)
        ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/tuple:759:2: note: 
      candidate constructor template not viable: requires 3 arguments, but 4
      were provided
        tuple(allocator_arg_t __tag, const _Alloc& __a, const tuple& __in)
        ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/tuple:763:2: note: 
      candidate constructor template not viable: requires 3 arguments, but 4
      were provided
        tuple(allocator_arg_t __tag, const _Alloc& __a, tuple&& __in)
        ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/tuple:772:2: note: 
      candidate constructor template not viable: requires 3 arguments, but 4
      were provided
        tuple(allocator_arg_t __tag, const _Alloc& __a,
        ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/tuple:784:11: note: 
      candidate constructor template not viable: requires 3 arguments, but 4
      were provided
        explicit tuple(allocator_arg_t __tag, const _Alloc& __a,
                 ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/tuple:796:2: note: 
      candidate constructor template not viable: requires 3 arguments, but 4
      were provided
        tuple(allocator_arg_t __tag, const _Alloc& __a,
        ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/tuple:808:11: note: 
      candidate constructor template not viable: requires 3 arguments, but 4
      were provided
        explicit tuple(allocator_arg_t __tag, const _Alloc& __a,
                 ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/tuple:654:17: note: 
      candidate constructor not viable: requires 1 argument, but 4 were provided
      constexpr tuple(tuple&&) = default; 
                ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/tuple:652:17: note: 
      candidate constructor not viable: requires 1 argument, but 4 were provided
      constexpr tuple(const tuple&) = default;
                ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/tuple:1400:14: error: 
      no matching constructor for initialization of 'tuple<llvm::LexicalScope
      *&&, const llvm::DILocalScope *&&, const llvm::DILocation *&&, bool &&>'
    { return tuple<_Elements&&...>(std::forward<_Elements>(__args)...); }
             ^                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../lib/CodeGen/LexicalScopes.cpp:186:43: note: in instantiation of function
      template specialization 'std::forward_as_tuple<llvm::LexicalScope *&,
      const llvm::DILocalScope *&, const llvm::DILocation *&, bool>' requested
      here
                                     std::forward_as_tuple(Parent, Scope,
                                          ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/tuple:600:18: note: 
      candidate template ignored: disabled by 'enable_if' [with _Dummy = void]
                 _TCC<_Dummy>::template
                 ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/tuple:611:18: note: 
      candidate template ignored: disabled by 'enable_if' [with _Dummy = void]
                 _TCC<_Dummy>::template
                 ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/tuple:628:5: note: 
      candidate template ignored: disabled by 'enable_if' [with _UElements =
      <llvm::LexicalScope *&, const llvm::DILocalScope *&, const
      llvm::DILocation *&, bool>]
                  _TC<sizeof...(_UElements) == 1, _Elements...>::template
                  ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/tuple:641:5: note: 
      candidate template ignored: disabled by 'enable_if' [with _UElements =
      <llvm::LexicalScope *&, const llvm::DILocalScope *&, const
      llvm::DILocation *&, bool>]
                  _TC<sizeof...(_UElements) == 1, _Elements...>::template
                  ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/tuple:737:19: note: 
      candidate template ignored: disabled by 'enable_if' [with _Alloc = const
      llvm::DILocalScope *, _UElements = <const llvm::DILocation *&, bool>]
        enable_if<_TMC<_UElements...>::template
                  ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/tuple:748:19: note: 
      candidate template ignored: disabled by 'enable_if' [with _Alloc = const
      llvm::DILocalScope *, _UElements = <const llvm::DILocation *&, bool>]
        enable_if<_TMC<_UElements...>::template
                  ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/tuple:579:17: note: 
      candidate constructor template not viable: requires 0 arguments, but 4
      were provided
      constexpr tuple()
                ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/tuple:589:26: note: 
      candidate constructor template not viable: requires 0 arguments, but 4
      were provided
      explicit constexpr tuple()
                         ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/tuple:670:19: note: 
      candidate constructor template not viable: requires single argument
      '__in', but 4 arguments were provided
        constexpr tuple(const tuple<_UElements...>& __in)
                  ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/tuple:682:28: note: 
      candidate constructor template not viable: requires single argument
      '__in', but 4 arguments were provided
        explicit constexpr tuple(const tuple<_UElements...>& __in)
                           ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/tuple:694:19: note: 
      candidate constructor template not viable: requires single argument
      '__in', but 4 arguments were provided
        constexpr tuple(tuple<_UElements...>&& __in)
                  ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/tuple:705:28: note: 
      candidate constructor template not viable: requires single argument
      '__in', but 4 arguments were provided
        explicit constexpr tuple(tuple<_UElements...>&& __in)
                           ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/tuple:721:2: note: 
      candidate constructor template not viable: requires 6 arguments, but 4
      were provided
        tuple(allocator_arg_t __tag, const _Alloc& __a,
        ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/tuple:732:11: note: 
      candidate constructor template not viable: requires 6 arguments, but 4
      were provided
        explicit tuple(allocator_arg_t __tag, const _Alloc& __a,
                 ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/tuple:711:2: note: 
      candidate constructor template not viable: requires 2 arguments, but 4
      were provided
        tuple(allocator_arg_t __tag, const _Alloc& __a)
        ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/tuple:759:2: note: 
      candidate constructor template not viable: requires 3 arguments, but 4
      were provided
        tuple(allocator_arg_t __tag, const _Alloc& __a, const tuple& __in)
        ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/tuple:763:2: note: 
      candidate constructor template not viable: requires 3 arguments, but 4
      were provided
        tuple(allocator_arg_t __tag, const _Alloc& __a, tuple&& __in)
        ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/tuple:772:2: note: 
      candidate constructor template not viable: requires 3 arguments, but 4
      were provided
        tuple(allocator_arg_t __tag, const _Alloc& __a,
        ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/tuple:784:11: note: 
      candidate constructor template not viable: requires 3 arguments, but 4
      were provided
        explicit tuple(allocator_arg_t __tag, const _Alloc& __a,
                 ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/tuple:796:2: note: 
      candidate constructor template not viable: requires 3 arguments, but 4
      were provided
        tuple(allocator_arg_t __tag, const _Alloc& __a,
        ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/tuple:808:11: note: 
      candidate constructor template not viable: requires 3 arguments, but 4
      were provided
        explicit tuple(allocator_arg_t __tag, const _Alloc& __a,
                 ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/tuple:654:17: note: 
      candidate constructor not viable: requires 1 argument, but 4 were provided
      constexpr tuple(tuple&&) = default; 
                ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/tuple:652:17: note: 
      candidate constructor not viable: requires 1 argument, but 4 were provided
      constexpr tuple(const tuple&) = default;
                ^
../../lib/CodeGen/LexicalScopes.cpp:208:32: error: no matching function for call
      to 'forward_as_tuple'
                               std::forward_as_tuple(Parent, Scope,
                               ^~~~~~~~~~~~~~~~~~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/tuple:1399:5: note: 
      candidate template ignored: substitution failure [with _Elements =
      <llvm::LexicalScope *&, const llvm::DILocalScope *&, nullptr_t, bool>]
    forward_as_tuple(_Elements&&... __args) noexcept

Any further thoughts?

alexfh edited reviewers, added: rsmith; removed: alexfh.Aug 13 2016, 10:02 AM
alexfh added a subscriber: alexfh.Aug 13 2016, 10:06 AM

I'm not the right person to review this, but the original code looks fine to me. Seems like a problem with libstdc++? Maybe Richard can say more precisely.

rsmith edited edge metadata.Aug 13 2016, 7:11 PM

clang 3.6, 3.7 and gcc 6.1.1 libstdc++ headers

Do we need to care about this configuration? Versions of clang prior to 3.9 didn't implement the abi_tag attribute, so presumably are going to fail to link even if the compilation succeeds?

Linking works fine, it's just a compilation issue.
Seems a nice thing for someone on 3.7 to be able to compile 3.9.
I certainly need to.

Can you explain what the problem is? Is this a bug in libstdc++'s tuple implementation?

The problem is either libstd++ tuple or clang's parsing of it. The second or third comment in this thread is the output log.
The result is someone on clang-3.7 and gcc6 has no way to upgrade their install.
In particular I need to compile LLVM/clang for their libraries not clang itself and it is not possible to do so currently.

dexonsmith resigned from this revision.Oct 19 2020, 2:53 PM
alexfh removed a subscriber: alexfh.Oct 21 2020, 7:22 AM