Problem building 102.3.0ESR on Windows

Hi,
I’m trying to upgrade our embedding from 91 to 102 so I followed the following steps to try to build on windows (using VS2019)

  1. Installed Rust (version 1.63)
  2. Installed LLVM/clang-cl 12.0.1
  3. Installed mozillabuild
  4. Download http://ftp.mozilla.org/pub/firefox/releases/102.3.0esr/source/firefox-102.3.0esr.source.tar.xz
  5. Made mozjs-102.3.0.tar.xz by running ‘python3 make-source-package.py’ in the js/src directory
  6. Made a mozconfig file containing

ac_add_options --enable-application=js
ac_add_options --prefix=C:/SOURCE20/spidermonkey_dir/js102_release
ac_add_options --disable-jemalloc
ac_add_options --disable-debug-symbols
ac_add_options --enable-optimize
ac_add_options --enable-strip
ac_add_options --enable-install-strip
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/js/src/releaseob

  1. Started mozillabuild, added Rust and LLVM to path with
    export PATH=$PATH:"/c/Program Files/LLVM/bin"
    export PATH=$PATH:"/c/Users/miles.thornton/AppData/Local/Programs/Rust stable MSVC 1.63/bin"
    and set the mozconfig file with
    export MOZCONFIG=/c/SOURCE20/javascript_dir/mozconfig/js102_win_release
  2. Tried to build with
    ./mach build

This churns away for a while and gives the following error

6:15.14 js/src/build/js_static.lib
6:15.21 js/src/build/mozjs-102.dll
6:16.03 lld-link: error: duplicate symbol: DllMain
6:16.03 >>> defined at …\Unified_cpp_js_src8.obj
6:16.03 >>> defined at …\mozglue\misc\WindowsDllMain.obj
6:16.08 gmake.exe[4]: *** [C:/SOURCE20/spidermonkey_dir/mozjs-102.3.0/config/rules.mk:540: mozjs-102.dll] Error 1
6:16.08 gmake.exe[3]: *** [C:/SOURCE20/spidermonkey_dir/mozjs-102.3.0/config/recurse.mk:72: js/src/build/target] Error 2
6:16.08 gmake.exe[2]: *** [C:/SOURCE20/spidermonkey_dir/mozjs-102.3.0/config/recurse.mk:34: compile] Error 2
6:16.08 gmake.exe[1]: *** [C:/SOURCE20/spidermonkey_dir/mozjs-102.3.0/config/rules.mk:361: default] Error 2
6:16.08 gmake.exe: *** [client.mk:63: build] Error 2
6:16.11 13 compiler warnings present.

Can anybody give me any help? What am I doing wrong?
In older versions I remember that the mozjs tarball did not contain mozglue/dllservices and I had to manually add it but it looks like things have changed in the build since then.
Is there something similar that I need to do?
I would be very grateful for any help.

Thanks

Miles

It looks like my comments in my mozconfig file starting with ‘#’ have been turned into markup in my post above. Apologies. I hope it still makes sense…
Actually, I’ve just realised that I can edit it so I have removed the comments…

This seems to be a known issue: Bug 1751561

You should be able to work around it by commenting out the DllMain function mozglue/misc/WindowsDllMain.cpp.

1 Like

Thanks for the reply and info.
I had managed to build it in the end yesterday by doing something similar (I edited mozglue/misc/moz.build and removed WindowsDllMain.cpp from SOURCES so it just didn’t compile it). However, I wasn’t sure if this was the “correct” thing to do and whether I would just get problems later on, so thanks for the info. Good to know that what I did was OK.

Thanks again for the prompt response.

Miles

Did you also have to do something for duplicate definitions of HeapAlloc, HeapFree, and HeapReAlloc? I’m thinking that I need to comment it out from /mozilla-unified/memory/mozalloc/winheap.cpp. What solution did you try, if you also had this problem?

After doing that, I was able to compile and run, and the interpreter seems to be working. Now I have to link it to my Windows app and see if I have any luck.

Thanks for sharing your mozconfig, it was extremely helpful!

1 Like

I am having this same issue you are describing here. Were you able to fix it?

If anyone wants to build SM ESR102.12.0 dll on Windows, check out my repo: https://bitbucket.org/TheQwertiest/mozjs

  • build_scripts/setup.py is a script that will walk through all the required steps, from downloading sources and correct mozilla-build, to applying required patches.
  • build_scripts/patches contains all the patches which are needed for build to complete and/or for embedding to work properly with MSVC.

Note: setup.py in mozjs repo only builds x86 library, but it can be easily adapted to build x64 as well (I haven’t tested that though, so it might require additional SM patches)

Note 2: mozjs repo contains only patches that must be applied before build (i.e. they can’t be applied post-build).

Additional patches are needed for embedding application to work though, see all mozjs-* files here: https://github.com/TheQwertiest/foo_spider_monkey_panel/tree/8f3721a6a122b528e1317268f83474581dc06c84/scripts/patches

Note 3: these patches use non-portable paths specific to my repo, so they should be fixed before applying to your SM headers.