* [gentoo-commits] repo/gentoo:master commit in: dev-libs/keystone/files/, dev-libs/keystone/
@ 2024-08-06 11:10 Sam James
  0 siblings, 0 replies; 2+ messages in thread
From: Sam James @ 2024-08-06 11:10 UTC (permalink / raw
  To: gentoo-commits
commit:     a96a616ddf52518754b62219309d1d289795d803
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Tue Aug  6 11:09:13 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Aug  6 11:09:13 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a96a616d
dev-libs/keystone: fix build w/ gcc-15
I admit I haven't sent this upstream as upstream don't seem to be
merging many PRs at the moment and it's also in some ancient copy
of bundled LLVM.
Signed-off-by: Sam James <sam <AT> gentoo.org>
 dev-libs/keystone/files/keystone-0.9.2-gcc15-cstdint.patch | 10 ++++++++++
 dev-libs/keystone/keystone-0.9.2-r3.ebuild                 |  1 +
 2 files changed, 11 insertions(+)
diff --git a/dev-libs/keystone/files/keystone-0.9.2-gcc15-cstdint.patch b/dev-libs/keystone/files/keystone-0.9.2-gcc15-cstdint.patch
new file mode 100644
index 000000000000..ba053db30040
--- /dev/null
+++ b/dev-libs/keystone/files/keystone-0.9.2-gcc15-cstdint.patch
@@ -0,0 +1,10 @@
+--- a/llvm/include/llvm/ADT/STLExtras.h
++++ b/llvm/include/llvm/ADT/STLExtras.h
+@@ -21,6 +21,7 @@
+ #include <algorithm> // for std::all_of
+ #include <cassert>
+ #include <cstddef> // for std::size_t
++#include <cstdint>
+ #include <cstdlib> // for qsort
+ #include <functional>
+ #include <iterator>
diff --git a/dev-libs/keystone/keystone-0.9.2-r3.ebuild b/dev-libs/keystone/keystone-0.9.2-r3.ebuild
index 3ac8106f976a..b6d645b0d8ee 100644
--- a/dev-libs/keystone/keystone-0.9.2-r3.ebuild
+++ b/dev-libs/keystone/keystone-0.9.2-r3.ebuild
@@ -50,6 +50,7 @@ REQUIRED_USE="
 
 PATCHES=(
 	"${FILESDIR}/${P}-strict-prototypes.patch"
+	"${FILESDIR}/${PN}-0.9.2-gcc15-cstdint.patch"
 )
 
 # Upstream doesn't flag patch releases (bug 858395)
^ permalink raw reply related	[flat|nested] 2+ messages in thread
* [gentoo-commits] repo/gentoo:master commit in: dev-libs/keystone/files/, dev-libs/keystone/
@ 2025-07-14  9:18 Sam James
  0 siblings, 0 replies; 2+ messages in thread
From: Sam James @ 2025-07-14  9:18 UTC (permalink / raw
  To: gentoo-commits
commit:     ad4249e5cec98b45e858a17e3e6071d1126350ec
Author:     Mario Haustein <mario.haustein <AT> hrz <DOT> tu-chemnitz <DOT> de>
AuthorDate: Sun Jul 13 09:27:55 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Jul 14 09:17:07 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ad4249e5
dev-libs/keystone: build with modern C and CMake
Closes: https://bugs.gentoo.org/952088
Closes: https://bugs.gentoo.org/924770
Signed-off-by: Mario Haustein <mario.haustein <AT> hrz.tu-chemnitz.de>
Part-of: https://github.com/gentoo/gentoo/pull/42985
Closes: https://github.com/gentoo/gentoo/pull/42985
Signed-off-by: Sam James <sam <AT> gentoo.org>
 .../keystone/files/keystone-0.9.2-modern-c.patch   | 319 +++++++++++++++++++++
 dev-libs/keystone/keystone-0.9.2-r4.ebuild         | 104 +++++++
 2 files changed, 423 insertions(+)
diff --git a/dev-libs/keystone/files/keystone-0.9.2-modern-c.patch b/dev-libs/keystone/files/keystone-0.9.2-modern-c.patch
new file mode 100644
index 000000000000..a3a55532cf12
--- /dev/null
+++ b/dev-libs/keystone/files/keystone-0.9.2-modern-c.patch
@@ -0,0 +1,319 @@
+From 41197bc85d6b95de3345f5a09d321469c2bba58e Mon Sep 17 00:00:00 2001
+From: Jordan Moore <lockbox@struct.foo>
+Date: Mon, 2 Jun 2025 16:36:27 -0400
+Subject: [PATCH 1/5] fix: cstdint explicitly included when used
+
+* fixes error in gcc15 where this header is no longer
+  implicitly included
+---
+ llvm/include/llvm/ADT/STLExtras.h | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/llvm/include/llvm/ADT/STLExtras.h b/llvm/include/llvm/ADT/STLExtras.h
+index 3346de93..a2adf853 100644
+--- a/llvm/include/llvm/ADT/STLExtras.h
++++ b/llvm/include/llvm/ADT/STLExtras.h
+@@ -21,6 +21,7 @@
+ #include <algorithm> // for std::all_of
+ #include <cassert>
+ #include <cstddef> // for std::size_t
++#include <cstdint>
+ #include <cstdlib> // for qsort
+ #include <functional>
+ #include <iterator>
+
+From f3f792cc05080a4bcc3c2886c0c7cee9294c4a05 Mon Sep 17 00:00:00 2001
+From: Jordan Moore <lockbox@struct.foo>
+Date: Mon, 2 Jun 2025 16:58:31 -0400
+Subject: [PATCH 2/5] fix: build with modern cmake
+
+---
+ CMakeLists.txt        | 19 +------------------
+ kstool/CMakeLists.txt |  2 +-
+ llvm/CMakeLists.txt   | 15 +--------------
+ 3 files changed, 3 insertions(+), 33 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 938d4983..9ce08362 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -1,7 +1,7 @@
+ # Keystone Assembler Engine (www.keystone-engine.org)
+ # By Nguyen Anh Quynh, 2016
+ 
+-cmake_minimum_required(VERSION 2.8.7)
++cmake_minimum_required(VERSION 3.10.0)
+ project(keystone)
+ 
+ set(KEYSTONE_VERSION_MAJOR 0)
+@@ -15,23 +15,6 @@ if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
+   set(CMAKE_BUILD_TYPE "Debug")
+ endif()
+ 
+-if (POLICY CMP0022)
+-  cmake_policy(SET CMP0022 NEW) # automatic when 2.8.12 is required
+-endif()
+-
+-if (POLICY CMP0051)
+-  # CMake 3.1 and higher include generator expressions of the form
+-  # $<TARGETLIB:obj> in the SOURCES property.  These need to be
+-  # stripped everywhere that access the SOURCES property, so we just
+-  # defer to the OLD behavior of not including generator expressions
+-  # in the output for now.
+-  cmake_policy(SET CMP0051 OLD)
+-endif()
+-
+-if (POLICY CMP0063)
+-  set(CMAKE_POLICY_DEFAULT_CMP0063 NEW) # automatic when 3.3.2 is required
+-endif()
+-
+ if (CMAKE_VERSION VERSION_LESS 3.1.20141117)
+   set(cmake_3_2_USES_TERMINAL)
+ else()
+diff --git a/kstool/CMakeLists.txt b/kstool/CMakeLists.txt
+index d28da481..25113821 100644
+--- a/kstool/CMakeLists.txt
++++ b/kstool/CMakeLists.txt
+@@ -1,7 +1,7 @@
+ # Kstool for Keystone assembler engine.
+ # By Nguyen Anh Quynh, 2016
+ 
+-cmake_minimum_required(VERSION 2.8)
++cmake_minimum_required(VERSION 3.10.0)
+ 
+ project(kstool)
+ 
+diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
+index d926b082..518613a5 100644
+--- a/llvm/CMakeLists.txt
++++ b/llvm/CMakeLists.txt
+@@ -1,6 +1,6 @@
+ # See docs/CMake.html for instructions about how to build LLVM with CMake.
+ 
+-cmake_minimum_required(VERSION 2.8.7)
++cmake_minimum_required(VERSION 3.10.0)
+ 
+ set(LLVM_INSTALL_TOOLCHAIN_ONLY ON)
+ 
+@@ -9,19 +9,6 @@ if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
+   set(CMAKE_BUILD_TYPE "Debug")
+ endif()
+ 
+-if(POLICY CMP0022)
+-  cmake_policy(SET CMP0022 NEW) # automatic when 2.8.12 is required
+-endif()
+-
+-if (POLICY CMP0051)
+-  # CMake 3.1 and higher include generator expressions of the form
+-  # $<TARGETLIB:obj> in the SOURCES property.  These need to be
+-  # stripped everywhere that access the SOURCES property, so we just
+-  # defer to the OLD behavior of not including generator expressions
+-  # in the output for now.
+-  cmake_policy(SET CMP0051 OLD)
+-endif()
+-
+ if(CMAKE_VERSION VERSION_LESS 3.1.20141117)
+   set(cmake_3_2_USES_TERMINAL)
+ else()
+
+From 4e2fcaa8fad81fc6016bd4d7d245d04719195381 Mon Sep 17 00:00:00 2001
+From: Jordan Moore <lockbox@struct.foo>
+Date: Mon, 2 Jun 2025 17:49:30 -0400
+Subject: [PATCH 3/5] fix: bindings: rust: moderize and format
+
+---
+ bindings/rust/Cargo.toml              |  1 +
+ bindings/rust/keystone-sys/Cargo.toml |  1 +
+ bindings/rust/keystone-sys/build.rs   |  2 +-
+ bindings/rust/keystone-sys/src/lib.rs | 14 ++------------
+ bindings/rust/src/lib.rs              |  2 +-
+ 5 files changed, 6 insertions(+), 14 deletions(-)
+
+diff --git a/bindings/rust/Cargo.toml b/bindings/rust/Cargo.toml
+index 3342e5a1..013a6e9d 100644
+--- a/bindings/rust/Cargo.toml
++++ b/bindings/rust/Cargo.toml
+@@ -1,6 +1,7 @@
+ [package]
+ name = "keystone"
+ version = "0.9.2"
++edition = "2018"
+ authors = [
+   "Remco Verhoef <remco.verhoef@dutchcoders.io>",
+   "Tasuku SUENAGA a.k.a. gunyarakun <tasuku-s-github@titech.ac>"
+diff --git a/bindings/rust/keystone-sys/Cargo.toml b/bindings/rust/keystone-sys/Cargo.toml
+index a836c305..7b88aff6 100644
+--- a/bindings/rust/keystone-sys/Cargo.toml
++++ b/bindings/rust/keystone-sys/Cargo.toml
+@@ -1,6 +1,7 @@
+ [package]
+ name = "keystone-sys"
+ version = "0.9.2"
++edition = "2018"
+ authors = [
+   "Remco Verhoef <remco.verhoef@dutchcoders.io>",
+   "Tasuku SUENAGA a.k.a. gunyarakun <tasuku-s-github@titech.ac>"
+diff --git a/bindings/rust/keystone-sys/build.rs b/bindings/rust/keystone-sys/build.rs
+index 9670fcb3..a92a41f2 100644
+--- a/bindings/rust/keystone-sys/build.rs
++++ b/bindings/rust/keystone-sys/build.rs
+@@ -17,7 +17,7 @@ fn build_with_cmake() {
+         // This only happens when using the crate via a `git` reference as the
+         // published version already embeds keystone's source.
+         let pwd = std::env::current_dir().unwrap();
+-        let keystone_dir = pwd.ancestors().skip(3).next().unwrap();
++        let keystone_dir = pwd.ancestors().nth(3).unwrap();
+         symlink(keystone_dir, "keystone").expect("failed to symlink keystone");
+     }
+ 
+diff --git a/bindings/rust/keystone-sys/src/lib.rs b/bindings/rust/keystone-sys/src/lib.rs
+index 6eb282a6..8bd5eefd 100644
+--- a/bindings/rust/keystone-sys/src/lib.rs
++++ b/bindings/rust/keystone-sys/src/lib.rs
+@@ -10,19 +10,9 @@ extern crate libc;
+ 
+ pub mod keystone_const;
+ 
++use ::libc::{c_char, c_int, c_uchar, c_uint, size_t};
++use ::std::{ffi::CStr, fmt, ptr};
+ use keystone_const::{Arch, Error, Mode, OptionType, OptionValue};
+-use ::std::{
+-    ffi::CStr,
+-    fmt,
+-    ptr,
+-};
+-use ::libc::{
+-    c_char,
+-    c_uchar,
+-    c_int,
+-    c_uint,
+-    size_t,
+-};
+ 
+ /// Opaque type representing the Keystone engine
+ #[repr(C)]
+diff --git a/bindings/rust/src/lib.rs b/bindings/rust/src/lib.rs
+index dd5bd042..dc8cd5e0 100644
+--- a/bindings/rust/src/lib.rs
++++ b/bindings/rust/src/lib.rs
+@@ -90,7 +90,7 @@ impl Keystone {
+         let err = unsafe { ffi::ks_open(arch, mode, &mut handle) };
+         if err == Error::OK {
+             Ok(Keystone {
+-                handle: handle.expect("Got NULL engine from ks_open()")
++                handle: handle.expect("Got NULL engine from ks_open()"),
+             })
+         } else {
+             Err(err)
+
+From bf3b00fba5a32bba3b3f7fb1d54e374338614a96 Mon Sep 17 00:00:00 2001
+From: Jordan Moore <lockbox@struct.foo>
+Date: Mon, 2 Jun 2025 17:50:07 -0400
+Subject: [PATCH 4/5] fix: only attempt to publish bindings on master
+
+---
+ .github/workflows/python-publish.yml | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml
+index 6f5e8554..cb0d2d5c 100644
+--- a/.github/workflows/python-publish.yml
++++ b/.github/workflows/python-publish.yml
+@@ -1,6 +1,9 @@
+ name: PyPI 📦 Distribution
+ 
+-on: [push]
++on:
++  push:
++    branches:
++      - master
+ 
+ jobs:
+   build:
+
+From 667cce956ce9c3b2ec7eb30d23198deb9596b427 Mon Sep 17 00:00:00 2001
+From: Jordan Moore <lockbox@struct.foo>
+Date: Mon, 2 Jun 2025 17:50:50 -0400
+Subject: [PATCH 5/5] feat: basic CI
+
+---
+ .github/workflows/cmake-build.yml | 31 +++++++++++++++++++++++++++++++
+ .github/workflows/rust-build.yml  | 31 +++++++++++++++++++++++++++++++
+ 2 files changed, 62 insertions(+)
+ create mode 100644 .github/workflows/cmake-build.yml
+ create mode 100644 .github/workflows/rust-build.yml
+
+diff --git a/.github/workflows/cmake-build.yml b/.github/workflows/cmake-build.yml
+new file mode 100644
+index 00000000..4de36eab
+--- /dev/null
++++ b/.github/workflows/cmake-build.yml
+@@ -0,0 +1,31 @@
++# Builds the codebase with cmake
++
++name: CMake CI
++on:
++  pull_request:
++  push:
++    branches:
++      - master
++
++jobs:
++  linux-build:
++    name: Linux
++    runs-on: ubuntu-24.04
++    steps:
++      - name: Checkout source code
++        uses: actions/checkout@v4
++      - name: Install prerequisites
++        shell: bash
++        run: |
++          sudo apt-get -y update
++          sudo apt-get install -y \
++              cmake \
++              gcc
++      - name: Configure
++        shell: bash
++        run: |
++          cmake -B build
++      - name: Bulid
++        shell: bash
++        run: |
++          cmake --build build
+diff --git a/.github/workflows/rust-build.yml b/.github/workflows/rust-build.yml
+new file mode 100644
+index 00000000..7f7c8e01
+--- /dev/null
++++ b/.github/workflows/rust-build.yml
+@@ -0,0 +1,31 @@
++# Builds the codebase with cmake on ubuntu, windows and macos.
++#
++name: Rust CI
++on:
++  pull_request:
++  push:
++    branches:
++      - master
++
++jobs:
++  linux-test:
++    name: Linux
++    runs-on: ubuntu-24.04
++    steps:
++      - uses: actions/checkout@v4
++      - uses: dtolnay/rust-toolchain@stable
++
++      - name: Install prerequisites
++        shell: bash
++        run: |
++          sudo apt-get -y update
++          sudo apt-get install -y \
++              cmake \
++              libclang-dev \
++              pkg-config \
++              gcc
++      - name: Build and test rust
++        shell: bash
++        run: |
++          cd bindings/rust
++          cargo test
diff --git a/dev-libs/keystone/keystone-0.9.2-r4.ebuild b/dev-libs/keystone/keystone-0.9.2-r4.ebuild
new file mode 100644
index 000000000000..efe4c95c6452
--- /dev/null
+++ b/dev-libs/keystone/keystone-0.9.2-r4.ebuild
@@ -0,0 +1,104 @@
+# Copyright 1999-2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+DISTUTILS_EXT=1
+DISTUTILS_OPTIONAL=1
+DISTUTILS_USE_PEP517=setuptools
+PYTHON_COMPAT=( python3_{10..13} )
+
+inherit cmake distutils-r1 flag-o-matic
+
+DESCRIPTION="assembly/assembler framework + bindings"
+HOMEPAGE="https://www.keystone-engine.org/"
+
+if [[ ${PV} == 9999* ]]; then
+	EGIT_REPO_URI="https://github.com/keystone-engine/keystone.git"
+	inherit git-r3
+else
+	SRC_URI="https://github.com/keystone-engine/keystone/archive/${PV/_rc/-rc}.tar.gz -> ${P}.tar.gz"
+	KEYWORDS="~amd64 ~arm ~arm64 ~ppc ~ppc64 ~x86"
+fi
+S="${WORKDIR}"/${P/_rc/-rc}
+
+LICENSE="GPL-2"
+SLOT="0"
+
+# Keep in sync with llvm/CMakeLists.txt
+KEYSTONE_TARGETS="AArch64 ARM Hexagon Mips PowerPC Sparc SystemZ X86"
+
+IUSE="python"
+
+RDEPEND="
+	python? ( ${PYTHON_DEPS} )
+"
+DEPEND="${RDEPEND}"
+BDEPEND="
+	python?
+	(
+		${DISTUTILS_DEPS}
+		${PYTHON_DEPS}
+	)
+"
+
+RESTRICT=test # only regression tests
+
+REQUIRED_USE="
+	python? ( ${PYTHON_REQUIRED_USE} )
+"
+
+PATCHES=(
+	"${FILESDIR}/${P}-strict-prototypes.patch"
+	"${FILESDIR}/${PN}-0.9.2-modern-c.patch"
+)
+
+# Upstream doesn't flag patch releases (bug 858395)
+QA_PKGCONFIG_VERSION="$(ver_cut 1-2)"
+
+wrap_python() {
+	if use python; then
+		pushd bindings/python >/dev/null || die
+		distutils-r1_${1} "$@"
+		popd >/dev/null || die
+	fi
+}
+
+pkg_setup() {
+	python_setup
+}
+
+src_prepare() {
+	sed -i '/NOT uppercase_CMAKE_BUILD_TYPE MATCHES/ s/DEBUG/GENTOO|DEBUG/' \
+		llvm/CMakeLists.txt || die
+	cmake_src_prepare
+	wrap_python ${FUNCNAME}
+}
+
+src_configure() {
+	# ODR violations in bundled LLVM (bug #924866)
+	filter-lto
+
+	local libdir="$(get_libdir)"
+	local mycmakeargs=(
+		-DCMAKE_CONFIGURATION_TYPES="Gentoo"
+		-DLLVM_LIBDIR_SUFFIX=${libdir#lib}
+		-DBUILD_SHARED_LIBS=ON
+		-DLLVM_TARGETS_TO_BUILD="${KEYSTONE_TARGETS// /;}"
+		-DLLVM_HOST_TRIPLE="${CHOST}"
+		-DPYTHON_EXECUTABLE="${PYTHON}"
+	)
+
+	cmake_src_configure
+	wrap_python ${FUNCNAME}
+}
+
+src_compile() {
+	cmake_src_compile
+	wrap_python ${FUNCNAME}
+}
+
+src_install() {
+	cmake_src_install
+	wrap_python ${FUNCNAME}
+}
^ permalink raw reply related	[flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-07-14  9:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-14  9:18 [gentoo-commits] repo/gentoo:master commit in: dev-libs/keystone/files/, dev-libs/keystone/ Sam James
  -- strict thread matches above, loose matches on Subject: below --
2024-08-06 11:10 Sam James
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox