@@ -595,18 +595,27 @@ fn is_newer_than_dist(dir_entry: &walkdir::DirEntry, dist_time: Duration) -> boo
595595/// server-side plugins is a degraded server, not a broken build, and failing
596596/// here would block anyone who never touches plugins. The absence is reported
597597/// at the point someone tries to use it, not swallowed.
598+ /// CI sets ATOMICSERVER_REQUIRE_PLUGIN_RUNTIME=true to fail the build instead
599+ /// of allowing this degradation in jobs that exercise server-side plugins.
598600fn build_plugin_runtime ( ) {
599601 const TARGET : & str = "wasm32-wasip2" ;
600602 const CRATE : & str = "atomic-plugin-runtime" ;
601603
602604 println ! ( "cargo:rerun-if-changed=../plugin-runtime/src" ) ;
603605 println ! ( "cargo:rerun-if-changed=../plugin-runtime/wit" ) ;
606+ println ! ( "cargo:rerun-if-changed=../plugin-runtime/Cargo.toml" ) ;
604607 println ! ( "cargo:rerun-if-env-changed=ATOMICSERVER_SKIP_PLUGIN_RUNTIME" ) ;
608+ println ! ( "cargo:rerun-if-env-changed=ATOMICSERVER_REQUIRE_PLUGIN_RUNTIME" ) ;
609+ let required = std:: env:: var ( "ATOMICSERVER_REQUIRE_PLUGIN_RUNTIME" ) . is_ok_and ( |v| v == "true" ) ;
605610
606611 let out_dir = std:: env:: var ( "OUT_DIR" ) . expect ( "OUT_DIR is set by cargo" ) ;
607612 let embedded = PathBuf :: from ( & out_dir) . join ( "plugin_runtime.wasm" ) ;
608613
609614 if std:: env:: var ( "ATOMICSERVER_SKIP_PLUGIN_RUNTIME" ) . is_ok_and ( |v| v == "true" ) {
615+ assert ! (
616+ !required,
617+ "the plugin runtime cannot be both required and skipped"
618+ ) ;
610619 p ! ( "ATOMICSERVER_SKIP_PLUGIN_RUNTIME is set, skipping the plugin runtime." ) ;
611620 let _ = std:: fs:: write ( & embedded, [ ] ) ;
612621
@@ -624,6 +633,10 @@ fn build_plugin_runtime() {
624633 . unwrap_or ( false ) ;
625634
626635 if !has_target {
636+ assert ! (
637+ !required,
638+ "the required {TARGET} plugin runtime target is unavailable"
639+ ) ;
627640 p ! ( "{TARGET} is unknown to this toolchain; plugins will not run server-side." ) ;
628641 let _ = std:: fs:: write ( & embedded, [ ] ) ;
629642
@@ -640,6 +653,16 @@ fn build_plugin_runtime() {
640653 . env_remove ( "CARGO_ENCODED_RUSTFLAGS" )
641654 . env_remove ( "RUSTFLAGS" )
642655 . env_remove ( "CARGO_BUILD_TARGET" )
656+ // rust-musl-cross exports TARGET_CC/AR for the native server.
657+ // cc-rs prefers these over the CC/AR selected by rquickjs's
658+ // WASI SDK, so leaking them compiles QuickJS with the Linux
659+ // toolchain instead of clang for WebAssembly.
660+ . env_remove ( "TARGET_CC" )
661+ . env_remove ( "TARGET_CXX" )
662+ . env_remove ( "TARGET_AR" )
663+ . env_remove ( "TARGET_RANLIB" )
664+ . env_remove ( "TARGET_CFLAGS" )
665+ . env_remove ( "TARGET_CXXFLAGS" )
643666 . current_dir ( ".." )
644667 . status ( ) ;
645668
@@ -658,6 +681,10 @@ fn build_plugin_runtime() {
658681 ) ;
659682 }
660683 _ => {
684+ assert ! (
685+ !required,
686+ "could not build the required {CRATE} for {TARGET}; see the nested cargo build error above"
687+ ) ;
661688 p ! (
662689 "could not build {CRATE} for {TARGET}; plugins will not run server-side. \
663690 Install the target with `rustup target add {TARGET}`.",
0 commit comments