Skip to content

kmod static building #389

@piyush-jena

Description

@piyush-jena

Hi!
The migration of kmod build system to meson no longer allows users to do a static build of kmod. I am using the following patch to do a static build. I was wondering if there's a possibility of merging this to the original code base.

From b5d3e27e19101712bab37695283c2d8bc3960b28 Mon Sep 17 00:00:00 2001
From: Piyush Jena <jepiyush@amazon.com>
Date: Tue, 8 Jul 2025 22:11:12 +0000
Subject: [PATCH] meson: add support for static builds

Signed-off-by: Piyush Jena <jepiyush@amazon.com>
---
 meson.build | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/meson.build b/meson.build
index a0cf675..4b16d6a 100644
--- a/meson.build
+++ b/meson.build
@@ -465,10 +465,16 @@ kmod_sources = files(
   'tools/static-nodes.c',
 )
 
+kmod_link_args = []
+if get_option('default_library') == 'static'
+  kmod_link_args += ['-static']
+endif
+
 kmod = executable(
   'kmod',
   kmod_sources,
   link_with : [libshared, libkmod_internal],
+  link_args : kmod_link_args,
   gnu_symbol_visibility : 'hidden',
   build_by_default : get_option('tools'),
   install : get_option('tools'),
-- 
2.47.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions