Skip to content
This repository was archived by the owner on Nov 12, 2022. It is now read-only.

SpiderMonkey upgrade #291

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
language: rust
sudo: 9000
dist: trusty
osx_image: xcode7
rust:
- nightly
os:
Expand All @@ -12,7 +13,9 @@ env:
- FEATURES="--features debugmozjs"

before_install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install ccache; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install ccache cmake; fi
- cmake --version

script:
- ccache -z
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ promises = ['mozjs_sys/promises']

[dependencies.mozjs_sys]
git = "https://github.com/servo/mozjs"
branch = "smup"

[dependencies]
lazy_static = "0.2.1"
Expand Down
70 changes: 58 additions & 12 deletions etc/README
Original file line number Diff line number Diff line change
@@ -1,16 +1,67 @@
Building bindings requires rust-bindgen checked out and built in ../../rust-bindgen
(it expects to find the binary in ../../rust-bindgen/target/debug/bindgen).

Generally, the steps for any platform require a rust-bindgen binary in
../rust-bindgen/target/debug/bindgen and an approprivate llvm/clang in the PATH.
Then:

cargo clean
cargo build
[ ignore errors in building js if bindings are out of date ]
./etc/bindings.sh
mv out.rs src/jsapi_your_platform_goes_here.rs
cargo test

=== Windows ===

rust-bindgen must be built using a rust for the pc-windows-gnu target, not msvc, even
when generating msvc bindings. Within a MINGW64 env, install mingw-w64-x86_64-clang
then build rust-bindgen with 'LIBCLANG_PATH=c:/msys64/mingw64/bin cargo build' (replace
c:/msys64 with the root of your msys2-64 install directory).
c:/msys64 with the root of your msys2-64 install directory). Alternatively, build
LLVM/Clang from source and set LLVM_CONFIG_PATH to point to llvm-config.exe, LIBCLANG_PATH
to the build/bin dir, and LIBCLANG_STATIC_PATH to the build/lib dir.

Make sure your PATH has the MINGW64 LLVM/Clang bin dir in it at the start.

The build-windows-bindings.sh script automates the below steps.
Prerequisites for running it:

1. A built llvm/clang for the pc-windows-gnu default target in the PATH
2. A rust-bindgen in ../rust-bindgen/target/debug/bindgen.exe built against
the above llvm/clang
3. Visual Studio 2015 environment variables present (see below for moz_vs info)

Running build-windows-bindings.sh and getting a cup of coffee *and drinking it*
(or having lunch, depending on host speed) will update all 4 of the windows
bindings files. If you come back without finishing at least a cup of coffee,
you'll be staring at cargo compiling lines. Espresso drinkers, you've been
warned. :)

==== MINGW/GNU bindings ====

Using a pc-windows-gnu rust:

rustup default x86_64-pc-windows-gnu

cargo clean
cargo build
[wait for everything to build; if bindings are out of date, it'll error out at the end -- that's okay]
./etc/bindings.sh
cp out.rs src/jsapi_windows_gcc_64.rs
cargo test

Then, do the same for debugmozjs:

cargo clean
cargo build --features debugmozjs
[wait for everything to build; if bindings are out of date, it'll error out at the end -- that's okay]
./etc/bindings.sh
cp out.rs src/jsapi_windows_gcc_64_debug.rs
cargo test --features debugmozjs # this will take forever; can just do a build

==== MSVC bindings ====

Now, build rust-mozjs using a pc-windows-msvc rust. Note that you'll need to be in an
Now, Do the same with a pc-windows-msvc rust. Note that you'll need to be in an
environment that has the Visual C++ env vars already set up for your compiler -- the msys
package http://people.mozilla.org/~vladimir/misc/moz-vs-0.1.2-any.pkg.tar.xz can help
with this (install with pacman -U moz-vs-0.1.2-any.pkg.tar.xz). After installation, running
Expand All @@ -20,25 +71,20 @@ a different compiler.

To generate VC14 (VS2015) bindings, in rust-mozjs:

rustup default x86_64-pc-windows-msvc

moz_vs 2015
cargo build
[wait for everything to build; if bindings are out of date, it'll error out at the end -- that's okay]
./etc/bindings.sh msvc14
cp out.rs src/jsapi_windows_msvc14_64.rs
cargo build # make sure the build finishes
cargo test

The debug bindings:

cargo clean
cargo build --features debugmozjs
[wait for everything to build]
[wait for everything to build; if bindings are out of date, it'll error out at the end -- that's okay]
./etc/bindings.sh msvc14
cp out.rs src/jsapi_windows_msvc14_64_debug.rs
cargo build --features debugmozjs

If you get errors about "static_assert expression is not an integral constant expression",
additional static_assert(offsetof(...)) sites need to be #if 0'd out (this ends up being
a non-constant-expression according to clang when built with the MSVC headers).

For generating the bindings with MSVC, only MSVC 2013 and 2015 are
supported (VC12 and 14). Run 'bindings.sh msvc12' and/or 'bindings.sh msvc14'.
cargo test --features debugmozjs # this will take forever; can just do a build
87 changes: 87 additions & 0 deletions etc/build-windows-bindings.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/bin/bash

set -e

# Make sure we're in the toplevel rust-mozjs dir
cd "`dirname $0`"/..

if [[ ! -f "Cargo.toml" || ! -f "./etc/bindings.sh" ]] ; then
echo "Expected to be in the toplevel rust-bindgen dir, but somehow in: `pwd`"
exit 1
fi

if [[ ! -f ../rust-bindgen/target/debug/bindgen.exe ]] ; then
echo "Can't find bindgen.exe in ../rust-bindgen/target/debug"
exit 1
fi

if [[ "$VSINSTALLDIR" == "" ]] ; then
echo "Visual Studio 2015 environment variables and paths must be set before running this!"
exit 1
fi

handle_error() {
set +x
local parent_lineno="$1"
local message="$2"
local code="${3:-1}"
if [[ -n "$message" ]] ; then
echo "Error on or near line ${parent_lineno}: ${message}; exiting with status ${code}"
else
echo "Error on or near line ${parent_lineno}; exiting with status ${code}"
fi
exit "${code}"
}

trap 'handle_error ${LINENO}' ERR

build_bindings() {
cargo clean
cargo build $3 || echo ... ignoring first build error ...
./etc/bindings.sh $4
cp out.rs src/jsapi_$1.rs
cargo $2 $3
}

# Unset these, to make sure nothing wants to build for msvc
echo "Saving and clearing Visual Studio environment variables..."
saved_vsinstalldir="$VSINSTALLDIR"
saved_include="$INCLUDE"
saved_lib="$LIB"
unset VSINSTALLDIR
unset INCLUDE
unset LIB

set -x

# gnu first
rustup default nightly-x86_64-pc-windows-gnu

build_bindings windows_gcc_64 test ""

# We don't test debugmozjs; it takes way too long
build_bindings windows_gcc_64_debug build "--features debugmozjs"

set +x

# MSVC next

echo "Restoring Visual Studio variables..."
export VSINSTALLDIR="${saved_vsinstalldir}"
export INCLUDE="${saved_include}"
export LIB="${saved_lib}"

set -x

rustup default nightly-x86_64-pc-windows-msvc

build_bindings windows_msvc14_64 test "" msvc14

# We don't test debugmozjs; it takes way too long
build_bindings windows_msvc14_64_debug build "--features debugmozjs" msvc14

set +x

echo "==== Success! ===="

rm out.rs
Loading