Skip to content

Commit fc1c03c

Browse files
committed
fix(auto): rename RUST_TARGET to NGX_RUST_TARGET
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.
1 parent 2d01596 commit fc1c03c

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

.github/workflows/sanitizers.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,10 @@ jobs:
6969
-fno-omit-frame-pointer
7070
-fsanitize=address,undefined
7171
LDFLAGS: -fsanitize=address,undefined
72-
RUST_TARGET: x86_64-unknown-linux-gnu
7372
RUSTFLAGS: -Zsanitizer=address -Zexternal-clangrt
73+
# Pass --target to cargo to ensure that sanitizer flags are not
74+
# applied to the build scripts and proc-macros.
75+
NGX_RUST_TARGET: x86_64-unknown-linux-gnu
7476
# Extra options passed to cargo rustc
7577
NGX_RUSTC_OPT: -Zbuild-std
7678
# Enable unstable features, such as the -Z options above,

examples/auto/rust

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@
6767
#
6868
# ngx_rust_make_modules
6969
# ```
70+
#
71+
# The following environment variables can affect the generated Makefile:
72+
#
73+
# - NGX_CARGO sets the "cargo" binary to use, e.g. NGX_CARGO=cargo-1.82
74+
# - NGX_RUST_TARGET passes the --target to the Rust compiler if set
75+
# - NGX_RUSTC_OPT passes additional options to "cargo rustc"
7076

7177
# Prevent duplicate invocation unless it is a newer library version
7278
if [ "${NGX_RUST_AUTO_VER:-0}" -ge 1 ]; then
@@ -136,7 +142,7 @@ case "$NGX_PLATFORM" in
136142
RUST_LIBS="$RUST_LIBS userenv.lib" # std::env::home_dir
137143
RUST_LIBS="$RUST_LIBS dbghelp.lib" # backtrace symbolization
138144

139-
RUST_TARGET=$RUST_TARGET_ARCH-pc-windows-msvc
145+
NGX_RUST_TARGET=${NGX_RUST_TARGET:-$RUST_TARGET_ARCH-pc-windows-msvc}
140146
;;
141147

142148
gcc | clang)
@@ -145,7 +151,7 @@ case "$NGX_PLATFORM" in
145151
RUST_LIBS="$RUST_LIBS -luserenv"
146152
RUST_LIBS="$RUST_LIBS -ldbghelp"
147153
# gnullvm on arm64?
148-
RUST_TARGET=$RUST_TARGET_ARCH-pc-windows-gnu
154+
NGX_RUST_TARGET=${NGX_RUST_TARGET:-$RUST_TARGET_ARCH-pc-windows-gnu}
149155
;;
150156

151157
esac
@@ -220,7 +226,7 @@ ngx_rust_target_path () {
220226
ngx_rust_obj=examples/$ngx_rust_obj
221227
fi
222228

223-
echo "${RUST_TARGET:+$RUST_TARGET/}$ngx_cargo_profile/$ngx_rust_obj"
229+
echo "${NGX_RUST_TARGET:+$NGX_RUST_TARGET/}$ngx_cargo_profile/$ngx_rust_obj"
224230
}
225231

226232

@@ -304,7 +310,7 @@ $ngx_rust_obj:
304310
--manifest-path "$ngx_cargo_manifest" \\
305311
--no-default-features \\
306312
--profile $ngx_cargo_profile \\
307-
${RUST_TARGET:+--target $RUST_TARGET} \\
313+
${NGX_RUST_TARGET:+--target $NGX_RUST_TARGET} \\
308314
--target-dir $NGX_OBJS/$ngx_addon_id \\
309315
--features "$ngx_rust_features" \\
310316
$ngx_rustc_module_opt $NGX_RUSTC_OPT

0 commit comments

Comments
 (0)