[PATCH] D66195: Move to C++14

JF Bastien via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 15 10:01:34 PDT 2019


jfb added a comment.

In D66195#1631746 <https://reviews.llvm.org/D66195#1631746>, @jfb wrote:

> Ugh that's an ugly one...
>
> In D66195#1631620 <https://reviews.llvm.org/D66195#1631620>, @thakis wrote:
>
> >   /b/s/w/ir/cache/builder/src/third_party/llvm/llvm/include/llvm/ADT/STLExtras.h:1322:19:   required from ‘void llvm::stable_sort(R&&, Compare) [with R = llvm::MutableArrayRef<lld::elf::InputSection*>&; Compare = std::function<bool(lld::elf::InputSectionBase*, lld::elf::InputSectionBase*)>]’
> >   /b/s/w/ir/cache/builder/src/third_party/llvm/lld/ELF/LinkerScript.cpp:347:44:   required from here
> >   /b/s/w/ir/cache/builder/src/third_party/llvm-build-tools/gcc510trusty/include/c++/5.1.0/bits/predefined_ops.h:123:46: error: no match for call to ‘(std::function<bool(lld::elf::InputSectionBase*, lld::elf::InputSectionBase*)>) (lld::elf::InputSectionBase&, lld::elf::InputSectionBase&)’
> >
>
>
> Looks like we do the following:
>
>   template <typename R, typename Compare>
>   void stable_sort(R &&Range, Compare C) {
>     std::stable_sort(adl_begin(Range), adl_end(Range), C);
>   }
>  
>   static void sortSections(MutableArrayRef<InputSection *> vec,
>                            SortSectionPolicy k) {
>     if (k != SortSectionPolicy::Default && k != SortSectionPolicy::None)
>       llvm::stable_sort(vec, getComparator(k));
>   }
>  
>   static std::function<bool(InputSectionBase *, InputSectionBase *)>
>   getComparator(SortSectionPolicy k) {
>     switch (k) {
>     case SortSectionPolicy::Alignment:
>       return [](InputSectionBase *a, InputSectionBase *b) {
>         // ">" is not a mistake. Sections with larger alignments are placed
>         // before sections with smaller alignments in order to reduce the
>         // amount of padding necessary. This is compatible with GNU.
>         return a->alignment > b->alignment;
>       };
>     case SortSectionPolicy::Name:
>       return [](InputSectionBase *a, InputSectionBase *b) {
>         return a->name < b->name;
>       };
>     case SortSectionPolicy::Priority:
>       return [](InputSectionBase *a, InputSectionBase *b) {
>         return getPriority(a->name) < getPriority(b->name);
>       };
>     default:
>       llvm_unreachable("unknown sort policy");
>     }
>   }
>
>
>
>
> > Has anyone seen this before? Any known workarounds?
>
> I haven't seen it before... taking a look now.


I have a repro, will try to figure out a workaround. It's fixed in 5.2. Talking to Jonathan Wakely we'd probably be better off on 5.5, but that'll be a separate discussion.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66195/new/

https://reviews.llvm.org/D66195





More information about the llvm-commits mailing list