Skip to content

Upgrade to SpiderMonkey 137 #584

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open

Upgrade to SpiderMonkey 137 #584

wants to merge 22 commits into from

Conversation

jdm
Copy link
Member

@jdm jdm commented May 21, 2025

@jdm
Copy link
Member Author

jdm commented May 22, 2025

TODO:

  • Android build says that NDK28 is required.
  • Clang version looks wrong for linux build — Should generate JSAPI bindings OK: ClangDiagnostic("/usr/lib/llvm-14/lib/clang/14.0.0/include/emmintrin.h:2228:19: error: use of undeclared identifier '__builtin_ia32_paddsb128
  • js_static_lib.list is missing, needed by the windows build
  • need to run clang-format on the c++ code

@jschwe
Copy link
Member

jschwe commented May 22, 2025

Clang version looks wrong for linux build — Should generate JSAPI bindings OK: ClangDiagnostic("/usr/lib/llvm-14/lib/clang/14.0.0/include/emmintrin.h:2228:19: error: use of undeclared identifier '__builtin_ia32_paddsb128

That could be rust-lang/rust-bindgen#2682 - you can work around this by explicitly setting LIBCLANG_PATH and CLANG_PATH.

@sagudev
Copy link
Member

sagudev commented May 22, 2025

for

js_static_lib.list is missing

we can go back to packing all files or manually hardcode list of files we need (if there is no list generated at build).

@sagudev
Copy link
Member

sagudev commented May 22, 2025

for integrity we should replace mozilla-esr128 with mozilla-release repo, update readme and bump version in mozjs-sys Cargo.toml

@jdm
Copy link
Member Author

jdm commented May 29, 2025

Note to self: the js_static_libs.list files looks like it came from

):
response_file_path = "%s.list" % obj.name.replace(".", "_")
response_file_ref = self._make_ar_response_file(
in the current mozjs. That code and _make_list_file are unchanged in 137, and the windows CI log shows js_static.lib being generated, so I'm not clear on what's different.

It's worth checking https://github.com/jdm/mozjs/blob/91a576a85a3f8902f5f2eaab6e1b9cd1d2d1bbca/mozjs-sys/mozjs/build/moz.configure/toolchain.configure#L3711C13-L3711C38

@jdm
Copy link
Member Author

jdm commented May 29, 2025

@jdm
Copy link
Member Author

jdm commented May 29, 2025

Currently blocked on:

  • mysterious error on android from the sysroot headers when using NDK28 (/opt/hostedtoolcache/ndk/r28b/x64/toolchains/llvm/prebuilt/linux-x86_64/bin/../sysroot/usr/include/c++/v1/__condition_variable/condition_variable.h:226:14: error: use of undeclared identifier 'pthread_cond_clockwait')
  • finding a usable LIBCLANG_PATH that allows the linux builds to succeed (edit: clang 15 appears to be good)
  • silent build failure for debugmozjs on linux

Currently investigating:

  • how to make windows builds correctly use the AR supports files (the build succeeds when forced on)
  • whether it's possible to continue using NDK 26 instead for android builds

@jdm
Copy link
Member Author

jdm commented May 29, 2025

The NDK 26 error is this:

  /home/runner/work/mozjs/mozjs/target/armv7-linux-androideabi/debug/build/mozjs_sys-993bc32b3ac46994/out/build/dist/include/fmt/format.h:3154:5: error: static assertion failed: This method is not to be used in Gecko, use format_float_gecko
      static_assert(false,

@jdm
Copy link
Member Author

jdm commented May 30, 2025

The windows build failures are a regression caused by https://hg-edge.mozilla.org/mozilla-central/rev/5dd0a7f7b85a, which mistranslated ar_supports_response_files so the list file is deleted before the ar command has a chance to read it.

@jdm
Copy link
Member Author

jdm commented May 30, 2025

The android issue looks like jsapi.cpp (our special file for bindgen) is not being built with __ANDROID_API__ defined to the expected level in the rest of mozjs.

@jdm
Copy link
Member Author

jdm commented Jun 10, 2025

debugmozjs failure:

 /home/runner/work/mozjs/mozjs/mozjs-sys/mozjs/js/src/vm/SavedStacks.cpp:2019:5: error: ‘constinit’ variable ‘js::ReconstructedSavedFramePrincipals::IsNotSystem’ does not have a constant initializer
   2019 |     ReconstructedSavedFramePrincipals::IsNotSystem;
        |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  In file included from /home/runner/work/mozjs/mozjs/target/debug/build/mozjs_sys-ff4674877348667e/out/build/dist/include/mozilla/Assertions.h:35,
                   from /home/runner/work/mozjs/mozjs/target/debug/build/mozjs_sys-ff4674877348667e/out/build/dist/include/mozilla/Casting.h:12,
                   from /home/runner/work/mozjs/mozjs/mozjs-sys/mozjs/js/src/jstypes.h:24,
                   from /home/runner/work/mozjs/mozjs/target/debug/build/mozjs_sys-ff4674877348667e/out/build/dist/include/js/shadow/Realm.h:12,
                   from /home/runner/work/mozjs/mozjs/mozjs-sys/mozjs/js/src/vm/Realm.cpp:7,
                   from Unified_cpp_js_src21.cpp:2:
  /home/runner/work/mozjs/mozjs/mozjs-sys/mozjs/js/src/vm/SavedStacks.cpp:2019:40:   in ‘constexpr’ expansion of ‘js::ReconstructedSavedFramePrincipals()’
  /home/runner/work/mozjs/mozjs/target/debug/build/mozjs_sys-ff4674877348667e/out/build/dist/include/mozilla/Likely.h:17:44: error: ‘__builtin_expect(((long int)(! js::ReconstructedSavedFramePrincipals::is((&((js::ReconstructedSavedFramePrincipals*)this)->js::ReconstructedSavedFramePrincipals::<anonymous>)))), 0)’ is not a constant expression
     17 | #  define MOZ_UNLIKELY(x) (__builtin_expect(!!(x), 0))
        |                           ~~~~~~~~~~~~~~~~~^~~~~~~~~~~
  /home/runner/work/mozjs/mozjs/target/debug/build/mozjs_sys-ff4674877348667e/out/build/dist/include/mozilla/Assertions.h:530:9: note: in expansion of macro ‘MOZ_UNLIKELY’
    530 |     if (MOZ_UNLIKELY(!MOZ_CHECK_ASSERT_ASSIGNMENT(expr))) {    \
        |         ^~~~~~~~~~~~
  /home/runner/work/mozjs/mozjs/target/debug/build/mozjs_sys-ff4674877348667e/out/build/dist/include/mozilla/Assertions.h:550:31: note: in expansion of macro ‘MOZ_ASSERT_HELPER1’
    550 | #define MOZ_ASSERT_GLUE(a, b) a b
        |                               ^
  /home/runner/work/mozjs/mozjs/target/debug/build/mozjs_sys-ff4674877348667e/out/build/dist/include/mozilla/Assertions.h:558:5: note: in expansion of macro ‘MOZ_ASSERT_GLUE’
    558 |     MOZ_ASSERT_GLUE(                                                    \
        |     ^~~~~~~~~~~~~~~
  /home/runner/work/mozjs/mozjs/target/debug/build/mozjs_sys-ff4674877348667e/out/build/dist/include/mozilla/MacroArgs.h:16:26: note: in expansion of macro ‘MOZ_CONCAT2’
     16 | #define MOZ_CONCAT(x, y) MOZ_CONCAT2(x, y)
        |                          ^~~~~~~~~~~
  /home/runner/work/mozjs/mozjs/target/debug/build/mozjs_sys-ff4674877348667e/out/build/dist/include/mozilla/MacroArgs.h:70:51: note: in expansion of macro ‘MOZ_CONCAT’
     70 | #define MOZ_PASTE_PREFIX_AND_ARG_COUNT_GLUE(a, b) a b
        |                                                   ^
  /home/runner/work/mozjs/mozjs/target/debug/build/mozjs_sys-ff4674877348667e/out/build/dist/include/mozilla/MacroArgs.h:72:3: note: in expansion of macro ‘MOZ_PASTE_PREFIX_AND_ARG_COUNT_GLUE’
     72 |   MOZ_PASTE_PREFIX_AND_ARG_COUNT_GLUE(MOZ_CONCAT,    \
        |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /home/runner/work/mozjs/mozjs/target/debug/build/mozjs_sys-ff4674877348667e/out/build/dist/include/mozilla/Assertions.h:559:9: note: in expansion of macro ‘MOZ_PASTE_PREFIX_AND_ARG_COUNT’
    559 |         MOZ_PASTE_PREFIX_AND_ARG_COUNT(MOZ_ASSERT_HELPER, __VA_ARGS__), \
        |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /home/runner/work/mozjs/mozjs/mozjs-sys/mozjs/js/src/vm/SavedFrame.h:204:5: note: in expansion of macro ‘MOZ_ASSERT’
    204 |     MOZ_ASSERT(is(this));
        |     ^~~~~~~~~~

Commenting out the problem MOZ_ASSERT allows the build to succeed.

@jdm jdm force-pushed the 137up branch 2 times, most recently from f7ff8f9 to d35fa2d Compare June 10, 2025 04:18
@jdm
Copy link
Member Author

jdm commented Jun 10, 2025

@mukilan You've done a bunch of Android build integration before, IIRC. Do you have any idea about what to try to fix this error when building jsapi.cpp for Android?

  cargo:warning=In file included from ./src/jsapi.cpp:7:
  cargo:warning=In file included from /home/runner/work/mozjs/mozjs/target/armv7-linux-androideabi/debug/build/mozjs_sys-4553abe797bed9fd/out/build/dist/include/jsapi.h:14:
  cargo:warning=In file included from /home/runner/work/mozjs/mozjs/target/armv7-linux-androideabi/debug/build/mozjs_sys-4553abe797bed9fd/out/build/dist/include/mozilla/Maybe.h:12:
  cargo:warning=In file included from /opt/hostedtoolcache/ndk/r28b/x64/toolchains/llvm/prebuilt/linux-x86_64/bin/../sysroot/usr/include/c++/v1/functional:525:
  cargo:warning=In file included from /opt/hostedtoolcache/ndk/r28b/x64/toolchains/llvm/prebuilt/linux-x86_64/bin/../sysroot/usr/include/c++/v1/__functional/boyer_moore_searcher.h:27:
  cargo:warning=In file included from /opt/hostedtoolcache/ndk/r28b/x64/toolchains/llvm/prebuilt/linux-x86_64/bin/../sysroot/usr/include/c++/v1/vector:2992:
  cargo:warning=In file included from /opt/hostedtoolcache/ndk/r28b/x64/toolchains/llvm/prebuilt/linux-x86_64/bin/../sysroot/usr/include/c++/v1/locale:209:
  cargo:warning=In file included from /opt/hostedtoolcache/ndk/r28b/x64/toolchains/llvm/prebuilt/linux-x86_64/bin/../sysroot/usr/include/c++/v1/ios:843:
  cargo:warning=In file included from /opt/hostedtoolcache/ndk/r28b/x64/toolchains/llvm/prebuilt/linux-x86_64/bin/../sysroot/usr/include/c++/v1/mutex:191:
  cargo:warning=/opt/hostedtoolcache/ndk/r28b/x64/toolchains/llvm/prebuilt/linux-x86_64/bin/../sysroot/usr/include/c++/v1/__condition_variable/condition_variable.h:226:14: error: use of undeclared identifier 'pthread_cond_clockwait'
  cargo:warning=  226 |   int __ec = pthread_cond_clockwait(&__cv_, __lk.mutex()->native_handle(), CLOCK_MONOTONIC, &__ts);
  cargo:warning=      |              ^
  cargo:warning=1 error generated.
...
  error occurred in cc-rs: command did not execute successfully (status code exit status: 1): LC_ALL="C" "/opt/hostedtoolcache/ndk/r28b/x64/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++" "-O0" "-DANDROID" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-2" "-fno-omit-frame-pointer" "--target=armv7-none-linux-android" "-I" "/home/runner/work/mozjs/mozjs/target/armv7-linux-androideabi/debug/build/mozjs_sys-4553abe797bed9fd/out/build/dist/include" "-I" "/home/runner/work/mozjs/mozjs/target/armv7-linux-androideabi/debug/build/mozjs_sys-4553abe797bed9fd/out/build/js/src" "-Wall" "-Wextra" "-include" "/home/runner/work/mozjs/mozjs/target/armv7-linux-androideabi/debug/build/mozjs_sys-4553abe797bed9fd/out/build/js/src/js-confdefs.h" "-std=gnu++17" "-std=c++17" "-xc++" "-fPIC" "-fno-rtti" "-fno-sized-deallocation" "-Wno-c++0x-extensions" "-Wno-return-type-c-linkage" "-Wno-unused-parameter" "-Wno-invalid-offsetof" "-Wno-unused-private-field" "-DSTATIC_JS_API" "-DRUST_BINDGEN" "-D__ANDROID_API__=30" "-o" "/home/runner/work/mozjs/mozjs/target/armv7-linux-androideabi/debug/build/mozjs_sys-4553abe797bed9fd/out/build/702045c0c9daef17-jsapi.o" "-c" "./src/jsapi.cpp"

CI log

@TimvdLippe
Copy link

What's the status/plan of this PR? I see that you made a lot of progress to make the Android build pass. Over in Servo a lot of WPT tests start passing. Are we waiting for a particular release or any other blocking factors we could help out with? I am eager to continue working on trusted types after this upgrade, but do take your time as required to get this across the finish line.

@jdm
Copy link
Member Author

jdm commented Jul 1, 2025

What's the status/plan of this PR? I see that you made a lot of progress to make the Android build pass. Over in Servo a lot of WPT tests start passing. Are we waiting for a particular release or any other blocking factors we could help out with? I am eager to continue working on trusted types after this upgrade, but do take your time as required to get this across the finish line.

At this point the only thing blocking it is solving the Android build issue from https://github.com/jdm/servo/actions/runs/15750256672 . Once that's complete, I need to collapse the stack of commits in this PR, make proper patches for the remaining changes to the upstream mozjs code, and figure out if the changes that allow it to build right now are acceptable to merge or if we need to dig deeper into why they're needed. In particular:

@jdm
Copy link
Member Author

jdm commented Jul 1, 2025

All that being said, there's nothing wrong with starting the trusted types implementation work on top of this branch and servo/servo#37077 if you're eager!

@jschwe
Copy link
Member

jschwe commented Jul 8, 2025

At this point the only thing blocking it is solving the Android build issue from https://github.com/jdm/servo/actions/runs/15750256672 .

Do you also have an associated servo branch with mach changes? Looks like the sysroot is not passed properly.

@jdm
Copy link
Member Author

jdm commented Jul 8, 2025

At this point the only thing blocking it is solving the Android build issue from https://github.com/jdm/servo/actions/runs/15750256672 .

Do you also have an associated servo branch with mach changes? Looks like the sysroot is not passed properly.

That's https://github.com/jdm/servo/tree/137up . Latest status at servo/servo#37077 (comment)

@TimvdLippe
Copy link

This PR is quite big with loads of commits and I have trouble following the status of it. It seems like many changes are related to the fact that files were moved into a subdirectory. Can we separate out the file moves from the actual upgrade so that it becomes easier to understand where this PR stands for merging?

@jdm
Copy link
Member Author

jdm commented Jul 27, 2025

There are no file moves apart from the upgrade itself as dar as I know. It's strictly the upgrade and the changes required to make it pass CI on all platforms.

@TimvdLippe
Copy link

Ah okay! Thanks for taking care of this massive undertaking

@jdm jdm force-pushed the 137up branch 2 times, most recently from 7455c98 to 620d967 Compare July 28, 2025 10:03
@jdm
Copy link
Member Author

jdm commented Jul 28, 2025

Oof. I no longer have the original xz file I downloaded, and I can't get it from taskcluster any more. I'd like to comment out the integrity step for this PR, get it merged, and then we can do a quick-ish followup for 138 that reinstates the patch integrity check using this repo's releases to host it.

jdm added 21 commits July 30, 2025 23:54
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
…roid.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
@jdm
Copy link
Member Author

jdm commented Jul 31, 2025

Servo builds and tests are passing, so we're good to review this for real.

@sagudev
Copy link
Member

sagudev commented Jul 31, 2025

Hm, main result is still failing.
What if we just comment out integrity check of patches, but keep the rest (like fmt check).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, this and 1634a4b suggest that we do some compilation wrong (wrong flags), but let's not block this on that.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants