From c3f482bb122663b080e33183b56b7e0ac15d5071 Mon Sep 17 00:00:00 2001 From: Danny Milosavljevic Date: Fri, 13 Feb 2026 22:57:53 +0100 Subject: gnu: Add protobuf-static-for-onnxruntime. * gnu/packages/protobuf.scm (protobuf-static-for-onnxruntime): New variable. Change-Id: I641eda7de77e6e56cde3bab5d35daefce246ef9e --- gnu/packages/protobuf.scm | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'gnu') diff --git a/gnu/packages/protobuf.scm b/gnu/packages/protobuf.scm index e0ea20c5063..6b174a8d4f4 100644 --- a/gnu/packages/protobuf.scm +++ b/gnu/packages/protobuf.scm @@ -265,6 +265,36 @@ yet extensible format. Google uses Protocol Buffers for almost all of its internal RPC protocols and file formats.") (license license:bsd-3))) +(define-public protobuf-static-for-onnxruntime + (package + (inherit protobuf) + (name "protobuf-static") + (arguments + (substitute-keyword-arguments (package-arguments protobuf) + ((#:configure-flags _) + #~(list "-DBUILD_SHARED_LIBS=OFF" + "-Dprotobuf_BUILD_SHARED_LIBS=OFF" + "-Dprotobuf_USE_EXTERNAL_GTEST=ON" + ;; -fPIC is needed because this .a will be linked into + ;; onnxruntime's shared .so. + "-DCMAKE_POSITION_INDEPENDENT_CODE=ON" + ;; C++17 is needed because descriptor.pb.h declares + ;; static constexpr members (e.g. FileOptions::SPEED) + ;; with out-of-line definitions in descriptor.pb.cc + ;; guarded by "#if (__cplusplus < 201703)". In C++14 + ;; both produce symbols, causing duplicate definitions + ;; when the .a is linked into a binary. C++17 makes + ;; static constexpr implicitly inline and suppresses + ;; the out-of-line definitions. + "-DCMAKE_CXX_STANDARD=17")) + ((#:phases phases) + #~(modify-phases #$phases + (delete 'move-static-libraries) + (replace 'set-c++-standard + (lambda _ + (substitute* "CMakeLists.txt" + (("CMAKE_CXX_STANDARD 11") "CMAKE_CXX_STANDARD 17")))))))))) + ;; Needed for python-mysql-connector-python (define-public protobuf-3.20 (package -- cgit v1.3