Skip to content

dynamic_modules: support for statically linked modules#43696

Merged
mathetake merged 20 commits into
envoyproxy:mainfrom
mathetake:staticalliylinkabledm
Mar 2, 2026
Merged

dynamic_modules: support for statically linked modules#43696
mathetake merged 20 commits into
envoyproxy:mainfrom
mathetake:staticalliylinkabledm

Conversation

@mathetake
Copy link
Copy Markdown
Member

@mathetake mathetake commented Feb 28, 2026

Commit Message: dynamic_modules: support for statically linked modules
Additional Description:

This commit allows statically linked dynamic modules though in that case it is not really a "dynamic". This allows downstream users who build their own Envoy binary to statically link their modules using bazel natively. This will also set the foundation for our discussed direction of the project: allowing new core extensions written as a dynamic module.

The idea is that these statically linked modules must prefix Envoy->DM callbacks (envoy_dynamic_module_on_*) with their own module names, and at the dynamic_modules loading phase, Envoy try to find the init symbol like foo_envoy_dynamic_module_on_init. If found, it is a statically linked module, and otherwise it will try to load the shared library normally.

Since this functionality is very low-level and not available for normal end users (i.e. anyone using official binaries), i intentionally did not add the release note.

Risk Level: low
Testing: done
Docs Changes: n/a
Release Notes: n/a
Platform Specific Features:
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
[Optional API Considerations:]


Verified that we can indeed build an Envoy binary with the Rust-SDK based dynamic module statically linked:

diff --git a/source/exe/BUILD b/source/exe/BUILD
index 16a51c89b3..a94ed56d17 100644
--- a/source/exe/BUILD
+++ b/source/exe/BUILD
@@ -31,7 +31,10 @@ envoy_cc_binary(
     }),
     rbe_pool = "6gig",
     stamped = True,
-    deps = [":envoy_main_entry_lib"],
+    deps = [
+        ":envoy_main_entry_lib",
+        "//test/extensions/dynamic_modules/test_data/rust:http_integration_test_static",
+    ],
 )

Produced

$ nm -D bazel-bin/source/exe/envoy-static | grep http_integration_test
000000000c841500 T http_integration_test_envoy_dynamic_module_on_bootstrap_extension_admin_request
000000000c840d80 T http_integration_test_envoy_dynamic_module_on_bootstrap_extension_config_destroy
000000000c840b40 T http_integration_test_envoy_dynamic_module_on_bootstrap_extension_config_new
000000000c8412a0 T http_integration_test_envoy_dynamic_module_on_bootstrap_extension_config_scheduled

@repokitteh-read-only
Copy link
Copy Markdown

As a reminder, PRs marked as draft will not be automatically assigned reviewers,
or be handled by maintainer-oncall triage.

Please mark your PR as ready when you want it to be reviewed!

🐱

Caused by: #43696 was opened by mathetake.

see: more, trace.

Signed-off-by: Takeshi Yoneda <tyoneda@netflix.com>
Signed-off-by: Takeshi Yoneda <tyoneda@netflix.com>
Signed-off-by: Takeshi Yoneda <tyoneda@netflix.com>
Signed-off-by: Takeshi Yoneda <tyoneda@netflix.com>
Signed-off-by: Takeshi Yoneda <tyoneda@netflix.com>
Signed-off-by: Takeshi Yoneda <tyoneda@netflix.com>
@mathetake mathetake force-pushed the staticalliylinkabledm branch from 02dce7c to 3adce38 Compare February 28, 2026 22:54
Signed-off-by: Takeshi Yoneda <tyoneda@netflix.com>
Signed-off-by: Takeshi Yoneda <tyoneda@netflix.com>
@@ -640,4 +640,1744 @@ __attribute__((weak)) bool envoy_dynamic_module_callback_matcher_get_header_valu
return false;
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change here is just adding missing weak references for testing. Nothing interesting here

// In this case, Envoy uses ``dlsym(RTLD_DEFAULT, ...)`` to resolve module symbols, with each
// symbol name prefixed by ``<name>_``. For example, ``foo_envoy_dynamic_module_on_program_init``
// is resolved instead of ``envoy_dynamic_module_on_program_init``.
// When using ``static://``, the ``do_not_close`` and ``load_globally`` fields are ignored.
Copy link
Copy Markdown
Member Author

@mathetake mathetake Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i was thinking about adding "is_static" or whatever flag but it is weird as it's not available to most of the people as well as it sounds very contradictory to the name "dynamic modules" of this proto. So I decided to have this naming schema stuff. Note that any name containing slash was invalid before, so this is backward compatible

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible for us to automatically infer static if we can find the module to be part of the build? Just not let users specify anything special. WDYT?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed! now it's implicit and no API change needed! Thanks for the good advice

@mathetake mathetake marked this pull request as ready for review March 1, 2026 01:40
@repokitteh-read-only
Copy link
Copy Markdown

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to (api/envoy/|docs/root/api-docs/).
envoyproxy/api-shepherds assignee is @mattklein123
CC @envoyproxy/api-watchers: FYI only for changes made to (api/envoy/|docs/root/api-docs/).

🐱

Caused by: #43696 was ready_for_review by mathetake.

see: more, trace.

lua*;
envoyGo*;
envoy_dynamic_module_callback_*;
*_envoy_dynamic_module_on_*;
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is necessary to allow the statically linked symbols to be available via dlsym


load("@rules_cc//cc:defs.bzl", "cc_import")

def envoy_dynamic_module_prefix_symbols(name, module_name, archive, tags = [], **kwargs):
Copy link
Copy Markdown
Member Author

@mathetake mathetake Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i am planning to use this one internally not only the tests here in upstream

@mathetake
Copy link
Copy Markdown
Member Author

Will fix the coverage in a bit

Signed-off-by: Takeshi Yoneda <tyoneda@netflix.com>
Signed-off-by: Takeshi Yoneda <tyoneda@netflix.com>
Signed-off-by: Takeshi Yoneda <tyoneda@netflix.com>
Signed-off-by: Takeshi Yoneda <tyoneda@netflix.com>
@mathetake mathetake assigned wbpcode and agrawroh and unassigned mattklein123 Mar 1, 2026
Signed-off-by: Takeshi Yoneda <tyoneda@netflix.com>
Signed-off-by: Takeshi Yoneda <tyoneda@netflix.com>
Signed-off-by: Takeshi Yoneda <tyoneda@netflix.com>
Signed-off-by: Takeshi Yoneda <tyoneda@netflix.com>
Signed-off-by: Takeshi Yoneda <tyoneda@netflix.com>
Signed-off-by: Takeshi Yoneda <tyoneda@netflix.com>
Signed-off-by: Takeshi Yoneda <tyoneda@netflix.com>
@agrawroh
Copy link
Copy Markdown
Member

agrawroh commented Mar 2, 2026

/retest

@mathetake mathetake merged commit ffc0de4 into envoyproxy:main Mar 2, 2026
29 checks passed
@mathetake mathetake deleted the staticalliylinkabledm branch March 2, 2026 17:53
bmjask pushed a commit to bmjask/envoy that referenced this pull request Mar 14, 2026
)

Commit Message: dynamic_modules: support for statically linked modules
Additional Description:

This commit allows statically linked dynamic modules though in that case
it is not really a "dynamic". This allows downstream users who build
their own Envoy binary to statically link their modules using bazel
natively. This will also set the foundation for our discussed direction
of the project: allowing new core extensions written as a dynamic
module.

The idea is that these statically linked modules must prefix Envoy->DM
callbacks (envoy_dynamic_module_on_*) with their own module names, and
at the dynamic_modules loading phase, Envoy try to find the init symbol
like foo_envoy_dynamic_module_on_init. If found, it is a statically
linked module, and otherwise it will try to load the shared library
normally.

Since this functionality is very low-level and not available for normal
end users (i.e. anyone using official binaries), i intentionally did not
add the release note.

Risk Level: low
Testing: done
Docs Changes: n/a
Release Notes: n/a
Platform Specific Features:

---------

Signed-off-by: Takeshi Yoneda <tyoneda@netflix.com>
Signed-off-by: bjmask <11672696+bjmask@users.noreply.github.com>
bvandewalle pushed a commit to bvandewalle/envoy that referenced this pull request Mar 17, 2026
)

Commit Message: dynamic_modules: support for statically linked modules
Additional Description:

This commit allows statically linked dynamic modules though in that case
it is not really a "dynamic". This allows downstream users who build
their own Envoy binary to statically link their modules using bazel
natively. This will also set the foundation for our discussed direction
of the project: allowing new core extensions written as a dynamic
module.

The idea is that these statically linked modules must prefix Envoy->DM
callbacks (envoy_dynamic_module_on_*) with their own module names, and
at the dynamic_modules loading phase, Envoy try to find the init symbol
like foo_envoy_dynamic_module_on_init. If found, it is a statically
linked module, and otherwise it will try to load the shared library
normally.

Since this functionality is very low-level and not available for normal
end users (i.e. anyone using official binaries), i intentionally did not
add the release note.

Risk Level: low
Testing: done
Docs Changes: n/a
Release Notes: n/a
Platform Specific Features:

---------

Signed-off-by: Takeshi Yoneda <tyoneda@netflix.com>
fishcakez pushed a commit to fishcakez/envoy that referenced this pull request Mar 25, 2026
)

Commit Message: dynamic_modules: support for statically linked modules
Additional Description:

This commit allows statically linked dynamic modules though in that case
it is not really a "dynamic". This allows downstream users who build
their own Envoy binary to statically link their modules using bazel
natively. This will also set the foundation for our discussed direction
of the project: allowing new core extensions written as a dynamic
module.

The idea is that these statically linked modules must prefix Envoy->DM
callbacks (envoy_dynamic_module_on_*) with their own module names, and
at the dynamic_modules loading phase, Envoy try to find the init symbol
like foo_envoy_dynamic_module_on_init. If found, it is a statically
linked module, and otherwise it will try to load the shared library
normally.

Since this functionality is very low-level and not available for normal
end users (i.e. anyone using official binaries), i intentionally did not
add the release note.

Risk Level: low
Testing: done
Docs Changes: n/a
Release Notes: n/a
Platform Specific Features:

---------

Signed-off-by: Takeshi Yoneda <tyoneda@netflix.com>
krinkinmu pushed a commit to grnmeira/envoy that referenced this pull request Apr 20, 2026
)

Commit Message: dynamic_modules: support for statically linked modules
Additional Description:

This commit allows statically linked dynamic modules though in that case
it is not really a "dynamic". This allows downstream users who build
their own Envoy binary to statically link their modules using bazel
natively. This will also set the foundation for our discussed direction
of the project: allowing new core extensions written as a dynamic
module.

The idea is that these statically linked modules must prefix Envoy->DM
callbacks (envoy_dynamic_module_on_*) with their own module names, and
at the dynamic_modules loading phase, Envoy try to find the init symbol
like foo_envoy_dynamic_module_on_init. If found, it is a statically
linked module, and otherwise it will try to load the shared library
normally.

Since this functionality is very low-level and not available for normal
end users (i.e. anyone using official binaries), i intentionally did not
add the release note.

Risk Level: low
Testing: done
Docs Changes: n/a
Release Notes: n/a
Platform Specific Features:

---------

Signed-off-by: Takeshi Yoneda <tyoneda@netflix.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants