summaryrefslogtreecommitdiff
path: root/gnu
diff options
context:
space:
mode:
authorDanny Milosavljevic <dannym@friendly-machines.com>2026-02-13 22:57:53 +0100
committerDanny Milosavljevic <dannym@friendly-machines.com>2026-03-07 03:09:48 +0100
commitc3f482bb122663b080e33183b56b7e0ac15d5071 (patch)
tree40645038f28cd8207e8bca1fe742f618bfccde9b /gnu
parentea517da151e5cd422136dcfe07f9e904a8e2b6bb (diff)
gnu: Add protobuf-static-for-onnxruntime.
* gnu/packages/protobuf.scm (protobuf-static-for-onnxruntime): New variable. Change-Id: I641eda7de77e6e56cde3bab5d35daefce246ef9e
Diffstat (limited to 'gnu')
-rw-r--r--gnu/packages/protobuf.scm30
1 files changed, 30 insertions, 0 deletions
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