@@ -250,21 +250,30 @@ ngx_rust_module () {
250250 ngx_module_libs_saved=$ngx_module_libs
251251 ngx_module_libs=" $ngx_rust_obj $ngx_module_libs $RUST_LIBS "
252252
253- # Module deps are usually added to the object file targets, but we don't have any
254- LINK_DEPS=" $LINK_DEPS $ngx_rust_obj "
255-
256- eval ${ngx_addon_id} _RUST_TARGETS=\"\$ ${ngx_addon_id} _RUST_TARGETS \
257- $ngx_rust_target_type :$ngx_rust_target_name \"
258-
259253 if [ -n " $ngx_rust_target_features " ]; then
260254 eval ${ngx_addon_id} _RUST_FEATURES=\"\$ ${ngx_addon_id} _RUST_FEATURES \
261255 $ngx_rust_target_features \"
262256 fi
263257
264- . auto/module
258+ . auto/module
259+
260+ ngx_rust_target=$ngx_rust_target_type :$ngx_rust_target_name
261+
262+ # module deps are usually added to the object file targets, but we don't have any
263+
264+ if [ " $ngx_module_link " = DYNAMIC ]; then
265+ # remember the dynamic module name and generate dependency later
266+ ngx_rust_target=$ngx_rust_target :$ngx_module
267+ else
268+ # add dependency to the binary target
269+ LINK_DEPS=" $LINK_DEPS $ngx_rust_obj "
270+ fi
271+
272+ eval ${ngx_addon_id} _RUST_TARGETS=\"\$ ${ngx_addon_id} _RUST_TARGETS \
273+ $ngx_rust_target \"
265274
266- ngx_module_deps=$ngx_module_deps_saved
267- ngx_module_libs=$ngx_module_libs_saved
275+ ngx_module_deps=$ngx_module_deps_saved
276+ ngx_module_libs=$ngx_module_libs_saved
268277}
269278
270279
@@ -278,8 +287,9 @@ ngx_rust_make_modules () {
278287 eval ngx_rust_targets=" \$ ${ngx_addon_id} _RUST_TARGETS"
279288
280289 for target in $ngx_rust_targets ; do
281- ngx_rust_target_type=${target%%:* }
282- ngx_rust_target_name=${target#*: }
290+ IFS=' :' read -r ngx_rust_target_type ngx_rust_target_name ngx_rust_module_name << END
291+ $target
292+ END
283293
284294 ngx_rust_make_module
285295 done
@@ -316,4 +326,14 @@ $ngx_rust_obj:
316326 $ngx_rustc_module_opt $NGX_RUSTC_OPT
317327
318328END
329+
330+ # Ensure that the "auto"-generated dynamic module target depends on the
331+ # static library. Normally this is achieved by attaching ADDON_DEPS to
332+ # the module object files, but we don't have any suitable C sources.
333+
334+ if [ -n " $ngx_rust_module_name " ]; then
335+ cat << END >> $NGX_MAKEFILE
336+ $NGX_OBJS$ngx_dirsep$ngx_rust_module_name$ngx_modext : $ngx_rust_obj
337+ END
338+ fi
319339}
0 commit comments