Skip to content

fix(auto): rename RUST_TARGET to NGX_RUST_TARGET #176

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 21, 2025

Conversation

bavshin-f5
Copy link
Member

This makes it more obvious that the variable is consumed by our script and not by the Rust toolchain itself.

Also, ensure that NGX_RUST_TARGET passed from the caller has priority over the detected value.

This makes it more obvious that the variable is consumed by our script
and not by the Rust toolchain itself.

Also, ensure that NGX_RUST_TARGET passed from the caller has priority
over the detected value.
This allows us to avoid the LINK_DEPS workaround, which resulted in
unintentionally adding dependencies to the nginx binary target.
@bavshin-f5
Copy link
Member Author

One more patch to auto/rust: fixed dependency generation for dynamic module targets.

Makefile changes for --add-dynamic-module
--- objs/Makefile.orig	2025-07-18 15:34:01.144938999 -0700
+++ objs/Makefile	2025-07-18 15:34:33.228938224 -0700
@@ -375,13 +375,7 @@
 	objs/src/stream/ngx_stream_upstream_random_module.o \
 	objs/src/stream/ngx_stream_upstream_zone_module.o \
 	objs/src/stream/ngx_stream_ssl_preread_module.o \
-	objs/ngx_modules.o \
-	objs/ngx_rust_examples/ngx-release/examples/libasync.a \
-	objs/ngx_rust_examples/ngx-release/examples/libawssig.a \
-	objs/ngx_rust_examples/ngx-release/examples/libcurl.a \
-	objs/ngx_rust_examples/ngx-release/examples/libshared_dict.a \
-	objs/ngx_rust_examples/ngx-release/examples/libupstream.a \
-	objs/ngx_rust_examples/ngx-release/examples/libhttporigdst.a
+	objs/ngx_modules.o
 
 	$(LINK) -o objs/nginx \
 	objs/src/core/nginx.o \
@@ -2118,6 +2112,7 @@
 		--features " linux" \
 		--example async 
 
+objs/ngx_http_async_module.so:	objs/ngx_rust_examples/ngx-release/examples/libasync.a
 
 # always run cargo instead of trying to track the source modifications
 .PHONY: objs/ngx_rust_examples/ngx-release/examples/libawssig.a
@@ -2134,6 +2129,7 @@
 		--features " linux" \
 		--example awssig 
 
+objs/ngx_http_awssigv4_module.so:	objs/ngx_rust_examples/ngx-release/examples/libawssig.a
 
 # always run cargo instead of trying to track the source modifications
 .PHONY: objs/ngx_rust_examples/ngx-release/examples/libcurl.a
@@ -2150,6 +2146,7 @@
 		--features " linux" \
 		--example curl 
 
+objs/ngx_http_curl_module.so:	objs/ngx_rust_examples/ngx-release/examples/libcurl.a
 
 # always run cargo instead of trying to track the source modifications
 .PHONY: objs/ngx_rust_examples/ngx-release/examples/libshared_dict.a
@@ -2166,6 +2163,7 @@
 		--features " linux" \
 		--example shared_dict 
 
+objs/ngx_http_shared_dict_module.so:	objs/ngx_rust_examples/ngx-release/examples/libshared_dict.a
 
 # always run cargo instead of trying to track the source modifications
 .PHONY: objs/ngx_rust_examples/ngx-release/examples/libupstream.a
@@ -2182,6 +2180,7 @@
 		--features " linux" \
 		--example upstream 
 
+objs/ngx_http_upstream_custom_module.so:	objs/ngx_rust_examples/ngx-release/examples/libupstream.a
 
 # always run cargo instead of trying to track the source modifications
 .PHONY: objs/ngx_rust_examples/ngx-release/examples/libhttporigdst.a
@@ -2198,16 +2197,11 @@
 		--features " linux" \
 		--example httporigdst 
 
+objs/ngx_http_orig_dst_module.so:	objs/ngx_rust_examples/ngx-release/examples/libhttporigdst.a
 
 modules:	objs/ngx_http_async_module.so
 
-objs/ngx_http_async_module.so:	objs/ngx_http_async_module_modules.o \
-	objs/ngx_rust_examples/ngx-release/examples/libasync.a \
-	objs/ngx_rust_examples/ngx-release/examples/libawssig.a \
-	objs/ngx_rust_examples/ngx-release/examples/libcurl.a \
-	objs/ngx_rust_examples/ngx-release/examples/libshared_dict.a \
-	objs/ngx_rust_examples/ngx-release/examples/libupstream.a \
-	objs/ngx_rust_examples/ngx-release/examples/libhttporigdst.a
+objs/ngx_http_async_module.so:	objs/ngx_http_async_module_modules.o
 
 	$(LINK) -o objs/ngx_http_async_module.so \
 	objs/ngx_http_async_module_modules.o \
@@ -2224,13 +2218,7 @@
 
 modules:	objs/ngx_http_awssigv4_module.so
 
-objs/ngx_http_awssigv4_module.so:	objs/ngx_http_awssigv4_module_modules.o \
-	objs/ngx_rust_examples/ngx-release/examples/libasync.a \
-	objs/ngx_rust_examples/ngx-release/examples/libawssig.a \
-	objs/ngx_rust_examples/ngx-release/examples/libcurl.a \
-	objs/ngx_rust_examples/ngx-release/examples/libshared_dict.a \
-	objs/ngx_rust_examples/ngx-release/examples/libupstream.a \
-	objs/ngx_rust_examples/ngx-release/examples/libhttporigdst.a
+objs/ngx_http_awssigv4_module.so:	objs/ngx_http_awssigv4_module_modules.o
 
 	$(LINK) -o objs/ngx_http_awssigv4_module.so \
 	objs/ngx_http_awssigv4_module_modules.o \
@@ -2247,13 +2235,7 @@
 
 modules:	objs/ngx_http_curl_module.so
 
-objs/ngx_http_curl_module.so:	objs/ngx_http_curl_module_modules.o \
-	objs/ngx_rust_examples/ngx-release/examples/libasync.a \
-	objs/ngx_rust_examples/ngx-release/examples/libawssig.a \
-	objs/ngx_rust_examples/ngx-release/examples/libcurl.a \
-	objs/ngx_rust_examples/ngx-release/examples/libshared_dict.a \
-	objs/ngx_rust_examples/ngx-release/examples/libupstream.a \
-	objs/ngx_rust_examples/ngx-release/examples/libhttporigdst.a
+objs/ngx_http_curl_module.so:	objs/ngx_http_curl_module_modules.o
 
 	$(LINK) -o objs/ngx_http_curl_module.so \
 	objs/ngx_http_curl_module_modules.o \
@@ -2270,13 +2252,7 @@
 
 modules:	objs/ngx_http_shared_dict_module.so
 
-objs/ngx_http_shared_dict_module.so:	objs/ngx_http_shared_dict_module_modules.o \
-	objs/ngx_rust_examples/ngx-release/examples/libasync.a \
-	objs/ngx_rust_examples/ngx-release/examples/libawssig.a \
-	objs/ngx_rust_examples/ngx-release/examples/libcurl.a \
-	objs/ngx_rust_examples/ngx-release/examples/libshared_dict.a \
-	objs/ngx_rust_examples/ngx-release/examples/libupstream.a \
-	objs/ngx_rust_examples/ngx-release/examples/libhttporigdst.a
+objs/ngx_http_shared_dict_module.so:	objs/ngx_http_shared_dict_module_modules.o
 
 	$(LINK) -o objs/ngx_http_shared_dict_module.so \
 	objs/ngx_http_shared_dict_module_modules.o \
@@ -2293,13 +2269,7 @@
 
 modules:	objs/ngx_http_upstream_custom_module.so
 
-objs/ngx_http_upstream_custom_module.so:	objs/ngx_http_upstream_custom_module_modules.o \
-	objs/ngx_rust_examples/ngx-release/examples/libasync.a \
-	objs/ngx_rust_examples/ngx-release/examples/libawssig.a \
-	objs/ngx_rust_examples/ngx-release/examples/libcurl.a \
-	objs/ngx_rust_examples/ngx-release/examples/libshared_dict.a \
-	objs/ngx_rust_examples/ngx-release/examples/libupstream.a \
-	objs/ngx_rust_examples/ngx-release/examples/libhttporigdst.a
+objs/ngx_http_upstream_custom_module.so:	objs/ngx_http_upstream_custom_module_modules.o
 
 	$(LINK) -o objs/ngx_http_upstream_custom_module.so \
 	objs/ngx_http_upstream_custom_module_modules.o \
@@ -2316,13 +2286,7 @@
 
 modules:	objs/ngx_http_orig_dst_module.so
 
-objs/ngx_http_orig_dst_module.so:	objs/ngx_http_orig_dst_module_modules.o \
-	objs/ngx_rust_examples/ngx-release/examples/libasync.a \
-	objs/ngx_rust_examples/ngx-release/examples/libawssig.a \
-	objs/ngx_rust_examples/ngx-release/examples/libcurl.a \
-	objs/ngx_rust_examples/ngx-release/examples/libshared_dict.a \
-	objs/ngx_rust_examples/ngx-release/examples/libupstream.a \
-	objs/ngx_rust_examples/ngx-release/examples/libhttporigdst.a
+objs/ngx_http_orig_dst_module.so:	objs/ngx_http_orig_dst_module_modules.o
 
 	$(LINK) -o objs/ngx_http_orig_dst_module.so \
 	objs/ngx_http_orig_dst_module_modules.o \

Makefile for static modules did not change.

This fixes an annoying rebuild of objs/nginx on every make call, and allows make binary to skip all the dynamic Rust modules.

Copy link
Contributor

@xeioex xeioex left a comment

Choose a reason for hiding this comment

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

LGTM.

@bavshin-f5 bavshin-f5 merged commit a92ca72 into nginx:main Jul 21, 2025
15 checks passed
@bavshin-f5 bavshin-f5 deleted the auto-var-names branch July 21, 2025 22:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants