diff options
author | Will Young <lost.networking@gmail.com> | 2021-12-02 14:42:03 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-02 09:42:03 -0500 |
commit | cb6aff46b65b68fd48293971a11c29633a0e21ff (patch) | |
tree | 39230260383f26e05cce066a150778abb612c7a7 | |
parent | 214c8e7895ec42f2a14ba912e4f3b5e3fd28824e (diff) | |
download | couchdb-cb6aff46b65b68fd48293971a11c29633a0e21ff.tar.gz |
feat(couchjs): add support for SpiderMonkey 91esr (#3842)
-rw-r--r-- | .github/workflows/ubuntu.yml | 92 | ||||
-rw-r--r-- | src/couch/priv/couch_js/86/main.cpp | 41 | ||||
-rw-r--r-- | src/couch/priv/couch_js/86/util.cpp | 2 | ||||
-rw-r--r-- | src/couch/rebar.config.script | 12 |
4 files changed, 129 insertions, 18 deletions
diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml new file mode 100644 index 000000000..e03e8376c --- /dev/null +++ b/.github/workflows/ubuntu.yml @@ -0,0 +1,92 @@ +name: Ubuntu build CI + +on: + workflow_dispatch: + +jobs: + + build: + + runs-on: ubuntu-latest + + steps: + - name: update + run: sudo apt-get update + - name: install + run: sudo apt-get --no-install-recommends -y install autoconf2.13 build-essential pkg-config libcurl4-openssl-dev erlang-dev rebar elixir + + - name: couch checkout + uses: actions/checkout@v2 + with: + path: couch + + - name: ICU checkout + uses: actions/checkout@v2 + with: + repository: unicode-org/icu + path: icubuild + + - name: ICU4C with gcc + env: + PREFIX: /usr/local + run: | + cd icubuild + mkdir build; + cd build; + ../icu4c/source/runConfigureICU --enable-debug --disable-release Linux/gcc --prefix=$PREFIX --enable-tracing; + make -j2; + make -j2 check; + ( cd ../icu4c/source/test/depstest && ./depstest.py ../../../../build/ ); + sudo make install; + + - name: Cache packages + uses: actions/cache@v2 + id: wgetcache + with: + key: wgetcache + path: | + firefox-91.3.0esr.source.tar.xz + foundationdb-clients_6.3.22-1_amd64.deb + foundationdb-server_6.3.22-1_amd64.deb + + - name: wget moz + if: steps.wgetcache.outputs.cache-hit != 'true' + run: wget -q https://www.foundationdb.org/downloads/6.3.22/ubuntu/installers/foundationdb-server_6.3.22-1_amd64.deb https://www.foundationdb.org/downloads/6.3.22/ubuntu/installers/foundationdb-clients_6.3.22-1_amd64.deb https://download.cdn.mozilla.net/pub/firefox/releases/91.3.0esr/source/firefox-91.3.0esr.source.tar.xz + + - name: build spidermonkeycheckout + run: | + tar xf firefox-91.3.0esr.source.tar.xz + export PKG_CONFIG_PATH=${{github.workspace}}/icu/lib/pkgconfig:$PKG_CONFIG_PATH + export AC_MACRODIR=${{github.workspace}}/firefox-91.3.0/build/autoconf/ + cd firefox-91.3.0 + export PYTHON=python3 + export M4=m4 + export AWK=awk + export CFLAGS="-I/usr/local/include" + export LDFLAGS="-L/usr/local/lib" + cd js/src + sh ../../build/autoconf/autoconf.sh --localdir=$PWD configure.in > configure + chmod +x configure + mkdir ${{github.workspace}}/build_OPT.OBJ + cd ${{github.workspace}}/build_OPT.OBJ + ${{github.workspace}}/firefox-91.3.0/js/src/configure --prefix=/usr/local --disable-ctypes --disable-jit --disable-jemalloc --enable-optimize --enable-hardening --with-intl-api --build-backends=RecursiveMake --with-system-icu --disable-debug --enable-gczeal + make + sudo make install + + - name: install + run: sudo apt-get --no-install-recommends -y install ./foundationdb-clients_6.3.22-1_amd64.deb ./foundationdb-server_6.3.22-1_amd64.deb + + - name: configure + run: | + cd couch + sed -i -e "s@DRV_CFLAGS -DPIC@DRV_CFLAGS -I/usr/local/include -DPIC@" src/couch/rebar.config.script + sed -i -e "s@DRV_LDFLAGS -lm@DRV_LDFLAGS -L/usr/local/lib -lm@" src/couch/rebar.config.script + sh ./configure --spidermonkey-version=91 --disable-docs + - name: Compile + run: | + cd couch + make release + - name: Run tests + run: | + cd couch + make check diff --git a/src/couch/priv/couch_js/86/main.cpp b/src/couch/priv/couch_js/86/main.cpp index 291409944..d75f119b2 100644 --- a/src/couch/priv/couch_js/86/main.cpp +++ b/src/couch/priv/couch_js/86/main.cpp @@ -186,6 +186,8 @@ quit(JSContext* cx, unsigned int argc, JS::Value* vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); int exit_code = args[0].toInt32();; + JS_DestroyContext(cx); + JS_ShutDown(); exit(exit_code); } @@ -254,20 +256,7 @@ static JSSecurityCallbacks security_callbacks = { nullptr }; - -int -main(int argc, const char* argv[]) -{ - JSContext* cx = NULL; - int i; - - couch_args* args = couch_parse_args(argc, argv); - - JS_Init(); - cx = JS_NewContext(args->stack_size); - if(cx == NULL) - return 1; - +int runWithContext(JSContext* cx, couch_args* args) { JS_SetGlobalJitCompilerOption(cx, JSJITCOMPILER_BASELINE_ENABLE, 0); JS_SetGlobalJitCompilerOption(cx, JSJITCOMPILER_ION_ENABLE, 0); @@ -293,7 +282,7 @@ main(int argc, const char* argv[]) if(couch_load_funcs(cx, global, global_functions) != true) return 1; - for(i = 0 ; args->scripts[i] ; i++) { + for(int i = 0 ; args->scripts[i] ; i++) { const char* filename = args->scripts[i]; // Compile and run @@ -336,6 +325,26 @@ main(int argc, const char* argv[]) // Give the GC a chance to run. JS_MaybeGC(cx); } - return 0; } + +int +main(int argc, const char* argv[]) +{ + JSContext* cx = NULL; + int ret; + + couch_args* args = couch_parse_args(argc, argv); + + JS_Init(); + cx = JS_NewContext(args->stack_size); + if(cx == NULL) { + JS_ShutDown(); + return 1; + } + ret = runWithContext(cx, args); + JS_DestroyContext(cx); + JS_ShutDown(); + + return ret; +} diff --git a/src/couch/priv/couch_js/86/util.cpp b/src/couch/priv/couch_js/86/util.cpp index cd120a03f..b61c76ad2 100644 --- a/src/couch/priv/couch_js/86/util.cpp +++ b/src/couch/priv/couch_js/86/util.cpp @@ -330,7 +330,7 @@ void couch_oom(JSContext* cx, void* data) { fprintf(stderr, "out of memory\n"); - exit(1); + _Exit(1); } diff --git a/src/couch/rebar.config.script b/src/couch/rebar.config.script index 43ae3cea7..8a9b03829 100644 --- a/src/couch/rebar.config.script +++ b/src/couch/rebar.config.script @@ -65,6 +65,8 @@ SMVsn = case lists:keyfind(spidermonkey_version, 1, CouchConfig) of "78"; {_, "86"} -> "86"; + {_, "91"} -> + "91"; undefined -> "1.8.5"; {_, Unsupported} -> @@ -89,6 +91,8 @@ ConfigH = [ CouchJSConfig = case SMVsn of "78" -> "priv/couch_js/86/config.h"; + "91" -> + "priv/couch_js/86/config.h"; _ -> "priv/couch_js/" ++ SMVsn ++ "/config.h" end. @@ -148,6 +152,11 @@ end. { "-DXP_UNIX -I/usr/include/mozjs-86 -I/usr/local/include/mozjs-86 -I/opt/homebrew/include/mozjs-86/ -std=c++17 -Wno-invalid-offsetof", "-L/usr/local/lib -L /opt/homebrew/lib/ -std=c++17 -lmozjs-86 -lm" + }; + {unix, _} when SMVsn == "91" -> + { + "-DXP_UNIX -I/usr/include/mozjs-91 -I/usr/local/include/mozjs-91 -I/opt/homebrew/include/mozjs-91/ -std=c++17 -Wno-invalid-offsetof", + "-L/usr/local/lib -L /opt/homebrew/lib/ -std=c++17 -lmozjs-91 -lm" } end. @@ -156,7 +165,8 @@ CouchJSSrc = case SMVsn of "60" -> ["priv/couch_js/60/*.cpp"]; "68" -> ["priv/couch_js/68/*.cpp"]; "78" -> ["priv/couch_js/86/*.cpp"]; - "86" -> ["priv/couch_js/86/*.cpp"] + "86" -> ["priv/couch_js/86/*.cpp"]; + "91" -> ["priv/couch_js/86/*.cpp"] end. CouchJSEnv = case SMVsn of |