See 
http://build-failures.rhaalovely.net/amd64-clang/2026-08-25/devel/llvm/21.log

This diff pulls in https://github.com/llvm/llvm-project/pull/160804
which is enough to make llvm/21 build with libcxx22. All reverse deps
also build (libcffi, zig stuff).

I split up REVISION into subpackages again since that was a source of
errors in recent llvm commits. I see no real benefit in lumping them all
together.

Index: Makefile
===================================================================
RCS file: /cvs/ports/devel/llvm/21/Makefile,v
diff -u -p -r1.22 Makefile
--- Makefile    25 Jul 2026 20:07:48 -0000      1.22
+++ Makefile    27 Aug 2026 17:12:50 -0000
@@ -2,7 +2,10 @@ LLVM_MAJOR =   21
 LLVM_VERSION = ${LLVM_MAJOR}.1.8
 LLVM_PKGSPEC = >=21,<22
 
-REVISION =     6
+REVISION-main =                7
+REVISION-libcxx =      6
+REVISION-lldb =                6
+REVISION-python =      6
 
 SHARED_LIBS += LLVM            0.0 \
                LTO             0.0 \
Index: patches/patch-llvm_include_llvm_CodeGen_RDFGraph_h
===================================================================
RCS file: patches/patch-llvm_include_llvm_CodeGen_RDFGraph_h
diff -N patches/patch-llvm_include_llvm_CodeGen_RDFGraph_h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-llvm_include_llvm_CodeGen_RDFGraph_h  27 Aug 2026 17:25:12 
-0000
@@ -0,0 +1,15 @@
+Fix build with libcxx22
+https://github.com/llvm/llvm-project/pull/160804
+
+Index: llvm/include/llvm/CodeGen/RDFGraph.h
+--- llvm/include/llvm/CodeGen/RDFGraph.h.orig
++++ llvm/include/llvm/CodeGen/RDFGraph.h
+@@ -447,7 +447,7 @@ struct NodeAllocator { (private)
+   AllocatorTy MemPool;
+ };
+ 
+-using RegisterSet = std::set<RegisterRef>;
++using RegisterSet = std::set<RegisterRef, RegisterRefLess>;
+ 
+ struct TargetOperandInfo {
+   TargetOperandInfo(const TargetInstrInfo &tii) : TII(tii) {}
Index: patches/patch-llvm_include_llvm_CodeGen_RDFRegisters_h
===================================================================
RCS file: patches/patch-llvm_include_llvm_CodeGen_RDFRegisters_h
diff -N patches/patch-llvm_include_llvm_CodeGen_RDFRegisters_h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-llvm_include_llvm_CodeGen_RDFRegisters_h      27 Aug 2026 
17:25:12 -0000
@@ -0,0 +1,84 @@
+Fix build with libcxx22
+https://github.com/llvm/llvm-project/pull/160804
+
+Index: llvm/include/llvm/CodeGen/RDFRegisters.h
+--- llvm/include/llvm/CodeGen/RDFRegisters.h.orig
++++ llvm/include/llvm/CodeGen/RDFRegisters.h
+@@ -199,6 +199,33 @@ struct PhysicalRegisterInfo { (private)
+   std::vector<AliasInfo> AliasInfos;
+ };
+ 
++struct RegisterRefEqualTo {
++  constexpr RegisterRefEqualTo(const llvm::rdf::PhysicalRegisterInfo &pri)
++      : PRI(&pri) {}
++
++  bool operator()(llvm::rdf::RegisterRef A, llvm::rdf::RegisterRef B) const {
++    return PRI->equal_to(A, B);
++  }
++
++private:
++  // Make it a pointer just in case. See comment in `RegisterRefLess` below.
++  const llvm::rdf::PhysicalRegisterInfo *PRI;
++};
++
++struct RegisterRefLess {
++  constexpr RegisterRefLess(const llvm::rdf::PhysicalRegisterInfo &pri)
++      : PRI(&pri) {}
++
++  bool operator()(llvm::rdf::RegisterRef A, llvm::rdf::RegisterRef B) const {
++    return PRI->less(A, B);
++  }
++
++private:
++  // Make it a pointer because apparently some versions of MSVC use std::swap
++  // on the comparator object.
++  const llvm::rdf::PhysicalRegisterInfo *PRI;
++};
++
+ struct RegisterAggr {
+   RegisterAggr(const PhysicalRegisterInfo &pri)
+       : Units(pri.getTRI().getNumRegUnits()), PRI(pri) {}
+@@ -334,18 +361,6 @@ template <> struct hash<llvm::rdf::RegisterAggr> {
+   }
+ };
+ 
+-template <> struct equal_to<llvm::rdf::RegisterRef> {
+-  constexpr equal_to(const llvm::rdf::PhysicalRegisterInfo &pri) : PRI(&pri) 
{}
+-
+-  bool operator()(llvm::rdf::RegisterRef A, llvm::rdf::RegisterRef B) const {
+-    return PRI->equal_to(A, B);
+-  }
+-
+-private:
+-  // Make it a pointer just in case. See comment in `less` below.
+-  const llvm::rdf::PhysicalRegisterInfo *PRI;
+-};
+-
+ template <> struct equal_to<llvm::rdf::RegisterAggr> {
+   bool operator()(const llvm::rdf::RegisterAggr &A,
+                   const llvm::rdf::RegisterAggr &B) const {
+@@ -353,23 +368,10 @@ template <> struct equal_to<llvm::rdf::RegisterAggr> {
+   }
+ };
+ 
+-template <> struct less<llvm::rdf::RegisterRef> {
+-  constexpr less(const llvm::rdf::PhysicalRegisterInfo &pri) : PRI(&pri) {}
+-
+-  bool operator()(llvm::rdf::RegisterRef A, llvm::rdf::RegisterRef B) const {
+-    return PRI->less(A, B);
+-  }
+-
+-private:
+-  // Make it a pointer because apparently some versions of MSVC use std::swap
+-  // on the std::less specialization.
+-  const llvm::rdf::PhysicalRegisterInfo *PRI;
+-};
+-
+ } // namespace std
+ 
+ namespace llvm::rdf {
+-using RegisterSet = std::set<RegisterRef, std::less<RegisterRef>>;
++using RegisterSet = std::set<RegisterRef, RegisterRefLess>;
+ } // namespace llvm::rdf
+ 
+ #endif // LLVM_CODEGEN_RDFREGISTERS_H
Index: patches/patch-llvm_lib_CodeGen_RDFLiveness_cpp
===================================================================
RCS file: patches/patch-llvm_lib_CodeGen_RDFLiveness_cpp
diff -N patches/patch-llvm_lib_CodeGen_RDFLiveness_cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-llvm_lib_CodeGen_RDFLiveness_cpp      27 Aug 2026 17:25:12 
-0000
@@ -0,0 +1,36 @@
+Fix build with libcxx22
+https://github.com/llvm/llvm-project/pull/160804
+
+Index: llvm/lib/CodeGen/RDFLiveness.cpp
+--- llvm/lib/CodeGen/RDFLiveness.cpp.orig
++++ llvm/lib/CodeGen/RDFLiveness.cpp
+@@ -652,8 +652,9 @@ void Liveness::computePhiInfo() {
+   // defs, cache the result of subtracting these defs from a given register
+   // ref.
+   using RefHash = std::hash<RegisterRef>;
+-  using RefEqual = std::equal_to<RegisterRef>;
+-  using SubMap = std::unordered_map<RegisterRef, RegisterRef>;
++  using RefEqual = RegisterRefEqualTo;
++  using SubMap =
++      std::unordered_map<RegisterRef, RegisterRef, RefHash, RefEqual>;
+   std::unordered_map<RegisterAggr, SubMap> Subs;
+   auto ClearIn = [](RegisterRef RR, const RegisterAggr &Mid, SubMap &SM) {
+     if (Mid.empty())
+@@ -868,7 +869,7 @@ void Liveness::computeLiveIns() {
+       std::vector<RegisterRef> LV;
+       for (const MachineBasicBlock::RegisterMaskPair &LI : B.liveins())
+         LV.push_back(RegisterRef(LI.PhysReg, LI.LaneMask));
+-      llvm::sort(LV, std::less<RegisterRef>(PRI));
++      llvm::sort(LV, RegisterRefLess(PRI));
+       dbgs() << printMBBReference(B) << "\t rec = {";
+       for (auto I : LV)
+         dbgs() << ' ' << Print(I, DFG);
+@@ -878,7 +879,7 @@ void Liveness::computeLiveIns() {
+       LV.clear();
+       for (RegisterRef RR : LiveMap[&B].refs())
+         LV.push_back(RR);
+-      llvm::sort(LV, std::less<RegisterRef>(PRI));
++      llvm::sort(LV, RegisterRefLess(PRI));
+       dbgs() << "\tcomp = {";
+       for (auto I : LV)
+         dbgs() << ' ' << Print(I, DFG);
Index: patches/patch-llvm_lib_Target_Hexagon_RDFCopy_cpp
===================================================================
RCS file: patches/patch-llvm_lib_Target_Hexagon_RDFCopy_cpp
diff -N patches/patch-llvm_lib_Target_Hexagon_RDFCopy_cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-llvm_lib_Target_Hexagon_RDFCopy_cpp   27 Aug 2026 17:25:12 
-0000
@@ -0,0 +1,15 @@
+Fix build with libcxx22
+https://github.com/llvm/llvm-project/pull/160804
+
+Index: llvm/lib/Target/Hexagon/RDFCopy.cpp
+--- llvm/lib/Target/Hexagon/RDFCopy.cpp.orig
++++ llvm/lib/Target/Hexagon/RDFCopy.cpp
+@@ -108,7 +108,7 @@ bool CopyPropagation::scanBlock(MachineBasicBlock *B) 
+   for (NodeAddr<InstrNode*> IA : BA.Addr->members(DFG)) {
+     if (DFG.IsCode<NodeAttrs::Stmt>(IA)) {
+       NodeAddr<StmtNode*> SA = IA;
+-      EqualityMap EM(std::less<RegisterRef>(DFG.getPRI()));
++      EqualityMap EM(RegisterRefLess(DFG.getPRI()));
+       if (interpretAsCopy(SA.Addr->getCode(), EM))
+         recordCopy(SA, EM);
+     }
Index: patches/patch-llvm_lib_Target_Hexagon_RDFCopy_h
===================================================================
RCS file: patches/patch-llvm_lib_Target_Hexagon_RDFCopy_h
diff -N patches/patch-llvm_lib_Target_Hexagon_RDFCopy_h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-llvm_lib_Target_Hexagon_RDFCopy_h     27 Aug 2026 17:25:12 
-0000
@@ -0,0 +1,35 @@
+Fix build with libcxx22
+https://github.com/llvm/llvm-project/pull/160804
+
+Index: llvm/lib/Target/Hexagon/RDFCopy.h
+--- llvm/lib/Target/Hexagon/RDFCopy.h.orig
++++ llvm/lib/Target/Hexagon/RDFCopy.h
+@@ -25,8 +25,8 @@ class MachineInstr;
+ namespace rdf {
+ 
+   struct CopyPropagation {
+-    CopyPropagation(DataFlowGraph &dfg) : MDT(dfg.getDT()), DFG(dfg),
+-        RDefMap(std::less<RegisterRef>(DFG.getPRI())) {}
++    CopyPropagation(DataFlowGraph &dfg)
++        : MDT(dfg.getDT()), DFG(dfg), RDefMap(RegisterRefLess(DFG.getPRI())) 
{}
+ 
+     virtual ~CopyPropagation() = default;
+ 
+@@ -35,7 +35,7 @@ namespace rdf {
+     bool trace() const { return Trace; }
+     DataFlowGraph &getDFG() { return DFG; }
+ 
+-    using EqualityMap = std::map<RegisterRef, RegisterRef>;
++    using EqualityMap = std::map<RegisterRef, RegisterRef, RegisterRefLess>;
+     virtual bool interpretAsCopy(const MachineInstr *MI, EqualityMap &EM);
+ 
+   private:
+@@ -45,7 +45,7 @@ namespace rdf {
+     bool Trace = false;
+ 
+     // map: register -> (map: stmt -> reaching def)
+-    std::map<RegisterRef,std::map<NodeId,NodeId>> RDefMap;
++    std::map<RegisterRef, std::map<NodeId, NodeId>, RegisterRefLess> RDefMap;
+     // map: statement -> (map: dst reg -> src reg)
+     std::map<NodeId, EqualityMap> CopyMap;
+     std::vector<NodeId> Copies;
Index: patches/patch-llvm_unittests_CodeGen_TypeTraitsTest_cpp
===================================================================
RCS file: patches/patch-llvm_unittests_CodeGen_TypeTraitsTest_cpp
diff -N patches/patch-llvm_unittests_CodeGen_TypeTraitsTest_cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-llvm_unittests_CodeGen_TypeTraitsTest_cpp     27 Aug 2026 
17:25:12 -0000
@@ -0,0 +1,61 @@
+Fix build with libcxx22
+https://github.com/llvm/llvm-project/pull/160804
+
+Index: llvm/unittests/CodeGen/TypeTraitsTest.cpp
+--- llvm/unittests/CodeGen/TypeTraitsTest.cpp.orig
++++ llvm/unittests/CodeGen/TypeTraitsTest.cpp
+@@ -6,13 +6,16 @@
+ //
+ 
//===----------------------------------------------------------------------===//
+ 
++#include "llvm/CodeGen/RDFRegisters.h"
+ #include "llvm/CodeGen/RegisterPressure.h"
+ #include "llvm/CodeGen/ScheduleDAG.h"
+ #include "llvm/CodeGen/SelectionDAGNodes.h"
+ #include "llvm/CodeGen/SlotIndexes.h"
+ #include "llvm/CodeGen/TargetPassConfig.h"
+ #include "gtest/gtest.h"
++#include <functional>
+ #include <type_traits>
++#include <utility>
+ 
+ using namespace llvm;
+ 
+@@ -24,5 +27,37 @@ static_assert(std::is_trivially_copyable_v<SDValue>, "
+ static_assert(std::is_trivially_copyable_v<SlotIndex>, "trivially copyable");
+ static_assert(std::is_trivially_copyable_v<IdentifyingPassPtr>,
+               "trivially copyable");
++
++// https://llvm.org/PR105169
++// Verify that we won't accidently specialize std::less and std::equal_to in a
++// wrong way.
++// C++17 [namespace.std]/2, C++20/23 [namespace.std]/5:
++//   A program may explicitly instantiate a template defined in the standard
++//   library only if the declaration
++//   - depends on the name of a user-defined type and
++//   - the instantiation meets the standard library requirements for the
++//   original template.
++template <class Fn> constexpr bool CheckStdCmpRequirements() {
++  // std::less and std::equal_to are literal, default constructible, and
++  // copyable classes.
++  Fn f1;
++  auto f2 = f1;
++  auto f3 = std::move(f2);
++  f2 = f3;
++  f2 = std::move(f3);
++
++  // Properties held on all known implementations, although not guaranteed by
++  // the standard.
++  static_assert(std::is_empty_v<Fn>);
++  static_assert(std::is_trivially_default_constructible_v<Fn>);
++  static_assert(std::is_trivially_copyable_v<Fn>);
++
++  return true;
++}
++
++static_assert(CheckStdCmpRequirements<std::less<rdf::RegisterRef>>(),
++              "same as the original template");
++static_assert(CheckStdCmpRequirements<std::equal_to<rdf::RegisterRef>>(),
++              "same as the original template");
+ #endif
+ 

Reply via email to