diff mbox series

[v2] apt: Fix build with clang and libc++

Message ID 20250721195750.1980040-1-raj.khem@gmail.com
State New
Headers show
Series [v2] apt: Fix build with clang and libc++ | expand

Commit Message

Khem Raj July 21, 2025, 7:57 p.m. UTC
Backport a fix to address random access iterator's expectation of
being const-qualified inside libc++ std::__insertion_sort_unguarded
implementation

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
v2: Backport a patch to fix build with libc++ instead of always enforcing libstdc++

 ...compilation-error-with-clang-libc-18.patch | 29 +++++++++++++++++++
 meta/recipes-devtools/apt/apt_2.6.1.bb        |  1 +
 2 files changed, 30 insertions(+)
 create mode 100644 meta/recipes-devtools/apt/apt/0001-Fix-compilation-error-with-clang-libc-18.patch
diff mbox series

Patch

diff --git a/meta/recipes-devtools/apt/apt/0001-Fix-compilation-error-with-clang-libc-18.patch b/meta/recipes-devtools/apt/apt/0001-Fix-compilation-error-with-clang-libc-18.patch
new file mode 100644
index 00000000000..e55205ca3ff
--- /dev/null
+++ b/meta/recipes-devtools/apt/apt/0001-Fix-compilation-error-with-clang-libc-18.patch
@@ -0,0 +1,29 @@ 
+From b4488583424b33f51cb031562a9e8df820ffda23 Mon Sep 17 00:00:00 2001
+From: Chongyun Lee <licy183@termux.dev>
+Date: Thu, 15 Aug 2024 21:31:24 +0800
+Subject: [PATCH] Fix compilation error with clang/libc++ 18
+
+Upstream-Status: Backport [https://salsa.debian.org/apt-team/apt/-/commit/b4488583424b33f51cb031562a9e8df820ffda23]
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ apt-pkg/cacheset.h | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/apt-pkg/cacheset.h b/apt-pkg/cacheset.h
+index 5dbb9bf08..1c67a65d6 100644
+--- a/apt-pkg/cacheset.h
++++ b/apt-pkg/cacheset.h
+@@ -218,11 +218,11 @@ public:
+ 	operator container_iterator(void) const { return _iter; }
+ 	inline iterator_type& operator++() { ++_iter; return static_cast<iterator_type&>(*this); }
+ 	inline iterator_type operator++(int) { iterator_type tmp(*this); operator++(); return tmp; }
+-	inline iterator_type operator+(typename container_iterator::difference_type const &n) { return iterator_type(_iter + n); }
++	inline iterator_type operator+(typename container_iterator::difference_type const &n) const { return iterator_type(_iter + n); }
+ 	inline iterator_type operator+=(typename container_iterator::difference_type const &n) { _iter += n; return static_cast<iterator_type&>(*this); }
+ 	inline iterator_type& operator--() { --_iter;; return static_cast<iterator_type&>(*this); }
+ 	inline iterator_type operator--(int) { iterator_type tmp(*this); operator--(); return tmp; }
+-	inline iterator_type operator-(typename container_iterator::difference_type const &n) { return iterator_type(_iter - n); }
++	inline iterator_type operator-(typename container_iterator::difference_type const &n) const { return iterator_type(_iter - n); }
+ 	inline typename container_iterator::difference_type operator-(iterator_type const &b) { return (_iter - b._iter); }
+ 	inline iterator_type operator-=(typename container_iterator::difference_type const &n) { _iter -= n; return static_cast<iterator_type&>(*this); }
+ 	inline bool operator!=(iterator_type const &i) const { return _iter != i._iter; }
diff --git a/meta/recipes-devtools/apt/apt_2.6.1.bb b/meta/recipes-devtools/apt/apt_2.6.1.bb
index 50ac2ea812c..b039599395e 100644
--- a/meta/recipes-devtools/apt/apt_2.6.1.bb
+++ b/meta/recipes-devtools/apt/apt_2.6.1.bb
@@ -15,6 +15,7 @@  SRC_URI = "${DEBIAN_MIRROR}/main/a/apt/${BPN}_${PV}.tar.xz \
            file://0001-Remove-using-std-binary_function.patch \
            file://0001-strutl-Add-missing-include-cstdint-gcc-15.patch \
            file://0001-Raise-cmake_minimum_required-to-3.13-to-avoid-warnin.patch \
+           file://0001-Fix-compilation-error-with-clang-libc-18.patch \
            "
 
 SRC_URI:append:class-native = " \