From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 96AF215808A for ; Sun, 20 Jul 2025 16:49:00 +0000 (UTC) Received: from lists.gentoo.org (bobolink.gentoo.org [140.211.166.189]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) (Authenticated sender: relay-lists.gentoo.org@gentoo.org) by smtp.gentoo.org (Postfix) with ESMTPSA id 7E284340E03 for ; Sun, 20 Jul 2025 16:49:00 +0000 (UTC) Received: from bobolink.gentoo.org (localhost [127.0.0.1]) by bobolink.gentoo.org (Postfix) with ESMTP id 7C2F511055E; Sun, 20 Jul 2025 16:48:59 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by bobolink.gentoo.org (Postfix) with ESMTPS id 72C8411055E for ; Sun, 20 Jul 2025 16:48:59 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 11109340E03 for ; Sun, 20 Jul 2025 16:48:59 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id A3CD2327C for ; Sun, 20 Jul 2025 16:48:57 +0000 (UTC) From: "Michał Górny" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Michał Górny" Message-ID: <1753030134.ab0bf9f6ffce10948bc5d0a9a90da24c85f9e00d.mgorny@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: sci-libs/symengine/, sci-libs/symengine/files/ X-VCS-Repository: repo/gentoo X-VCS-Files: sci-libs/symengine/files/symengine-0.14.0-llvm.patch sci-libs/symengine/symengine-0.14.0-r2.ebuild X-VCS-Directories: sci-libs/symengine/files/ sci-libs/symengine/ X-VCS-Committer: mgorny X-VCS-Committer-Name: Michał Górny X-VCS-Revision: ab0bf9f6ffce10948bc5d0a9a90da24c85f9e00d X-VCS-Branch: master Date: Sun, 20 Jul 2025 16:48:57 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 2cdbbe5f-68dc-4e21-84b0-1c41b4b143b7 X-Archives-Hash: 22a0d0459f6e7940e417a1b0ca9f89fd commit: ab0bf9f6ffce10948bc5d0a9a90da24c85f9e00d Author: Michał Górny gentoo org> AuthorDate: Sun Jul 20 16:48:17 2025 +0000 Commit: Michał Górny gentoo org> CommitDate: Sun Jul 20 16:48:54 2025 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ab0bf9f6 sci-libs/symengine: Backport upstream LLVM fixes Signed-off-by: Michał Górny gentoo.org> .../symengine/files/symengine-0.14.0-llvm.patch | 108 ++++++++++++++++++++ sci-libs/symengine/symengine-0.14.0-r2.ebuild | 111 +++++++++++++++++++++ 2 files changed, 219 insertions(+) diff --git a/sci-libs/symengine/files/symengine-0.14.0-llvm.patch b/sci-libs/symengine/files/symengine-0.14.0-llvm.patch new file mode 100644 index 000000000000..3697088f9f9a --- /dev/null +++ b/sci-libs/symengine/files/symengine-0.14.0-llvm.patch @@ -0,0 +1,108 @@ +From de7305e5e2fee97d80c25164a8f8c9f7ecfc9953 Mon Sep 17 00:00:00 2001 +From: Liam Keegan +Date: Thu, 26 Jun 2025 14:51:50 +0200 +Subject: [PATCH] Fix issues when compiled against LLVM 20 built with + assertions enabled + +- `Assertion `Level != OptimizationLevel::O0 && "Must request optimizations!"'` + - skip simplification pipeline for O0 + - copied from https://github.com/symengine/symengine/issues/2076#issue-2764070679 +- `Assertion `GV->hasName() && "Global must have name."'` + - give the function a name +- `getDeclaration` is deprecated in llvm 20 and will be removed in next version + - use replacement `getOrInsertDeclaration` for llvm >= 20 +- resolves #2076 +--- + symengine/llvm_double.cpp | 34 +++++++++++++++++++++------------- + 1 file changed, 21 insertions(+), 13 deletions(-) + +diff --git a/symengine/llvm_double.cpp b/symengine/llvm_double.cpp +index fe06ebcc7..8ae3b4adf 100644 +--- a/symengine/llvm_double.cpp ++++ b/symengine/llvm_double.cpp +@@ -52,6 +52,12 @@ using CodeGenOptLevel = llvm::CodeGenOpt::Level; + using CodeGenOptLevel = llvm::CodeGenOptLevel; + #endif + ++#if (LLVM_VERSION_MAJOR < 20) ++const auto &GetDeclaration = llvm::Intrinsic::getDeclaration; ++#else ++const auto &GetDeclaration = llvm::Intrinsic::getOrInsertDeclaration; ++#endif ++ + #if (LLVM_VERSION_MAJOR >= 21) + #define AddNoCapture(A) A.addCapturesAttr(llvm::CaptureInfo::none()) + #else +@@ -85,8 +91,8 @@ llvm::Function *LLVMVisitor::get_function_type(llvm::LLVMContext *context) + } + llvm::FunctionType *function_type = llvm::FunctionType::get( + llvm::Type::getVoidTy(*context), inp, /*isVarArgs=*/false); +- auto F = llvm::Function::Create(function_type, +- llvm::Function::InternalLinkage, "", mod); ++ auto F = llvm::Function::Create( ++ function_type, llvm::Function::InternalLinkage, "symengine_func", mod); + F->setCallingConv(llvm::CallingConv::C); + #if (LLVM_VERSION_MAJOR < 5) + { +@@ -265,16 +271,19 @@ void LLVMVisitor::init(const vec_basic &inputs, const vec_basic &outputs, + } else if (opt_level == 2) { + pb_opt_level = OptimizationLevel::O2; + } ++ ++ if (opt_level != 0) { + #if (LLVM_VERSION_MAJOR < 6) +- FPM = PB.buildFunctionSimplificationPipeline(pb_opt_level); ++ FPM = PB.buildFunctionSimplificationPipeline(pb_opt_level); + #elif (LLVM_VERSION_MAJOR < 12) +- FPM = PB.buildFunctionSimplificationPipeline( +- pb_opt_level, llvm::PassBuilder::ThinLTOPhase::None); ++ FPM = PB.buildFunctionSimplificationPipeline( ++ pb_opt_level, llvm::PassBuilder::ThinLTOPhase::None); + #else +- FPM = PB.buildFunctionSimplificationPipeline( +- pb_opt_level, llvm::ThinOrFullLTOPhase::None); ++ FPM = PB.buildFunctionSimplificationPipeline( ++ pb_opt_level, llvm::ThinOrFullLTOPhase::None); + #endif +- FPM.run(*F, FAM); ++ FPM.run(*F, FAM); ++ } + + // std::cout << "Optimized LLVM IR" << std::endl; + // module->print(llvm::errs(), nullptr); +@@ -293,7 +302,7 @@ void LLVMVisitor::init(const vec_basic &inputs, const vec_basic &outputs, + { + public: + std::string &ss_; +- MemoryBufferRefCallback(std::string &ss) : ss_(ss) {} ++ explicit MemoryBufferRefCallback(std::string &ss) : ss_(ss) {} + + void notifyObjectCompiled(const llvm::Module *M, + llvm::MemoryBufferRef obj) override +@@ -306,7 +315,7 @@ void LLVMVisitor::init(const vec_basic &inputs, const vec_basic &outputs, + std::unique_ptr + getObject(const llvm::Module *M) override + { +- return NULL; ++ return nullptr; + } + }; + +@@ -492,15 +501,14 @@ llvm::Function *LLVMVisitor::get_powi() + #if (LLVM_VERSION_MAJOR > 12) + arg_type.push_back(llvm::Type::getInt32Ty(mod->getContext())); + #endif +- return llvm::Intrinsic::getDeclaration(mod, llvm::Intrinsic::powi, +- arg_type); ++ return GetDeclaration(mod, llvm::Intrinsic::powi, arg_type); + } + + llvm::Function *get_float_intrinsic(llvm::Type *type, llvm::Intrinsic::ID id, + unsigned n, llvm::Module *mod) + { + std::vector arg_type(n, type); +- return llvm::Intrinsic::getDeclaration(mod, id, arg_type); ++ return GetDeclaration(mod, id, arg_type); + } + + void LLVMVisitor::bvisit(const Pow &x) diff --git a/sci-libs/symengine/symengine-0.14.0-r2.ebuild b/sci-libs/symengine/symengine-0.14.0-r2.ebuild new file mode 100644 index 000000000000..0b194f2965d3 --- /dev/null +++ b/sci-libs/symengine/symengine-0.14.0-r2.ebuild @@ -0,0 +1,111 @@ +# Copyright 1999-2025 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +LLVM_COMPAT=( {18..20} ) +LLVM_OPTIONAL=1 + +inherit cmake llvm-r2 toolchain-funcs + +DESCRIPTION="Fast symbolic manipulation library, written in C++" +HOMEPAGE="https://github.com/symengine/symengine/" +SRC_URI=" + https://github.com/symengine/${PN}/archive/v${PV}.tar.gz + -> ${P}.gh.tar.gz +" + +LICENSE="MIT" +SLOT="0/$(ver_cut 1-2)" +KEYWORDS="~amd64 ~arm ~arm64 ~loong ~ppc64 ~riscv ~x86" +IUSE=" + boost debug ecm +flint llvm +mpc +mpfr openmp primesieve tcmalloc + test +" +REQUIRED_USE=" + boost? ( !flint !mpc !mpfr ) + llvm? ( ${LLVM_REQUIRED_USE} ) + mpc? ( mpfr ) +" +RESTRICT="!test? ( test )" + +RDEPEND=" + boost? ( dev-libs/boost:= ) + !boost? ( dev-libs/gmp:= ) + debug? ( sys-libs/binutils-libs:= ) + ecm? ( sci-mathematics/gmp-ecm:= ) + flint? ( sci-mathematics/flint:= ) + mpc? ( dev-libs/mpc:= ) + mpfr? ( dev-libs/mpfr:= ) + llvm? ( $(llvm_gen_dep 'llvm-core/llvm:${LLVM_SLOT}=') ) + primesieve? ( sci-mathematics/primesieve:= ) + tcmalloc? ( dev-util/google-perftools ) +" +DEPEND=" + ${RDEPEND} + dev-libs/cereal +" + +PATCHES=( + # bug 957803, in git master + "${FILESDIR}/${P}-cmake4.patch" + # https://github.com/symengine/symengine/pull/2103 + "${FILESDIR}/${P}-llvm.patch" +) + +pkg_pretend() { + [[ ${MERGE_TYPE} != binary ]] && use openmp && tc-check-openmp +} + +pkg_setup() { + [[ ${MERGE_TYPE} != binary ]] && use openmp && tc-check-openmp +} + +src_configure() { + local int_class + + if use flint; then + int_class=flint + elif use mpfr; then + int_class=gmpxx + elif use boost; then + int_class=boostmp + else + int_class=gmp + fi + + einfo "Building with integer class: ${int_class}" + + local mycmakeargs=( + -DINSTALL_CMAKE_DIR="${EPREFIX}/usr/$(get_libdir)/cmake/symengine" + -DINTEGER_CLASS=${int_class} + # not installed + -DBUILD_BENCHMARKS=OFF + # broken with out-of-tree builds + -DBUILD_DOXYGEN=OFF + -DBUILD_TESTS=$(usex test) + # -DWITH_ARB provided by flint >= 2 + -DWITH_BFD=$(usex debug) + -DWITH_ECM=$(usex ecm) + -DWITH_FLINT=$(usex flint) + -DWITH_LLVM=$(usex llvm) + -DWITH_MPC=$(usex mpc) + -DWITH_MPFR=$(usex mpfr) + -DWITH_OPENMP=$(usex openmp) + -DWITH_PRIMESIEVE=$(usex primesieve) + -DWITH_PTHREAD=ON + -DWITH_SYMENGINE_ASSERT=$(usex debug) + -DWITH_SYMENGINE_THREAD_SAFE=ON + -DWITH_SYSTEM_CEREAL=ON + # TODO: package it + # -DWITH_SYSTEM_FASTFLOAT=ON + -DWITH_TCMALLOC=$(usex tcmalloc) + ) + if use llvm; then + mycmakeargs+=( + -DLLVM_ROOT="$(get_llvm_prefix -d)" + ) + fi + + cmake_src_configure +}