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 43 commits into
base: main
Choose a base branch
from
Open

Upgrade to SpiderMonkey 137 #584

wants to merge 43 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 added 16 commits June 9, 2025 23:43
Signed-off-by: Josh Matthews <[email protected]>
Signed-off-by: Josh Matthews <[email protected]>
Signed-off-by: Josh Matthews <[email protected]>
Signed-off-by: Josh Matthews <[email protected]>
Signed-off-by: Josh Matthews <[email protected]>
Signed-off-by: Josh Matthews <[email protected]>
Signed-off-by: Josh Matthews <[email protected]>
Signed-off-by: Josh Matthews <[email protected]>
Signed-off-by: Josh Matthews <[email protected]>
Signed-off-by: Josh Matthews <[email protected]>
Signed-off-by: Josh Matthews <[email protected]>
@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
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

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.

3 participants