-
Type:
Task
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
Query Integration
-
0
-
None
-
None
-
None
-
None
-
None
-
None
-
None
Overview
scripting_mozjs_test fails with undefined symbol errors when linked with LLD (ld.lld), as on the enterprise-rhel-8-arm64-grpc variant on v7.0-staging. The failure has been present since the MozJS ESR 140.7 upgrade (SERVER-117317).
ld.lld: error: undefined symbol: mozilla::PrintfTarget::vprint(char const*, std::__va_list) >>> referenced by Sprintf.h:64 >>> build/cached/mongo/scripting/mozjs/asan_handles_test.o ld.lld: error: undefined symbol: mozilla::PrintfTarget::PrintfTarget() >>> referenced by Sprintf.h:28 >>> build/cached/mongo/scripting/mozjs/asan_handles_test.o collect2: error: ld returned 1 exit status Failed while trying to build build/cached/mongo/scripting/scripting_mozjs_test
Root Cause
In ESR 140.7, mozilla/Casting.h gained #include "mozilla/Sprintf.h" (for a new DiagnosticMessage helper). Since Casting.h is included by jstypes.h, which is included by virtually every MozJS header, every consumer translation unit now transitively references PrintfTarget::vprint() and
PrintfTarget::PrintfTarget() through the static VsprintfBuf function in Sprintf.h.
These symbols are defined in Printf.cpp, compiled into the mozjs library. However, mozjs is aLIBDEPS_PRIVATE dependency of scripting (made private intentionally in SERVER-67113 to stay under the macOS dyld limit). Because it is private, mozjs is not propagated to scripting_mozjs_test's link line.
GNU ld (used by most other variants) resolves symbols permissively from transitive shared library dependencies. LLD does not — it requires the symbol's library to be directly on the link line.
Why this only affects v7.0 (SCons) and not v8.0+ (Bazel)
On v8.0 Bazel, //src/third_party/mozjs is a public deps of the scripting library, so it propagates transitively to all consumers including scripting_mozjs_test. On v7.0 SCons, mozjs is LIBDEPS_PRIVATE of scripting, which blocks transitive propagation.
We cannot simply move mozjs from LIBDEPS_PRIVATE to LIBDEPS to match Bazel, because it was made private intentionally in SERVER-67113 to reduce the link graph size and stay under the macOS dyld limit. Making it public again could re-trigger that issue on macOS builds.
Fix
Add $BUILD_DIR/third_party/mozjs/mozjs directly to scripting_mozjs_test's LIBDEPS in src/mongo/scripting/SConscript. This is the targeted fix
gives the test binary what it needs without expanding the transitive link graph for all consumers of scripting.
- is related to
-
SERVER-117317 Upgrade MozJS to ESR 140.7
-
- Closed
-
-
SERVER-67113 make mozjs library dependency private in scripting
-
- Closed
-