From fd787ecf1c59d2039a569b81f17bbaebf311a8d3 Mon Sep 17 00:00:00 2001 From: Andrew DiZenzo Date: Thu, 4 Jun 2026 05:44:40 +0000 Subject: [PATCH] fix(net): link validation helpers in no-auto parity --- crates/perry-codegen/src/ext_registry.rs | 30 ++++++++++++++++++++++++ run_parity_tests.sh | 19 +++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/crates/perry-codegen/src/ext_registry.rs b/crates/perry-codegen/src/ext_registry.rs index 2849bf334..eb66a9016 100644 --- a/crates/perry-codegen/src/ext_registry.rs +++ b/crates/perry-codegen/src/ext_registry.rs @@ -382,6 +382,14 @@ const FFI_REGISTRY: &[(&str, OwnerKind)] = &[ ("js_net_socket_address_get_family", OwnerKind::WellKnown("net")), ("js_net_socket_address_get_port", OwnerKind::WellKnown("net")), ("js_net_socket_address_get_flowlabel", OwnerKind::WellKnown("net")), + // #2013 — net validation rows whose runtime helpers live only in + // `perry-ext-net`. These calls can be emitted by native-table lowering, + // so they must independently flip the net well-known provider. + ("js_net_get_default_auto_select_family", OwnerKind::WellKnown("net")), + ("js_net_set_default_auto_select_family", OwnerKind::WellKnown("net")), + ("js_net_get_default_auto_select_family_attempt_timeout", OwnerKind::WellKnown("net")), + ("js_net_set_default_auto_select_family_attempt_timeout", OwnerKind::WellKnown("net")), + ("js_net_socket_set_timeout", OwnerKind::WellKnown("net")), // #1852 — chainable no-op option setters for Socket/Server. ("js_net_socket_noop_self", OwnerKind::WellKnown("net")), ("js_net_socket_get_type_of_service", OwnerKind::WellKnown("net")), @@ -604,4 +612,26 @@ mod tests { assert_symbol_routes_to(symbol, owner); } } + + /// #2013 regression: net validation fixtures emit provider-only + /// `perry-ext-net` symbols through native-table lowering. Each one must + /// route to the net well-known archive so `PERRY_NO_AUTO_OPTIMIZE=1` + /// compiles the fixtures instead of linking unresolved `js_net_*` calls. + #[test] + fn emitted_net_validation_external_symbols_route_to_net() { + let _guard = PROVIDER_TEST_LOCK + .lock() + .expect("provider test lock poisoned"); + for symbol in [ + "js_net_create_server", + "js_net_server_listen", + "js_net_get_default_auto_select_family", + "js_net_set_default_auto_select_family", + "js_net_get_default_auto_select_family_attempt_timeout", + "js_net_set_default_auto_select_family_attempt_timeout", + "js_net_socket_set_timeout", + ] { + assert_symbol_routes_to(symbol, OwnerKind::WellKnown("net")); + } + } } diff --git a/run_parity_tests.sh b/run_parity_tests.sh index 7bfc250e6..dd821f59b 100755 --- a/run_parity_tests.sh +++ b/run_parity_tests.sh @@ -362,10 +362,29 @@ if [[ -n "${PERRY_NO_AUTO_OPTIMIZE:-}" && "$TEST_SUITE" == "node-suite" ]]; then ;; esac fi +needs_ext_net=0 +if [[ "$TEST_SUITE" == "node-suite" ]]; then + case "$MODULE_FILTER" in + ""|net|net/*) + # node-suite/net commonly runs with PERRY_NO_AUTO_OPTIMIZE=1. + # That path links prebuilt well-known archives, so build ext-net + # once up front instead of failing on unresolved js_net_* symbols. + needs_ext_net=1 + ;; + esac +fi if ! cargo build --release --quiet "${BUILD_PACKAGES[@]}" "${BUILD_FEATURES[@]}" 2>/dev/null; then echo -e "${RED}Failed to build compiler/runtime archives${NC}" exit 1 fi +if [[ "$needs_ext_net" -eq 1 ]]; then + echo "Building net extension (release)..." + ext_net_jobs="${CARGO_BUILD_JOBS:-1}" + if ! cargo build --release --quiet -p perry-ext-net -j "$ext_net_jobs" 2>/dev/null; then + echo -e "${RED}Failed to build net extension library${NC}" + exit 1 + fi +fi if [[ ! -x "$PERRY_BIN" ]]; then echo -e "${RED}Expected $PERRY_BIN after release build${NC}" exit 1