guix_mirror_bot pushed a commit to branch master
in repository guix.

commit c3f482bb122663b080e33183b56b7e0ac15d5071
Author: Danny Milosavljevic <[email protected]>
AuthorDate: Fri Feb 13 22:57:53 2026 +0100

    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(+)

diff --git a/gnu/packages/protobuf.scm b/gnu/packages/protobuf.scm
index e0ea20c506..6b174a8d4f 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

Reply via email to